From 523c4a32a49f4151f0a05d38d8ff4db899298e7e Mon Sep 17 00:00:00 2001 From: Steve Soltys Date: Sat, 10 Nov 2018 16:01:31 -0500 Subject: [PATCH 1/2] Set LOCAL_PRIVATE_PLATFORM_APIS flag for Android Pie support --- Android.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/Android.mk b/Android.mk index 739b6d78..c3047eea 100644 --- a/Android.mk +++ b/Android.mk @@ -21,6 +21,7 @@ LOCAL_PACKAGE_NAME := Backup LOCAL_MODULE_TAGS := optional LOCAL_REQUIRED_MODULES := permissions_com.stevesoltys.backup.xml whitelist_com.stevesoltys.backup.xml LOCAL_PRIVILEGED_MODULE := true +LOCAL_PRIVATE_PLATFORM_APIS := true LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res include $(BUILD_PACKAGE) From 9f3d01e4f90a056e0174a21f6f99a896e001da00 Mon Sep 17 00:00:00 2001 From: Steve Soltys Date: Sun, 11 Nov 2018 17:18:55 -0500 Subject: [PATCH 2/2] Use stub backup and restore components by default in backup transport --- .../ConfigurableBackupTransport.java | 12 +-- .../component/stub/StubBackupComponent.java | 76 +++++++++++++++++++ .../component/stub/StubRestoreComponent.java | 53 +++++++++++++ 3 files changed, 136 insertions(+), 5 deletions(-) create mode 100644 src/com/stevesoltys/backup/transport/component/stub/StubBackupComponent.java create mode 100644 src/com/stevesoltys/backup/transport/component/stub/StubRestoreComponent.java diff --git a/src/com/stevesoltys/backup/transport/ConfigurableBackupTransport.java b/src/com/stevesoltys/backup/transport/ConfigurableBackupTransport.java index 675a9647..fac82afe 100644 --- a/src/com/stevesoltys/backup/transport/ConfigurableBackupTransport.java +++ b/src/com/stevesoltys/backup/transport/ConfigurableBackupTransport.java @@ -9,6 +9,8 @@ import android.os.ParcelFileDescriptor; import com.android.internal.util.Preconditions; import com.stevesoltys.backup.transport.component.BackupComponent; import com.stevesoltys.backup.transport.component.RestoreComponent; +import com.stevesoltys.backup.transport.component.stub.StubBackupComponent; +import com.stevesoltys.backup.transport.component.stub.StubRestoreComponent; /** * @author Steve Soltys @@ -23,8 +25,8 @@ public class ConfigurableBackupTransport extends BackupTransport { private RestoreComponent restoreComponent; public ConfigurableBackupTransport() { - backupComponent = null; - restoreComponent = null; + backupComponent = new StubBackupComponent(); + restoreComponent = new StubRestoreComponent(); } public void initialize(BackupComponent backupComponent, RestoreComponent restoreComponent) { @@ -37,12 +39,12 @@ public class ConfigurableBackupTransport extends BackupTransport { } public void reset() { - backupComponent = null; - restoreComponent = null; + backupComponent = new StubBackupComponent(); + restoreComponent = new StubRestoreComponent(); } public boolean isActive() { - return backupComponent != null && restoreComponent != null; + return !(backupComponent instanceof StubBackupComponent || restoreComponent instanceof StubRestoreComponent); } public BackupComponent getBackupComponent() { diff --git a/src/com/stevesoltys/backup/transport/component/stub/StubBackupComponent.java b/src/com/stevesoltys/backup/transport/component/stub/StubBackupComponent.java new file mode 100644 index 00000000..bb2fb66f --- /dev/null +++ b/src/com/stevesoltys/backup/transport/component/stub/StubBackupComponent.java @@ -0,0 +1,76 @@ +package com.stevesoltys.backup.transport.component.stub; + +import android.content.pm.PackageInfo; +import android.os.ParcelFileDescriptor; +import com.stevesoltys.backup.transport.component.BackupComponent; + +/** + * @author Steve Soltys + */ +public class StubBackupComponent implements BackupComponent { + + @Override + public String currentDestinationString() { + return null; + } + + @Override + public String dataManagementLabel() { + return null; + } + + @Override + public int initializeDevice() { + return 0; + } + + @Override + public int clearBackupData(PackageInfo packageInfo) { + return 0; + } + + @Override + public int finishBackup() { + return 0; + } + + @Override + public int performIncrementalBackup(PackageInfo targetPackage, ParcelFileDescriptor data) { + return 0; + } + + @Override + public int performFullBackup(PackageInfo targetPackage, ParcelFileDescriptor fileDescriptor) { + return 0; + } + + @Override + public int checkFullBackupSize(long size) { + return 0; + } + + @Override + public int sendBackupData(int numBytes) { + return 0; + } + + @Override + public void cancelFullBackup() { + + } + + @Override + public long getBackupQuota(String packageName, boolean fullBackup) { + return 0; + } + + @Override + public long requestBackupTime() { + return 0; + } + + @Override + public long requestFullBackupTime() { + return 0; + } +} diff --git a/src/com/stevesoltys/backup/transport/component/stub/StubRestoreComponent.java b/src/com/stevesoltys/backup/transport/component/stub/StubRestoreComponent.java new file mode 100644 index 00000000..56d6cfd3 --- /dev/null +++ b/src/com/stevesoltys/backup/transport/component/stub/StubRestoreComponent.java @@ -0,0 +1,53 @@ +package com.stevesoltys.backup.transport.component.stub; + +import android.content.pm.PackageInfo; +import android.os.ParcelFileDescriptor; +import com.stevesoltys.backup.transport.component.RestoreComponent; +import android.app.backup.RestoreDescription; +import android.app.backup.RestoreSet; + +/** + * @author Steve Soltys + */ +public class StubRestoreComponent implements RestoreComponent { + + @Override + public int startRestore(long token, PackageInfo[] packages) { + return 0; + } + + @Override + public RestoreDescription nextRestorePackage() { + return null; + } + + @Override + public int getRestoreData(ParcelFileDescriptor outputFileDescriptor) { + return 0; + } + + @Override + public int getNextFullRestoreDataChunk(ParcelFileDescriptor socket) { + return 0; + } + + @Override + public int abortFullRestore() { + return 0; + } + + @Override + public long getCurrentRestoreSet() { + return 0; + } + + @Override + public void finishRestore() { + + } + + @Override + public RestoreSet[] getAvailableRestoreSets() { + return new RestoreSet[0]; + } +}