Merge "Slight API renaming, better behavior."
diff --git a/api/current.txt b/api/current.txt
index 165d940..dd22a40 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -7780,8 +7780,7 @@
method public abstract int checkUriPermission(android.net.Uri, java.lang.String, java.lang.String, int, int, int);
method public abstract deprecated void clearWallpaper() throws java.io.IOException;
method public abstract android.content.Context createConfigurationContext(android.content.res.Configuration);
- method public abstract android.content.Context createCredentialEncryptedContext(android.content.Context);
- method public abstract android.content.Context createDeviceEncryptedContext(android.content.Context);
+ method public abstract android.content.Context createDeviceEncryptedStorageContext();
method public abstract android.content.Context createDisplayContext(android.view.Display);
method public abstract android.content.Context createPackageContext(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public abstract java.lang.String[] databaseList();
@@ -7837,8 +7836,7 @@
method public abstract deprecated int getWallpaperDesiredMinimumHeight();
method public abstract deprecated int getWallpaperDesiredMinimumWidth();
method public abstract void grantUriPermission(java.lang.String, android.net.Uri, int);
- method public abstract boolean isCredentialEncrypted();
- method public abstract boolean isDeviceEncrypted();
+ method public abstract boolean isDeviceEncryptedStorage();
method public boolean isRestricted();
method public final android.content.res.TypedArray obtainStyledAttributes(int[]);
method public final android.content.res.TypedArray obtainStyledAttributes(int, int[]) throws android.content.res.Resources.NotFoundException;
@@ -7970,8 +7968,7 @@
method public int checkUriPermission(android.net.Uri, java.lang.String, java.lang.String, int, int, int);
method public deprecated void clearWallpaper() throws java.io.IOException;
method public android.content.Context createConfigurationContext(android.content.res.Configuration);
- method public android.content.Context createCredentialEncryptedContext(android.content.Context);
- method public android.content.Context createDeviceEncryptedContext(android.content.Context);
+ method public android.content.Context createDeviceEncryptedStorageContext();
method public android.content.Context createDisplayContext(android.view.Display);
method public android.content.Context createPackageContext(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public java.lang.String[] databaseList();
@@ -8021,8 +8018,7 @@
method public deprecated int getWallpaperDesiredMinimumHeight();
method public deprecated int getWallpaperDesiredMinimumWidth();
method public void grantUriPermission(java.lang.String, android.net.Uri, int);
- method public boolean isCredentialEncrypted();
- method public boolean isDeviceEncrypted();
+ method public boolean isDeviceEncryptedStorage();
method public java.io.FileInputStream openFileInput(java.lang.String) throws java.io.FileNotFoundException;
method public java.io.FileOutputStream openFileOutput(java.lang.String, int) throws java.io.FileNotFoundException;
method public android.database.sqlite.SQLiteDatabase openOrCreateDatabase(java.lang.String, int, android.database.sqlite.SQLiteDatabase.CursorFactory);
@@ -28096,7 +28092,9 @@
method public boolean isSystemUser();
method public boolean isUserAGoat();
method public boolean isUserRunning(android.os.UserHandle);
+ method public boolean isUserRunningAndLocked();
method public boolean isUserRunningAndLocked(android.os.UserHandle);
+ method public boolean isUserRunningAndUnlocked();
method public boolean isUserRunningAndUnlocked(android.os.UserHandle);
method public boolean isUserRunningOrStopping(android.os.UserHandle);
method public deprecated boolean setRestrictionsChallenge(java.lang.String);
@@ -36250,8 +36248,7 @@
method public int checkUriPermission(android.net.Uri, java.lang.String, java.lang.String, int, int, int);
method public void clearWallpaper();
method public android.content.Context createConfigurationContext(android.content.res.Configuration);
- method public android.content.Context createCredentialEncryptedContext(android.content.Context);
- method public android.content.Context createDeviceEncryptedContext(android.content.Context);
+ method public android.content.Context createDeviceEncryptedStorageContext();
method public android.content.Context createDisplayContext(android.view.Display);
method public android.content.Context createPackageContext(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public java.lang.String[] databaseList();
@@ -36300,8 +36297,7 @@
method public int getWallpaperDesiredMinimumHeight();
method public int getWallpaperDesiredMinimumWidth();
method public void grantUriPermission(java.lang.String, android.net.Uri, int);
- method public boolean isCredentialEncrypted();
- method public boolean isDeviceEncrypted();
+ method public boolean isDeviceEncryptedStorage();
method public java.io.FileInputStream openFileInput(java.lang.String) throws java.io.FileNotFoundException;
method public java.io.FileOutputStream openFileOutput(java.lang.String, int) throws java.io.FileNotFoundException;
method public android.database.sqlite.SQLiteDatabase openOrCreateDatabase(java.lang.String, int, android.database.sqlite.SQLiteDatabase.CursorFactory);
diff --git a/api/system-current.txt b/api/system-current.txt
index 5bf5c20..ee20e5b 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -8024,8 +8024,8 @@
method public abstract int checkUriPermission(android.net.Uri, java.lang.String, java.lang.String, int, int, int);
method public abstract deprecated void clearWallpaper() throws java.io.IOException;
method public abstract android.content.Context createConfigurationContext(android.content.res.Configuration);
- method public abstract android.content.Context createCredentialEncryptedContext(android.content.Context);
- method public abstract android.content.Context createDeviceEncryptedContext(android.content.Context);
+ method public abstract android.content.Context createCredentialEncryptedStorageContext();
+ method public abstract android.content.Context createDeviceEncryptedStorageContext();
method public abstract android.content.Context createDisplayContext(android.view.Display);
method public abstract android.content.Context createPackageContext(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public abstract java.lang.String[] databaseList();
@@ -8081,8 +8081,8 @@
method public abstract deprecated int getWallpaperDesiredMinimumHeight();
method public abstract deprecated int getWallpaperDesiredMinimumWidth();
method public abstract void grantUriPermission(java.lang.String, android.net.Uri, int);
- method public abstract boolean isCredentialEncrypted();
- method public abstract boolean isDeviceEncrypted();
+ method public abstract boolean isCredentialEncryptedStorage();
+ method public abstract boolean isDeviceEncryptedStorage();
method public boolean isRestricted();
method public final android.content.res.TypedArray obtainStyledAttributes(int[]);
method public final android.content.res.TypedArray obtainStyledAttributes(int, int[]) throws android.content.res.Resources.NotFoundException;
@@ -8222,8 +8222,8 @@
method public int checkUriPermission(android.net.Uri, java.lang.String, java.lang.String, int, int, int);
method public deprecated void clearWallpaper() throws java.io.IOException;
method public android.content.Context createConfigurationContext(android.content.res.Configuration);
- method public android.content.Context createCredentialEncryptedContext(android.content.Context);
- method public android.content.Context createDeviceEncryptedContext(android.content.Context);
+ method public android.content.Context createCredentialEncryptedStorageContext();
+ method public android.content.Context createDeviceEncryptedStorageContext();
method public android.content.Context createDisplayContext(android.view.Display);
method public android.content.Context createPackageContext(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public java.lang.String[] databaseList();
@@ -8273,8 +8273,8 @@
method public deprecated int getWallpaperDesiredMinimumHeight();
method public deprecated int getWallpaperDesiredMinimumWidth();
method public void grantUriPermission(java.lang.String, android.net.Uri, int);
- method public boolean isCredentialEncrypted();
- method public boolean isDeviceEncrypted();
+ method public boolean isCredentialEncryptedStorage();
+ method public boolean isDeviceEncryptedStorage();
method public java.io.FileInputStream openFileInput(java.lang.String) throws java.io.FileNotFoundException;
method public java.io.FileOutputStream openFileOutput(java.lang.String, int) throws java.io.FileNotFoundException;
method public android.database.sqlite.SQLiteDatabase openOrCreateDatabase(java.lang.String, int, android.database.sqlite.SQLiteDatabase.CursorFactory);
@@ -30086,7 +30086,9 @@
method public boolean isSystemUser();
method public boolean isUserAGoat();
method public boolean isUserRunning(android.os.UserHandle);
+ method public boolean isUserRunningAndLocked();
method public boolean isUserRunningAndLocked(android.os.UserHandle);
+ method public boolean isUserRunningAndUnlocked();
method public boolean isUserRunningAndUnlocked(android.os.UserHandle);
method public boolean isUserRunningOrStopping(android.os.UserHandle);
method public deprecated boolean setRestrictionsChallenge(java.lang.String);
@@ -38573,8 +38575,8 @@
method public int checkUriPermission(android.net.Uri, java.lang.String, java.lang.String, int, int, int);
method public void clearWallpaper();
method public android.content.Context createConfigurationContext(android.content.res.Configuration);
- method public android.content.Context createCredentialEncryptedContext(android.content.Context);
- method public android.content.Context createDeviceEncryptedContext(android.content.Context);
+ method public android.content.Context createCredentialEncryptedStorageContext();
+ method public android.content.Context createDeviceEncryptedStorageContext();
method public android.content.Context createDisplayContext(android.view.Display);
method public android.content.Context createPackageContext(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public java.lang.String[] databaseList();
@@ -38623,8 +38625,8 @@
method public int getWallpaperDesiredMinimumHeight();
method public int getWallpaperDesiredMinimumWidth();
method public void grantUriPermission(java.lang.String, android.net.Uri, int);
- method public boolean isCredentialEncrypted();
- method public boolean isDeviceEncrypted();
+ method public boolean isCredentialEncryptedStorage();
+ method public boolean isDeviceEncryptedStorage();
method public java.io.FileInputStream openFileInput(java.lang.String) throws java.io.FileNotFoundException;
method public java.io.FileOutputStream openFileOutput(java.lang.String, int) throws java.io.FileNotFoundException;
method public android.database.sqlite.SQLiteDatabase openOrCreateDatabase(java.lang.String, int, android.database.sqlite.SQLiteDatabase.CursorFactory);
diff --git a/api/test-current.txt b/api/test-current.txt
index 39edceb..032507b 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -7780,8 +7780,7 @@
method public abstract int checkUriPermission(android.net.Uri, java.lang.String, java.lang.String, int, int, int);
method public abstract deprecated void clearWallpaper() throws java.io.IOException;
method public abstract android.content.Context createConfigurationContext(android.content.res.Configuration);
- method public abstract android.content.Context createCredentialEncryptedContext(android.content.Context);
- method public abstract android.content.Context createDeviceEncryptedContext(android.content.Context);
+ method public abstract android.content.Context createDeviceEncryptedStorageContext();
method public abstract android.content.Context createDisplayContext(android.view.Display);
method public abstract android.content.Context createPackageContext(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public abstract java.lang.String[] databaseList();
@@ -7837,8 +7836,7 @@
method public abstract deprecated int getWallpaperDesiredMinimumHeight();
method public abstract deprecated int getWallpaperDesiredMinimumWidth();
method public abstract void grantUriPermission(java.lang.String, android.net.Uri, int);
- method public abstract boolean isCredentialEncrypted();
- method public abstract boolean isDeviceEncrypted();
+ method public abstract boolean isDeviceEncryptedStorage();
method public boolean isRestricted();
method public final android.content.res.TypedArray obtainStyledAttributes(int[]);
method public final android.content.res.TypedArray obtainStyledAttributes(int, int[]) throws android.content.res.Resources.NotFoundException;
@@ -7970,8 +7968,7 @@
method public int checkUriPermission(android.net.Uri, java.lang.String, java.lang.String, int, int, int);
method public deprecated void clearWallpaper() throws java.io.IOException;
method public android.content.Context createConfigurationContext(android.content.res.Configuration);
- method public android.content.Context createCredentialEncryptedContext(android.content.Context);
- method public android.content.Context createDeviceEncryptedContext(android.content.Context);
+ method public android.content.Context createDeviceEncryptedStorageContext();
method public android.content.Context createDisplayContext(android.view.Display);
method public android.content.Context createPackageContext(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public java.lang.String[] databaseList();
@@ -8021,8 +8018,7 @@
method public deprecated int getWallpaperDesiredMinimumHeight();
method public deprecated int getWallpaperDesiredMinimumWidth();
method public void grantUriPermission(java.lang.String, android.net.Uri, int);
- method public boolean isCredentialEncrypted();
- method public boolean isDeviceEncrypted();
+ method public boolean isDeviceEncryptedStorage();
method public java.io.FileInputStream openFileInput(java.lang.String) throws java.io.FileNotFoundException;
method public java.io.FileOutputStream openFileOutput(java.lang.String, int) throws java.io.FileNotFoundException;
method public android.database.sqlite.SQLiteDatabase openOrCreateDatabase(java.lang.String, int, android.database.sqlite.SQLiteDatabase.CursorFactory);
@@ -28096,7 +28092,9 @@
method public boolean isSystemUser();
method public boolean isUserAGoat();
method public boolean isUserRunning(android.os.UserHandle);
+ method public boolean isUserRunningAndLocked();
method public boolean isUserRunningAndLocked(android.os.UserHandle);
+ method public boolean isUserRunningAndUnlocked();
method public boolean isUserRunningAndUnlocked(android.os.UserHandle);
method public boolean isUserRunningOrStopping(android.os.UserHandle);
method public deprecated boolean setRestrictionsChallenge(java.lang.String);
@@ -36252,8 +36250,7 @@
method public int checkUriPermission(android.net.Uri, java.lang.String, java.lang.String, int, int, int);
method public void clearWallpaper();
method public android.content.Context createConfigurationContext(android.content.res.Configuration);
- method public android.content.Context createCredentialEncryptedContext(android.content.Context);
- method public android.content.Context createDeviceEncryptedContext(android.content.Context);
+ method public android.content.Context createDeviceEncryptedStorageContext();
method public android.content.Context createDisplayContext(android.view.Display);
method public android.content.Context createPackageContext(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public java.lang.String[] databaseList();
@@ -36302,8 +36299,7 @@
method public int getWallpaperDesiredMinimumHeight();
method public int getWallpaperDesiredMinimumWidth();
method public void grantUriPermission(java.lang.String, android.net.Uri, int);
- method public boolean isCredentialEncrypted();
- method public boolean isDeviceEncrypted();
+ method public boolean isDeviceEncryptedStorage();
method public java.io.FileInputStream openFileInput(java.lang.String) throws java.io.FileNotFoundException;
method public java.io.FileOutputStream openFileOutput(java.lang.String, int) throws java.io.FileNotFoundException;
method public android.database.sqlite.SQLiteDatabase openOrCreateDatabase(java.lang.String, int, android.database.sqlite.SQLiteDatabase.CursorFactory);
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index 36e98f9..d90ed9f6 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -61,6 +61,7 @@
import android.os.ServiceManager;
import android.os.UserHandle;
import android.os.storage.IMountService;
+import android.os.storage.StorageManager;
import android.util.AndroidRuntimeException;
import android.util.ArrayMap;
import android.util.Log;
@@ -1744,17 +1745,21 @@
}
@Override
- public Context createDeviceEncryptedContext(Context context) {
- final int flags = (mFlags & ~Context.CONTEXT_STORAGE_CREDENTIAL_ENCRYPTED)
- | Context.CONTEXT_STORAGE_DEVICE_ENCRYPTED;
+ public Context createDeviceEncryptedStorageContext() {
+ if (!StorageManager.isFileBasedEncryptionEnabled()) {
+ return null;
+ }
+
+ final int flags = (mFlags & ~Context.CONTEXT_CREDENTIAL_ENCRYPTED_STORAGE)
+ | Context.CONTEXT_DEVICE_ENCRYPTED_STORAGE;
return new ContextImpl(this, mMainThread, mPackageInfo, mActivityToken,
mUser, flags, mDisplay, null, Display.INVALID_DISPLAY);
}
@Override
- public Context createCredentialEncryptedContext(Context context) {
- final int flags = (mFlags & ~Context.CONTEXT_STORAGE_DEVICE_ENCRYPTED)
- | Context.CONTEXT_STORAGE_CREDENTIAL_ENCRYPTED;
+ public Context createCredentialEncryptedStorageContext() {
+ final int flags = (mFlags & ~Context.CONTEXT_DEVICE_ENCRYPTED_STORAGE)
+ | Context.CONTEXT_CREDENTIAL_ENCRYPTED_STORAGE;
return new ContextImpl(this, mMainThread, mPackageInfo, mActivityToken,
mUser, flags, mDisplay, null, Display.INVALID_DISPLAY);
}
@@ -1765,13 +1770,13 @@
}
@Override
- public boolean isDeviceEncrypted() {
- return (mFlags & Context.CONTEXT_STORAGE_DEVICE_ENCRYPTED) != 0;
+ public boolean isDeviceEncryptedStorage() {
+ return (mFlags & Context.CONTEXT_DEVICE_ENCRYPTED_STORAGE) != 0;
}
@Override
- public boolean isCredentialEncrypted() {
- return (mFlags & Context.CONTEXT_STORAGE_CREDENTIAL_ENCRYPTED) != 0;
+ public boolean isCredentialEncryptedStorage() {
+ return (mFlags & Context.CONTEXT_CREDENTIAL_ENCRYPTED_STORAGE) != 0;
}
@Override
@@ -1781,13 +1786,12 @@
private File getDataDirFile() {
if (mPackageInfo != null) {
- if (isCredentialEncrypted()) {
+ if (isCredentialEncryptedStorage()) {
return mPackageInfo.getCredentialEncryptedDataDirFile();
- } else if (isDeviceEncrypted()) {
+ } else if (isDeviceEncryptedStorage()) {
return mPackageInfo.getDeviceEncryptedDataDirFile();
} else {
- throw new RuntimeException(
- "Storage location is neither credential nor device encrypted");
+ return mPackageInfo.getDataDirFile();
}
}
throw new RuntimeException("Not supported in system context");
@@ -1840,15 +1844,13 @@
// If creator didn't specify which storage to use, use the default
// location for application.
- if ((flags & Context.CONTEXT_STORAGE_MASK) == 0) {
+ if ((flags & (Context.CONTEXT_CREDENTIAL_ENCRYPTED_STORAGE
+ | Context.CONTEXT_DEVICE_ENCRYPTED_STORAGE)) == 0) {
final File dataDir = packageInfo.getDataDirFile();
if (Objects.equals(dataDir, packageInfo.getCredentialEncryptedDataDirFile())) {
- flags |= Context.CONTEXT_STORAGE_CREDENTIAL_ENCRYPTED;
+ flags |= Context.CONTEXT_CREDENTIAL_ENCRYPTED_STORAGE;
} else if (Objects.equals(dataDir, packageInfo.getDeviceEncryptedDataDirFile())) {
- flags |= Context.CONTEXT_STORAGE_DEVICE_ENCRYPTED;
- } else {
- throw new IllegalStateException("Storage location " + dataDir
- + " doesn't match either credential or device encrypted storage");
+ flags |= Context.CONTEXT_DEVICE_ENCRYPTED_STORAGE;
}
}
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 1f7fd9d..c61f204 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -53,8 +53,8 @@
import android.os.UserManager;
import android.provider.MediaStore;
import android.util.AttributeSet;
-import android.view.DisplayAdjustments;
import android.view.Display;
+import android.view.DisplayAdjustments;
import android.view.ViewDebug;
import android.view.WindowManager;
@@ -3870,7 +3870,7 @@
*
* @hide
*/
- public static final int CONTEXT_STORAGE_DEVICE_ENCRYPTED = 0x00000008;
+ public static final int CONTEXT_DEVICE_ENCRYPTED_STORAGE = 0x00000008;
/**
* Flag for use with {@link #createPackageContext}: point all file APIs at
@@ -3878,11 +3878,7 @@
*
* @hide
*/
- public static final int CONTEXT_STORAGE_CREDENTIAL_ENCRYPTED = 0x00000010;
-
- /** {@hide} */
- public static final int CONTEXT_STORAGE_MASK = CONTEXT_STORAGE_DEVICE_ENCRYPTED
- | CONTEXT_STORAGE_CREDENTIAL_ENCRYPTED;
+ public static final int CONTEXT_CREDENTIAL_ENCRYPTED_STORAGE = 0x00000010;
/**
* @hide Used to indicate we should tell the activity manager about the process
@@ -3987,19 +3983,23 @@
* Return a new Context object for the current Context but whose storage
* APIs are backed by device-encrypted storage.
* <p>
- * Data stored in device-encrypted storage is typically encrypted with a
- * key tied to the physical device, and they can be accessed whenever the
- * device has booted successfully, both <em>before and after</em> the user
- * has entered their credentials (such as a lock pattern or PIN).
+ * Data stored in device-encrypted storage is typically encrypted with a key
+ * tied to the physical device, and it can be accessed when the device has
+ * booted successfully, both <em>before and after</em> the user has
+ * authenticated with their credentials (such as a lock pattern or PIN).
+ * Because device-encrypted data is available before user authentication,
+ * you should carefully consider what data you store using this Context.
* <p>
* Each call to this method returns a new instance of a Context object;
* Context objects are not shared, however common state (ClassLoader, other
* Resources for the same configuration) may be so the Context itself can be
* fairly lightweight.
*
- * @see #isDeviceEncrypted()
+ * @return new Context or {@code null} if device-encrypted storage is not
+ * supported or available on this device.
+ * @see #isDeviceEncryptedStorage()
*/
- public abstract Context createDeviceEncryptedContext(Context context);
+ public abstract Context createDeviceEncryptedStorageContext();
/**
* Return a new Context object for the current Context but whose storage
@@ -4015,9 +4015,11 @@
* Resources for the same configuration) may be so the Context itself can be
* fairly lightweight.
*
- * @see #isCredentialEncrypted()
+ * @see #isCredentialEncryptedStorage()
+ * @hide
*/
- public abstract Context createCredentialEncryptedContext(Context context);
+ @SystemApi
+ public abstract Context createCredentialEncryptedStorageContext();
/**
* Gets the display adjustments holder for this context. This information
@@ -4045,15 +4047,17 @@
* Indicates if the storage APIs of this Context are backed by
* device-encrypted storage.
*
- * @see #createDeviceEncryptedContext(Context)
+ * @see #createDeviceEncryptedStorageContext()
*/
- public abstract boolean isDeviceEncrypted();
+ public abstract boolean isDeviceEncryptedStorage();
/**
* Indicates if the storage APIs of this Context are backed by
* credential-encrypted storage.
*
- * @see #createCredentialEncryptedContext(Context)
+ * @see #createCredentialEncryptedStorageContext()
+ * @hide
*/
- public abstract boolean isCredentialEncrypted();
+ @SystemApi
+ public abstract boolean isCredentialEncryptedStorage();
}
diff --git a/core/java/android/content/ContextWrapper.java b/core/java/android/content/ContextWrapper.java
index 73d0ddc..e49e771 100644
--- a/core/java/android/content/ContextWrapper.java
+++ b/core/java/android/content/ContextWrapper.java
@@ -792,22 +792,26 @@
}
@Override
- public Context createDeviceEncryptedContext(Context context) {
- return mBase.createDeviceEncryptedContext(context);
+ public Context createDeviceEncryptedStorageContext() {
+ return mBase.createDeviceEncryptedStorageContext();
+ }
+
+ /** {@hide} */
+ @SystemApi
+ @Override
+ public Context createCredentialEncryptedStorageContext() {
+ return mBase.createCredentialEncryptedStorageContext();
}
@Override
- public Context createCredentialEncryptedContext(Context context) {
- return mBase.createCredentialEncryptedContext(context);
+ public boolean isDeviceEncryptedStorage() {
+ return mBase.isDeviceEncryptedStorage();
}
+ /** {@hide} */
+ @SystemApi
@Override
- public boolean isDeviceEncrypted() {
- return mBase.isDeviceEncrypted();
- }
-
- @Override
- public boolean isCredentialEncrypted() {
- return mBase.isCredentialEncrypted();
+ public boolean isCredentialEncryptedStorage() {
+ return mBase.isCredentialEncryptedStorage();
}
}
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index 1346a39..00a874b 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -776,6 +776,16 @@
}
/**
+ * Return whether the calling user is running in a "locked" state. A user is
+ * unlocked only after they've entered their credentials (such as a lock
+ * pattern or PIN), and credential-encrypted private app data storage is
+ * available.
+ */
+ public boolean isUserRunningAndLocked() {
+ return isUserRunningAndLocked(Process.myUserHandle());
+ }
+
+ /**
* Return whether the given user is running in a "locked" state. A user
* is unlocked only after they've entered their credentials (such as a lock
* pattern or PIN), and credential-encrypted private app data storage is
@@ -793,6 +803,16 @@
}
/**
+ * Return whether the calling user is running in an "unlocked" state. A user
+ * is unlocked only after they've entered their credentials (such as a lock
+ * pattern or PIN), and credential-encrypted private app data storage is
+ * available.
+ */
+ public boolean isUserRunningAndUnlocked() {
+ return isUserRunningAndUnlocked(Process.myUserHandle());
+ }
+
+ /**
* Return whether the given user is running in an "unlocked" state. A user
* is unlocked only after they've entered their credentials (such as a lock
* pattern or PIN), and credential-encrypted private app data storage is
diff --git a/test-runner/src/android/test/mock/MockContext.java b/test-runner/src/android/test/mock/MockContext.java
index 4c3b598..96c8185 100644
--- a/test-runner/src/android/test/mock/MockContext.java
+++ b/test-runner/src/android/test/mock/MockContext.java
@@ -695,22 +695,26 @@
}
@Override
- public Context createDeviceEncryptedContext(Context context) {
+ public Context createDeviceEncryptedStorageContext() {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@hide} */
+ @SystemApi
+ @Override
+ public Context createCredentialEncryptedStorageContext() {
throw new UnsupportedOperationException();
}
@Override
- public Context createCredentialEncryptedContext(Context context) {
+ public boolean isDeviceEncryptedStorage() {
throw new UnsupportedOperationException();
}
+ /** {@hide} */
+ @SystemApi
@Override
- public boolean isDeviceEncrypted() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isCredentialEncrypted() {
+ public boolean isCredentialEncryptedStorage() {
throw new UnsupportedOperationException();
}
}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
index bd5335e..b09a14f 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
@@ -1804,24 +1804,24 @@
}
@Override
- public Context createDeviceEncryptedContext(Context context) {
+ public Context createDeviceEncryptedStorageContext() {
// pass
return null;
}
@Override
- public Context createCredentialEncryptedContext(Context context) {
+ public Context createCredentialEncryptedStorageContext() {
// pass
return null;
}
@Override
- public boolean isDeviceEncrypted() {
+ public boolean isDeviceEncryptedStorage() {
return false;
}
@Override
- public boolean isCredentialEncrypted() {
+ public boolean isCredentialEncryptedStorage() {
return false;
}
}