diff --git a/app/src/main/Android.mk b/app/src/main/Android.mk index f32fa8f3..124eda74 100644 --- a/app/src/main/Android.mk +++ b/app/src/main/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, java) LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res include $(BUILD_PACKAGE) diff --git a/app/src/main/java/com/stevesoltys/backup/transport/ConfigurableBackupTransport.java b/app/src/main/java/com/stevesoltys/backup/transport/ConfigurableBackupTransport.java index 675a9647..fac82afe 100644 --- a/app/src/main/java/com/stevesoltys/backup/transport/ConfigurableBackupTransport.java +++ b/app/src/main/java/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/app/src/main/java/com/stevesoltys/backup/transport/component/stub/StubBackupComponent.java b/app/src/main/java/com/stevesoltys/backup/transport/component/stub/StubBackupComponent.java new file mode 100644 index 00000000..bb2fb66f --- /dev/null +++ b/app/src/main/java/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/app/src/main/java/com/stevesoltys/backup/transport/component/stub/StubRestoreComponent.java b/app/src/main/java/com/stevesoltys/backup/transport/component/stub/StubRestoreComponent.java new file mode 100644 index 00000000..56d6cfd3 --- /dev/null +++ b/app/src/main/java/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]; + } +}