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:
Torsten Grote 2019-09-19 07:38:36 -03:00
parent 8adb94c6c9
commit 37ffacbafe
No known key found for this signature in database
GPG key ID: 3E5F77D92CF891FF
9 changed files with 20 additions and 16 deletions

View file

@ -6,12 +6,12 @@ apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
compileSdkVersion 29
buildToolsVersion '29.0.2'
defaultConfig {
minSdkVersion 26
targetSdkVersion 28
minSdkVersion 29
targetSdkVersion 29
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Binary file not shown.

Binary file not shown.

View file

@ -5,11 +5,6 @@
android:versionCode="5"
android:versionName="0.3.0">
<uses-sdk
android:minSdkVersion="26"
android:targetSdkVersion="28"
tools:ignore="GradleOverrides,OldTargetApi" />
<uses-permission
android:name="android.permission.BACKUP"
tools:ignore="ProtectedPermissions" />

View file

@ -4,6 +4,7 @@ import android.app.Application
import android.app.backup.IRestoreObserver
import android.app.backup.IRestoreSession
import android.app.backup.RestoreSet
import android.os.UserHandle
import android.util.Log
import androidx.annotation.WorkerThread
import androidx.lifecycle.LiveData
@ -40,7 +41,7 @@ class RestoreViewModel(app: Application) : RequireProvisioningViewModel(app), Re
internal val restoreFinished: LiveData<Int> get() = mRestoreFinished
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
if (session == null) {

View file

@ -43,7 +43,7 @@ class PackageService {
Log.d(TAG, "Got ${packageList.size} packages: $packageList")
// 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)}")

View file

@ -1,7 +1,12 @@
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.UserHandle;
import java.util.Set;
@ -31,7 +36,7 @@ public class RestoreSession extends IRestoreObserver.Stub {
return;
}
restoreSession = backupManager.beginRestoreSession(null, null);
restoreSession = backupManager.beginRestoreSessionForUser(UserHandle.myUserId(), null, null);
if (restoreSession == null) {
stop(RestoreResult.FAILURE);
@ -62,7 +67,7 @@ public class RestoreSession extends IRestoreObserver.Stub {
if (restoreSets.length > 0) {
RestoreSet restoreSet = restoreSets[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) {
stop(RestoreResult.FAILURE);

View file

@ -1,9 +1,12 @@
package com.stevesoltys.backup.ui.storage
import android.app.ActivityManager
import android.app.Application
import android.app.backup.BackupProgress
import android.app.backup.IBackupObserver
import android.net.Uri
import android.os.UserHandle
import android.os.UserManager
import android.util.Log
import androidx.annotation.WorkerThread
import com.stevesoltys.backup.Backup
@ -25,7 +28,7 @@ internal class BackupStorageViewModel(private val app: Application) : StorageVie
// initialize the new location
val observer = InitializationObserver()
Backup.backupManager.initializeTransports(arrayOf(TRANSPORT_ID), observer)
Backup.backupManager.initializeTransportsForUser(UserHandle.myUserId(), arrayOf(TRANSPORT_ID), observer)
}
@WorkerThread

View file

@ -10,7 +10,7 @@ buildscript {
}
dependencies {
// 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"
// NOTE: Do not place your application dependencies here; they belong