diff --git a/.github/scripts/run_tests.sh b/.github/scripts/run_tests.sh index 358c197a..fd4091bf 100755 --- a/.github/scripts/run_tests.sh +++ b/.github/scripts/run_tests.sh @@ -10,10 +10,8 @@ echo "Installing Seedvault app..." ./gradlew --stacktrace :app:installDebugAndroidTest sleep 60 -D2D_BACKUP_TEST=$1 - large_test_exit_code=0 -./gradlew --stacktrace -Pinstrumented_test_size=large -Pd2d_backup_test="$D2D_BACKUP_TEST" :app:connectedAndroidTest || large_test_exit_code=$? +./gradlew --stacktrace -Pinstrumented_test_size=large :app:connectedAndroidTest || large_test_exit_code=$? adb pull /sdcard/seedvault_test_results diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e4b9432e..363d0484 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,7 +20,6 @@ jobs: matrix: android_target: [ 34 ] emulator_type: [ aosp_atd ] - d2d_backup_test: [ true, false ] steps: - name: Checkout Code uses: actions/checkout@v3 @@ -53,7 +52,7 @@ jobs: disable-animations: true script: | ./app/development/scripts/provision_emulator.sh "test" "system-images;android-${{ matrix.android_target }};${{ matrix.emulator_type }};x86_64" - ./.github/scripts/run_tests.sh ${{ matrix.d2d_backup_test }} + ./.github/scripts/run_tests.sh - name: Upload test results if: always() diff --git a/app/build.gradle.kts b/app/build.gradle.kts index db81278f..05285696 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -39,9 +39,6 @@ android { testInstrumentationRunnerArguments["size"] = testSize } - - val d2dBackupTest = project.findProperty("d2d_backup_test")?.toString() ?: "true" - testInstrumentationRunnerArguments["d2d_backup_test"] = d2dBackupTest } signingConfigs { diff --git a/app/src/androidTest/java/com/stevesoltys/seedvault/KoinInstrumentationTestApp.kt b/app/src/androidTest/java/com/stevesoltys/seedvault/KoinInstrumentationTestApp.kt index b12c7ab7..8e405f2a 100644 --- a/app/src/androidTest/java/com/stevesoltys/seedvault/KoinInstrumentationTestApp.kt +++ b/app/src/androidTest/java/com/stevesoltys/seedvault/KoinInstrumentationTestApp.kt @@ -32,7 +32,7 @@ class KoinInstrumentationTestApp : App() { val testModule = module { val context = this@KoinInstrumentationTestApp - single { spyk(PackageService(context, get(), get(), get())) } + single { spyk(PackageService(context, get(), get())) } single { spyk(SettingsManager(context)) } single { spyk(BackupNotificationManager(context)) } diff --git a/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/LargeBackupTestBase.kt b/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/LargeBackupTestBase.kt index 55c5d4c4..738e19e6 100644 --- a/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/LargeBackupTestBase.kt +++ b/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/LargeBackupTestBase.kt @@ -74,7 +74,6 @@ internal interface LargeBackupTestBase : LargeTestBase { full = mutableMapOf(), kv = mutableMapOf(), userApps = packageService.userApps, - userNotAllowedApps = packageService.userNotAllowedApps ) val completed = spyOnBackup(backupResult) diff --git a/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/LargeRestoreTestBase.kt b/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/LargeRestoreTestBase.kt index 89ea8e9a..a2384191 100644 --- a/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/LargeRestoreTestBase.kt +++ b/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/LargeRestoreTestBase.kt @@ -63,7 +63,6 @@ internal interface LargeRestoreTestBase : LargeTestBase { full = mutableMapOf(), kv = mutableMapOf(), userApps = emptyList(), // will update everything below this after restore - userNotAllowedApps = emptyList() ) spyOnRestoreData(result) @@ -97,7 +96,6 @@ internal interface LargeRestoreTestBase : LargeTestBase { return result.copy( userApps = packageService.userApps, - userNotAllowedApps = packageService.userNotAllowedApps ) } diff --git a/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/LargeTestBase.kt b/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/LargeTestBase.kt index 1f7d63cc..467b5a28 100644 --- a/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/LargeTestBase.kt +++ b/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/LargeTestBase.kt @@ -112,11 +112,9 @@ internal interface LargeTestBase : KoinComponent { } 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 timeStamp = simpleDateFormat.format(Calendar.getInstance().time) - return "${timeStamp}_${d2d}_${testName.replace(" ", "_")}" + return "${timeStamp}_${testName.replace(" ", "_")}" } @OptIn(DelicateCoroutinesApi::class) diff --git a/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/SeedvaultLargeTest.kt b/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/SeedvaultLargeTest.kt index ba66e3d7..0c83cfa1 100644 --- a/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/SeedvaultLargeTest.kt +++ b/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/SeedvaultLargeTest.kt @@ -7,7 +7,6 @@ package com.stevesoltys.seedvault.e2e import android.content.pm.PackageManager import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.platform.app.InstrumentationRegistry import kotlinx.coroutines.runBlocking import org.junit.After import org.junit.Before @@ -52,17 +51,6 @@ internal abstract class SeedvaultLargeTest : startRecordingTest(keepRecordingScreen, name.methodName) restoreBaselineBackup() - - val arguments = InstrumentationRegistry.getArguments() - - if (arguments.getString("d2d_backup_test") == "true") { - println("Enabling D2D backups for test") - settingsManager.setD2dBackupsEnabled(true) - - } else { - println("Disabling D2D backups for test") - settingsManager.setD2dBackupsEnabled(false) - } } @After diff --git a/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/SeedvaultLargeTestResult.kt b/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/SeedvaultLargeTestResult.kt index 7dad500e..dcbf1c58 100644 --- a/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/SeedvaultLargeTestResult.kt +++ b/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/SeedvaultLargeTestResult.kt @@ -24,7 +24,6 @@ internal data class SeedvaultLargeTestResult( val full: MutableMap, val kv: MutableMap>, val userApps: List, - val userNotAllowedApps: List, ) { - fun allUserApps() = userApps + userNotAllowedApps + fun allUserApps() = userApps } diff --git a/app/src/main/java/com/stevesoltys/seedvault/repo/SnapshotCreator.kt b/app/src/main/java/com/stevesoltys/seedvault/repo/SnapshotCreator.kt index 15ee5f87..15d9df26 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/repo/SnapshotCreator.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/repo/SnapshotCreator.kt @@ -131,7 +131,7 @@ internal class SnapshotCreator( androidId = Settings.Secure.getString(context.contentResolver, ANDROID_ID) ?: "" sdkInt = Build.VERSION.SDK_INT androidIncremental = Build.VERSION.INCREMENTAL - d2D = settingsManager.d2dBackupsEnabled() + d2D = true putAllApps(appBuilderMap.mapValues { it.value.build() }) putAllBlobs(this@SnapshotCreator.blobsMap) }.build() diff --git a/app/src/main/java/com/stevesoltys/seedvault/settings/AppListRetriever.kt b/app/src/main/java/com/stevesoltys/seedvault/settings/AppListRetriever.kt index 6d9b156c..38336882 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/settings/AppListRetriever.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/settings/AppListRetriever.kt @@ -62,7 +62,6 @@ internal class AppListRetriever( val appListSections = linkedMapOf( AppSectionTitle(R.string.backup_section_system) to getSpecialApps(), AppSectionTitle(R.string.backup_section_user) to getApps(), - AppSectionTitle(R.string.backup_section_not_allowed) to getNotAllowedApps() ).filter { it.value.isNotEmpty() } return appListSections.flatMap { (sectionTitle, appList) -> @@ -129,21 +128,6 @@ internal class AppListRetriever( }).sortedBy { it.name.lowercase(locale) } } - private fun getNotAllowedApps(): List { - val locale = Locale.getDefault() - return packageService.userNotAllowedApps.map { - AppStatus( - packageName = it.packageName, - enabled = settingsManager.isBackupEnabled(it.packageName), - icon = getIconFromPackageManager(it.packageName), - name = getAppName(context, it.packageName).toString(), - time = 0, - size = null, - status = FAILED_NOT_ALLOWED, - ) - }.sortedBy { it.name.lowercase(locale) } - } - private fun getIconFromPackageManager(packageName: String): Drawable = try { pm.getApplicationIcon(packageName) } catch (e: PackageManager.NameNotFoundException) { diff --git a/app/src/main/java/com/stevesoltys/seedvault/settings/ExpertSettingsFragment.kt b/app/src/main/java/com/stevesoltys/seedvault/settings/ExpertSettingsFragment.kt index 07b25f9a..94243f06 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/settings/ExpertSettingsFragment.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/settings/ExpertSettingsFragment.kt @@ -46,18 +46,6 @@ class ExpertSettingsFragment : PreferenceFragmentCompat() { quotaPreference.isChecked = newValue as Boolean true } - - val d2dPreference = findPreference(PREF_KEY_D2D_BACKUPS) - - d2dPreference?.setOnPreferenceChangeListener { _, newValue -> - d2dPreference.isChecked = newValue as Boolean - - // automatically enable unlimited quota when enabling D2D backups - if (d2dPreference.isChecked) { - quotaPreference?.isChecked = true - } - true - } } override fun onStart() { diff --git a/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsManager.kt b/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsManager.kt index 25a23706..6e8a41e1 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsManager.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsManager.kt @@ -56,7 +56,6 @@ private const val PREF_KEY_BACKUP_APP_BLACKLIST = "backupAppBlacklist" private const val PREF_KEY_BACKUP_STORAGE = "backup_storage" internal const val PREF_KEY_UNLIMITED_QUOTA = "unlimited_quota" -internal const val PREF_KEY_D2D_BACKUPS = "d2d_backups" internal const val PREF_KEY_LAST_BACKUP = "lastBackup" class SettingsManager(private val context: Context) { @@ -249,14 +248,6 @@ class SettingsManager(private val context: Context) { fun isQuotaUnlimited() = prefs.getBoolean(PREF_KEY_UNLIMITED_QUOTA, false) - fun d2dBackupsEnabled() = prefs.getBoolean(PREF_KEY_D2D_BACKUPS, false) - - fun setD2dBackupsEnabled(enabled: Boolean) { - prefs.edit() - .putBoolean(PREF_KEY_D2D_BACKUPS, enabled) - .apply() - } - /** * This assumes that if there's no storage plugin set, it is the first start. * We enforce a storage plugin and don't allow unsetting one, diff --git a/app/src/main/java/com/stevesoltys/seedvault/transport/ConfigurableBackupTransport.kt b/app/src/main/java/com/stevesoltys/seedvault/transport/ConfigurableBackupTransport.kt index 160c6aca..e5dbe02c 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/transport/ConfigurableBackupTransport.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/transport/ConfigurableBackupTransport.kt @@ -62,13 +62,7 @@ class ConfigurableBackupTransport internal constructor(private val context: Cont * which is accessible to the BackupAgent. * This allows the agent to decide what to do based on properties of the transport. */ - override fun getTransportFlags(): Int { - return if (settingsManager.d2dBackupsEnabled()) { - D2D_TRANSPORT_FLAGS - } else { - DEFAULT_TRANSPORT_FLAGS - } - } + override fun getTransportFlags(): Int = D2D_TRANSPORT_FLAGS /** * Ask the transport for an [Intent] that can be used to launch diff --git a/app/src/main/java/com/stevesoltys/seedvault/transport/backup/BackupModule.kt b/app/src/main/java/com/stevesoltys/seedvault/transport/backup/BackupModule.kt index 8bd7bd54..4adc8cc1 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/transport/backup/BackupModule.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/transport/backup/BackupModule.kt @@ -14,7 +14,6 @@ val backupModule = module { single { PackageService( context = androidContext(), - backupManager = get(), settingsManager = get(), backendManager = get(), ) diff --git a/app/src/main/java/com/stevesoltys/seedvault/transport/backup/PackageService.kt b/app/src/main/java/com/stevesoltys/seedvault/transport/backup/PackageService.kt index 51ecceda..4e0da947 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/transport/backup/PackageService.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/transport/backup/PackageService.kt @@ -5,12 +5,10 @@ package com.stevesoltys.seedvault.transport.backup -import android.app.backup.IBackupManager import android.content.Context import android.content.Intent import android.content.Intent.ACTION_MAIN import android.content.Intent.CATEGORY_LAUNCHER -import android.content.pm.ApplicationInfo.FLAG_ALLOW_BACKUP import android.content.pm.ApplicationInfo.FLAG_STOPPED import android.content.pm.ApplicationInfo.FLAG_SYSTEM import android.content.pm.ApplicationInfo.FLAG_TEST_ONLY @@ -22,7 +20,6 @@ import android.content.pm.PackageManager.GET_SIGNING_CERTIFICATES import android.content.pm.PackageManager.MATCH_SYSTEM_ONLY import android.content.pm.ResolveInfo import android.os.RemoteException -import android.os.UserHandle import android.util.Log import android.util.Log.INFO import androidx.annotation.WorkerThread @@ -41,13 +38,11 @@ private const val LOG_MAX_PACKAGES = 100 */ internal class PackageService( private val context: Context, - private val backupManager: IBackupManager, private val settingsManager: SettingsManager, private val backendManager: BackendManager, ) { private val packageManager: PackageManager = context.packageManager - private val myUserId = UserHandle.myUserId() private val backend: Backend get() = backendManager.backend val eligiblePackages: List @@ -64,14 +59,7 @@ internal class PackageService( logPackages(packages) } - val eligibleApps = if (settingsManager.d2dBackupsEnabled()) { - // if D2D is enabled, use the "new method" for filtering packages - packages.filter(::shouldIncludeAppInBackup).toTypedArray() - } else { - // otherwise, use the BackupManager call. - backupManager.filterAppsEligibleForBackupForUser(myUserId, packages.toTypedArray()) - } - + val eligibleApps = packages.filter(::shouldIncludeAppInBackup).toTypedArray() // log eligible packages if (Log.isLoggable(TAG, INFO)) { Log.i(TAG, "Filtering left ${eligibleApps.size} eligible packages:") @@ -140,17 +128,7 @@ internal class PackageService( /** * A list of apps that do not allow backup. */ - val userNotAllowedApps: List - @WorkerThread - get() { - // if D2D backups are enabled, all apps are allowed - if (settingsManager.d2dBackupsEnabled()) return emptyList() - - return packageManager.getInstalledPackages(0).filter { packageInfo -> - !packageInfo.allowsBackup() && - !packageInfo.isSystemApp() - } - } + val userNotAllowedApps: List = emptyList() val launchableSystemApps: List @WorkerThread @@ -196,26 +174,20 @@ internal class PackageService( } private fun PackageInfo.allowsBackup(): Boolean { + /** + * TODO: Consider ways of replicating the system's logic so that the user can have + * advance knowledge of apps that the system will exclude, particularly apps targeting + * SDK 30 or below. + * + * At backup time, the system will filter out any apps that *it* does not want to be + * backed up. If the user has enabled D2D, *we* generally want to back up as much as + * possible; part of the point of D2D is to ignore FLAG_ALLOW_BACKUP (allowsBackup). + * So, we return true. + * See frameworks/base/services/backup/java/com/android/server/backup/utils/ + * BackupEligibilityRules.java lines 74-81 and 163-167 (tag: android-13.0.0_r8). + */ val appInfo = applicationInfo - if (packageName == MAGIC_PACKAGE_MANAGER || appInfo == null) return false - - return if (settingsManager.d2dBackupsEnabled()) { - /** - * TODO: Consider ways of replicating the system's logic so that the user can have - * advance knowledge of apps that the system will exclude, particularly apps targeting - * SDK 30 or below. - * - * At backup time, the system will filter out any apps that *it* does not want to be - * backed up. If the user has enabled D2D, *we* generally want to back up as much as - * possible; part of the point of D2D is to ignore FLAG_ALLOW_BACKUP (allowsBackup). - * So, we return true. - * See frameworks/base/services/backup/java/com/android/server/backup/utils/ - * BackupEligibilityRules.java lines 74-81 and 163-167 (tag: android-13.0.0_r8). - */ - true - } else { - appInfo.flags and FLAG_ALLOW_BACKUP != 0 - } + return !(packageName == MAGIC_PACKAGE_MANAGER || appInfo == null) } /** diff --git a/app/src/main/java/com/stevesoltys/seedvault/transport/restore/RestoreCoordinator.kt b/app/src/main/java/com/stevesoltys/seedvault/transport/restore/RestoreCoordinator.kt index 95fa79e2..f8b76198 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/transport/restore/RestoreCoordinator.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/transport/restore/RestoreCoordinator.kt @@ -167,10 +167,6 @@ internal class RestoreCoordinator( */ fun beforeStartRestore(restorableBackup: RestorableBackup) { this.restorableBackup = restorableBackup - - if (restorableBackup.d2dBackup) { - settingsManager.setD2dBackupsEnabled(true) - } } /** diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b08e55b8..8a5c2fff 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -69,8 +69,6 @@ Expert settings Unlimited app quota Do not impose a limitation on the size of app backups.\n\nWarning: This can fill up your storage location quickly. Not needed for most apps. - Device-to-device backups - This forces backups for most apps, even when they disallow them. This is alpha, use at your own risk. Save app log Developers can diagnose bugs with these logs.\n\nWarning: The log file might contain personally identifiable information. Review before and delete after sharing! Error: Could not save app log @@ -204,7 +202,6 @@ Backup quota exceeded Backup quota was exceeded App not installed - Apps that do not allow data backup Restore from backup diff --git a/app/src/main/res/xml/settings_expert.xml b/app/src/main/res/xml/settings_expert.xml index 3929fceb..547fd80a 100644 --- a/app/src/main/res/xml/settings_expert.xml +++ b/app/src/main/res/xml/settings_expert.xml @@ -9,12 +9,6 @@ android:key="unlimited_quota" android:summary="@string/settings_expert_quota_summary" android:title="@string/settings_expert_quota_title" /> - (), s.blobsMap)