diff options
45 files changed, 722 insertions, 285 deletions
diff --git a/api/current.txt b/api/current.txt index 165d9407016e..dd22a402d362 100644 --- a/api/current.txt +++ b/api/current.txt @@ -7780,8 +7780,7 @@ package android.content { 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 @@ package android.content { 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 @@ package android.content { 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 @@ package android.content { 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 @@ package android.os { 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 @@ package android.test.mock { 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 @@ package android.test.mock { 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 5bf5c2076774..ee20e5bca9fb 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -8024,8 +8024,8 @@ package android.content { 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 @@ package android.content { 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 @@ package android.content { 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 @@ package android.content { 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 @@ package android.os { 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 @@ package android.test.mock { 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 @@ package android.test.mock { 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 39edceb102c0..032507b122ac 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -7780,8 +7780,7 @@ package android.content { 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 @@ package android.content { 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 @@ package android.content { 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 @@ package android.content { 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 @@ package android.os { 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 @@ package android.test.mock { 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 @@ package android.test.mock { 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 36e98f9f0567..d90ed9f6e639 100644 --- a/core/java/android/app/ContextImpl.java +++ b/core/java/android/app/ContextImpl.java @@ -61,6 +61,7 @@ import android.os.RemoteException; 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 @@ class ContextImpl extends Context { } @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 @@ class ContextImpl extends Context { } @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 @@ class ContextImpl extends Context { 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 @@ class ContextImpl extends Context { // 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/bluetooth/BluetoothHeadsetClientCall.java b/core/java/android/bluetooth/BluetoothHeadsetClientCall.java index 7b5a045e27f0..1fb7825fb9a7 100644 --- a/core/java/android/bluetooth/BluetoothHeadsetClientCall.java +++ b/core/java/android/bluetooth/BluetoothHeadsetClientCall.java @@ -172,8 +172,12 @@ public final class BluetoothHeadsetClientCall implements Parcelable { } public String toString() { + return toString(false); + } + + public String toString(boolean loggable) { StringBuilder builder = new StringBuilder("BluetoothHeadsetClientCall{mDevice: "); - builder.append(mDevice); + builder.append(loggable ? mDevice.hashCode() : mDevice); builder.append(", mId: "); builder.append(mId); builder.append(", mState: "); @@ -189,7 +193,7 @@ public final class BluetoothHeadsetClientCall implements Parcelable { default: builder.append(mState); break; } builder.append(", mNumber: "); - builder.append(mNumber); + builder.append(loggable ? mNumber.hashCode() : mNumber); builder.append(", mMultiParty: "); builder.append(mMultiParty); builder.append(", mOutgoing: "); diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 1f7fd9dee9ba..c61f20444813 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -53,8 +53,8 @@ import android.os.UserHandle; 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 @@ public abstract class Context { * * @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 @@ public abstract class Context { * * @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 @@ public abstract class Context { * 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 @@ public abstract class Context { * 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 @@ public abstract class Context { * 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 73d0ddc46fac..e49e771d4124 100644 --- a/core/java/android/content/ContextWrapper.java +++ b/core/java/android/content/ContextWrapper.java @@ -792,22 +792,26 @@ public class ContextWrapper extends Context { } @Override - public Context createDeviceEncryptedContext(Context context) { - return mBase.createDeviceEncryptedContext(context); + public Context createDeviceEncryptedStorageContext() { + return mBase.createDeviceEncryptedStorageContext(); } + /** {@hide} */ + @SystemApi @Override - public Context createCredentialEncryptedContext(Context context) { - return mBase.createCredentialEncryptedContext(context); + public Context createCredentialEncryptedStorageContext() { + return mBase.createCredentialEncryptedStorageContext(); } @Override - public boolean isDeviceEncrypted() { - return mBase.isDeviceEncrypted(); + public boolean isDeviceEncryptedStorage() { + return mBase.isDeviceEncryptedStorage(); } + /** {@hide} */ + @SystemApi @Override - public boolean isCredentialEncrypted() { - return mBase.isCredentialEncrypted(); + public boolean isCredentialEncryptedStorage() { + return mBase.isCredentialEncryptedStorage(); } } diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index bc7620cee3f9..a27d1cb845c8 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -4471,6 +4471,22 @@ public class Intent implements Parcelable, Cloneable { * @hide */ public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000; + /** + * If set, the broadcast will always go to manifest receivers in background (cached + * or not running) apps, regardless of whether that would be done by default. By + * default they will only receive broadcasts if the broadcast has specified an + * explicit component or package name. + * @hide + */ + public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000; + /** + * If set, the broadcast will never go to manifest receivers in background (cached + * or not running) apps, regardless of whether that would be done by default. By + * default they will receive broadcasts if the broadcast has specified an + * explicit component or package name. + * @hide + */ + public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000; /** * @hide Flags that can't be changed with PendingIntent. diff --git a/core/java/android/content/pm/ActivityInfo.java b/core/java/android/content/pm/ActivityInfo.java index 4a3c59bd8426..0cb0e9fce251 100644 --- a/core/java/android/content/pm/ActivityInfo.java +++ b/core/java/android/content/pm/ActivityInfo.java @@ -756,13 +756,20 @@ public class ActivityInfo extends ComponentInfo } public void dump(Printer pw, String prefix) { + dump(pw, prefix, DUMP_FLAG_ALL); + } + + /** @hide */ + public void dump(Printer pw, String prefix, int flags) { super.dumpFront(pw, prefix); if (permission != null) { pw.println(prefix + "permission=" + permission); } - pw.println(prefix + "taskAffinity=" + taskAffinity - + " targetActivity=" + targetActivity - + " persistableMode=" + persistableModeToString()); + if ((flags&DUMP_FLAG_DETAILS) != 0) { + pw.println(prefix + "taskAffinity=" + taskAffinity + + " targetActivity=" + targetActivity + + " persistableMode=" + persistableModeToString()); + } if (launchMode != 0 || flags != 0 || theme != 0) { pw.println(prefix + "launchMode=" + launchMode + " flags=0x" + Integer.toHexString(flags) @@ -777,14 +784,17 @@ public class ActivityInfo extends ComponentInfo if (uiOptions != 0) { pw.println(prefix + " uiOptions=0x" + Integer.toHexString(uiOptions)); } - pw.println(prefix + "resizeable=" + resizeable + " supportsPip=" + supportsPip); - pw.println(prefix + "lockTaskLaunchMode=" + lockTaskLaunchModeToString(lockTaskLaunchMode)); + if ((flags&DUMP_FLAG_DETAILS) != 0) { + pw.println(prefix + "resizeable=" + resizeable + " supportsPip=" + supportsPip); + pw.println(prefix + "lockTaskLaunchMode=" + + lockTaskLaunchModeToString(lockTaskLaunchMode)); + } if (layout != null) { pw.println(prefix + "initialLayout=" + layout.width + "|" + layout.widthFraction + ", " + layout.height + "|" + layout.heightFraction + ", " + layout.gravity); } - super.dumpBack(pw, prefix); + super.dumpBack(pw, prefix, flags); } public String toString() { diff --git a/core/java/android/content/pm/ApplicationInfo.java b/core/java/android/content/pm/ApplicationInfo.java index 4c5e76661c43..0633bff7a286 100644 --- a/core/java/android/content/pm/ApplicationInfo.java +++ b/core/java/android/content/pm/ApplicationInfo.java @@ -710,21 +710,30 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable { public int installLocation = PackageInfo.INSTALL_LOCATION_UNSPECIFIED; public void dump(Printer pw, String prefix) { + dump(pw, prefix, DUMP_FLAG_ALL); + } + + /** @hide */ + public void dump(Printer pw, String prefix, int flags) { super.dumpFront(pw, prefix); - if (className != null) { + if ((flags&DUMP_FLAG_DETAILS) != 0 && className != null) { pw.println(prefix + "className=" + className); } if (permission != null) { pw.println(prefix + "permission=" + permission); } pw.println(prefix + "processName=" + processName); - pw.println(prefix + "taskAffinity=" + taskAffinity); + if ((flags&DUMP_FLAG_DETAILS) != 0) { + pw.println(prefix + "taskAffinity=" + taskAffinity); + } pw.println(prefix + "uid=" + uid + " flags=0x" + Integer.toHexString(flags) + " privateFlags=0x" + Integer.toHexString(privateFlags) + " theme=0x" + Integer.toHexString(theme)); - pw.println(prefix + "requiresSmallestWidthDp=" + requiresSmallestWidthDp - + " compatibleWidthLimitDp=" + compatibleWidthLimitDp - + " largestWidthLimitDp=" + largestWidthLimitDp); + if ((flags&DUMP_FLAG_DETAILS) != 0) { + pw.println(prefix + "requiresSmallestWidthDp=" + requiresSmallestWidthDp + + " compatibleWidthLimitDp=" + compatibleWidthLimitDp + + " largestWidthLimitDp=" + largestWidthLimitDp); + } pw.println(prefix + "sourceDir=" + sourceDir); if (!Objects.equals(sourceDir, publicSourceDir)) { pw.println(prefix + "publicSourceDir=" + publicSourceDir); @@ -739,31 +748,36 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable { if (resourceDirs != null) { pw.println(prefix + "resourceDirs=" + resourceDirs); } - if (seinfo != null) { + if ((flags&DUMP_FLAG_DETAILS) != 0 && seinfo != null) { pw.println(prefix + "seinfo=" + seinfo); } pw.println(prefix + "dataDir=" + dataDir); - pw.println(prefix + "deviceEncryptedDataDir=" + deviceEncryptedDataDir); - pw.println(prefix + "credentialEncryptedDataDir=" + credentialEncryptedDataDir); - if (sharedLibraryFiles != null) { - pw.println(prefix + "sharedLibraryFiles=" + Arrays.toString(sharedLibraryFiles)); + if ((flags&DUMP_FLAG_DETAILS) != 0) { + pw.println(prefix + "deviceEncryptedDataDir=" + deviceEncryptedDataDir); + pw.println(prefix + "credentialEncryptedDataDir=" + credentialEncryptedDataDir); + if (sharedLibraryFiles != null) { + pw.println(prefix + "sharedLibraryFiles=" + Arrays.toString(sharedLibraryFiles)); + } } pw.println(prefix + "enabled=" + enabled + " targetSdkVersion=" + targetSdkVersion + " versionCode=" + versionCode); - if (manageSpaceActivityName != null) { - pw.println(prefix + "manageSpaceActivityName="+manageSpaceActivityName); - } - if (descriptionRes != 0) { - pw.println(prefix + "description=0x"+Integer.toHexString(descriptionRes)); - } - if (uiOptions != 0) { - pw.println(prefix + "uiOptions=0x" + Integer.toHexString(uiOptions)); - } - pw.println(prefix + "supportsRtl=" + (hasRtlSupport() ? "true" : "false")); - if (fullBackupContent > 0) { - pw.println(prefix + "fullBackupContent=@xml/" + fullBackupContent); - } else { - pw.println(prefix + "fullBackupContent=" + (fullBackupContent < 0 ? "false" : "true")); + if ((flags&DUMP_FLAG_DETAILS) != 0) { + if (manageSpaceActivityName != null) { + pw.println(prefix + "manageSpaceActivityName=" + manageSpaceActivityName); + } + if (descriptionRes != 0) { + pw.println(prefix + "description=0x" + Integer.toHexString(descriptionRes)); + } + if (uiOptions != 0) { + pw.println(prefix + "uiOptions=0x" + Integer.toHexString(uiOptions)); + } + pw.println(prefix + "supportsRtl=" + (hasRtlSupport() ? "true" : "false")); + if (fullBackupContent > 0) { + pw.println(prefix + "fullBackupContent=@xml/" + fullBackupContent); + } else { + pw.println(prefix + "fullBackupContent=" + + (fullBackupContent < 0 ? "false" : "true")); + } } super.dumpBack(pw, prefix); } diff --git a/core/java/android/content/pm/ComponentInfo.java b/core/java/android/content/pm/ComponentInfo.java index ad7ebe5e7fd9..a295cc55b00a 100644 --- a/core/java/android/content/pm/ComponentInfo.java +++ b/core/java/android/content/pm/ComponentInfo.java @@ -150,23 +150,32 @@ public class ComponentInfo extends PackageItemInfo { protected void dumpFront(Printer pw, String prefix) { super.dumpFront(pw, prefix); + if (processName != null && !packageName.equals(processName)) { + pw.println(prefix + "processName=" + processName); + } pw.println(prefix + "enabled=" + enabled + " exported=" + exported - + " encryptionAware=" + encryptionAware + " processName=" + processName); + + " encryptionAware=" + encryptionAware); if (descriptionRes != 0) { pw.println(prefix + "description=" + descriptionRes); } } - + protected void dumpBack(Printer pw, String prefix) { - if (applicationInfo != null) { - pw.println(prefix + "ApplicationInfo:"); - applicationInfo.dump(pw, prefix + " "); - } else { - pw.println(prefix + "ApplicationInfo: null"); + dumpBack(pw, prefix, DUMP_FLAG_ALL); + } + + void dumpBack(Printer pw, String prefix, int flags) { + if ((flags&DUMP_FLAG_APPLICATION) != 0) { + if (applicationInfo != null) { + pw.println(prefix + "ApplicationInfo:"); + applicationInfo.dump(pw, prefix + " ", flags); + } else { + pw.println(prefix + "ApplicationInfo: null"); + } } super.dumpBack(pw, prefix); } - + public void writeToParcel(Parcel dest, int parcelableFlags) { super.writeToParcel(dest, parcelableFlags); if ((parcelableFlags & Parcelable.PARCELABLE_ELIDE_DUPLICATES) != 0) { diff --git a/core/java/android/content/pm/PackageItemInfo.java b/core/java/android/content/pm/PackageItemInfo.java index 22a899cda05b..4df83036daaf 100644 --- a/core/java/android/content/pm/PackageItemInfo.java +++ b/core/java/android/content/pm/PackageItemInfo.java @@ -282,6 +282,21 @@ public class PackageItemInfo { return null; } + /** + * @hide Flag for dumping: include all details. + */ + public static final int DUMP_FLAG_DETAILS = 1<<0; + + /** + * @hide Flag for dumping: include nested ApplicationInfo. + */ + public static final int DUMP_FLAG_APPLICATION = 1<<1; + + /** + * @hide Flag for dumping: all flags to dump everything. + */ + public static final int DUMP_FLAG_ALL = DUMP_FLAG_DETAILS | DUMP_FLAG_APPLICATION; + protected void dumpFront(Printer pw, String prefix) { if (name != null) { pw.println(prefix + "name=" + name); diff --git a/core/java/android/content/pm/ProviderInfo.java b/core/java/android/content/pm/ProviderInfo.java index f6ea058b526f..7e7b32f03fd1 100644 --- a/core/java/android/content/pm/ProviderInfo.java +++ b/core/java/android/content/pm/ProviderInfo.java @@ -115,9 +115,15 @@ public final class ProviderInfo extends ComponentInfo } public void dump(Printer pw, String prefix) { + dump(pw, prefix, DUMP_FLAG_ALL); + } + + /** @hide */ + public void dump(Printer pw, String prefix, int flags) { super.dumpFront(pw, prefix); pw.println(prefix + "authority=" + authority); pw.println(prefix + "flags=0x" + Integer.toHexString(flags)); + super.dumpBack(pw, prefix, flags); } public int describeContents() { diff --git a/core/java/android/content/pm/ResolveInfo.java b/core/java/android/content/pm/ResolveInfo.java index 7bab35ce7e8e..a5fb451db61d 100644 --- a/core/java/android/content/pm/ResolveInfo.java +++ b/core/java/android/content/pm/ResolveInfo.java @@ -260,6 +260,11 @@ public class ResolveInfo implements Parcelable { } public void dump(Printer pw, String prefix) { + dump(pw, prefix, PackageItemInfo.DUMP_FLAG_ALL); + } + + /** @hide */ + public void dump(Printer pw, String prefix, int flags) { if (filter != null) { pw.println(prefix + "Filter:"); filter.dump(pw, prefix + " "); @@ -279,16 +284,16 @@ public class ResolveInfo implements Parcelable { } if (activityInfo != null) { pw.println(prefix + "ActivityInfo:"); - activityInfo.dump(pw, prefix + " "); + activityInfo.dump(pw, prefix + " ", flags); } else if (serviceInfo != null) { pw.println(prefix + "ServiceInfo:"); - serviceInfo.dump(pw, prefix + " "); + serviceInfo.dump(pw, prefix + " ", flags); } else if (providerInfo != null) { pw.println(prefix + "ProviderInfo:"); - providerInfo.dump(pw, prefix + " "); + providerInfo.dump(pw, prefix + " ", flags); } } - + public ResolveInfo() { targetUserId = UserHandle.USER_CURRENT; } diff --git a/core/java/android/content/pm/ServiceInfo.java b/core/java/android/content/pm/ServiceInfo.java index 796c2a422921..74e5c2a65982 100644 --- a/core/java/android/content/pm/ServiceInfo.java +++ b/core/java/android/content/pm/ServiceInfo.java @@ -74,9 +74,15 @@ public class ServiceInfo extends ComponentInfo } public void dump(Printer pw, String prefix) { + dump(pw, prefix, DUMP_FLAG_ALL); + } + + /** @hide */ + void dump(Printer pw, String prefix, int flags) { super.dumpFront(pw, prefix); pw.println(prefix + "permission=" + permission); pw.println(prefix + "flags=0x" + Integer.toHexString(flags)); + super.dumpBack(pw, prefix, flags); } public String toString() { diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java index 8a87bff2c8b5..02d4e59af6e4 100644 --- a/core/java/android/hardware/Camera.java +++ b/core/java/android/hardware/Camera.java @@ -47,6 +47,8 @@ import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; +import static android.system.OsConstants.*; + /** * The Camera class is used to set image capture settings, start/stop preview, * snap pictures, and retrieve frames for encoding for video. This class is a @@ -173,13 +175,6 @@ public class Camera { private final Object mAutoFocusCallbackLock = new Object(); private static final int NO_ERROR = 0; - private static final int EACCESS = -13; - private static final int ENODEV = -19; - private static final int EBUSY = -16; - private static final int EINVAL = -22; - private static final int ENOSYS = -38; - private static final int EUSERS = -87; - private static final int EOPNOTSUPP = -95; /** * Broadcast Action: A new picture is taken by the camera, and the entry of @@ -415,30 +410,28 @@ public class Camera { private Camera(int cameraId, int halVersion) { int err = cameraInitVersion(cameraId, halVersion); if (checkInitErrors(err)) { - switch(err) { - case EACCESS: - throw new RuntimeException("Fail to connect to camera service"); - case ENODEV: - throw new RuntimeException("Camera initialization failed"); - case ENOSYS: - throw new RuntimeException("Camera initialization failed because some methods" - + " are not implemented"); - case EOPNOTSUPP: - throw new RuntimeException("Camera initialization failed because the hal" - + " version is not supported by this device"); - case EINVAL: - throw new RuntimeException("Camera initialization failed because the input" - + " arugments are invalid"); - case EBUSY: - throw new RuntimeException("Camera initialization failed because the camera" - + " device was already opened"); - case EUSERS: - throw new RuntimeException("Camera initialization failed because the max" - + " number of camera devices were already opened"); - default: - // Should never hit this. - throw new RuntimeException("Unknown camera error"); + if (err == -EACCES) { + throw new RuntimeException("Fail to connect to camera service"); + } else if (err == -ENODEV) { + throw new RuntimeException("Camera initialization failed"); + } else if (err == -ENOSYS) { + throw new RuntimeException("Camera initialization failed because some methods" + + " are not implemented"); + } else if (err == -EOPNOTSUPP) { + throw new RuntimeException("Camera initialization failed because the hal" + + " version is not supported by this device"); + } else if (err == -EINVAL) { + throw new RuntimeException("Camera initialization failed because the input" + + " arugments are invalid"); + } else if (err == -EBUSY) { + throw new RuntimeException("Camera initialization failed because the camera" + + " device was already opened"); + } else if (err == -EUSERS) { + throw new RuntimeException("Camera initialization failed because the max" + + " number of camera devices were already opened"); } + // Should never hit this. + throw new RuntimeException("Unknown camera error"); } } @@ -490,15 +483,13 @@ public class Camera { Camera(int cameraId) { int err = cameraInitNormal(cameraId); if (checkInitErrors(err)) { - switch(err) { - case EACCESS: - throw new RuntimeException("Fail to connect to camera service"); - case ENODEV: - throw new RuntimeException("Camera initialization failed"); - default: - // Should never hit this. - throw new RuntimeException("Unknown camera error"); + if (err == -EACCES) { + throw new RuntimeException("Fail to connect to camera service"); + } else if (err == -ENODEV) { + throw new RuntimeException("Camera initialization failed"); } + // Should never hit this. + throw new RuntimeException("Unknown camera error"); } } diff --git a/core/java/android/hardware/camera2/legacy/CameraDeviceUserShim.java b/core/java/android/hardware/camera2/legacy/CameraDeviceUserShim.java index 6b8e1134f4d2..798c94126073 100644 --- a/core/java/android/hardware/camera2/legacy/CameraDeviceUserShim.java +++ b/core/java/android/hardware/camera2/legacy/CameraDeviceUserShim.java @@ -43,6 +43,9 @@ import android.view.Surface; import java.util.ArrayList; import java.util.List; +import static android.system.OsConstants.EACCES; +import static android.system.OsConstants.ENODEV; + /** * Compatibility implementation of the Camera2 API binder interface. * @@ -88,6 +91,14 @@ public class CameraDeviceUserShim implements ICameraDeviceUser { mSurfaceIdCounter = 0; } + private static int translateErrorsFromCamera1(int errorCode) { + if (errorCode == -EACCES) { + return CameraBinderDecorator.PERMISSION_DENIED; + } + + return errorCode; + } + /** * Create a separate looper/thread for the camera to run on; open the camera. * @@ -382,7 +393,7 @@ public class CameraDeviceUserShim implements ICameraDeviceUser { } if (mLegacyDevice.isClosed()) { Log.e(TAG, "Cannot submit request, device has been closed."); - return CameraBinderDecorator.ENODEV; + return -ENODEV; } synchronized(mConfigureLock) { @@ -402,7 +413,7 @@ public class CameraDeviceUserShim implements ICameraDeviceUser { } if (mLegacyDevice.isClosed()) { Log.e(TAG, "Cannot submit request list, device has been closed."); - return CameraBinderDecorator.ENODEV; + return -ENODEV; } synchronized(mConfigureLock) { @@ -421,7 +432,7 @@ public class CameraDeviceUserShim implements ICameraDeviceUser { } if (mLegacyDevice.isClosed()) { Log.e(TAG, "Cannot cancel request, device has been closed."); - return CameraBinderDecorator.ENODEV; + return -ENODEV; } synchronized(mConfigureLock) { @@ -442,7 +453,7 @@ public class CameraDeviceUserShim implements ICameraDeviceUser { } if (mLegacyDevice.isClosed()) { Log.e(TAG, "Cannot begin configure, device has been closed."); - return CameraBinderDecorator.ENODEV; + return -ENODEV; } synchronized(mConfigureLock) { @@ -462,7 +473,7 @@ public class CameraDeviceUserShim implements ICameraDeviceUser { } if (mLegacyDevice.isClosed()) { Log.e(TAG, "Cannot end configure, device has been closed."); - return CameraBinderDecorator.ENODEV; + return -ENODEV; } ArrayList<Surface> surfaces = null; @@ -490,7 +501,7 @@ public class CameraDeviceUserShim implements ICameraDeviceUser { } if (mLegacyDevice.isClosed()) { Log.e(TAG, "Cannot delete stream, device has been closed."); - return CameraBinderDecorator.ENODEV; + return -ENODEV; } synchronized(mConfigureLock) { @@ -515,7 +526,7 @@ public class CameraDeviceUserShim implements ICameraDeviceUser { } if (mLegacyDevice.isClosed()) { Log.e(TAG, "Cannot create stream, device has been closed."); - return CameraBinderDecorator.ENODEV; + return -ENODEV; } synchronized(mConfigureLock) { @@ -552,7 +563,7 @@ public class CameraDeviceUserShim implements ICameraDeviceUser { } if (mLegacyDevice.isClosed()) { Log.e(TAG, "Cannot create default request, device has been closed."); - return CameraBinderDecorator.ENODEV; + return -ENODEV; } CameraMetadataNative template; @@ -585,7 +596,7 @@ public class CameraDeviceUserShim implements ICameraDeviceUser { } if (mLegacyDevice.isClosed()) { Log.e(TAG, "Cannot wait until idle, device has been closed."); - return CameraBinderDecorator.ENODEV; + return -ENODEV; } synchronized(mConfigureLock) { @@ -605,7 +616,7 @@ public class CameraDeviceUserShim implements ICameraDeviceUser { } if (mLegacyDevice.isClosed()) { Log.e(TAG, "Cannot flush, device has been closed."); - return CameraBinderDecorator.ENODEV; + return -ENODEV; } synchronized(mConfigureLock) { @@ -627,7 +638,7 @@ public class CameraDeviceUserShim implements ICameraDeviceUser { } if (mLegacyDevice.isClosed()) { Log.e(TAG, "Cannot prepare stream, device has been closed."); - return CameraBinderDecorator.ENODEV; + return -ENODEV; } // LEGACY doesn't support actual prepare, just signal success right away @@ -647,7 +658,7 @@ public class CameraDeviceUserShim implements ICameraDeviceUser { } if (mLegacyDevice.isClosed()) { Log.e(TAG, "Cannot tear down stream, device has been closed."); - return CameraBinderDecorator.ENODEV; + return -ENODEV; } // LEGACY doesn't support actual teardown, so just a no-op diff --git a/core/java/android/hardware/camera2/legacy/LegacyExceptionUtils.java b/core/java/android/hardware/camera2/legacy/LegacyExceptionUtils.java index 4b7cfbf79b77..4501e81a1ef2 100644 --- a/core/java/android/hardware/camera2/legacy/LegacyExceptionUtils.java +++ b/core/java/android/hardware/camera2/legacy/LegacyExceptionUtils.java @@ -19,6 +19,8 @@ package android.hardware.camera2.legacy; import android.hardware.camera2.utils.CameraBinderDecorator; import android.util.AndroidException; +import static android.system.OsConstants.ENODEV; + /** * Utility class containing exception handling used solely by the compatibility mode shim. */ @@ -51,18 +53,15 @@ public class LegacyExceptionUtils { * exceptions.</p> * * @param errorFlag error to throw as an exception. - * @throws {@link BufferQueueAbandonedException} for {@link CameraBinderDecorator#ENODEV}. + * @throws {@link BufferQueueAbandonedException} for -ENODEV. * @throws {@link UnsupportedOperationException} for an unknown negative error code. * @return {@code errorFlag} if the value was non-negative, throws otherwise. */ public static int throwOnError(int errorFlag) throws BufferQueueAbandonedException { - switch (errorFlag) { - case CameraBinderDecorator.NO_ERROR: { - return CameraBinderDecorator.NO_ERROR; - } - case CameraBinderDecorator.BAD_VALUE: { - throw new BufferQueueAbandonedException(); - } + if (errorFlag == CameraBinderDecorator.NO_ERROR) { + return CameraBinderDecorator.NO_ERROR; + } else if (errorFlag == -ENODEV) { + throw new BufferQueueAbandonedException(); } if (errorFlag < 0) { diff --git a/core/java/android/hardware/camera2/utils/CameraBinderDecorator.java b/core/java/android/hardware/camera2/utils/CameraBinderDecorator.java index 1aee79477e3f..162edc9ab469 100644 --- a/core/java/android/hardware/camera2/utils/CameraBinderDecorator.java +++ b/core/java/android/hardware/camera2/utils/CameraBinderDecorator.java @@ -22,6 +22,7 @@ import static android.hardware.camera2.CameraAccessException.CAMERA_IN_USE; import static android.hardware.camera2.CameraAccessException.CAMERA_ERROR; import static android.hardware.camera2.CameraAccessException.MAX_CAMERAS_IN_USE; import static android.hardware.camera2.CameraAccessException.CAMERA_DEPRECATED_HAL; +import static android.system.OsConstants.*; import android.os.DeadObjectException; import android.os.RemoteException; @@ -37,12 +38,12 @@ import java.lang.reflect.Method; public class CameraBinderDecorator { public static final int NO_ERROR = 0; - public static final int PERMISSION_DENIED = -1; - public static final int ALREADY_EXISTS = -17; - public static final int BAD_VALUE = -22; - public static final int DEAD_OBJECT = -32; - public static final int INVALID_OPERATION = -38; - public static final int TIMED_OUT = -110; + public static final int PERMISSION_DENIED = -EPERM; + public static final int ALREADY_EXISTS = -EEXIST; + public static final int BAD_VALUE = -EINVAL; + public static final int DEAD_OBJECT = -ENOSYS; + public static final int INVALID_OPERATION = -EPIPE; + public static final int TIMED_OUT = -ETIMEDOUT; /** * TODO: add as error codes in Errors.h @@ -52,12 +53,6 @@ public class CameraBinderDecorator { * - NOT_SUPPORTED * - TOO_MANY_USERS */ - public static final int EACCES = -13; - public static final int EBUSY = -16; - public static final int ENODEV = -19; - public static final int EOPNOTSUPP = -95; - public static final int EUSERS = -87; - static class CameraBinderDecoratorListener implements Decorator.DecoratorListener { @@ -101,35 +96,34 @@ public class CameraBinderDecorator { * @param errorFlag error to throw as an exception. */ public static void throwOnError(int errorFlag) { - switch (errorFlag) { - case NO_ERROR: - return; - case PERMISSION_DENIED: - throw new SecurityException("Lacking privileges to access camera service"); - case ALREADY_EXISTS: - // This should be handled at the call site. Typically this isn't bad, - // just means we tried to do an operation that already completed. - return; - case BAD_VALUE: - throw new IllegalArgumentException("Bad argument passed to camera service"); - case DEAD_OBJECT: - throw new CameraRuntimeException(CAMERA_DISCONNECTED); - case TIMED_OUT: - throw new CameraRuntimeException(CAMERA_ERROR, - "Operation timed out in camera service"); - case EACCES: - throw new CameraRuntimeException(CAMERA_DISABLED); - case EBUSY: - throw new CameraRuntimeException(CAMERA_IN_USE); - case EUSERS: - throw new CameraRuntimeException(MAX_CAMERAS_IN_USE); - case ENODEV: - throw new CameraRuntimeException(CAMERA_DISCONNECTED); - case EOPNOTSUPP: - throw new CameraRuntimeException(CAMERA_DEPRECATED_HAL); - case INVALID_OPERATION: - throw new CameraRuntimeException(CAMERA_ERROR, - "Illegal state encountered in camera service."); + if (errorFlag == NO_ERROR) { + return; + } else if (errorFlag == PERMISSION_DENIED) { + throw new SecurityException("Lacking privileges to access camera service"); + } else if (errorFlag == ALREADY_EXISTS) { + // This should be handled at the call site. Typically this isn't bad, + // just means we tried to do an operation that already completed. + return; + } else if (errorFlag == BAD_VALUE) { + throw new IllegalArgumentException("Bad argument passed to camera service"); + } else if (errorFlag == DEAD_OBJECT) { + throw new CameraRuntimeException(CAMERA_DISCONNECTED); + } else if (errorFlag == TIMED_OUT) { + throw new CameraRuntimeException(CAMERA_ERROR, + "Operation timed out in camera service"); + } else if (errorFlag == -EACCES) { + throw new CameraRuntimeException(CAMERA_DISABLED); + } else if (errorFlag == -EBUSY) { + throw new CameraRuntimeException(CAMERA_IN_USE); + } else if (errorFlag == -EUSERS) { + throw new CameraRuntimeException(MAX_CAMERAS_IN_USE); + } else if (errorFlag == -ENODEV) { + throw new CameraRuntimeException(CAMERA_DISCONNECTED); + } else if (errorFlag == -EOPNOTSUPP) { + throw new CameraRuntimeException(CAMERA_DEPRECATED_HAL); + } else if (errorFlag == INVALID_OPERATION) { + throw new CameraRuntimeException(CAMERA_ERROR, + "Illegal state encountered in camera service."); } /** diff --git a/core/java/android/hardware/soundtrigger/SoundTrigger.java b/core/java/android/hardware/soundtrigger/SoundTrigger.java index c85e97b5c27b..d49040987a2e 100644 --- a/core/java/android/hardware/soundtrigger/SoundTrigger.java +++ b/core/java/android/hardware/soundtrigger/SoundTrigger.java @@ -25,6 +25,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.UUID; +import static android.system.OsConstants.*; + /** * The SoundTrigger class provides access via JNI to the native service managing * the sound trigger HAL. @@ -35,11 +37,11 @@ public class SoundTrigger { public static final int STATUS_OK = 0; public static final int STATUS_ERROR = Integer.MIN_VALUE; - public static final int STATUS_PERMISSION_DENIED = -1; - public static final int STATUS_NO_INIT = -19; - public static final int STATUS_BAD_VALUE = -22; - public static final int STATUS_DEAD_OBJECT = -32; - public static final int STATUS_INVALID_OPERATION = -38; + public static final int STATUS_PERMISSION_DENIED = -EPERM; + public static final int STATUS_NO_INIT = -ENODEV; + public static final int STATUS_BAD_VALUE = -EINVAL; + public static final int STATUS_DEAD_OBJECT = -EPIPE; + public static final int STATUS_INVALID_OPERATION = -ENOSYS; /***************************************************************************** * A ModuleProperties describes a given sound trigger hardware module diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java index 1346a390be45..00a874b2d6fe 100644 --- a/core/java/android/os/UserManager.java +++ b/core/java/android/os/UserManager.java @@ -776,6 +776,16 @@ public class UserManager { } /** + * 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 @@ public class UserManager { } /** + * 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/core/java/android/security/net/config/CertificateSource.java b/core/java/android/security/net/config/CertificateSource.java index 2b7829eb6a31..7e3601e1fbea 100644 --- a/core/java/android/security/net/config/CertificateSource.java +++ b/core/java/android/security/net/config/CertificateSource.java @@ -23,4 +23,5 @@ import java.security.cert.X509Certificate; public interface CertificateSource { Set<X509Certificate> getCertificates(); X509Certificate findBySubjectAndPublicKey(X509Certificate cert); + X509Certificate findByIssuerAndSignature(X509Certificate cert); } diff --git a/core/java/android/security/net/config/CertificatesEntryRef.java b/core/java/android/security/net/config/CertificatesEntryRef.java index 1d15e19a99f2..ff728efc2d93 100644 --- a/core/java/android/security/net/config/CertificatesEntryRef.java +++ b/core/java/android/security/net/config/CertificatesEntryRef.java @@ -51,4 +51,13 @@ public final class CertificatesEntryRef { return new TrustAnchor(foundCert, mOverridesPins); } + + public TrustAnchor findByIssuerAndSignature(X509Certificate cert) { + X509Certificate foundCert = mSource.findByIssuerAndSignature(cert); + if (foundCert == null) { + return null; + } + + return new TrustAnchor(foundCert, mOverridesPins); + } } diff --git a/core/java/android/security/net/config/DirectoryCertificateSource.java b/core/java/android/security/net/config/DirectoryCertificateSource.java index a261e0611e45..bf29efabb00a 100644 --- a/core/java/android/security/net/config/DirectoryCertificateSource.java +++ b/core/java/android/security/net/config/DirectoryCertificateSource.java @@ -95,6 +95,21 @@ abstract class DirectoryCertificateSource implements CertificateSource { }); } + @Override + public X509Certificate findByIssuerAndSignature(final X509Certificate cert) { + return findCert(cert.getIssuerX500Principal(), new CertSelector() { + @Override + public boolean match(X509Certificate ca) { + try { + cert.verify(ca.getPublicKey()); + return true; + } catch (Exception e) { + return false; + } + } + }); + } + private static interface CertSelector { boolean match(X509Certificate cert); } diff --git a/core/java/android/security/net/config/KeyStoreCertificateSource.java b/core/java/android/security/net/config/KeyStoreCertificateSource.java index 7a01a6488a04..b6105cd5da4c 100644 --- a/core/java/android/security/net/config/KeyStoreCertificateSource.java +++ b/core/java/android/security/net/config/KeyStoreCertificateSource.java @@ -80,4 +80,14 @@ class KeyStoreCertificateSource implements CertificateSource { } return anchor.getTrustedCert(); } + + @Override + public X509Certificate findByIssuerAndSignature(X509Certificate cert) { + ensureInitialized(); + java.security.cert.TrustAnchor anchor = mIndex.findByIssuerAndSignature(cert); + if (anchor == null) { + return null; + } + return anchor.getTrustedCert(); + } } diff --git a/core/java/android/security/net/config/NetworkSecurityConfig.java b/core/java/android/security/net/config/NetworkSecurityConfig.java index 2ab07b5abf18..0a2edff2295f 100644 --- a/core/java/android/security/net/config/NetworkSecurityConfig.java +++ b/core/java/android/security/net/config/NetworkSecurityConfig.java @@ -134,6 +134,17 @@ public final class NetworkSecurityConfig { return null; } + /** @hide */ + public TrustAnchor findTrustAnchorByIssuerAndSignature(X509Certificate cert) { + for (CertificatesEntryRef ref : mCertificatesEntryRefs) { + TrustAnchor anchor = ref.findByIssuerAndSignature(cert); + if (anchor != null) { + return anchor; + } + } + return null; + } + /** * Return a {@link Builder} for the default {@code NetworkSecurityConfig}. * diff --git a/core/java/android/security/net/config/NetworkSecurityTrustManager.java b/core/java/android/security/net/config/NetworkSecurityTrustManager.java index 6013c1e4023e..982ed68f13da 100644 --- a/core/java/android/security/net/config/NetworkSecurityTrustManager.java +++ b/core/java/android/security/net/config/NetworkSecurityTrustManager.java @@ -46,17 +46,13 @@ public class NetworkSecurityTrustManager implements X509TrustManager { throw new NullPointerException("config must not be null"); } mNetworkSecurityConfig = config; - // TODO: Create our own better KeyStoreImpl try { + TrustedCertificateStoreAdapter certStore = new TrustedCertificateStoreAdapter(config); + // Provide an empty KeyStore since TrustManagerImpl doesn't support null KeyStores. + // TrustManagerImpl will use certStore to lookup certificates. KeyStore store = KeyStore.getInstance(KeyStore.getDefaultType()); store.load(null); - int certNum = 0; - for (TrustAnchor anchor : mNetworkSecurityConfig.getTrustAnchors()) { - store.setEntry(String.valueOf(certNum++), - new KeyStore.TrustedCertificateEntry(anchor.certificate), - null); - } - mDelegate = new TrustManagerImpl(store); + mDelegate = new TrustManagerImpl(store, null, certStore); } catch (GeneralSecurityException | IOException e) { throw new RuntimeException(e); } diff --git a/core/java/android/security/net/config/ResourceCertificateSource.java b/core/java/android/security/net/config/ResourceCertificateSource.java index b007f8f00a55..e489c2c529eb 100644 --- a/core/java/android/security/net/config/ResourceCertificateSource.java +++ b/core/java/android/security/net/config/ResourceCertificateSource.java @@ -90,4 +90,14 @@ public class ResourceCertificateSource implements CertificateSource { } return anchor.getTrustedCert(); } + + @Override + public X509Certificate findByIssuerAndSignature(X509Certificate cert) { + ensureInitialized(); + java.security.cert.TrustAnchor anchor = mIndex.findByIssuerAndSignature(cert); + if (anchor == null) { + return null; + } + return anchor.getTrustedCert(); + } } diff --git a/core/java/android/security/net/config/TrustedCertificateStoreAdapter.java b/core/java/android/security/net/config/TrustedCertificateStoreAdapter.java new file mode 100644 index 000000000000..4a90f8223ad7 --- /dev/null +++ b/core/java/android/security/net/config/TrustedCertificateStoreAdapter.java @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.security.net.config; + +import java.io.File; +import java.security.cert.Certificate; +import java.security.cert.X509Certificate; +import java.util.Date; +import java.util.Set; + +import com.android.org.conscrypt.TrustedCertificateStore; + +/** @hide */ +public class TrustedCertificateStoreAdapter extends TrustedCertificateStore { + private final NetworkSecurityConfig mConfig; + + public TrustedCertificateStoreAdapter(NetworkSecurityConfig config) { + mConfig = config; + } + + @Override + public X509Certificate findIssuer(X509Certificate cert) { + TrustAnchor anchor = mConfig.findTrustAnchorByIssuerAndSignature(cert); + if (anchor == null) { + return null; + } + return anchor.certificate; + } + + @Override + public X509Certificate getTrustAnchor(X509Certificate cert) { + TrustAnchor anchor = mConfig.findTrustAnchorBySubjectAndPublicKey(cert); + if (anchor == null) { + return null; + } + return anchor.certificate; + } + + @Override + public boolean isUserAddedCertificate(X509Certificate cert) { + // isUserAddedCertificate is used only for pinning overrides, so use overridesPins here. + TrustAnchor anchor = mConfig.findTrustAnchorBySubjectAndPublicKey(cert); + if (anchor == null) { + return false; + } + return anchor.overridesPins; + } + + @Override + public File getCertificateFile(File dir, X509Certificate x) { + // getCertificateFile is only used for tests, do not support it here. + throw new UnsupportedOperationException(); + } + + // The methods below are exposed in TrustedCertificateStore but not used by conscrypt, do not + // support them. + + @Override + public Certificate getCertificate(String alias) { + throw new UnsupportedOperationException(); + } + + @Override + public Certificate getCertificate(String alias, boolean includeDeletedSystem) { + throw new UnsupportedOperationException(); + } + + @Override + public Date getCreationDate(String alias) { + throw new UnsupportedOperationException(); + } + + @Override + public Set<String> aliases() { + throw new UnsupportedOperationException(); + } + + @Override + public Set<String> userAliases() { + throw new UnsupportedOperationException(); + } + + @Override + public Set<String> allSystemAliases() { + throw new UnsupportedOperationException(); + } + + @Override + public boolean containsAlias(String alias) { + throw new UnsupportedOperationException(); + } + + @Override + public String getCertificateAlias(Certificate c) { + throw new UnsupportedOperationException(); + } + + @Override + public String getCertificateAlias(Certificate c, boolean includeDeletedSystem) { + throw new UnsupportedOperationException(); + } +} diff --git a/core/jni/android_os_Debug.cpp b/core/jni/android_os_Debug.cpp index 1ee7ea8f7ea6..71f881e6d6e1 100644 --- a/core/jni/android_os_Debug.cpp +++ b/core/jni/android_os_Debug.cpp @@ -595,6 +595,36 @@ enum { MEMINFO_COUNT }; +static long get_zram_mem_used() +{ +#define ZRAM_SYSFS "/sys/block/zram0/" + FILE *f = fopen(ZRAM_SYSFS "mm_stat", "r"); + if (f) { + long mem_used_total = 0; + + int matched = fscanf(f, "%*d %*d %ld %*d %*d %*d %*d", &mem_used_total); + if (matched != 1) + ALOGW("failed to parse " ZRAM_SYSFS "mm_stat"); + + fclose(f); + return mem_used_total; + } + + f = fopen(ZRAM_SYSFS "mem_used_total", "r"); + if (f) { + long mem_used_total = 0; + + int matched = fscanf(f, "%ld", &mem_used_total); + if (matched != 1) + ALOGW("failed to parse " ZRAM_SYSFS "mem_used_total"); + + fclose(f); + return mem_used_total; + } + + return 0; +} + static void android_os_Debug_getMemInfo(JNIEnv *env, jobject clazz, jlongArray out) { char buffer[1024]; @@ -680,15 +710,7 @@ static void android_os_Debug_getMemInfo(JNIEnv *env, jobject clazz, jlongArray o if (*p) p++; } - fd = open("/sys/block/zram0/mem_used_total", O_RDONLY); - if (fd >= 0) { - len = read(fd, buffer, sizeof(buffer)-1); - close(fd); - if (len > 0) { - buffer[len] = 0; - mem[MEMINFO_ZRAM_TOTAL] = atoll(buffer)/1024; - } - } + mem[MEMINFO_ZRAM_TOTAL] = get_zram_mem_used() / 1024; // Recompute Vmalloc Used since the value in meminfo // doesn't account for I/O remapping which doesn't use RAM. mem[MEMINFO_VMALLOC_USED] = get_allocated_vmalloc_memory() / 1024; diff --git a/libs/hwui/tests/common/scenes/ShapeAnimation.cpp b/libs/hwui/tests/common/scenes/ShapeAnimation.cpp new file mode 100644 index 000000000000..0cba34479a3c --- /dev/null +++ b/libs/hwui/tests/common/scenes/ShapeAnimation.cpp @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "TestSceneBase.h" +#include "utils/Color.h" + +#include <cstdio> + +class ShapeAnimation; + +static TestScene::Registrar _Shapes(TestScene::Info{ + "shapes", + "A grid of shape drawing test cases.", + TestScene::simpleCreateScene<ShapeAnimation> +}); + +class ShapeAnimation : public TestScene { +public: + sp<RenderNode> card; + void createContent(int width, int height, TestCanvas& canvas) override { + card = TestUtils::createNode(0, 0, width, height, + [width](RenderProperties& props, TestCanvas& canvas) { + std::function<void(TestCanvas&, float, const SkPaint&)> ops[] = { + [](TestCanvas& canvas, float size, const SkPaint& paint) { + canvas.drawArc(0, 0, size, size, 50, 189, true, paint); + }, + [](TestCanvas& canvas, float size, const SkPaint& paint) { + canvas.drawOval(0, 0, size, size, paint); + }, + [](TestCanvas& canvas, float size, const SkPaint& paint) { + SkPath diamondPath; + diamondPath.moveTo(size / 2, 0); + diamondPath.lineTo(size, size / 2); + diamondPath.lineTo(size / 2, size); + diamondPath.lineTo(0, size / 2); + diamondPath.close(); + canvas.drawPath(diamondPath, paint); + }, + [](TestCanvas& canvas, float size, const SkPaint& paint) { + float data[] = {0, 0, size, size, 0, size, size, 0 }; + canvas.drawLines(data, sizeof(data) / sizeof(float), paint); + }, + [](TestCanvas& canvas, float size, const SkPaint& paint) { + float data[] = {0, 0, size, size, 0, size, size, 0 }; + canvas.drawPoints(data, sizeof(data) / sizeof(float), paint); + }, + [](TestCanvas& canvas, float size, const SkPaint& paint) { + canvas.drawRect(0, 0, size, size, paint); + }, + [](TestCanvas& canvas, float size, const SkPaint& paint) { + float rad = size / 4; + canvas.drawRoundRect(0, 0, size, size, rad, rad, paint); + } + }; + float cellSpace = dp(4); + float cellSize = floorf(width / 7 - cellSpace); + + // each combination of strokeWidth + style gets a column + int outerCount = canvas.save(SkCanvas::kMatrixClip_SaveFlag); + SkPaint paint; + paint.setAntiAlias(true); + SkPaint::Style styles[] = { + SkPaint::kStroke_Style, SkPaint::kFill_Style, SkPaint::kStrokeAndFill_Style }; + for (auto style : styles) { + paint.setStyle(style); + for (auto strokeWidth : { 0.0f, 0.5f, 8.0f }) { + paint.setStrokeWidth(strokeWidth); + // fill column with each op + int middleCount = canvas.save(SkCanvas::kMatrixClip_SaveFlag); + for (auto op : ops) { + int innerCount = canvas.save(SkCanvas::kMatrixClip_SaveFlag); + canvas.clipRect(0, 0, cellSize, cellSize, SkRegion::kIntersect_Op); + canvas.drawColor(Color::White, SkXfermode::Mode::kSrcOver_Mode); + op(canvas, cellSize, paint); + canvas.restoreToCount(innerCount); + canvas.translate(cellSize + cellSpace, 0); + } + canvas.restoreToCount(middleCount); + canvas.translate(0, cellSize + cellSpace); + } + } + canvas.restoreToCount(outerCount); + }); + canvas.drawColor(Color::Grey_500, SkXfermode::Mode::kSrcOver_Mode); + canvas.drawRenderNode(card.get()); + } + + void doFrame(int frameNr) override { + card->mutateStagingProperties().setTranslationY(frameNr % 150); + card->setPropertyFieldsDirty(RenderNode::Y); + } +}; diff --git a/libs/hwui/utils/RingBuffer.h b/libs/hwui/utils/RingBuffer.h index 6895f07fd60a..06bcdcd7d84b 100644 --- a/libs/hwui/utils/RingBuffer.h +++ b/libs/hwui/utils/RingBuffer.h @@ -32,7 +32,7 @@ public: ~RingBuffer() {} constexpr size_t capacity() const { return SIZE; } - size_t size() { return mCount; } + size_t size() const { return mCount; } T& next() { mHead = (mHead + 1) % SIZE; @@ -54,6 +54,10 @@ public: return mBuffer[(mHead + index + 1) % mCount]; } + const T& operator[](size_t index) const { + return mBuffer[(mHead + index + 1) % mCount]; + } + void clear() { mCount = 0; mHead = -1; diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraBinderTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraBinderTest.java index 57969baffdf9..6f742037dbe4 100644 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraBinderTest.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraBinderTest.java @@ -129,7 +129,7 @@ public class CameraBinderTest extends AndroidTestCase { int res = mUtils.getCameraService().supportsCameraApi(cameraId, API_VERSION_2); - if (res != CameraBinderTestUtils.NO_ERROR && res != CameraBinderTestUtils.EOPNOTSUPP) { + if (res != CameraBinderTestUtils.NO_ERROR && res != -android.system.OsConstants.EOPNOTSUPP) { fail("Camera service returned bad value when queried if it supports camera2 api: " + res + " for camera ID " + cameraId); } diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraBinderTestUtils.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraBinderTestUtils.java index 6be538ae3597..5c4b23bb7b33 100644 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraBinderTestUtils.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraBinderTestUtils.java @@ -2,6 +2,7 @@ package com.android.mediaframeworktest.integration; import static org.junit.Assert.assertNotNull; +import static android.system.OsConstants.*; import android.content.Context; import android.content.pm.FeatureInfo; @@ -18,11 +19,10 @@ public class CameraBinderTestUtils { static final String CAMERA_SERVICE_BINDER_NAME = "media.camera"; protected static final int USE_CALLING_UID = -1; - protected static final int BAD_VALUE = -22; - protected static final int INVALID_OPERATION = -38; - protected static final int ALREADY_EXISTS = -17; + protected static final int BAD_VALUE = -EINVAL; + protected static final int INVALID_OPERATION = -ENOSYS; + protected static final int ALREADY_EXISTS = -EEXIST; public static final int NO_ERROR = 0; - public static final int EOPNOTSUPP = -95; private final Context mContext; public CameraBinderTestUtils(Context context) { diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/CameraUtilsBinderDecoratorTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/CameraUtilsBinderDecoratorTest.java index 727af781bd04..33c638801c4b 100644 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/CameraUtilsBinderDecoratorTest.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/CameraUtilsBinderDecoratorTest.java @@ -27,6 +27,7 @@ import android.test.suitebuilder.annotation.SmallTest; import static org.mockito.Mockito.*; import static android.hardware.camera2.utils.CameraBinderDecorator.*; import static android.hardware.camera2.CameraAccessException.*; +import static android.system.OsConstants.*; import junit.framework.Assert; @@ -78,9 +79,9 @@ public class CameraUtilsBinderDecoratorTest extends junit.framework.TestCase { when(mock.doSomethingAlreadyExists()).thenReturn(ALREADY_EXISTS); when(mock.doSomethingBadValue()).thenReturn(BAD_VALUE); when(mock.doSomethingDeadObject()).thenReturn(DEAD_OBJECT); - when(mock.doSomethingBadPolicy()).thenReturn(EACCES); - when(mock.doSomethingDeviceBusy()).thenReturn(EBUSY); - when(mock.doSomethingNoSuchDevice()).thenReturn(ENODEV); + when(mock.doSomethingBadPolicy()).thenReturn(-EACCES); + when(mock.doSomethingDeviceBusy()).thenReturn(-EBUSY); + when(mock.doSomethingNoSuchDevice()).thenReturn(-ENODEV); when(mock.doSomethingUnknownErrorCode()).thenReturn(SOME_ARBITRARY_NEGATIVE_INT); when(mock.doSomethingThrowDeadObjectException()).thenThrow(new DeadObjectException()); when(mock.doSomethingThrowTransactionTooLargeException()).thenThrow( diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarGestureHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarGestureHelper.java index a2616fe46efb..d35e57b10c51 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarGestureHelper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarGestureHelper.java @@ -270,7 +270,7 @@ public class NavigationBarGestureHelper extends GestureDetector.SimpleOnGestureL public void onTuningChanged(String key, String newValue) { switch (key) { case KEY_DOCK_WINDOW_GESTURE: - mDockWindowEnabled = (newValue != null) && + mDockWindowEnabled = (newValue == null) || (Integer.parseInt(newValue) != 0); break; } diff --git a/services/core/java/com/android/server/am/BroadcastQueue.java b/services/core/java/com/android/server/am/BroadcastQueue.java index 2fb71c3a8e24..1bab7b99ec62 100644 --- a/services/core/java/com/android/server/am/BroadcastQueue.java +++ b/services/core/java/com/android/server/am/BroadcastQueue.java @@ -1075,9 +1075,18 @@ public final class BroadcastQueue { } } + // This is safe to do even if we are skipping the broadcast, and we need + // this information now to evaluate whether it is going to be allowed to run. + final int receiverUid = info.activityInfo.applicationInfo.uid; + // If it's a singleton, it needs to be the same app or a special app + if (r.callingUid != Process.SYSTEM_UID && isSingleton + && mService.isValidSingletonCall(r.callingUid, receiverUid)) { + info.activityInfo = mService.getActivityInfoForUser(info.activityInfo, 0); + } String targetProcess = info.activityInfo.processName; ProcessRecord app = mService.getProcessRecordLocked(targetProcess, info.activityInfo.applicationInfo.uid, false); + if (!skip) { final int allowed = mService.checkAllowBackgroundLocked( info.activityInfo.applicationInfo.uid, info.activityInfo.packageName, -1); @@ -1086,9 +1095,17 @@ public final class BroadcastQueue { // completely disabled from launches, or it is delayed and the broadcast // was not explicitly sent to it and this would result in a new process // for it being created. - if (allowed == ActivityManager.APP_START_MODE_DISABLED + if (allowed == ActivityManager.APP_START_MODE_DISABLED) { + Slog.w(TAG, "Background execution disabled: receiving " + + r.intent + " to " + + component.flattenToShortString()); + skip = true; + } + if (((r.intent.getFlags()&Intent.FLAG_RECEIVER_EXCLUDE_BACKGROUND) != 0) || (r.intent.getComponent() == null - && r.intent.getPackage() == null && app == null)) { + && r.intent.getPackage() == null && app == null + && ((r.intent.getFlags() + & Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND) == 0))) { Slog.w(TAG, "Background execution not allowed: receiving " + r.intent + " to " + component.flattenToShortString()); @@ -1110,12 +1127,6 @@ public final class BroadcastQueue { r.state = BroadcastRecord.APP_RECEIVE; r.curComponent = component; - final int receiverUid = info.activityInfo.applicationInfo.uid; - // If it's a singleton, it needs to be the same app or a special app - if (r.callingUid != Process.SYSTEM_UID && isSingleton - && mService.isValidSingletonCall(r.callingUid, receiverUid)) { - info.activityInfo = mService.getActivityInfoForUser(info.activityInfo, 0); - } r.curReceiver = info.activityInfo; if (DEBUG_MU && r.callingUid > UserHandle.PER_USER_RANGE) { Slog.v(TAG_MU, "Updated broadcast record activity info for secondary user, " diff --git a/services/core/java/com/android/server/am/BroadcastRecord.java b/services/core/java/com/android/server/am/BroadcastRecord.java index b42bcff15f83..1a269cf840f7 100644 --- a/services/core/java/com/android/server/am/BroadcastRecord.java +++ b/services/core/java/com/android/server/am/BroadcastRecord.java @@ -188,7 +188,7 @@ final class BroadcastRecord extends Binder { if (o instanceof BroadcastFilter) ((BroadcastFilter)o).dumpBrief(pw, p2); else if (o instanceof ResolveInfo) - ((ResolveInfo)o).dump(printer, p2); + ((ResolveInfo)o).dump(printer, p2, 0); } } diff --git a/services/core/java/com/android/server/am/UserController.java b/services/core/java/com/android/server/am/UserController.java index f6f82da6f75c..62e78a456c98 100644 --- a/services/core/java/com/android/server/am/UserController.java +++ b/services/core/java/com/android/server/am/UserController.java @@ -253,7 +253,8 @@ final class UserController { final Intent bootIntent = new Intent(Intent.ACTION_BOOT_COMPLETED, null); bootIntent.putExtra(Intent.EXTRA_USER_HANDLE, userId); - bootIntent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT); + bootIntent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT + | Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); mService.broadcastIntentLocked(null, null, bootIntent, null, null, 0, null, null, new String[] { android.Manifest.permission.RECEIVE_BOOT_COMPLETED }, AppOpsManager.OP_NONE, null, true, false, MY_PID, SYSTEM_UID, userId); diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 2f8157ef6865..3a8a9882f403 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -9797,6 +9797,15 @@ public class PackageManagerService extends IPackageManager.Stub { if (r1.system != r2.system) { return r1.system ? -1 : 1; } + if (r1.activityInfo != null) { + return r1.activityInfo.packageName.compareTo(r2.activityInfo.packageName); + } + if (r1.serviceInfo != null) { + return r1.serviceInfo.packageName.compareTo(r2.serviceInfo.packageName); + } + if (r1.providerInfo != null) { + return r1.providerInfo.packageName.compareTo(r2.providerInfo.packageName); + } return 0; } }; diff --git a/services/core/java/com/android/server/pm/PackageManagerShellCommand.java b/services/core/java/com/android/server/pm/PackageManagerShellCommand.java index f9ed7607f024..b18c84678a8e 100644 --- a/services/core/java/com/android/server/pm/PackageManagerShellCommand.java +++ b/services/core/java/com/android/server/pm/PackageManagerShellCommand.java @@ -103,11 +103,11 @@ class PackageManagerShellCommand extends ShellCommand { return runUninstall(); case "resolve-activity": return runResolveActivity(); - case "query-intent-activities": + case "query-activities": return runQueryIntentActivities(); - case "query-intent-services": + case "query-services": return runQueryIntentServices(); - case "query-intent-receivers": + case "query-receivers": return runQueryIntentReceivers(); default: return handleDefaultCommands(cmd); @@ -1043,13 +1043,13 @@ class PackageManagerShellCommand extends ShellCommand { pw.println(" -s: short summary"); pw.println(" -d: only list dangerous permissions"); pw.println(" -u: list only the permissions users will see"); - pw.println(" resolve-intent [--user USER_ID] INTENT"); + pw.println(" resolve-activity [--user USER_ID] INTENT"); pw.println(" Prints the activity that resolves to the given Intent."); - pw.println(" query-intent-activities [--user USER_ID] INTENT"); + pw.println(" query-activities [--user USER_ID] INTENT"); pw.println(" Prints all activities that can handle the given Intent."); - pw.println(" query-intent-services [--user USER_ID] INTENT"); + pw.println(" query-services [--user USER_ID] INTENT"); pw.println(" Prints all services that can handle the given Intent."); - pw.println(" query-intent-receivers [--user USER_ID] INTENT"); + pw.println(" query-receivers [--user USER_ID] INTENT"); pw.println(" Prints all broadcast receivers that can handle the given Intent."); pw.println(); Intent.printIntentArgsHelp(pw , ""); diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java index 109d214e1167..3efd0fb7ad7a 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java @@ -266,8 +266,6 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne pw.print(" Session service="); pw.println(mInfo.getSessionService()); pw.println(" Service info:"); mInfo.getServiceInfo().dump(new PrintWriterPrinter(pw), " "); - pw.println(" Application info:"); - mInfo.getServiceInfo().applicationInfo.dump(new PrintWriterPrinter(pw), " "); pw.print(" Recognition service="); pw.println(mInfo.getRecognitionService()); pw.print(" Settings activity="); pw.println(mInfo.getSettingsActivity()); pw.print(" Supports assist="); pw.println(mInfo.getSupportsAssist()); diff --git a/test-runner/src/android/test/mock/MockContext.java b/test-runner/src/android/test/mock/MockContext.java index 4c3b5987f05d..96c818571df0 100644 --- a/test-runner/src/android/test/mock/MockContext.java +++ b/test-runner/src/android/test/mock/MockContext.java @@ -695,22 +695,26 @@ public class MockContext extends Context { } @Override - public Context createDeviceEncryptedContext(Context context) { + public Context createDeviceEncryptedStorageContext() { throw new UnsupportedOperationException(); } + /** {@hide} */ + @SystemApi @Override - public Context createCredentialEncryptedContext(Context context) { + public Context createCredentialEncryptedStorageContext() { throw new UnsupportedOperationException(); } @Override - public boolean isDeviceEncrypted() { + public boolean isDeviceEncryptedStorage() { throw new UnsupportedOperationException(); } + /** {@hide} */ + @SystemApi @Override - public boolean isCredentialEncrypted() { + public boolean isCredentialEncryptedStorage() { throw new UnsupportedOperationException(); } } diff --git a/tests/NetworkSecurityConfigTest/src/android/security/net/config/TestCertificateSource.java b/tests/NetworkSecurityConfigTest/src/android/security/net/config/TestCertificateSource.java index 69b2a9d55642..0c360631c294 100644 --- a/tests/NetworkSecurityConfigTest/src/android/security/net/config/TestCertificateSource.java +++ b/tests/NetworkSecurityConfigTest/src/android/security/net/config/TestCertificateSource.java @@ -44,4 +44,12 @@ public class TestCertificateSource implements CertificateSource { } return anchor.getTrustedCert(); } + + public X509Certificate findByIssuerAndSignature(X509Certificate cert) { + java.security.cert.TrustAnchor anchor = mIndex.findByIssuerAndSignature(cert); + if (anchor == null) { + return null; + } + return anchor.getTrustedCert(); + } } 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 bd5335ebb38d..b09a14fd1b39 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 @@ public final class BridgeContext extends Context { } @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; } } |