Upgrade to Android 10 (Q)
If somebody wants the backup app to work on a lower Android version, they need to maintain a branch for that which uses and targets the old API.
This commit is contained in:
parent
8adb94c6c9
commit
37ffacbafe
9 changed files with 20 additions and 16 deletions
|
@ -6,12 +6,12 @@ apply plugin: 'kotlin-android-extensions'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
|
|
||||||
compileSdkVersion 28
|
compileSdkVersion 29
|
||||||
buildToolsVersion '28.0.3'
|
buildToolsVersion '29.0.2'
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 26
|
minSdkVersion 29
|
||||||
targetSdkVersion 28
|
targetSdkVersion 29
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -5,11 +5,6 @@
|
||||||
android:versionCode="5"
|
android:versionCode="5"
|
||||||
android:versionName="0.3.0">
|
android:versionName="0.3.0">
|
||||||
|
|
||||||
<uses-sdk
|
|
||||||
android:minSdkVersion="26"
|
|
||||||
android:targetSdkVersion="28"
|
|
||||||
tools:ignore="GradleOverrides,OldTargetApi" />
|
|
||||||
|
|
||||||
<uses-permission
|
<uses-permission
|
||||||
android:name="android.permission.BACKUP"
|
android:name="android.permission.BACKUP"
|
||||||
tools:ignore="ProtectedPermissions" />
|
tools:ignore="ProtectedPermissions" />
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.app.Application
|
||||||
import android.app.backup.IRestoreObserver
|
import android.app.backup.IRestoreObserver
|
||||||
import android.app.backup.IRestoreSession
|
import android.app.backup.IRestoreSession
|
||||||
import android.app.backup.RestoreSet
|
import android.app.backup.RestoreSet
|
||||||
|
import android.os.UserHandle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.annotation.WorkerThread
|
import androidx.annotation.WorkerThread
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
|
@ -40,7 +41,7 @@ class RestoreViewModel(app: Application) : RequireProvisioningViewModel(app), Re
|
||||||
internal val restoreFinished: LiveData<Int> get() = mRestoreFinished
|
internal val restoreFinished: LiveData<Int> get() = mRestoreFinished
|
||||||
|
|
||||||
internal fun loadRestoreSets() {
|
internal fun loadRestoreSets() {
|
||||||
val session = this.session ?: backupManager.beginRestoreSession(null, TRANSPORT_ID)
|
val session = this.session ?: backupManager.beginRestoreSessionForUser(UserHandle.myUserId(), null, TRANSPORT_ID)
|
||||||
this.session = session
|
this.session = session
|
||||||
|
|
||||||
if (session == null) {
|
if (session == null) {
|
||||||
|
|
|
@ -43,7 +43,7 @@ class PackageService {
|
||||||
Log.d(TAG, "Got ${packageList.size} packages: $packageList")
|
Log.d(TAG, "Got ${packageList.size} packages: $packageList")
|
||||||
|
|
||||||
// TODO why is this filtering out so much?
|
// TODO why is this filtering out so much?
|
||||||
val eligibleApps = backupManager.filterAppsEligibleForBackup(packageList.toTypedArray())
|
val eligibleApps = backupManager.filterAppsEligibleForBackupForUser(UserHandle.myUserId(), packageList.toTypedArray())
|
||||||
|
|
||||||
Log.d(TAG, "Filtering left ${eligibleApps.size} eligible packages: ${Arrays.toString(eligibleApps)}")
|
Log.d(TAG, "Filtering left ${eligibleApps.size} eligible packages: ${Arrays.toString(eligibleApps)}")
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
package com.stevesoltys.backup.session.restore;
|
package com.stevesoltys.backup.session.restore;
|
||||||
|
|
||||||
import android.app.backup.*;
|
import android.app.backup.BackupManager;
|
||||||
|
import android.app.backup.IBackupManager;
|
||||||
|
import android.app.backup.IRestoreObserver;
|
||||||
|
import android.app.backup.IRestoreSession;
|
||||||
|
import android.app.backup.RestoreSet;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
import android.os.UserHandle;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -31,7 +36,7 @@ public class RestoreSession extends IRestoreObserver.Stub {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
restoreSession = backupManager.beginRestoreSession(null, null);
|
restoreSession = backupManager.beginRestoreSessionForUser(UserHandle.myUserId(), null, null);
|
||||||
|
|
||||||
if (restoreSession == null) {
|
if (restoreSession == null) {
|
||||||
stop(RestoreResult.FAILURE);
|
stop(RestoreResult.FAILURE);
|
||||||
|
@ -62,7 +67,7 @@ public class RestoreSession extends IRestoreObserver.Stub {
|
||||||
if (restoreSets.length > 0) {
|
if (restoreSets.length > 0) {
|
||||||
RestoreSet restoreSet = restoreSets[0];
|
RestoreSet restoreSet = restoreSets[0];
|
||||||
String[] packageArray = packages.toArray(new String[0]);
|
String[] packageArray = packages.toArray(new String[0]);
|
||||||
int result = restoreSession.restoreSome(restoreSet.token, this, null, packageArray);
|
int result = restoreSession.restorePackages(restoreSet.token, this, packageArray, null);
|
||||||
|
|
||||||
if (result != BackupManager.SUCCESS) {
|
if (result != BackupManager.SUCCESS) {
|
||||||
stop(RestoreResult.FAILURE);
|
stop(RestoreResult.FAILURE);
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
package com.stevesoltys.backup.ui.storage
|
package com.stevesoltys.backup.ui.storage
|
||||||
|
|
||||||
|
import android.app.ActivityManager
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.app.backup.BackupProgress
|
import android.app.backup.BackupProgress
|
||||||
import android.app.backup.IBackupObserver
|
import android.app.backup.IBackupObserver
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import android.os.UserHandle
|
||||||
|
import android.os.UserManager
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.annotation.WorkerThread
|
import androidx.annotation.WorkerThread
|
||||||
import com.stevesoltys.backup.Backup
|
import com.stevesoltys.backup.Backup
|
||||||
|
@ -25,7 +28,7 @@ internal class BackupStorageViewModel(private val app: Application) : StorageVie
|
||||||
|
|
||||||
// initialize the new location
|
// initialize the new location
|
||||||
val observer = InitializationObserver()
|
val observer = InitializationObserver()
|
||||||
Backup.backupManager.initializeTransports(arrayOf(TRANSPORT_ID), observer)
|
Backup.backupManager.initializeTransportsForUser(UserHandle.myUserId(), arrayOf(TRANSPORT_ID), observer)
|
||||||
}
|
}
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
|
|
|
@ -10,7 +10,7 @@ buildscript {
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
// newer versions require us to remove targetSdkVersion from Manifest
|
// newer versions require us to remove targetSdkVersion from Manifest
|
||||||
classpath 'com.android.tools.build:gradle:3.1.0'
|
classpath 'com.android.tools.build:gradle:3.5.0'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
|
Loading…
Reference in a new issue