Merge pull request #41 from grote/android-10
Make app work for Android 10
This commit is contained in:
commit
6eb6f64696
11 changed files with 34 additions and 22 deletions
|
@ -1,9 +1,13 @@
|
|||
dist: trusty
|
||||
|
||||
jdk:
|
||||
- openjdk11
|
||||
|
||||
language: android
|
||||
android:
|
||||
components:
|
||||
- build-tools-28.0.3
|
||||
- android-28
|
||||
- build-tools-29.0.2
|
||||
- android-29
|
||||
|
||||
licenses:
|
||||
- android-sdk-license-.+
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
||||
|
@ -67,6 +67,9 @@ android {
|
|||
|
||||
gradle.projectsEvaluated {
|
||||
tasks.withType(JavaCompile) {
|
||||
if (JavaVersion.current() >= JavaVersion.VERSION_1_9) {
|
||||
options.compilerArgs.addAll(['--release', '8'])
|
||||
}
|
||||
options.compilerArgs.add('-Xbootclasspath/p:app/libs/android.jar:app/libs/libcore.jar')
|
||||
}
|
||||
}
|
||||
|
@ -81,6 +84,7 @@ preBuild.doLast {
|
|||
parsedXml.component[1].remove(jdkNode)
|
||||
|
||||
def sdkString = "Android API " + android.compileSdkVersion.substring("android-".length()) + " Platform"
|
||||
//noinspection GroovyResultOfObjectAllocationIgnored // the note gets inserted
|
||||
new Node(parsedXml.component[1], 'orderEntry', ['type': 'jdk', 'jdkName': sdkString, 'jdkType': 'Android SDK'])
|
||||
XmlUtil.serialize(parsedXml, new FileOutputStream(imlFile))
|
||||
|
||||
|
@ -101,7 +105,7 @@ def aospDeps = fileTree(include: [
|
|||
dependencies {
|
||||
compileOnly aospDeps
|
||||
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||
|
||||
implementation 'commons-io:commons-io:2.6'
|
||||
implementation 'io.github.novacrypto:BIP39:2019.01.27'
|
||||
|
@ -115,9 +119,9 @@ dependencies {
|
|||
lintChecks 'com.github.thirdegg:lint-rules:0.0.4-alpha'
|
||||
|
||||
testImplementation aospDeps
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.5.0'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.5.2'
|
||||
testImplementation 'io.mockk:mockk:1.9.3'
|
||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.5.0'
|
||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.5.2'
|
||||
|
||||
androidTestImplementation 'androidx.test:runner:1.2.0'
|
||||
androidTestImplementation 'androidx.test:rules:1.2.0'
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -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" />
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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)}")
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -100,7 +100,7 @@ class DocumentsStorage(private val context: Context, storage: Storage?, token: L
|
|||
|
||||
@Throws(IOException::class)
|
||||
fun getOutputStream(file: DocumentFile): OutputStream {
|
||||
return context.contentResolver.openOutputStream(file.uri) ?: throw IOException()
|
||||
return context.contentResolver.openOutputStream(file.uri, "wt") ?: throw IOException()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue