Make BackupManager encryption aware.

Backup requires both CE and DE storage to be available, so delay
spinning up the backup system until the user is unlocked, since
that's when CE storage becomes available.  Note that devices without
FBE immediately transition USER_SYSTEM into the unlocked state,
since their CE is always available.

Offer to backup and restore files under both CE and DE.  Since DE
is effectively the same as CE, most logic is simply duplicated for
now, but it could be simplified in the future.  Since system apps
can force their default storage location to DE, we always build
explicit CE and DE paths.

Add getDataDir() to give clean access to the top-level private data
directory, but disclaim that apps shouldn't create files there.

Bug: 26279618
Change-Id: Ic34a4b330223725db93b1d0f5c9dffc88002c61f
This commit is contained in:
Jeff Sharkey
2016-02-17 15:29:38 -07:00
parent 0f5e52462a
commit 5808319629
12 changed files with 279 additions and 73 deletions

View File

@@ -810,6 +810,25 @@ public abstract class Context {
*/
public abstract File getSharedPreferencesPath(String name);
/**
* Returns the absolute path to the directory on the filesystem where all
* private files belonging to this app are stored. This is the top-level
* directory under which {@link #getFilesDir()}, {@link #getCacheDir()}, etc
* are contained. Apps should <em>not</em> create any files or directories
* as direct children of this directory, since it's a reserved namespace
* belonging to the platform. Instead, use {@link #getDir(String, int)} or
* other storage APIs.
* <p>
* The returned path may change over time if the calling app is moved to an
* adopted storage device, so only relative paths should be persisted.
* <p>
* No additional permissions are required for the calling app to read or
* write files under the returned path.
*
* @see #getDir(String, int)
*/
public abstract File getDataDir();
/**
* Returns the absolute path to the directory on the filesystem where files
* created with {@link #openFileOutput} are stored.

View File

@@ -211,6 +211,11 @@ public class ContextWrapper extends Context {
return mBase.fileList();
}
@Override
public File getDataDir() {
return mBase.getDataDir();
}
@Override
public File getFilesDir() {
return mBase.getFilesDir();