summaryrefslogtreecommitdiffstats
path: root/core/java/android/app/backup
diff options
context:
space:
mode:
authorChristopher Tate <ctate@google.com>2013-02-14 16:55:46 -0800
committerChristopher Tate <ctate@google.com>2013-02-14 18:46:53 -0800
commit416c39e8d48048fa4a997c09460c262cca871fc4 (patch)
tree9acf7f7763e5c0f9a657a4389feac2e76b843814 /core/java/android/app/backup
parent0786207be59d34a8ba8a7a1e93602002fac97587 (diff)
downloadframeworks_base-416c39e8d48048fa4a997c09460c262cca871fc4.zip
frameworks_base-416c39e8d48048fa4a997c09460c262cca871fc4.tar.gz
frameworks_base-416c39e8d48048fa4a997c09460c262cca871fc4.tar.bz2
Full backup now saves getExternalFilesDir() content with the app data
... instead of only saving it with the enormous "shared storage" generic data blob. In parallel, we no longer store managed app-specific files on external storage as part of the generic shared-storage blob. At restore time we just go ahead and apply such files, though, because they're a priori going to be part of an archive generated by an older version of the platform, so that's how the data is expected to be handled in those circumstances. Bug 6718844 Change-Id: I4410514d368b11d74b3afe6b92d363d4115a3415
Diffstat (limited to 'core/java/android/app/backup')
-rw-r--r--core/java/android/app/backup/BackupAgent.java14
-rw-r--r--core/java/android/app/backup/FullBackup.java1
2 files changed, 15 insertions, 0 deletions
diff --git a/core/java/android/app/backup/BackupAgent.java b/core/java/android/app/backup/BackupAgent.java
index 9ad33a5..b678df7 100644
--- a/core/java/android/app/backup/BackupAgent.java
+++ b/core/java/android/app/backup/BackupAgent.java
@@ -227,6 +227,7 @@ public abstract class BackupAgent extends ContextWrapper {
String libDir = (appInfo.nativeLibraryDir != null)
? new File(appInfo.nativeLibraryDir).getCanonicalPath()
: null;
+ String externalFilesDir = getExternalFilesDir(null).getCanonicalPath();
// Filters, the scan queue, and the set of resulting entities
HashSet<String> filterSet = new HashSet<String>();
@@ -254,6 +255,12 @@ public abstract class BackupAgent extends ContextWrapper {
filterSet.add(databaseDir);
filterSet.remove(sharedPrefsDir);
fullBackupFileTree(packageName, FullBackup.SHAREDPREFS_TREE_TOKEN, sharedPrefsDir, filterSet, data);
+
+ // getExternalFilesDir() location associated with this app. Technically there should
+ // not be any files here if the app does not properly have permission to access
+ // external storage, but edge cases happen. fullBackupFileTree() catches
+ // IOExceptions and similar, and treats them as non-fatal, so we rely on that here.
+ fullBackupFileTree(packageName, FullBackup.MANAGED_EXTERNAL_TREE_TOKEN, externalFilesDir, null, data);
}
/**
@@ -274,6 +281,7 @@ public abstract class BackupAgent extends ContextWrapper {
String spDir;
String cacheDir;
String libDir;
+ String efDir;
String filePath;
ApplicationInfo appInfo = getApplicationInfo();
@@ -287,6 +295,7 @@ public abstract class BackupAgent extends ContextWrapper {
libDir = (appInfo.nativeLibraryDir == null)
? null
: new File(appInfo.nativeLibraryDir).getCanonicalPath();
+ efDir = getExternalFilesDir(null).getCanonicalPath();
// Now figure out which well-defined tree the file is placed in, working from
// most to least specific. We also specifically exclude the lib and cache dirs.
@@ -315,6 +324,9 @@ public abstract class BackupAgent extends ContextWrapper {
} else if (filePath.startsWith(mainDir)) {
domain = FullBackup.ROOT_TREE_TOKEN;
rootpath = mainDir;
+ } else if (filePath.startsWith(efDir)) {
+ domain = FullBackup.MANAGED_EXTERNAL_TREE_TOKEN;
+ rootpath = efDir;
} else {
Log.w(TAG, "File " + filePath + " is in an unsupported location; skipping");
return;
@@ -438,6 +450,8 @@ public abstract class BackupAgent extends ContextWrapper {
basePath = getSharedPrefsFile("foo").getParentFile().getCanonicalPath();
} else if (domain.equals(FullBackup.CACHE_TREE_TOKEN)) {
basePath = getCacheDir().getCanonicalPath();
+ } else if (domain.equals(FullBackup.MANAGED_EXTERNAL_TREE_TOKEN)) {
+ basePath = getExternalFilesDir(null).getCanonicalPath();
} else {
// Not a supported location
Log.i(TAG, "Data restored from non-app domain " + domain + ", ignoring");
diff --git a/core/java/android/app/backup/FullBackup.java b/core/java/android/app/backup/FullBackup.java
index f859599..2fe08f3 100644
--- a/core/java/android/app/backup/FullBackup.java
+++ b/core/java/android/app/backup/FullBackup.java
@@ -46,6 +46,7 @@ public class FullBackup {
public static final String DATA_TREE_TOKEN = "f";
public static final String DATABASE_TREE_TOKEN = "db";
public static final String SHAREDPREFS_TREE_TOKEN = "sp";
+ public static final String MANAGED_EXTERNAL_TREE_TOKEN = "ef";
public static final String CACHE_TREE_TOKEN = "c";
public static final String SHARED_STORAGE_TOKEN = "shared";