Use stub backup and restore components by default in backup transport

This commit is contained in:
Steve Soltys 2018-11-11 17:18:55 -05:00
parent 523c4a32a4
commit 9f3d01e4f9
3 changed files with 136 additions and 5 deletions

View file

@ -9,6 +9,8 @@ import android.os.ParcelFileDescriptor;
import com.android.internal.util.Preconditions; import com.android.internal.util.Preconditions;
import com.stevesoltys.backup.transport.component.BackupComponent; import com.stevesoltys.backup.transport.component.BackupComponent;
import com.stevesoltys.backup.transport.component.RestoreComponent; 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 * @author Steve Soltys
@ -23,8 +25,8 @@ public class ConfigurableBackupTransport extends BackupTransport {
private RestoreComponent restoreComponent; private RestoreComponent restoreComponent;
public ConfigurableBackupTransport() { public ConfigurableBackupTransport() {
backupComponent = null; backupComponent = new StubBackupComponent();
restoreComponent = null; restoreComponent = new StubRestoreComponent();
} }
public void initialize(BackupComponent backupComponent, RestoreComponent restoreComponent) { public void initialize(BackupComponent backupComponent, RestoreComponent restoreComponent) {
@ -37,12 +39,12 @@ public class ConfigurableBackupTransport extends BackupTransport {
} }
public void reset() { public void reset() {
backupComponent = null; backupComponent = new StubBackupComponent();
restoreComponent = null; restoreComponent = new StubRestoreComponent();
} }
public boolean isActive() { public boolean isActive() {
return backupComponent != null && restoreComponent != null; return !(backupComponent instanceof StubBackupComponent || restoreComponent instanceof StubRestoreComponent);
} }
public BackupComponent getBackupComponent() { public BackupComponent getBackupComponent() {

View file

@ -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;
}
}

View file

@ -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];
}
}