Skip to content

Instantly share code, notes, and snippets.

View bastionkid's full-sized avatar

Akash Khunt bastionkid

View GitHub Profile
@bastionkid
bastionkid / int_progression_iterator_decompiled_bytecode.txt
Created September 15, 2022 11:00
Decompiled Bytecode for IntProgressionIterator
// plain kotlin code
for (i in 0 until observers.size) {
observers[i].onStatusChange()
}
// decompiled bytecode of the above for loop
int i = 0;
for(int var5 = ((Scratch_2)this).observers.size(); i < var5; ++i) {
((Observer)((Scratch_2)this).observers.get(i)).onStatusChange();
@bastionkid
bastionkid / list_iterator_decompiled_bytecode.txt
Created September 15, 2022 11:00
Decompiled Bytecode for ListIterator
// plain kotlin code
for (observer in observers) {
observer.onStatusChange()
}
// decompiled bytecode of the above for loop
Iterator var2 = ((Scratch_2)this).observers.iterator();
while(var2.hasNext()) {
Observer observer = (Observer)var2.next();
@bastionkid
bastionkid / center_aligned_text.kt
Last active October 12, 2022 06:22
Center Aligned Text composable with Modifier.wrapContentHeight()
fun CenterAlignedText() {
Text(
text = "Center",
textAlign = TextAlign.Center,
modifier = Modifier.size(100.dp)
.background(Color.Cyan)
.wrapContentHeight(),
)
}
@bastionkid
bastionkid / baseline_profile_generate_error.txt
Last active December 27, 2022 10:40
Baseline Profile Test Error Logs
12-27 16:04:05.090 15634 15662 E GrantPermissionCallable: Permission: android.permission.READ_EXTERNAL_STORAGE cannot be granted!
12-27 16:04:05.091 15634 15662 E TestRunner: failed: startup(com.tatadigital.tcp.example.benchmark.ExampleStartupBenchmark)
12-27 16:04:05.091 15634 15662 E TestRunner: ----- begin exception -----
12-27 16:04:05.092 15634 15662 E TestRunner: junit.framework.AssertionFailedError: Failed to grant permissions, see logcat for details
12-27 16:04:05.092 15634 15662 E TestRunner: at junit.framework.Assert.fail(Assert.java:50)
12-27 16:04:05.092 15634 15662 E TestRunner: at androidx.test.runner.permission.PermissionRequester.requestPermissions(PermissionRequester.java:111)
12-27 16:04:05.092 15634 15662 E TestRunner: at androidx.test.rule.GrantPermissionRule$RequestPermissionStatement.evaluate(GrantPermissionRule.java:133)
12-27 16:04:05.092 15634 15662 E TestRunner: at org.junit.rules.RunRules.evaluate(RunRules.java:20)
12-27 16:04:05.092 15634 15662 E TestRunner: at org.junit.runne
@bastionkid
bastionkid / build.gradle.kts
Created June 13, 2023 07:26
abi splits configuration
android {
...
splits {
abi {
val onlyInclude = fun(abiTag: kotlin.String) {
// Enables building multiple APKs per ABI.
isEnable = true
// By default all ABIs are included, so use reset() and include to specify that
@bastionkid
bastionkid / build.gradle.kts
Created June 13, 2023 07:26
density splits configuration
android {
...
splits {
...
density {
val onlyInclude = fun (density: kotlin.String) {
// Enables building multiple APKs per ABI.
isEnable = true
@bastionkid
bastionkid / commit_short_sha.sh
Created June 13, 2023 08:04
Shell script to generate short SHA from git head commit
#!/bin/bash
commit_id=$(git rev-parse HEAD)
echo "${commit_id:0:7}"
@bastionkid
bastionkid / compare_apks_dictionary.py
Last active June 15, 2023 07:29
compare_apks.py - Dictionary Build phase
# generate dictionary of the grouped contents of an apk file
def get_apk_components(apk_file, size_type):
command = f"{apk_analyzer_path} files list --{size_type} {apk_file}"
files_with_size_string = execute_command(command)
files_with_size_list = files_with_size_string.split('\n')
components = {}
for item in files_with_size_list:
@bastionkid
bastionkid / compare_apks_setup.py
Last active June 15, 2023 07:29
compare_apks.py - Setup phase
# read arguments passed to this script
apk_1_sha = sys.argv[1]
apk_2_sha = sys.argv[2]
apk_1_name = f"{apk_1_sha}.apk"
apk_2_name = f"{apk_2_sha}.apk"
# apk_analyzer_path location will change based on the GHA runner that you're using i.e. mac/windows/ubuntu etc
apk_analyzer_path = "/usr/local/lib/android/sdk/cmdline-tools/latest/bin/apkanalyzer"
@bastionkid
bastionkid / compare_apks_html.py
Last active June 16, 2023 05:00
compare_apks.py - Generate HTML report phase
# generate html file containing size diff in HRF
def generate_size_diff_html():
html = "<html>"
html += "<body><h1>Download Size Diff Report</h1><h3>Affected Products</h3>"
html += "<ul><li><h4><code>release</code></h4><table>"
html += f"<tr><th>Component</th><th>Base ({apk_1_sha})</th><th>Merge ({apk_2_sha})</th><th>Diff</th></tr>"
# print diff of each components of both of the apk files
for component in set(components_1.keys()) | set(components_2.keys()):
size_1 = components_1.get(component, 0)