Try to fix issue where our transport doesn't get registered in emulator

This commit is contained in:
Torsten Grote 2024-05-31 16:53:26 -03:00
parent 08727651af
commit c483332b15
No known key found for this signature in database
GPG key ID: 3E5F77D92CF891FF
5 changed files with 26 additions and 36 deletions

View file

@ -3,21 +3,12 @@
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# #
adb root echo "Disable auto-restore"
sleep 5 adb shell bmgr autorestore false
adb remount
echo "Installing Seedvault app..." echo "Installing Seedvault app..."
adb shell mkdir -p /system/priv-app/Seedvault ./gradlew --stacktrace :app:installDebugAndroidTest
adb push app/build/outputs/apk/release/app-release.apk /system/priv-app/Seedvault/Seedvault.apk sleep 60
echo "Installing Seedvault permissions..."
adb push permissions_com.stevesoltys.seedvault.xml /system/etc/permissions/privapp-permissions-seedvault.xml
adb push allowlist_com.stevesoltys.seedvault.xml /system/etc/sysconfig/allowlist-seedvault.xml
echo "Setting Seedvault transport..."
sleep 10
adb shell bmgr transport com.stevesoltys.seedvault.transport.ConfigurableBackupTransport
D2D_BACKUP_TEST=$1 D2D_BACKUP_TEST=$1

View file

@ -11,10 +11,9 @@ if [ -z "$ANDROID_HOME" ]; then
fi fi
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
DEVELOPMENT_DIR=$SCRIPT_DIR/..
ROOT_PROJECT_DIR=$SCRIPT_DIR/../../.. ROOT_PROJECT_DIR=$SCRIPT_DIR/../../..
EMULATOR_DEVICE_NAME=$($ANDROID_HOME/platform-tools/adb devices | grep emulator | cut -f1) EMULATOR_DEVICE_NAME=$("$ANDROID_HOME"/platform-tools/adb devices | grep emulator | cut -f1)
if [ -z "$EMULATOR_DEVICE_NAME" ]; then if [ -z "$EMULATOR_DEVICE_NAME" ]; then
echo "Emulator device name not found" echo "Emulator device name not found"
@ -29,13 +28,9 @@ $ADB remount # remount /system as writable
echo "Installing Seedvault app..." echo "Installing Seedvault app..."
$ADB shell mkdir -p /system/priv-app/Seedvault $ADB shell mkdir -p /system/priv-app/Seedvault
$ADB push $ROOT_PROJECT_DIR/app/build/outputs/apk/release/app-release.apk /system/priv-app/Seedvault/Seedvault.apk $ADB push "$ROOT_PROJECT_DIR"/app/build/outputs/apk/release/app-release.apk /system/priv-app/Seedvault/Seedvault.apk
echo "Installing Seedvault permissions..." echo "Installing Seedvault permissions..."
$ADB push $ROOT_PROJECT_DIR/permissions_com.stevesoltys.seedvault.xml /system/etc/permissions/privapp-permissions-seedvault.xml $ADB push "$ROOT_PROJECT_DIR"/permissions_com.stevesoltys.seedvault.xml /system/etc/permissions/privapp-permissions-seedvault.xml
$ADB push $ROOT_PROJECT_DIR/allowlist_com.stevesoltys.seedvault.xml /system/etc/sysconfig/allowlist-seedvault.xml $ADB push "$ROOT_PROJECT_DIR"/allowlist_com.stevesoltys.seedvault.xml /system/etc/sysconfig/allowlist-seedvault.xml
$ADB shell am force-stop com.stevesoltys.seedvault
$ADB shell am broadcast -a android.intent.action.BOOT_COMPLETED $ADB shell am broadcast -a android.intent.action.BOOT_COMPLETED
echo "Setting Seedvault transport..."
$ADB shell bmgr transport com.stevesoltys.seedvault.transport.ConfigurableBackupTransport

View file

