From 9f3d01e4f90a056e0174a21f6f99a896e001da00 Mon Sep 17 00:00:00 2001 From: Steve Soltys Date: Sun, 11 Nov 2018 17:18:55 -0500 Subject: [PATCH] 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]; + } +}