Skip to content

Commit f2356e4

Browse files
committed
Harden emulator installs before running instrumentation
1 parent 45626d5 commit f2356e4

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

scripts/build-android-app.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,13 +1293,19 @@ adb_install_file_path() {
12931293
return 1
12941294
fi
12951295

1296+
local install_status=1
12961297
if "$ADB_BIN" -s "$serial" shell pm install -r -t -g "$remote_tmp"; then
1297-
"$ADB_BIN" -s "$serial" shell rm -f "$remote_tmp" >/dev/null 2>&1 || true
1298-
return 0
1298+
install_status=0
1299+
else
1300+
local apk_size
1301+
apk_size=$(stat -c%s "$apk" 2>/dev/null || wc -c <"$apk")
1302+
if [ -n "$apk_size" ] && "$ADB_BIN" -s "$serial" shell "cat '$remote_tmp' | pm install -r -t -g -S $apk_size"; then
1303+
install_status=0
1304+
fi
12991305
fi
13001306

13011307
"$ADB_BIN" -s "$serial" shell rm -f "$remote_tmp" >/dev/null 2>&1 || true
1302-
return 1
1308+
return $install_status
13031309
}
13041310

13051311
ba_log "Inspecting Gradle application identifiers"

0 commit comments

Comments
 (0)