Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ gradle-app.setting

## Android
gen/

## Emulator
app/backup.tar.gz
24 changes: 0 additions & 24 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -258,27 +258,3 @@ tasks.register<Exec>("startEmulator") {
environment("JAVA_HOME", System.getProperty("java.home"))
}
}

tasks.register<Exec>("installEmulatorRelease") {
group = "emulator"

dependsOn(tasks.getByName("assembleRelease"))

doFirst {
commandLine("${project.projectDir}/development/scripts/install_app.sh")

environment("ANDROID_HOME", android.sdkDirectory.absolutePath)
environment("JAVA_HOME", System.getProperty("java.home"))
}
}

tasks.register<Exec>("clearEmulatorAppData") {
group = "emulator"

doFirst {
commandLine("${project.projectDir}/development/scripts/clear_app_data.sh")

environment("ANDROID_HOME", android.sdkDirectory.absolutePath)
environment("JAVA_HOME", System.getProperty("java.home"))
}
}
20 changes: 3 additions & 17 deletions app/development/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@
It is possible to install and run Seedvault in an emulator. This is likely the path of least resistance, since you don't need to build AOSP from source to make and test code changes.

It's also helpful for quickly testing Seedvault on newer versions of Android.
Please note that this process has only been tested on Linux.

Please note that this process has only been tested on Linux. If the scripts break with newer versions, try looking at the changes made to the pipeline defined in [.cirrus.yaml](../../.cirrus.yml).

### Setup

After opening the project in Android Studio, try running the `app:provisionEmulator` Gradle task.

This task runs the script in `scripts/provision_emulator.sh`:

```bash
./app/development/scripts/provision_emulator.sh "seedvault" "system-images;android-33;google_apis;x86_64"
```
This task runs the script in `scripts/provision_emulator.sh`

### Starting the emulator

Expand All @@ -26,17 +23,6 @@ This task runs the script in `scripts/start_emulator.sh`:

```bash
./app/development/scripts/start_emulator.sh "seedvault"
```

### Testing changes

Once the emulator is provisioned and running, you should be able to use the `app:installEmulatorRelease`
Gradle task to install updates.

This task depends on `app:assembleRelease` and runs the script in `scripts/install_app.sh`:

```bash
./app/development/scripts/install_app.sh
```

There's also an Android Studio [runtime configuration](https://developer.android.com/studio/run/rundebugconfig) `app-emulator` which will build, install, and automatically launch the `com.stevesoltys.seedvault.settings.SettingsActivity` as if you clicked `Backup` in settings.
Expand Down
26 changes: 0 additions & 26 deletions app/development/scripts/clear_app_data.sh

This file was deleted.

36 changes: 0 additions & 36 deletions app/development/scripts/install_app.sh

This file was deleted.

70 changes: 41 additions & 29 deletions app/development/scripts/provision_emulator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)

# replicates steps found in .cirrus.yml

echo "Downloading system image..."
yes | "$ANDROID_HOME"/cmdline-tools/latest/bin/sdkmanager --install "$SYSTEM_IMAGE"

Expand Down Expand Up @@ -57,47 +59,57 @@
fi

ADB="$ANDROID_HOME/platform-tools/adb -s $EMULATOR_DEVICE_NAME"

Check warning

Code scanning / Shellcheck (reported by Codacy)

Expressions don't expand in single quotes, use double quotes for that. Warning

Expressions don't expand in single quotes, use double quotes for that.
echo "Downloading seedvault test data"

if [ ! -f backup.tar.gz ]; then
echo "Downloading test backup..."
wget https://github.com/seedvault-app/seedvault-test-data/releases/download/3/backup.tar.gz
fi

echo "Waiting for emulator to boot..."
$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;'

Check warning

Code scanning / Shellcheck (reported by Codacy)

Expressions don't expand in single quotes, use double quotes for that. Warning

Expressions don't expand in single quotes, use double quotes for that.

Check warning

Code scanning / Shellcheck (reported by Codacy)

Expressions don't expand in single quotes, use double quotes for that. Warning

Expressions don't expand in single quotes, use double quotes for that.

echo "Provisioning emulator for write access to '/system'..."
$ADB root
sleep 3 # wait for adb to restart
sleep 5 # wait for adb to restart
$ADB remount # remount /system as writable

echo "Rebooting emulator..."
$ADB reboot # need to reboot first time we remount
$ADB wait-for-device shell "while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;"

echo "Provisioning emulator for Seedvault..."
"$SCRIPT_DIR"/install_app.sh

echo "Rebooting emulator..."
$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;'

Check warning

Code scanning / Shellcheck (reported by Codacy)

Expressions don't expand in single quotes, use double quotes for that. Warning

Expressions don't expand in single quotes, use double quotes for that.
$ADB root
sleep 5
$ADB remount
sleep 5

echo "Disabling backup..."
$ADB shell bmgr enable false
echo "Installing Seedvault"

echo "Downloading and extracting test backup to '/sdcard/seedvault_baseline'..."
com1='while [[ -z $('

Check warning

Code scanning / Shellcheck (reported by Codacy)

Expressions don't expand in single quotes, use double quotes for that. Warning

Expressions don't expand in single quotes, use double quotes for that.
com2=' shell mount | grep "/system " | grep "(rw,") ]]; do sleep 1; done;'
timeout 180s bash -c "${com1}${ADB}${com2}";
$ADB wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;'

Check warning

Code scanning / Shellcheck (reported by Codacy)

Expressions don't expand in single quotes, use double quotes for that. Warning

Expressions don't expand in single quotes, use double quotes for that.

if [ ! -f backup.tar.gz ]; then
echo "Downloading test backup..."
wget --quiet https://github.com/seedvault-app/seedvault-test-data/releases/download/3/backup.tar.gz
fi
$ADB shell mkdir -p /sdcard/seedvault_baseline
$ADB push backup.tar.gz /sdcard/seedvault_baseline/backup.tar.gz
$ADB shell tar xzf /sdcard/seedvault_baseline/backup.tar.gz --directory=/sdcard/seedvault_baseline

$ADB root
sleep 3 # wait for adb to restart
$ADB push backup.tar.gz /sdcard
rm backup.tar.gz
ROOT_PROJECT_DIR=$SCRIPT_DIR/../../..

$ADB wait-for-device
$ADB shell mkdir -p /sdcard/seedvault_baseline
$ADB shell tar xzf /sdcard/backup.tar.gz --directory=/sdcard/seedvault_baseline
$ADB shell rm /sdcard/backup.tar.gz
$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"/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

# uncomment to enable installing contactsbackup
# $ADB shell mkdir -p /system/priv-app/ContactsBackup;
# $ADB push "$ROOT_PROJECT_DIR"/contactsbackup/build/outputs/apk/release/contactsbackup-release.apk /system/priv-app/ContactsBackup/contactsbackup.apk
# $ADB push "$ROOT_PROJECT_DIR"/contactsbackup/default-permissions_org.calyxos.backup.contacts.xml /system/etc/default-permissions/default-permissions_org.calyxos.backup.contacts.xml

# sometimes a system dialog (e.g. launcher stopped) is showing and taking focus
$ADB shell am broadcast -a android.intent.action.CLOSE_SYSTEM_DIALOGS
$ADB shell bmgr enable true
$ADB reboot
$ADB wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;'
sleep 15 # wait for android to recognize new transport
$ADB shell bmgr transport com.stevesoltys.seedvault.transport.ConfigurableBackupTransport
$ADB reboot
$ADB wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;'

echo "Emulator '$EMULATOR_NAME' has been provisioned with Seedvault!"
Loading