Merge branch 'master' into feature/standalone

This commit is contained in:
Steve Soltys 2018-11-11 20:53:57 -05:00
commit 2fa09be854
4 changed files with 137 additions and 5 deletions

View file

@ -21,6 +21,7 @@ LOCAL_PACKAGE_NAME := Backup
LOCAL_MODULE_TAGS := optional LOCAL_MODULE_TAGS := optional
LOCAL_REQUIRED_MODULES := permissions_com.stevesoltys.backup.xml whitelist_com.stevesoltys.backup.xml LOCAL_REQUIRED_MODULES := permissions_com.stevesoltys.backup.xml whitelist_com.stevesoltys.backup.xml
LOCAL_PRIVILEGED_MODULE := true LOCAL_PRIVILEGED_MODULE := true
LOCAL_PRIVATE_PLATFORM_APIS := true
LOCAL_SRC_FILES := $(call all-java-files-under, java) LOCAL_SRC_FILES := $(call all-java-files-under, java)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
include $(BUILD_PACKAGE) include $(BUILD_PACKAGE)

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