@ -20,25 +20,23 @@ EMULATOR_NAME=$1
SYSTEM_IMAGE=$2 SYSTEM_IMAGE=$2
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
DEVELOPMENT_DIR=$SCRIPT_DIR/..
ROOT_PROJECT_DIR=$SCRIPT_DIR/../../..
echo "Downloading system image..." echo "Downloading system image..."
yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install "$SYSTEM_IMAGE" yes | "$ANDROID_HOME"/cmdline-tools/latest/bin/sdkmanager --install "$SYSTEM_IMAGE"
# create AVD if it doesn't exist # create AVD if it doesn't exist
if $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager list avd | grep -q "$EMULATOR_NAME"; then if "$ANDROID_HOME"/cmdline-tools/latest/bin/avdmanager list avd | grep -q "$EMULATOR_NAME"; then
echo "AVD already exists. Skipping creation." echo "AVD already exists. Skipping creation."
else else
echo "Creating AVD..." echo "Creating AVD..."
echo 'no' | $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd -n "$EMULATOR_NAME" -k "$SYSTEM_IMAGE" echo 'no' | "$ANDROID_HOME"/cmdline-tools/latest/bin/avdmanager create avd -n "$EMULATOR_NAME" -k "$SYSTEM_IMAGE"
sleep 1 sleep 1
fi fi
EMULATOR_DEVICE_NAME=$($ANDROID_HOME/platform-tools/adb devices | grep emulator | cut -f1) EMULATOR_DEVICE_NAME=$("$ANDROID_HOME"/platform-tools/adb devices | grep emulator | cut -f1)
if [ -z "$EMULATOR_DEVICE_NAME" ]; then if [ -z "$EMULATOR_DEVICE_NAME" ]; then
$SCRIPT_DIR/start_emulator.sh "$EMULATOR_NAME" "$SCRIPT_DIR"/start_emulator.sh "$EMULATOR_NAME"
fi fi
# wait for emulator device to appear with 180 second timeout # wait for emulator device to appear with 180 second timeout
@ -47,7 +45,7 @@ echo "Waiting for emulator device..."
for i in {1..180}; do for i in {1..180}; do
if [ -z "$EMULATOR_DEVICE_NAME" ]; then if [ -z "$EMULATOR_DEVICE_NAME" ]; then
sleep 1 sleep 1
EMULATOR_DEVICE_NAME=$($ANDROID_HOME/platform-tools/adb devices | grep emulator | cut -f1) EMULATOR_DEVICE_NAME=$("$ANDROID_HOME"/platform-tools/adb devices | grep emulator | cut -f1)
else else
break break
fi fi
@ -73,16 +71,14 @@ $ADB reboot # need to reboot first time we remount
$ADB wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;' $ADB wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;'
echo "Provisioning emulator for Seedvault..." echo "Provisioning emulator for Seedvault..."
$SCRIPT_DIR/install_app.sh "$SCRIPT_DIR"/install_app.sh
echo "Rebooting emulator..." echo "Rebooting emulator..."
$ADB reboot $ADB reboot
$ADB wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;' $ADB wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;'
echo "Setting backup transport to Seedvault..." echo "Disabling backup..."
$ADB shell bmgr enable true $ADB shell bmgr enable false
sleep 5
$ADB shell bmgr transport com.stevesoltys.seedvault.transport.ConfigurableBackupTransport
echo "Downloading and extracting test backup to '/sdcard/seedvault_baseline'..." echo "Downloading and extracting test backup to '/sdcard/seedvault_baseline'..."

View file

@ -113,9 +113,11 @@ internal interface LargeTestBase : KoinComponent {
} }
fun testResultFilename(testName: String): String { fun testResultFilename(testName: String): String {
val arguments = InstrumentationRegistry.getArguments()
val d2d = if (arguments.getString("d2d_backup_test") == "true") "d2d" else ""
val simpleDateFormat = SimpleDateFormat("yyyyMMdd_hhmmss") val simpleDateFormat = SimpleDateFormat("yyyyMMdd_hhmmss")
val timeStamp = simpleDateFormat.format(Calendar.getInstance().time) val timeStamp = simpleDateFormat.format(Calendar.getInstance().time)
return "${timeStamp}_${testName.replace(" ", "_")}" return "${timeStamp}_${d2d}_${testName.replace(" ", "_")}"
} }
@OptIn(DelicateCoroutinesApi::class) @OptIn(DelicateCoroutinesApi::class)

View file

@ -16,6 +16,7 @@ import org.junit.rules.TestName
import org.junit.runner.RunWith import org.junit.runner.RunWith
import org.koin.core.component.KoinComponent import org.koin.core.component.KoinComponent
import java.io.File import java.io.File
import java.lang.Thread.sleep
import java.util.concurrent.atomic.AtomicBoolean import java.util.concurrent.atomic.AtomicBoolean
@RunWith(AndroidJUnit4::class) @RunWith(AndroidJUnit4::class)
@ -44,6 +45,11 @@ internal abstract class SeedvaultLargeTest :
resetApplicationState() resetApplicationState()
clearTestBackups() clearTestBackups()
runCommand("bmgr enable true")
sleep(60_000)
runCommand("bmgr transport com.stevesoltys.seedvault.transport.ConfigurableBackupTransport")
sleep(60_000)
startRecordingTest(keepRecordingScreen, name.methodName) startRecordingTest(keepRecordingScreen, name.methodName)
restoreBaselineBackup() restoreBaselineBackup()