Skip to content

Commit

Permalink
deploy: trigger logcat -c after package installs, increase sleeps a…
Browse files Browse the repository at this point in the history
… bit (#314)
  • Loading branch information
larpon authored Sep 24, 2024
1 parent 97a1fe6 commit bc87aa0
Showing 1 changed file with 36 additions and 29 deletions.
65 changes: 36 additions & 29 deletions android/deploy.v
Original file line number Diff line number Diff line change
Expand Up @@ -102,33 +102,36 @@ pub fn deploy_apk(opt DeployOptions) ! {
}
}

adb_cmd := [
adb,
'-s "${device_id}"',
'install',
'-r',
opt.deploy_file,
]
util.verbosity_print_cmd(adb_cmd, opt.verbosity)
util.run_or_error(adb_cmd)!

// Clearing the logs should be done *after* install so there is actually
// something in the logs to clear - otherwise the clear command might fail,
// presumably because of low log activity. It seem to happen more often on
// devices with low log activity (like the slim `aosp_atd` emulator images).
adb_logcat_clear_cmd := [
adb,
'-s "${device_id}"',
'logcat',
'-c',
]
if opt.clear_device_log || (opt.run != '' && opt.device_log) {
// Give adb/Android/connection time to settle... *sigh*
time.sleep(150 * time.millisecond)
// Clear logs first
opt.verbose(1, 'Clearing log buffer on device "${device_id}"...')
util.verbosity_print_cmd(adb_logcat_clear_cmd, opt.verbosity)
util.run_or_error(adb_logcat_clear_cmd)!
// Give adb/Android/connection time to settle... *sigh*
time.sleep(100 * time.millisecond)
}

adb_cmd := [
adb,
'-s "${device_id}"',
'install',
'-r',
opt.deploy_file,
]
util.verbosity_print_cmd(adb_cmd, opt.verbosity)
util.run_or_error(adb_cmd)!

// Give adb/Android/connection time to settle... *sigh*
time.sleep(100 * time.millisecond)
time.sleep(150 * time.millisecond)

if opt.run != '' {
opt.verbose(1, 'Running "${opt.run}" on "${device_id}"...')
Expand Down Expand Up @@ -205,35 +208,39 @@ pub fn deploy_aab(opt DeployOptions) ! {
}
}

// java -jar bundletool.jar install-apks --apks=/MyApp/my_app.apks
bundletool_install_apks_cmd := [
java_exe,
'-jar',
bundletool,
'install-apks',
'--device-id ${device_id}',
'--apks="' + apks_path + '"',
]
util.verbosity_print_cmd(bundletool_install_apks_cmd, opt.verbosity)
util.run_or_error(bundletool_install_apks_cmd)!

// Clearing the logs should be done *after* install so there is actually
// something in the logs to clear - otherwise the clear command might fail,
// presumably because of low log activity. It seem to happen more often on
// devices with low log activity (like the slim `aosp_atd` emulator images).
adb_logcat_clear_cmd := [
adb,
'-s "${device_id}"',
'logcat',
'-c',
]
if opt.clear_device_log || (opt.run != '' && opt.device_log) {
// Give adb/Android/connection time to settle... *sigh*
time.sleep(150 * time.millisecond)
// Clear logs first
opt.verbose(1, 'Clearing log buffer on device "${device_id}"...')
util.verbosity_print_cmd(adb_logcat_clear_cmd, opt.verbosity)
util.run_or_error(adb_logcat_clear_cmd)!
// Give adb/Android/connection time to settle... *sigh*
time.sleep(100 * time.millisecond)
}

// java -jar bundletool.jar install-apks --apks=/MyApp/my_app.apks
bundletool_install_apks_cmd := [
java_exe,
'-jar',
bundletool,
'install-apks',
'--device-id ${device_id}',
'--apks="' + apks_path + '"',
]
util.verbosity_print_cmd(bundletool_install_apks_cmd, opt.verbosity)
util.run_or_error(bundletool_install_apks_cmd)!

// Give adb/Android/connection time to settle... *sigh*
time.sleep(100 * time.millisecond)
time.sleep(150 * time.millisecond)

if opt.run != '' {
if opt.verbosity > 0 {
Expand Down

0 comments on commit bc87aa0

Please sign in to comment.