summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2019-05-04 23:16:32 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2019-05-04 23:16:32 +0000
commit1e9515afd4abf1b1a7678555fa17830fed075007 (patch)
tree62ccf6cc3c5ab5016389d17e0cb1adf8fc9428a3
parentbe853756f8a215492b11ae545206d12b64d3a03c (diff)
parent2141bb48d626369da6313aac930939b8faa83226 (diff)
downloadlibbackup-android-platform-11.0.0_r6.tar.gz
Snap for 5533215 from 2141bb48d626369da6313aac930939b8faa83226 to rvc-releaseandroid-vts-11.0_r9android-vts-11.0_r8android-vts-11.0_r7android-vts-11.0_r6android-vts-11.0_r5android-vts-11.0_r4android-vts-11.0_r3android-vts-11.0_r2android-vts-11.0_r16android-vts-11.0_r15android-vts-11.0_r14android-vts-11.0_r13android-vts-11.0_r12android-vts-11.0_r11android-vts-11.0_r10android-vts-11.0_r1android-security-11.0.0_r76android-security-11.0.0_r75android-security-11.0.0_r74android-security-11.0.0_r73android-security-11.0.0_r72android-security-11.0.0_r71android-security-11.0.0_r70android-security-11.0.0_r69android-security-11.0.0_r68android-security-11.0.0_r67android-security-11.0.0_r66android-security-11.0.0_r65android-security-11.0.0_r64android-security-11.0.0_r63android-security-11.0.0_r62android-security-11.0.0_r61android-security-11.0.0_r60android-security-11.0.0_r59android-security-11.0.0_r58android-security-11.0.0_r57android-security-11.0.0_r56android-security-11.0.0_r55android-security-11.0.0_r54android-security-11.0.0_r53android-security-11.0.0_r52android-security-11.0.0_r51android-security-11.0.0_r50android-security-11.0.0_r49android-security-11.0.0_r1android-platform-11.0.0_r9android-platform-11.0.0_r8android-platform-11.0.0_r7android-platform-11.0.0_r6android-platform-11.0.0_r5android-platform-11.0.0_r40android-platform-11.0.0_r4android-platform-11.0.0_r39android-platform-11.0.0_r38android-platform-11.0.0_r37android-platform-11.0.0_r36android-platform-11.0.0_r35android-platform-11.0.0_r34android-platform-11.0.0_r33android-platform-11.0.0_r32android-platform-11.0.0_r31android-platform-11.0.0_r30android-platform-11.0.0_r3android-platform-11.0.0_r29android-platform-11.0.0_r28android-platform-11.0.0_r27android-platform-11.0.0_r26android-platform-11.0.0_r25android-platform-11.0.0_r24android-platform-11.0.0_r23android-platform-11.0.0_r22android-platform-11.0.0_r21android-platform-11.0.0_r20android-platform-11.0.0_r2android-platform-11.0.0_r19android-platform-11.0.0_r18android-platform-11.0.0_r17android-platform-11.0.0_r16android-platform-11.0.0_r15android-platform-11.0.0_r14android-platform-11.0.0_r13android-platform-11.0.0_r12android-platform-11.0.0_r11android-platform-11.0.0_r10android-platform-11.0.0_r1android-cts-11.0_r9android-cts-11.0_r8android-cts-11.0_r7android-cts-11.0_r6android-cts-11.0_r5android-cts-11.0_r4android-cts-11.0_r3android-cts-11.0_r2android-cts-11.0_r16android-cts-11.0_r15android-cts-11.0_r14android-cts-11.0_r13android-cts-11.0_r12android-cts-11.0_r11android-cts-11.0_r10android-cts-11.0_r1android-11.0.0_r6android-11.0.0_r5android-11.0.0_r4android-11.0.0_r3android-11.0.0_r25android-11.0.0_r2android-11.0.0_r17android-11.0.0_r1android11-tests-releaseandroid11-security-releaseandroid11-s1-releaseandroid11-releaseandroid11-platform-releaseandroid11-gsi
Change-Id: I129e7518c5afb84031e539152a489154aeef033d
-rw-r--r--build.gradle10
-rw-r--r--src/com/google/android/libraries/backup/shadow/BackupAgentHelperShadow.java6
-rw-r--r--src/com/google/android/libraries/backup/shadow/UnsupportedBackupHelperSimulator.java58
3 files changed, 71 insertions, 3 deletions
diff --git a/build.gradle b/build.gradle
index 7a33abd..15071ea 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,6 +1,16 @@
apply plugin: 'com.android.library'
android {
+ compileSdkVersion 28
+ buildToolsVersion '28.0.0'
+
+ defaultConfig {
+ // Most backup classes (e.g. SharedPreferencesBackupHelper) were added
+ // in Froyo.
+ minSdkVersion 8
+ targetSdkVersion 28
+ }
+
publishNonDefault true
buildTypes {
diff --git a/src/com/google/android/libraries/backup/shadow/BackupAgentHelperShadow.java b/src/com/google/android/libraries/backup/shadow/BackupAgentHelperShadow.java
index 18deabf..5615723 100644
--- a/src/com/google/android/libraries/backup/shadow/BackupAgentHelperShadow.java
+++ b/src/com/google/android/libraries/backup/shadow/BackupAgentHelperShadow.java
@@ -26,7 +26,6 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.annotation.RealObject;
-import org.robolectric.fakes.RoboSharedPreferences;
/**
* Shadow class for end-to-end testing of {@link BackupAgentHelper} subclasses in unit tests.
@@ -141,8 +140,9 @@ public class BackupAgentHelperShadow {
} else if (helperClass == FileBackupHelper.class) {
simulator = FileBackupHelperSimulator.fromHelper(keyPrefix, (FileBackupHelper) helper);
} else {
- throw new UnsupportedOperationException(
- "Unknown backup helper class for key prefix \"" + keyPrefix + "\": " + helperClass);
+ Log.w(
+ TAG, "Unknown backup helper class for key prefix \"" + keyPrefix + "\": " + helperClass);
+ simulator = new UnsupportedBackupHelperSimulator(keyPrefix, helper);
}
helperSimulators.put(keyPrefix, simulator);
}
diff --git a/src/com/google/android/libraries/backup/shadow/UnsupportedBackupHelperSimulator.java b/src/com/google/android/libraries/backup/shadow/UnsupportedBackupHelperSimulator.java
new file mode 100644
index 0000000..15ee687
--- /dev/null
+++ b/src/com/google/android/libraries/backup/shadow/UnsupportedBackupHelperSimulator.java
@@ -0,0 +1,58 @@
+package com.google.android.libraries.backup.shadow;
+
+import android.app.backup.BackupHelper;
+import android.content.Context;
+import android.util.Log;
+
+/**
+ * No-op backup helper representing all an unsupported backup helpers.
+ *
+ * <p>{@see BackupAgentHelperShadow}
+ */
+public class UnsupportedBackupHelperSimulator extends BackupHelperSimulator {
+ private static final String TAG = "UnsupportedBckupHlprSim";
+ private final BackupHelper mHelper;
+
+ UnsupportedBackupHelperSimulator(String keyPrefix, BackupHelper helper) {
+ super(keyPrefix);
+ mHelper = helper;
+ }
+
+ @Override
+ public Object backup(Context context) {
+ return new UnsupportedBackupHelperOutput(mHelper);
+ }
+
+ @Override
+ public void restore(Context context, Object data) {
+ if (!(data instanceof UnsupportedBackupHelperOutput)) {
+ throw new IllegalArgumentException(
+ "Invalid type of data to restore in unsupported helper \""
+ + keyPrefix
+ + "\": "
+ + (data == null ? null : data.getClass()));
+ }
+ Log.w(
+ TAG,
+ "Attempt to restore from an unsupported backup helper: " + mHelper.getClass().getName());
+ }
+
+ public static class UnsupportedBackupHelperOutput {
+ public final BackupHelper wrappedHelper;
+
+ public UnsupportedBackupHelperOutput(BackupHelper helper) {
+ wrappedHelper = helper;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return obj instanceof UnsupportedBackupHelperOutput
+ && wrappedHelper.equals(((UnsupportedBackupHelperOutput) obj).wrappedHelper);
+ }
+
+ @Override
+ public int hashCode() {
+ return wrappedHelper.hashCode();
+ }
+ }
+}