Merge "Allow Instant Apps to read Settings defined by apps" into oc-dev
diff --git a/api/current.txt b/api/current.txt
index fc23b36..c8bfa47 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -15,7 +15,6 @@
     field public static final java.lang.String ACCESS_WIFI_STATE = "android.permission.ACCESS_WIFI_STATE";
     field public static final java.lang.String ACCOUNT_MANAGER = "android.permission.ACCOUNT_MANAGER";
     field public static final java.lang.String ADD_VOICEMAIL = "com.android.voicemail.permission.ADD_VOICEMAIL";
-    field public static final java.lang.String ALLOCATE_AGGRESSIVE = "android.permission.ALLOCATE_AGGRESSIVE";
     field public static final java.lang.String ANSWER_PHONE_CALLS = "android.permission.ANSWER_PHONE_CALLS";
     field public static final java.lang.String BATTERY_STATS = "android.permission.BATTERY_STATS";
     field public static final java.lang.String BIND_ACCESSIBILITY_SERVICE = "android.permission.BIND_ACCESSIBILITY_SERVICE";
@@ -6494,7 +6493,7 @@
     field public static final java.lang.String EXTRA_PROVISIONING_WIFI_PROXY_PORT = "android.app.extra.PROVISIONING_WIFI_PROXY_PORT";
     field public static final java.lang.String EXTRA_PROVISIONING_WIFI_SECURITY_TYPE = "android.app.extra.PROVISIONING_WIFI_SECURITY_TYPE";
     field public static final java.lang.String EXTRA_PROVISIONING_WIFI_SSID = "android.app.extra.PROVISIONING_WIFI_SSID";
-    field public static final int FLAG_EVICT_CE_KEY = 1; // 0x1
+    field public static final int FLAG_EVICT_CREDENTIAL_ENCRYPTION_KEY = 1; // 0x1
     field public static final int FLAG_MANAGED_CAN_ACCESS_PARENT = 2; // 0x2
     field public static final int FLAG_PARENT_CAN_ACCESS_MANAGED = 1; // 0x1
     field public static final int KEYGUARD_DISABLE_FEATURES_ALL = 2147483647; // 0x7fffffff
@@ -6992,8 +6991,8 @@
 
   public final class StorageStats implements android.os.Parcelable {
     method public int describeContents();
+    method public long getAppBytes();
     method public long getCacheBytes();
-    method public long getCodeBytes();
     method public long getDataBytes();
     method public void writeToParcel(android.os.Parcel, int);
     field public static final android.os.Parcelable.Creator<android.app.usage.StorageStats> CREATOR;
@@ -8425,7 +8424,7 @@
     ctor public ClipData(android.content.ClipDescription, android.content.ClipData.Item);
     ctor public ClipData(android.content.ClipData);
     method public void addItem(android.content.ClipData.Item);
-    method public void addItem(android.content.ClipData.Item, android.content.ContentResolver);
+    method public void addItem(android.content.ContentResolver, android.content.ClipData.Item);
     method public int describeContents();
     method public android.content.ClipDescription getDescription();
     method public android.content.ClipData.Item getItemAt(int);
@@ -13762,6 +13761,7 @@
     method public void detachFromGLContext();
     method public long getTimestamp();
     method public void getTransformMatrix(float[]);
+    method public boolean isReleased();
     method public void release();
     method public void releaseTexImage();
     method public void setDefaultBufferSize(int, int);
@@ -14494,7 +14494,7 @@
     method public final void takePicture(android.hardware.Camera.ShutterCallback, android.hardware.Camera.PictureCallback, android.hardware.Camera.PictureCallback, android.hardware.Camera.PictureCallback);
     method public final void unlock();
     field public static final java.lang.String ACTION_NEW_PICTURE = "android.hardware.action.NEW_PICTURE";
-    field public static final deprecated java.lang.String ACTION_NEW_VIDEO = "android.hardware.action.NEW_VIDEO";
+    field public static final java.lang.String ACTION_NEW_VIDEO = "android.hardware.action.NEW_VIDEO";
     field public static final int CAMERA_ERROR_EVICTED = 2; // 0x2
     field public static final int CAMERA_ERROR_SERVER_DIED = 100; // 0x64
     field public static final int CAMERA_ERROR_UNKNOWN = 1; // 0x1
@@ -30676,7 +30676,6 @@
     method public android.util.SizeF getSizeF(java.lang.String);
     method public <T extends android.os.Parcelable> android.util.SparseArray<T> getSparseParcelableArray(java.lang.String);
     method public java.util.ArrayList<java.lang.String> getStringArrayList(java.lang.String);
-    method public java.util.UUID getUuid(java.lang.String);
     method public boolean hasFileDescriptors();
     method public void putAll(android.os.Bundle);
     method public void putBinder(java.lang.String, android.os.IBinder);
@@ -30701,7 +30700,6 @@
     method public void putSizeF(java.lang.String, android.util.SizeF);
     method public void putSparseParcelableArray(java.lang.String, android.util.SparseArray<? extends android.os.Parcelable>);
     method public void putStringArrayList(java.lang.String, java.util.ArrayList<java.lang.String>);
-    method public void putUuid(java.lang.String, java.util.UUID);
     method public void readFromParcel(android.os.Parcel);
     method public void setClassLoader(java.lang.ClassLoader);
     method public void writeToParcel(android.os.Parcel, int);
@@ -31231,7 +31229,6 @@
     method public final <T> void readTypedArray(T[], android.os.Parcelable.Creator<T>);
     method public final <T> void readTypedList(java.util.List<T>, android.os.Parcelable.Creator<T>);
     method public final <T> T readTypedObject(android.os.Parcelable.Creator<T>);
-    method public final java.util.UUID readUuid();
     method public final java.lang.Object readValue(java.lang.ClassLoader);
     method public final void recycle();
     method public final void setDataCapacity(int);
@@ -31277,7 +31274,6 @@
     method public final <T extends android.os.Parcelable> void writeTypedArray(T[], int);
     method public final <T extends android.os.Parcelable> void writeTypedList(java.util.List<T>);
     method public final <T extends android.os.Parcelable> void writeTypedObject(T, int);
-    method public final void writeUuid(java.util.UUID);
     method public final void writeValue(java.lang.Object);
     field public static final android.os.Parcelable.Creator<java.lang.String> STRING_CREATOR;
   }
@@ -31909,9 +31905,9 @@
   }
 
   public class StorageManager {
-    method public void allocateBytes(java.util.UUID, long, int) throws java.io.IOException;
-    method public void allocateBytes(java.io.FileDescriptor, long, int) throws java.io.IOException;
-    method public long getAllocatableBytes(java.util.UUID, int) throws java.io.IOException;
+    method public void allocateBytes(java.util.UUID, long) throws java.io.IOException;
+    method public void allocateBytes(java.io.FileDescriptor, long) throws java.io.IOException;
+    method public long getAllocatableBytes(java.util.UUID) throws java.io.IOException;
     method public long getCacheQuotaBytes(java.util.UUID) throws java.io.IOException;
     method public long getCacheSizeBytes(java.util.UUID) throws java.io.IOException;
     method public java.lang.String getMountedObbPath(java.lang.String);
@@ -31924,7 +31920,6 @@
     method public boolean isEncrypted(java.io.File);
     method public boolean isObbMounted(java.lang.String);
     method public boolean mountObb(java.lang.String, java.lang.String, android.os.storage.OnObbStateChangeListener);
-    method public android.os.ParcelFileDescriptor openProxyFileDescriptor(int, android.os.ProxyFileDescriptorCallback) throws java.io.IOException;
     method public android.os.ParcelFileDescriptor openProxyFileDescriptor(int, android.os.ProxyFileDescriptorCallback, android.os.Handler) throws java.io.IOException;
     method public void setCacheBehaviorGroup(java.io.File, boolean) throws java.io.IOException;
     method public void setCacheBehaviorTombstone(java.io.File, boolean) throws java.io.IOException;
@@ -31932,7 +31927,6 @@
     field public static final java.lang.String ACTION_MANAGE_STORAGE = "android.os.storage.action.MANAGE_STORAGE";
     field public static final java.lang.String EXTRA_REQUESTED_BYTES = "android.os.storage.extra.REQUESTED_BYTES";
     field public static final java.lang.String EXTRA_UUID = "android.os.storage.extra.UUID";
-    field public static final int FLAG_ALLOCATE_AGGRESSIVE = 1; // 0x1
     field public static final java.util.UUID UUID_DEFAULT;
   }
 
@@ -47778,7 +47772,7 @@
     method public void unregisterCallback(android.view.autofill.AutofillManager.AutofillCallback);
     field public static final java.lang.String EXTRA_ASSIST_STRUCTURE = "android.view.autofill.extra.ASSIST_STRUCTURE";
     field public static final java.lang.String EXTRA_AUTHENTICATION_RESULT = "android.view.autofill.extra.AUTHENTICATION_RESULT";
-    field public static final java.lang.String EXTRA_DATA_EXTRAS = "android.view.autofill.extra.DATA_EXTRAS";
+    field public static final java.lang.String EXTRA_CLIENT_STATE = "android.view.autofill.extra.EXTRA_CLIENT_STATE";
   }
 
   public static abstract class AutofillManager.AutofillCallback {
diff --git a/api/removed.txt b/api/removed.txt
index 13bccd6..8c81ef4 100644
--- a/api/removed.txt
+++ b/api/removed.txt
@@ -18,12 +18,17 @@
     method public deprecated java.lang.String getDeviceInitializerApp();
     method public deprecated android.content.ComponentName getDeviceInitializerComponent();
     method public void setAffiliationIds(android.content.ComponentName, java.util.List<java.lang.String>);
+    field public static final deprecated int FLAG_EVICT_CE_KEY = 1; // 0x1
   }
 
 }
 
 package android.app.usage {
 
+  public final class StorageStats implements android.os.Parcelable {
+    method public deprecated long getCodeBytes();
+  }
+
   public class StorageStatsManager {
     method public deprecated long getFreeBytes(java.lang.String) throws java.io.IOException;
     method public deprecated long getTotalBytes(java.lang.String) throws java.io.IOException;
@@ -38,6 +43,10 @@
 
 package android.content {
 
+  public class ClipData implements android.os.Parcelable {
+    method public deprecated void addItem(android.content.ClipData.Item, android.content.ContentResolver);
+  }
+
   public abstract class Context {
     method public abstract android.content.SharedPreferences getSharedPreferences(java.io.File, int);
     method public abstract java.io.File getSharedPreferencesPath(java.lang.String);
diff --git a/api/system-current.txt b/api/system-current.txt
index 1fe7288..1696bfa 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -6737,7 +6737,7 @@
     field public static final java.lang.String EXTRA_PROVISIONING_WIFI_PROXY_PORT = "android.app.extra.PROVISIONING_WIFI_PROXY_PORT";
     field public static final java.lang.String EXTRA_PROVISIONING_WIFI_SECURITY_TYPE = "android.app.extra.PROVISIONING_WIFI_SECURITY_TYPE";
     field public static final java.lang.String EXTRA_PROVISIONING_WIFI_SSID = "android.app.extra.PROVISIONING_WIFI_SSID";
-    field public static final int FLAG_EVICT_CE_KEY = 1; // 0x1
+    field public static final int FLAG_EVICT_CREDENTIAL_ENCRYPTION_KEY = 1; // 0x1
     field public static final int FLAG_MANAGED_CAN_ACCESS_PARENT = 2; // 0x2
     field public static final int FLAG_PARENT_CAN_ACCESS_MANAGED = 1; // 0x1
     field public static final int KEYGUARD_DISABLE_FEATURES_ALL = 2147483647; // 0x7fffffff
@@ -7460,8 +7460,8 @@
 
   public final class StorageStats implements android.os.Parcelable {
     method public int describeContents();
+    method public long getAppBytes();
     method public long getCacheBytes();
-    method public long getCodeBytes();
     method public long getDataBytes();
     method public void writeToParcel(android.os.Parcel, int);
     field public static final android.os.Parcelable.Creator<android.app.usage.StorageStats> CREATOR;
@@ -8924,7 +8924,7 @@
     ctor public ClipData(android.content.ClipDescription, android.content.ClipData.Item);
     ctor public ClipData(android.content.ClipData);
     method public void addItem(android.content.ClipData.Item);
-    method public void addItem(android.content.ClipData.Item, android.content.ContentResolver);
+    method public void addItem(android.content.ContentResolver, android.content.ClipData.Item);
     method public int describeContents();
     method public android.content.ClipDescription getDescription();
     method public android.content.ClipData.Item getItemAt(int);
@@ -14540,6 +14540,7 @@
     method public void detachFromGLContext();
     method public long getTimestamp();
     method public void getTransformMatrix(float[]);
+    method public boolean isReleased();
     method public void release();
     method public void releaseTexImage();
     method public void setDefaultBufferSize(int, int);
@@ -15272,7 +15273,7 @@
     method public final void takePicture(android.hardware.Camera.ShutterCallback, android.hardware.Camera.PictureCallback, android.hardware.Camera.PictureCallback, android.hardware.Camera.PictureCallback);
     method public final void unlock();
     field public static final java.lang.String ACTION_NEW_PICTURE = "android.hardware.action.NEW_PICTURE";
-    field public static final deprecated java.lang.String ACTION_NEW_VIDEO = "android.hardware.action.NEW_VIDEO";
+    field public static final java.lang.String ACTION_NEW_VIDEO = "android.hardware.action.NEW_VIDEO";
     field public static final int CAMERA_ERROR_EVICTED = 2; // 0x2
     field public static final int CAMERA_ERROR_SERVER_DIED = 100; // 0x64
     field public static final int CAMERA_ERROR_UNKNOWN = 1; // 0x1
@@ -27271,6 +27272,7 @@
     method public java.lang.Object getTaggedData(int);
     method public long getTimestamp();
     method public int getType();
+    method public int getUid();
     method public boolean isLongCounterBucket();
     method public boolean isSubsetOf(android.metrics.LogMaker);
     method public boolean isValidValue(java.lang.Object);
@@ -33437,7 +33439,6 @@
     method public android.util.SizeF getSizeF(java.lang.String);
     method public <T extends android.os.Parcelable> android.util.SparseArray<T> getSparseParcelableArray(java.lang.String);
     method public java.util.ArrayList<java.lang.String> getStringArrayList(java.lang.String);
-    method public java.util.UUID getUuid(java.lang.String);
     method public boolean hasFileDescriptors();
     method public void putAll(android.os.Bundle);
     method public void putBinder(java.lang.String, android.os.IBinder);
@@ -33462,7 +33463,6 @@
     method public void putSizeF(java.lang.String, android.util.SizeF);
     method public void putSparseParcelableArray(java.lang.String, android.util.SparseArray<? extends android.os.Parcelable>);
     method public void putStringArrayList(java.lang.String, java.util.ArrayList<java.lang.String>);
-    method public void putUuid(java.lang.String, java.util.UUID);
     method public void readFromParcel(android.os.Parcel);
     method public void setClassLoader(java.lang.ClassLoader);
     method public void writeToParcel(android.os.Parcel, int);
@@ -34024,7 +34024,6 @@
     method public final <T> void readTypedArray(T[], android.os.Parcelable.Creator<T>);
     method public final <T> void readTypedList(java.util.List<T>, android.os.Parcelable.Creator<T>);
     method public final <T> T readTypedObject(android.os.Parcelable.Creator<T>);
-    method public final java.util.UUID readUuid();
     method public final java.lang.Object readValue(java.lang.ClassLoader);
     method public final void recycle();
     method public final void setDataCapacity(int);
@@ -34070,7 +34069,6 @@
     method public final <T extends android.os.Parcelable> void writeTypedArray(T[], int);
     method public final <T extends android.os.Parcelable> void writeTypedList(java.util.List<T>);
     method public final <T extends android.os.Parcelable> void writeTypedObject(T, int);
-    method public final void writeUuid(java.util.UUID);
     method public final void writeValue(java.lang.Object);
     field public static final android.os.Parcelable.Creator<java.lang.String> STRING_CREATOR;
   }
@@ -34808,8 +34806,11 @@
   }
 
   public class StorageManager {
+    method public void allocateBytes(java.util.UUID, long) throws java.io.IOException;
     method public void allocateBytes(java.util.UUID, long, int) throws java.io.IOException;
+    method public void allocateBytes(java.io.FileDescriptor, long) throws java.io.IOException;
     method public void allocateBytes(java.io.FileDescriptor, long, int) throws java.io.IOException;
+    method public long getAllocatableBytes(java.util.UUID) throws java.io.IOException;
     method public long getAllocatableBytes(java.util.UUID, int) throws java.io.IOException;
     method public long getCacheQuotaBytes(java.util.UUID) throws java.io.IOException;
     method public long getCacheSizeBytes(java.util.UUID) throws java.io.IOException;
@@ -34823,7 +34824,6 @@
     method public boolean isEncrypted(java.io.File);
     method public boolean isObbMounted(java.lang.String);
     method public boolean mountObb(java.lang.String, java.lang.String, android.os.storage.OnObbStateChangeListener);
-    method public android.os.ParcelFileDescriptor openProxyFileDescriptor(int, android.os.ProxyFileDescriptorCallback) throws java.io.IOException;
     method public android.os.ParcelFileDescriptor openProxyFileDescriptor(int, android.os.ProxyFileDescriptorCallback, android.os.Handler) throws java.io.IOException;
     method public void setCacheBehaviorGroup(java.io.File, boolean) throws java.io.IOException;
     method public void setCacheBehaviorTombstone(java.io.File, boolean) throws java.io.IOException;
@@ -46743,6 +46743,7 @@
     method public int getTag();
     method public int getThreadId();
     method public long getTimeNanos();
+    method public int getUid();
   }
 
   public deprecated class EventLogTags {
@@ -51366,7 +51367,7 @@
     method public void unregisterCallback(android.view.autofill.AutofillManager.AutofillCallback);
     field public static final java.lang.String EXTRA_ASSIST_STRUCTURE = "android.view.autofill.extra.ASSIST_STRUCTURE";
     field public static final java.lang.String EXTRA_AUTHENTICATION_RESULT = "android.view.autofill.extra.AUTHENTICATION_RESULT";
-    field public static final java.lang.String EXTRA_DATA_EXTRAS = "android.view.autofill.extra.DATA_EXTRAS";
+    field public static final java.lang.String EXTRA_CLIENT_STATE = "android.view.autofill.extra.EXTRA_CLIENT_STATE";
   }
 
   public static abstract class AutofillManager.AutofillCallback {
diff --git a/api/system-removed.txt b/api/system-removed.txt
index 2ef8690..659236d 100644
--- a/api/system-removed.txt
+++ b/api/system-removed.txt
@@ -16,12 +16,17 @@
     method public deprecated android.os.UserHandle createAndInitializeUser(android.content.ComponentName, java.lang.String, java.lang.String, android.content.ComponentName, android.os.Bundle);
     method public deprecated android.os.UserHandle createUser(android.content.ComponentName, java.lang.String);
     method public void setAffiliationIds(android.content.ComponentName, java.util.List<java.lang.String>);
+    field public static final deprecated int FLAG_EVICT_CE_KEY = 1; // 0x1
   }
 
 }
 
 package android.app.usage {
 
+  public final class StorageStats implements android.os.Parcelable {
+    method public deprecated long getCodeBytes();
+  }
+
   public class StorageStatsManager {
     method public deprecated long getFreeBytes(java.lang.String) throws java.io.IOException;
     method public deprecated long getTotalBytes(java.lang.String) throws java.io.IOException;
@@ -36,6 +41,10 @@
 
 package android.content {
 
+  public class ClipData implements android.os.Parcelable {
+    method public deprecated void addItem(android.content.ClipData.Item, android.content.ContentResolver);
+  }
+
   public abstract class Context {
     method public abstract android.content.SharedPreferences getSharedPreferences(java.io.File, int);
     method public abstract java.io.File getSharedPreferencesPath(java.lang.String);
diff --git a/api/test-current.txt b/api/test-current.txt
index 68f69ad..a97f165 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -15,7 +15,6 @@
     field public static final java.lang.String ACCESS_WIFI_STATE = "android.permission.ACCESS_WIFI_STATE";
     field public static final java.lang.String ACCOUNT_MANAGER = "android.permission.ACCOUNT_MANAGER";
     field public static final java.lang.String ADD_VOICEMAIL = "com.android.voicemail.permission.ADD_VOICEMAIL";
-    field public static final java.lang.String ALLOCATE_AGGRESSIVE = "android.permission.ALLOCATE_AGGRESSIVE";
     field public static final java.lang.String ANSWER_PHONE_CALLS = "android.permission.ANSWER_PHONE_CALLS";
     field public static final java.lang.String BATTERY_STATS = "android.permission.BATTERY_STATS";
     field public static final java.lang.String BIND_ACCESSIBILITY_SERVICE = "android.permission.BIND_ACCESSIBILITY_SERVICE";
@@ -6524,7 +6523,7 @@
     field public static final java.lang.String EXTRA_PROVISIONING_WIFI_SECURITY_TYPE = "android.app.extra.PROVISIONING_WIFI_SECURITY_TYPE";
     field public static final java.lang.String EXTRA_PROVISIONING_WIFI_SSID = "android.app.extra.PROVISIONING_WIFI_SSID";
     field public static final java.lang.String EXTRA_RESTRICTION = "android.app.extra.RESTRICTION";
-    field public static final int FLAG_EVICT_CE_KEY = 1; // 0x1
+    field public static final int FLAG_EVICT_CREDENTIAL_ENCRYPTION_KEY = 1; // 0x1
     field public static final int FLAG_MANAGED_CAN_ACCESS_PARENT = 2; // 0x2
     field public static final int FLAG_PARENT_CAN_ACCESS_MANAGED = 1; // 0x1
     field public static final int KEYGUARD_DISABLE_FEATURES_ALL = 2147483647; // 0x7fffffff
@@ -7022,8 +7021,8 @@
 
   public final class StorageStats implements android.os.Parcelable {
     method public int describeContents();
+    method public long getAppBytes();
     method public long getCacheBytes();
-    method public long getCodeBytes();
     method public long getDataBytes();
     method public void writeToParcel(android.os.Parcel, int);
     field public static final android.os.Parcelable.Creator<android.app.usage.StorageStats> CREATOR;
@@ -8456,7 +8455,7 @@
     ctor public ClipData(android.content.ClipDescription, android.content.ClipData.Item);
     ctor public ClipData(android.content.ClipData);
     method public void addItem(android.content.ClipData.Item);
-    method public void addItem(android.content.ClipData.Item, android.content.ContentResolver);
+    method public void addItem(android.content.ContentResolver, android.content.ClipData.Item);
     method public int describeContents();
     method public android.content.ClipDescription getDescription();
     method public android.content.ClipData.Item getItemAt(int);
@@ -13804,6 +13803,7 @@
     method public void detachFromGLContext();
     method public long getTimestamp();
     method public void getTransformMatrix(float[]);
+    method public boolean isReleased();
     method public void release();
     method public void releaseTexImage();
     method public void setDefaultBufferSize(int, int);
@@ -14540,7 +14540,7 @@
     method public final void takePicture(android.hardware.Camera.ShutterCallback, android.hardware.Camera.PictureCallback, android.hardware.Camera.PictureCallback, android.hardware.Camera.PictureCallback);
     method public final void unlock();
     field public static final java.lang.String ACTION_NEW_PICTURE = "android.hardware.action.NEW_PICTURE";
-    field public static final deprecated java.lang.String ACTION_NEW_VIDEO = "android.hardware.action.NEW_VIDEO";
+    field public static final java.lang.String ACTION_NEW_VIDEO = "android.hardware.action.NEW_VIDEO";
     field public static final int CAMERA_ERROR_EVICTED = 2; // 0x2
     field public static final int CAMERA_ERROR_SERVER_DIED = 100; // 0x64
     field public static final int CAMERA_ERROR_UNKNOWN = 1; // 0x1
@@ -30784,7 +30784,6 @@
     method public android.util.SizeF getSizeF(java.lang.String);
     method public <T extends android.os.Parcelable> android.util.SparseArray<T> getSparseParcelableArray(java.lang.String);
     method public java.util.ArrayList<java.lang.String> getStringArrayList(java.lang.String);
-    method public java.util.UUID getUuid(java.lang.String);
     method public boolean hasFileDescriptors();
     method public void putAll(android.os.Bundle);
     method public void putBinder(java.lang.String, android.os.IBinder);
@@ -30809,7 +30808,6 @@
     method public void putSizeF(java.lang.String, android.util.SizeF);
     method public void putSparseParcelableArray(java.lang.String, android.util.SparseArray<? extends android.os.Parcelable>);
     method public void putStringArrayList(java.lang.String, java.util.ArrayList<java.lang.String>);
-    method public void putUuid(java.lang.String, java.util.UUID);
     method public void readFromParcel(android.os.Parcel);
     method public void setClassLoader(java.lang.ClassLoader);
     method public void writeToParcel(android.os.Parcel, int);
@@ -31360,7 +31358,6 @@
     method public final <T> void readTypedArray(T[], android.os.Parcelable.Creator<T>);
     method public final <T> void readTypedList(java.util.List<T>, android.os.Parcelable.Creator<T>);
     method public final <T> T readTypedObject(android.os.Parcelable.Creator<T>);
-    method public final java.util.UUID readUuid();
     method public final java.lang.Object readValue(java.lang.ClassLoader);
     method public final void recycle();
     method public final void setDataCapacity(int);
@@ -31406,7 +31403,6 @@
     method public final <T extends android.os.Parcelable> void writeTypedArray(T[], int);
     method public final <T extends android.os.Parcelable> void writeTypedList(java.util.List<T>);
     method public final <T extends android.os.Parcelable> void writeTypedObject(T, int);
-    method public final void writeUuid(java.util.UUID);
     method public final void writeValue(java.lang.Object);
     field public static final android.os.Parcelable.Creator<java.lang.String> STRING_CREATOR;
   }
@@ -32042,9 +32038,9 @@
   }
 
   public class StorageManager {
-    method public void allocateBytes(java.util.UUID, long, int) throws java.io.IOException;
-    method public void allocateBytes(java.io.FileDescriptor, long, int) throws java.io.IOException;
-    method public long getAllocatableBytes(java.util.UUID, int) throws java.io.IOException;
+    method public void allocateBytes(java.util.UUID, long) throws java.io.IOException;
+    method public void allocateBytes(java.io.FileDescriptor, long) throws java.io.IOException;
+    method public long getAllocatableBytes(java.util.UUID) throws java.io.IOException;
     method public long getCacheQuotaBytes(java.util.UUID) throws java.io.IOException;
     method public long getCacheSizeBytes(java.util.UUID) throws java.io.IOException;
     method public java.lang.String getMountedObbPath(java.lang.String);
@@ -32057,7 +32053,6 @@
     method public boolean isEncrypted(java.io.File);
     method public boolean isObbMounted(java.lang.String);
     method public boolean mountObb(java.lang.String, java.lang.String, android.os.storage.OnObbStateChangeListener);
-    method public android.os.ParcelFileDescriptor openProxyFileDescriptor(int, android.os.ProxyFileDescriptorCallback) throws java.io.IOException;
     method public android.os.ParcelFileDescriptor openProxyFileDescriptor(int, android.os.ProxyFileDescriptorCallback, android.os.Handler) throws java.io.IOException;
     method public void setCacheBehaviorGroup(java.io.File, boolean) throws java.io.IOException;
     method public void setCacheBehaviorTombstone(java.io.File, boolean) throws java.io.IOException;
@@ -32065,7 +32060,6 @@
     field public static final java.lang.String ACTION_MANAGE_STORAGE = "android.os.storage.action.MANAGE_STORAGE";
     field public static final java.lang.String EXTRA_REQUESTED_BYTES = "android.os.storage.extra.REQUESTED_BYTES";
     field public static final java.lang.String EXTRA_UUID = "android.os.storage.extra.UUID";
-    field public static final int FLAG_ALLOCATE_AGGRESSIVE = 1; // 0x1
     field public static final java.util.UUID UUID_DEFAULT;
   }
 
@@ -48157,7 +48151,7 @@
     method public void unregisterCallback(android.view.autofill.AutofillManager.AutofillCallback);
     field public static final java.lang.String EXTRA_ASSIST_STRUCTURE = "android.view.autofill.extra.ASSIST_STRUCTURE";
     field public static final java.lang.String EXTRA_AUTHENTICATION_RESULT = "android.view.autofill.extra.AUTHENTICATION_RESULT";
-    field public static final java.lang.String EXTRA_DATA_EXTRAS = "android.view.autofill.extra.DATA_EXTRAS";
+    field public static final java.lang.String EXTRA_CLIENT_STATE = "android.view.autofill.extra.EXTRA_CLIENT_STATE";
   }
 
   public static abstract class AutofillManager.AutofillCallback {
diff --git a/api/test-removed.txt b/api/test-removed.txt
index 13bccd6..8c81ef4 100644
--- a/api/test-removed.txt
+++ b/api/test-removed.txt
@@ -18,12 +18,17 @@
     method public deprecated java.lang.String getDeviceInitializerApp();
     method public deprecated android.content.ComponentName getDeviceInitializerComponent();
     method public void setAffiliationIds(android.content.ComponentName, java.util.List<java.lang.String>);
+    field public static final deprecated int FLAG_EVICT_CE_KEY = 1; // 0x1
   }
 
 }
 
 package android.app.usage {
 
+  public final class StorageStats implements android.os.Parcelable {
+    method public deprecated long getCodeBytes();
+  }
+
   public class StorageStatsManager {
     method public deprecated long getFreeBytes(java.lang.String) throws java.io.IOException;
     method public deprecated long getTotalBytes(java.lang.String) throws java.io.IOException;
@@ -38,6 +43,10 @@
 
 package android.content {
 
+  public class ClipData implements android.os.Parcelable {
+    method public deprecated void addItem(android.content.ClipData.Item, android.content.ContentResolver);
+  }
+
   public abstract class Context {
     method public abstract android.content.SharedPreferences getSharedPreferences(java.io.File, int);
     method public abstract java.io.File getSharedPreferencesPath(java.lang.String);
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 5683619..28fe319 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -1285,7 +1285,7 @@
          * action is sent. These remote inputs are guaranteed to return true on a call to
          * {@link RemoteInput#isDataOnly}.
          *
-         * May return null if no data-only remote inputs were added.
+         * Returns null if there are no data-only remote inputs.
          *
          * This method exists so that legacy RemoteInput collectors that pre-date the addition
          * of non-textual RemoteInputs do not access these remote inputs.
diff --git a/core/java/android/app/RemoteInput.java b/core/java/android/app/RemoteInput.java
index d1dc859..8ab19c0 100644
--- a/core/java/android/app/RemoteInput.java
+++ b/core/java/android/app/RemoteInput.java
@@ -118,6 +118,11 @@
         return mChoices;
     }
 
+    /**
+     * Get possible non-textual inputs that are accepted.
+     * This can be {@code null} if the input does not accept non-textual values.
+     * See {@link Builder#setAllowDataType}.
+     */
     public Set<String> getAllowedDataTypes() {
         return mAllowedDataTypes;
     }
@@ -202,7 +207,9 @@
         }
 
         /**
-         * Specifies whether the user can provide arbitrary values.
+         * Specifies whether the user can provide arbitrary values. This allows an input
+         * to accept non-textual values. Examples of usage are an input that wants audio
+         * or an image.
          *
          * @param mimeType A mime type that results are allowed to come in.
          *         Be aware that text results (see {@link #setAllowFreeFormInput}
@@ -374,7 +381,12 @@
     }
 
     /**
-     * Same as {@link #addResultsToIntent} but for setting data results.
+     * Same as {@link #addResultsToIntent} but for setting data results. This is used
+     * for inputs that accept non-textual results (see {@link Builder#setAllowDataType}).
+     * Only one result can be provided for every mime type accepted by the RemoteInput.
+     * If multiple inputs of the same mime type are expected then multiple RemoteInputs
+     * should be used.
+     *
      * @param remoteInput The remote input for which results are being provided
      * @param intent The intent to add remote input results to. The {@link ClipData}
      *               field of the intent will be modified to contain the results.
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index f5df67b..8fcabce 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -3030,17 +3030,24 @@
      * keyring. The user's credential will need to be entered again in order to derive the
      * credential encryption key that will be stored back in the keyring for future use.
      * <p>
-     * This flag can only be used by a profile owner when locking a managed profile on an FBE
-     * device.
+     * This flag can only be used by a profile owner when locking a managed profile when
+     * {@link #getStorageEncryptionStatus} returns {@link #ENCRYPTION_STATUS_ACTIVE_PER_USER}.
      * <p>
      * In order to secure user data, the user will be stopped and restarted so apps should wait
      * until they are next run to perform further actions.
      */
+    public static final int FLAG_EVICT_CREDENTIAL_ENCRYPTION_KEY = 1;
+
+    /**
+     * Instead use {@link #FLAG_EVICT_CREDENTIAL_ENCRYPTION_KEY}.
+     * @removed
+     */
+    @Deprecated
     public static final int FLAG_EVICT_CE_KEY = 1;
 
     /** @hide */
     @Retention(RetentionPolicy.SOURCE)
-    @IntDef(flag=true, value={FLAG_EVICT_CE_KEY})
+    @IntDef(flag=true, value={FLAG_EVICT_CREDENTIAL_ENCRYPTION_KEY})
     public @interface LockNowFlag {}
 
     /**
@@ -3072,15 +3079,17 @@
      * This method can be called on the {@link DevicePolicyManager} instance returned by
      * {@link #getParentProfileInstance(ComponentName)} in order to lock the parent profile.
      *
-     * @param flags May be 0 or {@link #FLAG_EVICT_CE_KEY}.
+     * @param flags May be 0 or {@link #FLAG_EVICT_CREDENTIAL_ENCRYPTION_KEY}.
      * @throws SecurityException if the calling application does not own an active administrator
      *             that uses {@link DeviceAdminInfo#USES_POLICY_FORCE_LOCK} or the
-     *             {@link #FLAG_EVICT_CE_KEY} flag is passed by an application that is not a profile
+     *             {@link #FLAG_EVICT_CREDENTIAL_ENCRYPTION_KEY} flag is passed by an application
+     *             that is not a profile
      *             owner of a managed profile.
-     * @throws IllegalArgumentException if the {@link #FLAG_EVICT_CE_KEY} flag is passed when
-     *             locking the parent profile.
-     * @throws UnsupportedOperationException if the {@link #FLAG_EVICT_CE_KEY} flag is passed on a
-     *             non-FBE device.
+     * @throws IllegalArgumentException if the {@link #FLAG_EVICT_CREDENTIAL_ENCRYPTION_KEY} flag is
+     *             passed when locking the parent profile.
+     * @throws UnsupportedOperationException if the {@link #FLAG_EVICT_CREDENTIAL_ENCRYPTION_KEY}
+     *             flag is passed when {@link #getStorageEncryptionStatus} does not return
+     *             {@link #ENCRYPTION_STATUS_ACTIVE_PER_USER}.
      */
     public void lockNow(@LockNowFlag int flags) {
         if (mService != null) {
diff --git a/core/java/android/app/usage/ExternalStorageStats.java b/core/java/android/app/usage/ExternalStorageStats.java
index 10c9b5f..83ac779e 100644
--- a/core/java/android/app/usage/ExternalStorageStats.java
+++ b/core/java/android/app/usage/ExternalStorageStats.java
@@ -16,6 +16,7 @@
 
 package android.app.usage;
 
+import android.annotation.BytesLong;
 import android.os.Parcel;
 import android.os.Parcelable;
 import android.os.UserHandle;
@@ -37,7 +38,7 @@
      * Return the total bytes used by all files in the shared/external storage
      * hosted on this volume.
      */
-    public long getTotalBytes() {
+    public @BytesLong long getTotalBytes() {
         return totalBytes;
     }
 
@@ -45,7 +46,7 @@
      * Return the total bytes used by audio files in the shared/external storage
      * hosted on this volume.
      */
-    public long getAudioBytes() {
+    public @BytesLong long getAudioBytes() {
         return audioBytes;
     }
 
@@ -53,7 +54,7 @@
      * Return the total bytes used by video files in the shared/external storage
      * hosted on this volume.
      */
-    public long getVideoBytes() {
+    public @BytesLong long getVideoBytes() {
         return videoBytes;
     }
 
@@ -61,7 +62,7 @@
      * Return the total bytes used by image files in the shared/external storage
      * hosted on this volume.
      */
-    public long getImageBytes() {
+    public @BytesLong long getImageBytes() {
         return imageBytes;
     }
 
@@ -72,7 +73,7 @@
      * This data is already accounted against individual apps as returned
      * through {@link StorageStats}.
      */
-    public long getAppBytes() {
+    public @BytesLong long getAppBytes() {
         return appBytes;
     }
 
diff --git a/core/java/android/app/usage/StorageStats.java b/core/java/android/app/usage/StorageStats.java
index 26c702c0..3a27751 100644
--- a/core/java/android/app/usage/StorageStats.java
+++ b/core/java/android/app/usage/StorageStats.java
@@ -16,6 +16,7 @@
 
 package android.app.usage;
 
+import android.annotation.BytesLong;
 import android.content.Context;
 import android.os.Parcel;
 import android.os.Parcelable;
@@ -33,18 +34,24 @@
     /** {@hide} */ public long cacheBytes;
 
     /**
-     * Return the size of all code. This includes {@code APK} files and
-     * optimized compiler output.
+     * Return the size of app. This includes {@code APK} files, optimized
+     * compiler output, and unpacked native libraries.
      * <p>
      * If the primary external/shared storage is hosted on this storage device,
      * then this includes files stored under {@link Context#getObbDir()}.
      * <p>
      * Code is shared between all users on a multiuser device.
      */
-    public long getCodeBytes() {
+    public @BytesLong long getAppBytes() {
         return codeBytes;
     }
 
+    /** @removed */
+    @Deprecated
+    public long getCodeBytes() {
+        return getAppBytes();
+    }
+
     /**
      * Return the size of all data. This includes files stored under
      * {@link Context#getDataDir()}, {@link Context#getCacheDir()},
@@ -58,7 +65,7 @@
      * <p>
      * Data is isolated for each user on a multiuser device.
      */
-    public long getDataBytes() {
+    public @BytesLong long getDataBytes() {
         return dataBytes;
     }
 
@@ -72,7 +79,7 @@
      * <p>
      * Cached data is isolated for each user on a multiuser device.
      */
-    public long getCacheBytes() {
+    public @BytesLong long getCacheBytes() {
         return cacheBytes;
     }
 
diff --git a/core/java/android/app/usage/StorageStatsManager.java b/core/java/android/app/usage/StorageStatsManager.java
index 5497d57..d9d958c 100644
--- a/core/java/android/app/usage/StorageStatsManager.java
+++ b/core/java/android/app/usage/StorageStatsManager.java
@@ -18,6 +18,7 @@
 
 import static android.os.storage.StorageManager.convert;
 
+import android.annotation.BytesLong;
 import android.annotation.NonNull;
 import android.annotation.TestApi;
 import android.annotation.WorkerThread;
@@ -37,13 +38,16 @@
 import java.util.UUID;
 
 /**
- * Provides access to detailed storage statistics.
+ * Access to detailed storage statistics. This provides a summary of how apps,
+ * users, and external/shared storage is utilizing disk space.
  * <p class="note">
- * Note: this API requires the permission
- * {@code android.permission.PACKAGE_USAGE_STATS}, which is a system-level
- * permission that will not be granted to normal apps. However, declaring the
- * permission expresses your intention to use this API and an end user can then
- * choose to grant this permission through the Settings application.
+ * Note: no permissions are required when calling these APIs for your own
+ * package or UID. However, requesting details for any other package requires
+ * the {@code android.Manifest.permission#PACKAGE_USAGE_STATS} permission, which
+ * is a system-level permission that will not be granted to normal apps.
+ * Declaring that permission expresses your intention to use this API and an end
+ * user can then choose to grant this permission through the Settings
+ * application.
  * </p>
  */
 public class StorageStatsManager {
@@ -73,19 +77,22 @@
     }
 
     /**
-     * Return the total size of the underlying media that is hosting this
-     * storage volume.
+     * Return the total size of the underlying physical media that is hosting
+     * this storage volume.
      * <p>
-     * To reduce end user confusion, this value matches the total storage size
-     * advertised in a retail environment, which is typically larger than the
-     * actual usable partition space.
+     * This value is best suited for visual display to end users, since it's
+     * designed to reflect the total storage size advertised in a retail
+     * environment.
+     * <p>
+     * Apps making logical decisions about disk space should always use
+     * {@link File#getTotalSpace()} instead of this value.
      *
      * @param storageUuid the UUID of the storage volume you're interested in,
      *            such as {@link StorageManager#UUID_DEFAULT}.
      * @throws IOException when the storage device isn't present.
      */
     @WorkerThread
-    public long getTotalBytes(@NonNull UUID storageUuid) throws IOException {
+    public @BytesLong long getTotalBytes(@NonNull UUID storageUuid) throws IOException {
         try {
             return mService.getTotalBytes(convert(storageUuid), mContext.getOpPackageName());
         } catch (ParcelableException e) {
@@ -105,19 +112,20 @@
     /**
      * Return the free space on the requested storage volume.
      * <p>
-     * The free space is equivalent to {@link File#getUsableSpace()} plus the
-     * size of any cached data that can be automatically deleted by the system
-     * as additional space is needed.
+     * This value is best suited for visual display to end users, since it's
+     * designed to reflect both unused space <em>and</em> and cached space that
+     * could be reclaimed by the system.
      * <p>
-     * This method may take several seconds to calculate the requested values,
-     * so it should only be called from a worker thread.
+     * Apps making logical decisions about disk space should always use
+     * {@link StorageManager#getAllocatableBytes(UUID, int)} instead of this
+     * value.
      *
      * @param storageUuid the UUID of the storage volume you're interested in,
      *            such as {@link StorageManager#UUID_DEFAULT}.
      * @throws IOException when the storage device isn't present.
      */
     @WorkerThread
-    public long getFreeBytes(@NonNull UUID storageUuid) throws IOException {
+    public @BytesLong long getFreeBytes(@NonNull UUID storageUuid) throws IOException {
         try {
             return mService.getFreeBytes(convert(storageUuid), mContext.getOpPackageName());
         } catch (ParcelableException e) {
@@ -137,9 +145,15 @@
     /**
      * Return storage statistics for a specific package on the requested storage
      * volume.
-     * <p>
-     * This method may take several seconds to calculate the requested values,
-     * so it should only be called from a worker thread.
+     * <p class="note">
+     * Note: no permissions are required when calling this API for your own
+     * package. However, requesting details for any other package requires the
+     * {@code android.Manifest.permission#PACKAGE_USAGE_STATS} permission, which
+     * is a system-level permission that will not be granted to normal apps.
+     * Declaring that permission expresses your intention to use this API and an
+     * end user can then choose to grant this permission through the Settings
+     * application.
+     * </p>
      * <p class="note">
      * Note: if the requested package uses the {@code android:sharedUserId}
      * manifest feature, this call will be forced into a slower manual
@@ -158,8 +172,9 @@
      * @see PackageInfo#packageName
      */
     @WorkerThread
-    public @NonNull StorageStats queryStatsForPackage(@NonNull UUID storageUuid, String packageName,
-            UserHandle user) throws PackageManager.NameNotFoundException, IOException {
+    public @NonNull StorageStats queryStatsForPackage(@NonNull UUID storageUuid,
+            @NonNull String packageName, @NonNull UserHandle user)
+            throws PackageManager.NameNotFoundException, IOException {
         try {
             return mService.queryStatsForPackage(convert(storageUuid), packageName,
                     user.getIdentifier(), mContext.getOpPackageName());
@@ -182,9 +197,15 @@
     /**
      * Return storage statistics for a specific UID on the requested storage
      * volume.
-     * <p>
-     * This method may take several seconds to calculate the requested values,
-     * so it should only be called from a worker thread.
+     * <p class="note">
+     * Note: no permissions are required when calling this API for your own UID.
+     * However, requesting details for any other UID requires the
+     * {@code android.Manifest.permission#PACKAGE_USAGE_STATS} permission, which
+     * is a system-level permission that will not be granted to normal apps.
+     * Declaring that permission expresses your intention to use this API and an
+     * end user can then choose to grant this permission through the Settings
+     * application.
+     * </p>
      *
      * @param storageUuid the UUID of the storage volume you're interested in,
      *            such as {@link StorageManager#UUID_DEFAULT}.
@@ -194,7 +215,8 @@
      * @see ApplicationInfo#uid
      */
     @WorkerThread
-    public StorageStats queryStatsForUid(@NonNull UUID storageUuid, int uid) throws IOException {
+    public @NonNull StorageStats queryStatsForUid(@NonNull UUID storageUuid, int uid)
+            throws IOException {
         try {
             return mService.queryStatsForUid(convert(storageUuid), uid,
                     mContext.getOpPackageName());
@@ -215,9 +237,14 @@
     /**
      * Return storage statistics for a specific {@link UserHandle} on the
      * requested storage volume.
-     * <p>
-     * This method may take several seconds to calculate the requested values,
-     * so it should only be called from a worker thread.
+     * <p class="note">
+     * Note: this API requires the
+     * {@code android.Manifest.permission#PACKAGE_USAGE_STATS} permission, which
+     * is a system-level permission that will not be granted to normal apps.
+     * Declaring that permission expresses your intention to use this API and an
+     * end user can then choose to grant this permission through the Settings
+     * application.
+     * </p>
      *
      * @param storageUuid the UUID of the storage volume you're interested in,
      *            such as {@link StorageManager#UUID_DEFAULT}.
@@ -226,8 +253,8 @@
      * @see android.os.Process#myUserHandle()
      */
     @WorkerThread
-    public StorageStats queryStatsForUser(@NonNull UUID storageUuid, UserHandle user)
-            throws IOException {
+    public @NonNull StorageStats queryStatsForUser(@NonNull UUID storageUuid,
+            @NonNull UserHandle user) throws IOException {
         try {
             return mService.queryStatsForUser(convert(storageUuid), user.getIdentifier(),
                     mContext.getOpPackageName());
@@ -248,9 +275,14 @@
     /**
      * Return shared/external storage statistics for a specific
      * {@link UserHandle} on the requested storage volume.
-     * <p>
-     * This method may take several seconds to calculate the requested values,
-     * so it should only be called from a worker thread.
+     * <p class="note">
+     * Note: this API requires the
+     * {@code android.Manifest.permission#PACKAGE_USAGE_STATS} permission, which
+     * is a system-level permission that will not be granted to normal apps.
+     * Declaring that permission expresses your intention to use this API and an
+     * end user can then choose to grant this permission through the Settings
+     * application.
+     * </p>
      *
      * @param storageUuid the UUID of the storage volume you're interested in,
      *            such as {@link StorageManager#UUID_DEFAULT}.
@@ -258,8 +290,8 @@
      * @see android.os.Process#myUserHandle()
      */
     @WorkerThread
-    public ExternalStorageStats queryExternalStatsForUser(@NonNull UUID storageUuid,
-            UserHandle user) throws IOException {
+    public @NonNull ExternalStorageStats queryExternalStatsForUser(@NonNull UUID storageUuid,
+            @NonNull UserHandle user) throws IOException {
         try {
             return mService.queryExternalStatsForUser(convert(storageUuid), user.getIdentifier(),
                     mContext.getOpPackageName());
diff --git a/core/java/android/content/ClipData.java b/core/java/android/content/ClipData.java
index 6703bd4..5bc1f18 100644
--- a/core/java/android/content/ClipData.java
+++ b/core/java/android/content/ClipData.java
@@ -846,7 +846,7 @@
      * Add a new Item to the overall ClipData container.
      * <p> This method will <em>not</em> update the list of available MIME types in the
      * {@link ClipDescription}. It should be used only when adding items which do not add new
-     * MIME types to this clip. If this is not the case, use {@link #addItem(Item, ContentResolver)}
+     * MIME types to this clip. If this is not the case, use {@link #addItem(ContentResolver, Item)}
      * or call {@link #ClipData(CharSequence, String[], Item)} with a complete list of MIME types.
      * @param item Item to be added.
      */
@@ -857,15 +857,21 @@
         mItems.add(item);
     }
 
+    /** @removed use #addItem(ContentResolver, Item) instead */
+    @Deprecated
+    public void addItem(Item item, ContentResolver resolver) {
+        addItem(resolver, item);
+    }
+
     /**
      * Add a new Item to the overall ClipData container.
      * <p> Unlike {@link #addItem(Item)}, this method will update the list of available MIME types
      * in the {@link ClipDescription}.
-     * @param item Item to be added.
      * @param resolver ContentResolver used to get information about the URI possibly contained in
      * the item.
+     * @param item Item to be added.
      */
-    public void addItem(Item item, ContentResolver resolver) {
+    public void addItem(ContentResolver resolver, Item item) {
         addItem(item);
 
         if (item.getHtmlText() != null) {
diff --git a/core/java/android/content/pm/ApplicationInfo.java b/core/java/android/content/pm/ApplicationInfo.java
index 6c5d26a..06f7916 100644
--- a/core/java/android/content/pm/ApplicationInfo.java
+++ b/core/java/android/content/pm/ApplicationInfo.java
@@ -1205,7 +1205,8 @@
         dest.writeInt(largestWidthLimitDp);
         if (storageUuid != null) {
             dest.writeInt(1);
-            dest.writeUuid(storageUuid);
+            dest.writeLong(storageUuid.getMostSignificantBits());
+            dest.writeLong(storageUuid.getLeastSignificantBits());
         } else {
             dest.writeInt(0);
         }
@@ -1271,7 +1272,7 @@
         compatibleWidthLimitDp = source.readInt();
         largestWidthLimitDp = source.readInt();
         if (source.readInt() != 0) {
-            storageUuid = source.readUuid();
+            storageUuid = new UUID(source.readLong(), source.readLong());
             volumeUuid = StorageManager.convert(storageUuid);
         }
         scanSourceDir = source.readString();
diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java
index 061346c..aa35a66 100644
--- a/core/java/android/hardware/Camera.java
+++ b/core/java/android/hardware/Camera.java
@@ -189,7 +189,7 @@
      *
      * <p>In {@link android.os.Build.VERSION_CODES#O Android O} this broadcast has been brought
      * back, but only for <em>registered</em> receivers.  Apps that are actively running can
-     * against listen to the broadcast if they want an immediate clear signal about a picture
+     * again listen to the broadcast if they want an immediate clear signal about a picture
      * being taken, however anything doing heavy work (or needing to be launched) as a result of
      * this should still use JobScheduler.</p>
      */
@@ -208,12 +208,11 @@
      *
      * <p>In {@link android.os.Build.VERSION_CODES#O Android O} this broadcast has been brought
      * back, but only for <em>registered</em> receivers.  Apps that are actively running can
-     * against listen to the broadcast if they want an immediate clear signal about a video
+     * again listen to the broadcast if they want an immediate clear signal about a video
      * being taken, however anything doing heavy work (or needing to be launched) as a result of
      * this should still use JobScheduler.</p>
      */
     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
-    @Deprecated
     public static final String ACTION_NEW_VIDEO = "android.hardware.action.NEW_VIDEO";
 
     /**
diff --git a/core/java/android/metrics/LogMaker.java b/core/java/android/metrics/LogMaker.java
index 3c6baa7..2bb43bd 100644
--- a/core/java/android/metrics/LogMaker.java
+++ b/core/java/android/metrics/LogMaker.java
@@ -170,6 +170,27 @@
     }
 
     /**
+     * This will be set by the system when the log is persisted.
+     * Client-supplied values will be ignored.
+     *
+     * @param uid to replace the existing setting.
+     * @hide
+     */
+    public LogMaker setUid(int uid) {
+        entries.put(MetricsEvent.RESERVED_FOR_LOGBUILDER_UID, uid);
+        return this;
+    }
+
+    /**
+     * Remove the UID property.
+     * @hide
+     */
+    public LogMaker clearUid() {
+        entries.remove(MetricsEvent.RESERVED_FOR_LOGBUILDER_UID);
+        return this;
+    }
+
+    /**
      * The name of the counter or histogram.
      * Only useful for counter or histogram category objects.
      * @param name to replace the existing setting.
@@ -319,6 +340,16 @@
         }
     }
 
+    /** @return the UID of the log, or -1. */
+    public int getUid() {
+        Object obj = entries.get(MetricsEvent.RESERVED_FOR_LOGBUILDER_UID);
+        if (obj instanceof Integer) {
+            return (Integer) obj;
+        } else {
+            return -1;
+        }
+    }
+
     /** @return the name of the counter, or null. */
     public String getCounterName() {
         Object obj = entries.get(MetricsEvent.RESERVED_FOR_LOGBUILDER_NAME);
diff --git a/core/java/android/metrics/MetricsReader.java b/core/java/android/metrics/MetricsReader.java
index 5be977a..5f356ca 100644
--- a/core/java/android/metrics/MetricsReader.java
+++ b/core/java/android/metrics/MetricsReader.java
@@ -93,6 +93,7 @@
             }
             final LogMaker log = new LogMaker(objects)
                     .setTimestamp(eventTimestampMs)
+                    .setUid(event.getUid())
                     .setProcessId(event.getProcessId());
             if (log.getCategory() == MetricsEvent.METRICS_CHECKPOINT) {
                 if (log.getSubtype() == mCheckpointTag) {
@@ -155,11 +156,13 @@
     public static class Event {
         long mTimeMillis;
         int mPid;
+        int mUid;
         Object mData;
 
-        public Event(long timeMillis, int pid, Object data) {
+        public Event(long timeMillis, int pid, int uid, Object data) {
             mTimeMillis = timeMillis;
             mPid = pid;
+            mUid = uid;
             mData = data;
         }
 
@@ -167,6 +170,7 @@
             mTimeMillis = TimeUnit.MILLISECONDS.convert(
                     nativeEvent.getTimeNanos(), TimeUnit.NANOSECONDS);
             mPid = nativeEvent.getProcessId();
+            mUid = nativeEvent.getUid();
             mData = nativeEvent.getData();
         }
 
@@ -178,6 +182,10 @@
             return mPid;
         }
 
+        public int getUid() {
+            return mUid;
+        }
+
         public Object getData() {
             return mData;
         }
diff --git a/core/java/android/os/Bundle.java b/core/java/android/os/Bundle.java
index 167c46d..9b5ff29 100644
--- a/core/java/android/os/Bundle.java
+++ b/core/java/android/os/Bundle.java
@@ -25,7 +25,6 @@
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.UUID;
 
 /**
  * A mapping from String keys to various {@link Parcelable} values.
@@ -477,18 +476,6 @@
     }
 
     /**
-     * Inserts a UUID value into the mapping of this Bundle, replacing
-     * any existing value for the given key.  Either key or value may be null.
-     *
-     * @param key a String, or null
-     * @param value a UUID object, or null
-     */
-    public void putUuid(@Nullable String key, @Nullable UUID value) {
-        unparcel();
-        mMap.put(key, value);
-    }
-
-    /**
      * Inserts an array of Parcelable values into the mapping of this Bundle,
      * replacing any existing value for the given key.  Either key or value may
      * be null.
@@ -871,26 +858,6 @@
      * value is explicitly associated with the key.
      *
      * @param key a String, or null
-     * @return a UUID value, or null
-     */
-    @Nullable
-    public UUID getUuid(@Nullable String key) {
-        unparcel();
-        final Object o = mMap.get(key);
-        try {
-            return (UUID) o;
-        } catch (ClassCastException e) {
-            typeWarning(key, o, "UUID", e);
-            return null;
-        }
-    }
-
-    /**
-     * Returns the value associated with the given key, or null if
-     * no mapping of the desired type exists for the given key or a null
-     * value is explicitly associated with the key.
-     *
-     * @param key a String, or null
      * @return a Bundle value, or null
      */
     @Nullable
diff --git a/core/java/android/os/Parcel.java b/core/java/android/os/Parcel.java
index c1647c7..28bdacf 100644
--- a/core/java/android/os/Parcel.java
+++ b/core/java/android/os/Parcel.java
@@ -50,7 +50,6 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.UUID;
 
 /**
  * Container for a message (data and object references) that can
@@ -242,7 +241,6 @@
     private static final int VAL_SIZE = 26;
     private static final int VAL_SIZEF = 27;
     private static final int VAL_DOUBLEARRAY = 28;
-    private static final int VAL_UUID = 29;
 
     // The initial int32 in a Binder call's reply Parcel header:
     // Keep these in sync with libbinder's binder/Status.h.
@@ -831,15 +829,6 @@
     }
 
     /**
-     * Flatten a UUID into the parcel at the current dataPosition(),
-     * growing dataCapacity() if needed.
-     */
-    public final void writeUuid(UUID val) {
-        writeLong(val.getMostSignificantBits());
-        writeLong(val.getLeastSignificantBits());
-    }
-
-    /**
      * Flatten a List into the parcel at the current dataPosition(), growing
      * dataCapacity() if needed.  The List values are written using
      * {@link #writeValue} and must follow the specification there.
@@ -1687,9 +1676,6 @@
         } else if (v instanceof double[]) {
             writeInt(VAL_DOUBLEARRAY);
             writeDoubleArray((double[]) v);
-        } else if (v instanceof UUID) {
-            writeInt(VAL_UUID);
-            writeUuid((UUID) v);
         } else {
             Class<?> clazz = v.getClass();
             if (clazz.isArray() && clazz.getComponentType() == Object.class) {
@@ -2194,13 +2180,6 @@
     }
 
     /**
-     * Read a UUID from the parcel at the current dataPosition().
-     */
-    public final UUID readUuid() {
-        return new UUID(readLong(), readLong());
-    }
-
-    /**
      * Read and return a byte[] object from the parcel.
      */
     public final byte[] createByteArray() {
@@ -2750,9 +2729,6 @@
         case VAL_DOUBLEARRAY:
             return createDoubleArray();
 
-        case VAL_UUID:
-            return readUuid();
-
         default:
             int off = dataPosition() - 4;
             throw new RuntimeException(
diff --git a/core/java/android/os/storage/StorageManager.java b/core/java/android/os/storage/StorageManager.java
index baa29b0..bd43d6a 100644
--- a/core/java/android/os/storage/StorageManager.java
+++ b/core/java/android/os/storage/StorageManager.java
@@ -19,14 +19,18 @@
 import static android.net.TrafficStats.GB_IN_BYTES;
 import static android.net.TrafficStats.MB_IN_BYTES;
 
+import android.annotation.BytesLong;
 import android.annotation.IntDef;
 import android.annotation.NonNull;
 import android.annotation.Nullable;
 import android.annotation.RequiresPermission;
 import android.annotation.SdkConstant;
+import android.annotation.SystemApi;
+import android.annotation.WorkerThread;
 import android.app.ActivityThread;
 import android.content.ContentResolver;
 import android.content.Context;
+import android.content.Intent;
 import android.content.pm.ApplicationInfo;
 import android.content.pm.IPackageMoveObserver;
 import android.content.pm.PackageManager;
@@ -135,6 +139,7 @@
      * thus it cannot be used to uniquely identify a particular physical device.
      *
      * @see #getUuidForPath(File)
+     * @see ApplicationInfo#storageUuid
      */
     public static final UUID UUID_DEFAULT = UUID
             .fromString("41217664-9172-527a-b3d5-edabb50a7d69");
@@ -166,6 +171,7 @@
      * @see #ACTION_MANAGE_STORAGE
      * @see #UUID_DEFAULT
      * @see #getUuidForPath(File)
+     * @see Intent#putExtra(String, java.io.Serializable)
      */
     public static final String EXTRA_UUID = "android.os.storage.extra.UUID";
 
@@ -1414,6 +1420,7 @@
     public @NonNull ParcelFileDescriptor openProxyFileDescriptor(
             int mode, ProxyFileDescriptorCallback callback, Handler handler, ThreadFactory factory)
                     throws IOException {
+        Preconditions.checkNotNull(callback);
         MetricsLogger.count(mContext, "storage_open_proxy_file_descriptor", 1);
         // Retry is needed because the mount point mFuseAppLoop is using may be unmounted before
         // invoking StorageManagerService#openProxyFileDescriptor. In this case, we need to re-mount
@@ -1460,19 +1467,7 @@
         }
     }
 
-    /**
-     * Opens seekable ParcelFileDescriptor that routes file operation requests to
-     * ProxyFileDescriptorCallback.
-     *
-     * @param mode The desired access mode, must be one of
-     *     {@link ParcelFileDescriptor#MODE_READ_ONLY},
-     *     {@link ParcelFileDescriptor#MODE_WRITE_ONLY}, or
-     *     {@link ParcelFileDescriptor#MODE_READ_WRITE}
-     * @param callback Callback to process file operation requests issued on returned file
-     *     descriptor.
-     * @return Seekable ParcelFileDescriptor.
-     * @throws IOException
-     */
+    /** {@hide} */
     public @NonNull ParcelFileDescriptor openProxyFileDescriptor(
             int mode, ProxyFileDescriptorCallback callback)
                     throws IOException {
@@ -1496,6 +1491,7 @@
     public @NonNull ParcelFileDescriptor openProxyFileDescriptor(
             int mode, ProxyFileDescriptorCallback callback, Handler handler)
                     throws IOException {
+        Preconditions.checkNotNull(handler);
         return openProxyFileDescriptor(mode, callback, handler, null);
     }
 
@@ -1533,7 +1529,8 @@
      *             doesn't support cache quotas.
      * @see #getCacheSizeBytes(UUID)
      */
-    public long getCacheQuotaBytes(@NonNull UUID storageUuid) throws IOException {
+    @WorkerThread
+    public @BytesLong long getCacheQuotaBytes(@NonNull UUID storageUuid) throws IOException {
         try {
             final ApplicationInfo app = mContext.getApplicationInfo();
             return mStorageManager.getCacheQuotaBytes(convert(storageUuid), app.uid);
@@ -1573,7 +1570,8 @@
      *             doesn't support cache quotas.
      * @see #getCacheQuotaBytes(UUID)
      */
-    public long getCacheSizeBytes(@NonNull UUID storageUuid) throws IOException {
+    @WorkerThread
+    public @BytesLong long getCacheSizeBytes(@NonNull UUID storageUuid) throws IOException {
         try {
             final ApplicationInfo app = mContext.getApplicationInfo();
             return mStorageManager.getCacheSizeBytes(convert(storageUuid), app.uid);
@@ -1631,8 +1629,10 @@
      * @see #getAllocatableBytes(UUID, int)
      * @see #allocateBytes(UUID, long, int)
      * @see #allocateBytes(FileDescriptor, long, int)
+     * @hide
      */
     @RequiresPermission(android.Manifest.permission.ALLOCATE_AGGRESSIVE)
+    @SystemApi
     public static final int FLAG_ALLOCATE_AGGRESSIVE = 1;
 
     /** @hide */
@@ -1656,7 +1656,7 @@
      * the returned value will fail.
      * <p>
      * If the returned value is not large enough for the data you'd like to
-     * store, you can launch {@link #ACTION_MANAGE_STORAGE} with the
+     * persist, you can launch {@link #ACTION_MANAGE_STORAGE} with the
      * {@link #EXTRA_UUID} and {@link #EXTRA_REQUESTED_BYTES} options to help
      * involve the user in freeing up disk space.
      * <p class="note">
@@ -1670,13 +1670,19 @@
      *            vary widely depending on the underlying storage device. The
      *            UUID for a specific path can be obtained using
      *            {@link #getUuidForPath(File)}.
-     * @param flags to apply to the request.
      * @return the maximum number of new bytes that the calling app can allocate
      *         using {@link #allocateBytes(UUID, long, int)} or
      *         {@link #allocateBytes(FileDescriptor, long, int)}.
      * @throws IOException when the storage device isn't present, or when it
      *             doesn't support allocating space.
      */
+    public @BytesLong long getAllocatableBytes(@NonNull UUID storageUuid)
+            throws IOException {
+        return getAllocatableBytes(storageUuid, 0);
+    }
+
+    /** @hide */
+    @SystemApi
     public long getAllocatableBytes(@NonNull UUID storageUuid, @AllocateFlags int flags)
             throws IOException {
         try {
@@ -1713,14 +1719,20 @@
      *            allocate disk space. The UUID for a specific path can be
      *            obtained using {@link #getUuidForPath(File)}.
      * @param bytes the number of bytes to allocate.
-     * @param flags to apply to the request.
      * @throws IOException when the storage device isn't present, or when it
      *             doesn't support allocating space, or if the device had
      *             trouble allocating the requested space.
      * @see #getAllocatableBytes(UUID, int)
      */
-    public void allocateBytes(@NonNull UUID storageUuid, long bytes, @AllocateFlags int flags)
+    public void allocateBytes(@NonNull UUID storageUuid, @BytesLong long bytes)
             throws IOException {
+        allocateBytes(storageUuid, bytes, 0);
+    }
+
+    /** @hide */
+    @SystemApi
+    public void allocateBytes(@NonNull UUID storageUuid, @BytesLong long bytes,
+            @AllocateFlags int flags) throws IOException {
         try {
             mStorageManager.allocateBytes(convert(storageUuid), bytes, flags);
         } catch (ParcelableException e) {
@@ -1732,7 +1744,7 @@
 
     /** @removed */
     @Deprecated
-    public void allocateBytes(@NonNull File path, long bytes, @AllocateFlags int flags)
+    public void allocateBytes(@NonNull File path, @BytesLong long bytes, @AllocateFlags int flags)
             throws IOException {
         allocateBytes(getUuidForPath(path), bytes, flags);
     }
@@ -1756,14 +1768,19 @@
      *            requested size, it will be extended without modifying any
      *            existing contents. If the open file is larger than this
      *            requested size, it will be truncated.
-     * @param flags to apply to the request.
      * @throws IOException when the storage device isn't present, or when it
      *             doesn't support allocating space, or if the device had
      *             trouble allocating the requested space.
      * @see #getAllocatableBytes(UUID, int)
      * @see Environment#isExternalStorageEmulated(File)
      */
-    public void allocateBytes(FileDescriptor fd, long bytes, @AllocateFlags int flags)
+    public void allocateBytes(FileDescriptor fd, @BytesLong long bytes) throws IOException {
+        allocateBytes(fd, bytes, 0);
+    }
+
+    /** @hide */
+    @SystemApi
+    public void allocateBytes(FileDescriptor fd, @BytesLong long bytes, @AllocateFlags int flags)
             throws IOException {
         final File file = ParcelFileDescriptor.getFile(fd);
         for (int i = 0; i < 3; i++) {
diff --git a/core/java/android/util/EventLog.java b/core/java/android/util/EventLog.java
index 6d4281b..92f218b 100644
--- a/core/java/android/util/EventLog.java
+++ b/core/java/android/util/EventLog.java
@@ -68,6 +68,7 @@
         private static final int THREAD_OFFSET = 8;
         private static final int SECONDS_OFFSET = 12;
         private static final int NANOSECONDS_OFFSET = 16;
+        private static final int UID_OFFSET = 24;
 
         // Layout for event log v1 format, v2 and v3 use HEADER_SIZE_OFFSET
         private static final int V1_PAYLOAD_START = 20;
@@ -91,6 +92,20 @@
             return mBuffer.getInt(PROCESS_OFFSET);
         }
 
+        /**
+         * @return the UID which wrote the log entry
+         * @hide
+         */
+        @SystemApi
+        public int getUid() {
+            try {
+                return mBuffer.getInt(UID_OFFSET);
+            } catch (IndexOutOfBoundsException e) {
+                // buffer won't contain the UID if the caller doesn't have permission.
+                return -1;
+            }
+        }
+
         /** @return the thread ID which wrote the log entry */
         public int getThreadId() {
             return mBuffer.getInt(THREAD_OFFSET);
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index 5ff83ea..18c1b8c 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -5414,6 +5414,9 @@
         if (mDefaultFocus != null) {
             clearDefaultFocus(mDefaultFocus);
         }
+        if (mFocusedInCluster != null) {
+            clearFocusedInCluster(mFocusedInCluster);
+        }
         if (clearChildFocus) {
             clearChildFocus(focused);
             if (!rootViewRequestFocus()) {
diff --git a/core/java/android/view/autofill/AutofillManager.java b/core/java/android/view/autofill/AutofillManager.java
index ab30a04..94ca562 100644
--- a/core/java/android/view/autofill/AutofillManager.java
+++ b/core/java/android/view/autofill/AutofillManager.java
@@ -94,7 +94,8 @@
      * <p>
      * Type: {@link android.os.Bundle}
      */
-    public static final String EXTRA_DATA_EXTRAS = "android.view.autofill.extra.DATA_EXTRAS";
+    public static final String EXTRA_CLIENT_STATE =
+            "android.view.autofill.extra.EXTRA_CLIENT_STATE";
 
     static final String SESSION_ID_TAG = "android:sessionId";
     static final String LAST_AUTOFILLED_DATA_TAG = "android:lastAutoFilledData";
diff --git a/core/jni/android/graphics/Path.cpp b/core/jni/android/graphics/Path.cpp
index 292454b..d3d6882 100644
--- a/core/jni/android/graphics/Path.cpp
+++ b/core/jni/android/graphics/Path.cpp
@@ -26,6 +26,7 @@
 
 #include "SkPath.h"
 #include "SkPathOps.h"
+#include "SkGeometry.h" // WARNING: Internal Skia Header
 
 #include <Caches.h>
 #include <vector>
@@ -355,8 +356,9 @@
         }
     }
 
-    static void createVerbSegments(SkPath::Verb verb, const SkPoint* points,
-        std::vector<SkPoint>& segmentPoints, std::vector<float>& lengths, float errorSquared) {
+    static void createVerbSegments(const SkPath::Iter& pathIter, SkPath::Verb verb,
+            const SkPoint* points, std::vector<SkPoint>& segmentPoints,
+            std::vector<float>& lengths, float errorSquared, float errorConic) {
         switch (verb) {
             case SkPath::kMove_Verb:
                 addMove(segmentPoints, lengths, points[0]);
@@ -375,8 +377,27 @@
                 addBezier(points, cubicBezierCalculation, segmentPoints, lengths,
                     errorSquared, true);
                 break;
+            case SkPath::kConic_Verb: {
+                SkAutoConicToQuads converter;
+                const SkPoint* quads = converter.computeQuads(
+                        points, pathIter.conicWeight(), errorConic);
+                for (int i = 0; i < converter.countQuads(); i++) {
+                    // Note: offset each subsequent quad by 2, since end points are shared
+                    const SkPoint* quad = quads + i * 2;
+                    addBezier(quad, quadraticBezierCalculation, segmentPoints, lengths,
+                        errorConic, false);
+                }
+                break;
+            }
             default:
-                // Leave element as NULL, Conic sections are not supported.
+                static_assert(SkPath::kMove_Verb == 0
+                                && SkPath::kLine_Verb == 1
+                                && SkPath::kQuad_Verb == 2
+                                && SkPath::kConic_Verb == 3
+                                && SkPath::kCubic_Verb == 4
+                                && SkPath::kClose_Verb == 5
+                                && SkPath::kDone_Verb == 6,
+                        "Path enum changed, new types may have been added.");
                 break;
         }
     }
@@ -398,9 +419,11 @@
         std::vector<SkPoint> segmentPoints;
         std::vector<float> lengths;
         float errorSquared = acceptableError * acceptableError;
+        float errorConic = acceptableError / 2; // somewhat arbitrary
 
         while ((verb = pathIter.next(points, false)) != SkPath::kDone_Verb) {
-            createVerbSegments(verb, points, segmentPoints, lengths, errorSquared);
+            createVerbSegments(pathIter, verb, points, segmentPoints, lengths,
+                    errorSquared, errorConic);
         }
 
         if (segmentPoints.empty()) {
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index eacb02f..8bf96e3 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -1697,7 +1697,8 @@
     <permission android:name="android.permission.CACHE_CONTENT"
         android:protectionLevel="signature" />
 
-    <!-- Allows an application to aggressively allocate disk space.
+    <!-- @SystemApi @hide
+         Allows an application to aggressively allocate disk space.
          <p>Not for use by third-party applications.
     -->
     <permission android:name="android.permission.ALLOCATE_AGGRESSIVE"
diff --git a/core/res/res/layout/autofill_save.xml b/core/res/res/layout/autofill_save.xml
index 2f7ad3a..cbea275 100644
--- a/core/res/res/layout/autofill_save.xml
+++ b/core/res/res/layout/autofill_save.xml
@@ -94,6 +94,7 @@
                 android:layout_height="wrap_content"
                 style="@style/Widget.Material.Button.Colored"
                 android:text="@string/autofill_save_yes">
+                <requestFocus />
             </Button>
 
         </com.android.internal.widget.ButtonBarLayout>
diff --git a/core/res/res/values/themes_device_defaults.xml b/core/res/res/values/themes_device_defaults.xml
index d80ff1d..7517946 100644
--- a/core/res/res/values/themes_device_defaults.xml
+++ b/core/res/res/values/themes_device_defaults.xml
@@ -744,6 +744,7 @@
         <item name="colorPrimaryDark">@color/primary_dark_device_default_settings_light</item>
         <item name="colorSecondary">@color/secondary_device_default_settings_light</item>
         <item name="colorAccent">@color/accent_device_default_light</item>
+        <item name="colorEdgeEffect">@android:color/black</item>
     </style>
 
     <!-- @hide DeviceDefault theme for a window that should use Settings theme colors
diff --git a/core/tests/coretests/src/android/metrics/LogMakerTest.java b/core/tests/coretests/src/android/metrics/LogMakerTest.java
index 63c1f87..ada59cd 100644
--- a/core/tests/coretests/src/android/metrics/LogMakerTest.java
+++ b/core/tests/coretests/src/android/metrics/LogMakerTest.java
@@ -179,6 +179,14 @@
         assertEquals(-1, builder.getProcessId());
     }
 
+    public void testSetAndClearUid() {
+        LogMaker builder = new LogMaker(0);
+        builder.setUid(1);
+        assertEquals(1, builder.getUid());
+        builder.clearUid();
+        assertEquals(-1, builder.getUid());
+    }
+
     public void testGiantLogOmitted() {
         LogMaker badBuilder = new LogMaker(0);
         StringBuilder b = new StringBuilder();
diff --git a/core/tests/coretests/src/android/metrics/MetricsReaderTest.java b/core/tests/coretests/src/android/metrics/MetricsReaderTest.java
index d06f522..d10b351 100644
--- a/core/tests/coretests/src/android/metrics/MetricsReaderTest.java
+++ b/core/tests/coretests/src/android/metrics/MetricsReaderTest.java
@@ -26,6 +26,8 @@
 public class MetricsReaderTest extends TestCase {
     private static final int FULL_N = 10;
     private static final int CHECKPOINTED_N = 4;
+    private static final int PID = 1;
+    private static final int UID = 2;
 
     class FakeLogReader extends MetricsReader.LogReader {
         MetricsReader.Event[] mEvents;
@@ -36,7 +38,8 @@
             for (int i = 0; i < FULL_N; i++) {
                 mEvents[i] = new MetricsReader.Event(
                         1000L + i,
-                        1,
+                        PID,
+                        UID,
                         new LogMaker(i).serialize());
             }
         }
@@ -88,6 +91,13 @@
         }
     }
 
+    public void testPidUid() {
+        mReader.read(0);
+        LogMaker log = mReader.next();
+        assertEquals(PID, log.getProcessId());
+        assertEquals(UID, log.getUid());
+    }
+
     public void testBlockingRead_readResetsHorizon() {
         mReader.read(1000);
         assertEquals(1000, mLogReader.mHorizonMs);
diff --git a/graphics/java/android/graphics/Path.java b/graphics/java/android/graphics/Path.java
index 3631373..098cdc6 100644
--- a/graphics/java/android/graphics/Path.java
+++ b/graphics/java/android/graphics/Path.java
@@ -16,8 +16,10 @@
 
 package android.graphics;
 
+import android.annotation.FloatRange;
 import android.annotation.NonNull;
 import android.annotation.Nullable;
+import android.annotation.Size;
 
 import dalvik.annotation.optimization.CriticalNative;
 import dalvik.annotation.optimization.FastNative;
@@ -805,7 +807,12 @@
      *                        the error is less than half a pixel.
      * @return An array of components for points approximating the Path.
      */
-    public float[] approximate(float acceptableError) {
+    @NonNull
+    @Size(min = 6, multiple = 3)
+    public float[] approximate(@FloatRange(from = 0) float acceptableError) {
+        if (acceptableError < 0) {
+            throw new IllegalArgumentException("AcceptableError must be greater than or equal to 0");
+        }
         return nApproximate(mNativePath, acceptableError);
     }
 
diff --git a/graphics/java/android/graphics/SurfaceTexture.java b/graphics/java/android/graphics/SurfaceTexture.java
index 24fb673..97edf22 100644
--- a/graphics/java/android/graphics/SurfaceTexture.java
+++ b/graphics/java/android/graphics/SurfaceTexture.java
@@ -16,14 +16,14 @@
 
 package android.graphics;
 
-import java.lang.ref.WeakReference;
-
 import android.annotation.Nullable;
 import android.os.Handler;
 import android.os.Looper;
 import android.os.Message;
 import android.view.Surface;
 
+import java.lang.ref.WeakReference;
+
 /**
  * Captures frames from an image stream as an OpenGL ES texture.
  *
@@ -345,14 +345,17 @@
      * Always call this method when you are done with SurfaceTexture. Failing
      * to do so may delay resource deallocation for a significant amount of
      * time.
+     *
+     * @see #isReleased()
      */
     public void release() {
         nativeRelease();
     }
 
     /**
-     * Returns true if the SurfaceTexture was released
-     * @hide
+     * Returns true if the SurfaceTexture was released.
+     *
+     * @see #release()
      */
     public boolean isReleased() {
         return nativeIsReleased();
@@ -400,7 +403,6 @@
     private native void nativeReleaseTexImage();
     private native int nativeDetachFromGLContext();
     private native int nativeAttachToGLContext(int texName);
-    private native int nativeGetQueuedCount();
     private native void nativeRelease();
     private native boolean nativeIsReleased();
 }
diff --git a/libs/hwui/PathTessellator.cpp b/libs/hwui/PathTessellator.cpp
index 9246237..64b2c45 100644
--- a/libs/hwui/PathTessellator.cpp
+++ b/libs/hwui/PathTessellator.cpp
@@ -1005,6 +1005,14 @@
                 break;
             }
             default:
+                static_assert(SkPath::kMove_Verb == 0
+                                && SkPath::kLine_Verb == 1
+                                && SkPath::kQuad_Verb == 2
+                                && SkPath::kConic_Verb == 3
+                                && SkPath::kCubic_Verb == 4
+                                && SkPath::kClose_Verb == 5
+                                && SkPath::kDone_Verb == 6,
+                        "Path enum changed, new types may have been added");
                 break;
             }
     }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java
index b5f7ee6..4d47e6b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java
@@ -222,11 +222,21 @@
             for (AsyncTask task : mRunningTasks) {
                 task.cancel(true /* mayInterruptIfRunning */);
             }
+            mRunningTasks.clear();
         }
 
         public void addInflationTask(AsyncTask asyncInflationTask) {
             mRunningTasks.add(asyncInflationTask);
         }
+
+        public void onInflationTaskFinished(AsyncTask asyncInflationTask) {
+            mRunningTasks.remove(asyncInflationTask);
+        }
+
+        @VisibleForTesting
+        public ArraySet<AsyncTask> getRunningTasks() {
+            return mRunningTasks;
+        }
     }
 
     private final ArrayMap<String, Entry> mEntries = new ArrayMap<>();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationInflater.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationInflater.java
index 6c6dfa4..7cfc767 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationInflater.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationInflater.java
@@ -325,6 +325,7 @@
 
         @Override
         protected void onPostExecute(Notification.Builder builder) {
+            mRow.getEntry().onInflationTaskFinished(this);
             if (mError == null) {
                 finishInflation(mReInflateFlags, builder, mPackageContext);
             } else {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationInflaterTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationInflaterTest.java
index 65e0568..fbb25e5 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationInflaterTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationInflaterTest.java
@@ -115,13 +115,21 @@
     public void testInflationThrowsErrorDoesntCallUpdated() throws Exception {
         mRow.getPrivateLayout().removeAllViews();
         mRow.getStatusBarNotification().getNotification().contentView
-                = new RemoteViews(mContext.getPackageName(), R.layout.status_bar);;
+                = new RemoteViews(mContext.getPackageName(), R.layout.status_bar);
         runThenWaitForInflation(() -> mNotificationInflater.inflateNotificationViews(),
                 true /* expectingException */, mNotificationInflater);
         Assert.assertTrue(mRow.getPrivateLayout().getChildCount() == 0);
         verify(mRow, times(0)).onNotificationUpdated();
     }
 
+    @Test
+    public void testAsyncTaskRemoved() throws Exception {
+        mRow.getEntry().abortInflation();
+        runThenWaitForInflation(() -> mNotificationInflater.inflateNotificationViews(),
+                mNotificationInflater);
+        Assert.assertTrue(mRow.getEntry().getRunningTasks().size() == 0);
+    }
+
     public static void runThenWaitForInflation(Runnable block,
             NotificationInflater inflater) throws Exception {
         runThenWaitForInflation(block, false /* expectingException */, inflater);
diff --git a/proto/src/metrics_constants.proto b/proto/src/metrics_constants.proto
index dc082e1..cc6e435 100644
--- a/proto/src/metrics_constants.proto
+++ b/proto/src/metrics_constants.proto
@@ -3636,7 +3636,7 @@
     // OS: N
     ACTION_GET_CONTACT = 864;
 
-    // This values should never appear in log outputs - it is reserved for
+    // This value should never appear in log outputs - it is reserved for
     // internal platform metrics use.
     RESERVED_FOR_LOGBUILDER_PID = 865;
 
@@ -3948,6 +3948,10 @@
     // OS: O
     NOTIFICATION_CHANNEL_LOCK_SCREEN_VIS = 942;
 
+    // This value should never appear in log outputs - it is reserved for
+    // internal platform metrics use.
+    RESERVED_FOR_LOGBUILDER_UID = 943;
+
     // ---- End O Constants, all O constants go above this line ----
 
     // Add new aosp constants above this line.
diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java
index f4fd0be..c85ce436 100644
--- a/services/autofill/java/com/android/server/autofill/Session.java
+++ b/services/autofill/java/com/android/server/autofill/Session.java
@@ -1253,7 +1253,7 @@
         final Intent fillInIntent = new Intent();
         fillInIntent.putExtra(AutofillManager.EXTRA_ASSIST_STRUCTURE, structure);
         if (extras != null) {
-            fillInIntent.putExtra(AutofillManager.EXTRA_DATA_EXTRAS, extras);
+            fillInIntent.putExtra(AutofillManager.EXTRA_CLIENT_STATE, extras);
         }
         return fillInIntent;
     }
diff --git a/services/core/java/com/android/server/am/KeyguardController.java b/services/core/java/com/android/server/am/KeyguardController.java
index dd16e22..144eb11 100644
--- a/services/core/java/com/android/server/am/KeyguardController.java
+++ b/services/core/java/com/android/server/am/KeyguardController.java
@@ -95,6 +95,7 @@
             return;
         }
         mKeyguardShowing = showing;
+        dismissDockedStackIfNeeded();
         if (showing) {
             mKeyguardGoingAway = false;
             mDismissalRequested = false;
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index fff10e9..e2b838f 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -5149,7 +5149,7 @@
 
     private void onBluetoothA2dpDeviceConfigChange(BluetoothDevice btDevice)
     {
-        if (DEBUG_VOL) {
+        if (DEBUG_DEVICES) {
             Log.d(TAG, "onBluetoothA2dpDeviceConfigChange btDevice=" + btDevice);
         }
         if (btDevice == null) {
@@ -5166,8 +5166,13 @@
             final DeviceListSpec deviceSpec = mConnectedDevices.get(key);
             if (deviceSpec != null) {
                 // Device is connected
-                AudioSystem.handleDeviceConfigChange(device, address,
-                        btDevice.getName());
+               if (AudioSystem.handleDeviceConfigChange(device, address,
+                        btDevice.getName()) != AudioSystem.AUDIO_STATUS_OK) {
+                   // force A2DP device disconnection in case of error so that AudioService state is
+                   // consistent with audio policy manager state
+                   setBluetoothA2dpDeviceConnectionState(
+                           btDevice, BluetoothA2dp.STATE_DISCONNECTED, BluetoothProfile.A2DP_SINK);
+               }
             }
         }
     }
diff --git a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
index c802179..d9ca00c 100644
--- a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
+++ b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
@@ -2879,17 +2879,11 @@
             final List<UserInfo> users = mUserManager.getUsers();
             for (int ui = users.size() - 1; ui >= 0; ui--) {
                 UserInfo user = users.get(ui);
-                for (int i = mPowerSaveTempWhitelistAppIds.size() - 1; i >= 0; i--) {
-                    if (mPowerSaveTempWhitelistAppIds.valueAt(i)) {
-                        int appId = mPowerSaveTempWhitelistAppIds.keyAt(i);
-                        int uid = UserHandle.getUid(user.id, appId);
-                        uidRules.put(uid, FIREWALL_RULE_ALLOW);
-                    }
-                }
-                for (int i = mPowerSaveWhitelistAppIds.size() - 1; i >= 0; i--) {
-                    int appId = mPowerSaveWhitelistAppIds.keyAt(i);
-                    int uid = UserHandle.getUid(user.id, appId);
-                    uidRules.put(uid, FIREWALL_RULE_ALLOW);
+                updateRulesForWhitelistedAppIds(uidRules, mPowerSaveTempWhitelistAppIds, user.id);
+                updateRulesForWhitelistedAppIds(uidRules, mPowerSaveWhitelistAppIds, user.id);
+                if (chain == FIREWALL_CHAIN_POWERSAVE) {
+                    updateRulesForWhitelistedAppIds(uidRules,
+                            mPowerSaveWhitelistExceptIdleAppIds, user.id);
                 }
             }
             for (int i = mUidState.size() - 1; i >= 0; i--) {
@@ -2903,16 +2897,39 @@
         }
     }
 
-    private boolean isWhitelistedBatterySaverUL(int uid) {
+    private void updateRulesForWhitelistedAppIds(final SparseIntArray uidRules,
+            final SparseBooleanArray whitelistedAppIds, int userId) {
+        for (int i = whitelistedAppIds.size() - 1; i >= 0; --i) {
+            if (whitelistedAppIds.valueAt(i)) {
+                final int appId = whitelistedAppIds.keyAt(i);
+                final int uid = UserHandle.getUid(userId, appId);
+                uidRules.put(uid, FIREWALL_RULE_ALLOW);
+            }
+        }
+    }
+
+    /**
+     * @param deviceIdleMode if true then we don't consider
+     *        {@link #mPowerSaveWhitelistExceptIdleAppIds} for checking if the {@param uid} is
+     *        whitelisted.
+     */
+    private boolean isWhitelistedBatterySaverUL(int uid, boolean deviceIdleMode) {
         final int appId = UserHandle.getAppId(uid);
-        return mPowerSaveTempWhitelistAppIds.get(appId) || mPowerSaveWhitelistAppIds.get(appId);
+        boolean isWhitelisted = mPowerSaveTempWhitelistAppIds.get(appId)
+                || mPowerSaveWhitelistAppIds.get(appId);
+        if (!deviceIdleMode) {
+            isWhitelisted = isWhitelisted || mPowerSaveWhitelistExceptIdleAppIds.get(appId);
+        }
+        return isWhitelisted;
     }
 
     // NOTE: since both fw_dozable and fw_powersave uses the same map
     // (mPowerSaveTempWhitelistAppIds) for whitelisting, we can reuse their logic in this method.
     private void updateRulesForWhitelistedPowerSaveUL(int uid, boolean enabled, int chain) {
         if (enabled) {
-            if (isWhitelistedBatterySaverUL(uid) || isUidForegroundOnRestrictPowerUL(uid)) {
+            final boolean isWhitelisted = isWhitelistedBatterySaverUL(uid,
+                    chain == FIREWALL_CHAIN_DOZABLE);
+            if (isWhitelisted || isUidForegroundOnRestrictPowerUL(uid)) {
                 setUidFirewallRule(chain, uid, FIREWALL_RULE_ALLOW);
             } else {
                 setUidFirewallRule(chain, uid, FIREWALL_RULE_DEFAULT);
@@ -3430,7 +3447,7 @@
         final boolean restrictMode = isIdle || mRestrictPower || mDeviceIdleMode;
         final boolean isForeground = isUidForegroundOnRestrictPowerUL(uid);
 
-        final boolean isWhitelisted = isWhitelistedBatterySaverUL(uid);
+        final boolean isWhitelisted = isWhitelistedBatterySaverUL(uid, mDeviceIdleMode);
         final int oldRule = oldUidRules & MASK_ALL_NETWORKS;
         int newRule = RULE_NONE;
 
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 15df545..a56590e 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -17189,10 +17189,10 @@
                 PackageParser.Permission perm = pkg.permissions.get(i);
                 BasePermission bp = mSettings.mPermissions.get(perm.info.name);
 
-                // Don't allow anyone but the platform to define ephemeral permissions.
+                // Don't allow anyone but the system to define ephemeral permissions.
                 if ((perm.info.protectionLevel & PermissionInfo.PROTECTION_FLAG_EPHEMERAL) != 0
-                        && !PLATFORM_PACKAGE_NAME.equals(pkg.packageName)) {
-                    Slog.w(TAG, "Package " + pkg.packageName
+                        && !systemApp) {
+                    Slog.w(TAG, "Non-System package " + pkg.packageName
                             + " attempting to delcare ephemeral permission "
                             + perm.info.name + "; Removing ephemeral.");
                     perm.info.protectionLevel &= ~PermissionInfo.PROTECTION_FLAG_EPHEMERAL;
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 2ddce16..6584672 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -4651,19 +4651,20 @@
             final long ident = mInjector.binderClearCallingIdentity();
             try {
                 // Evict key
-                if ((flags & DevicePolicyManager.FLAG_EVICT_CE_KEY) != 0) {
-                    enforceManagedProfile(callingUserId, "set FLAG_EVICT_CE_KEY");
+                if ((flags & DevicePolicyManager.FLAG_EVICT_CREDENTIAL_ENCRYPTION_KEY) != 0) {
+                    enforceManagedProfile(
+                            callingUserId, "set FLAG_EVICT_CREDENTIAL_ENCRYPTION_KEY");
                     if (!isProfileOwner(admin.info.getComponent(), callingUserId)) {
-                        throw new SecurityException(
-                               "Only profile owner admins can set FLAG_EVICT_CE_KEY");
+                        throw new SecurityException("Only profile owner admins can set "
+                                + "FLAG_EVICT_CREDENTIAL_ENCRYPTION_KEY");
                     }
                     if (parent) {
                         throw new IllegalArgumentException(
-                                "Cannot set FLAG_EVICT_CE_KEY for the parent");
+                                "Cannot set FLAG_EVICT_CREDENTIAL_ENCRYPTION_KEY for the parent");
                     }
                     if (!mInjector.storageManagerIsFileBasedEncryptionEnabled()) {
                         throw new UnsupportedOperationException(
-                                "FLAG_EVICT_CE_KEY only applies to FBE devices");
+                                "FLAG_EVICT_CREDENTIAL_ENCRYPTION_KEY only applies to FBE devices");
                     }
                     mUserManager.evictCredentialEncryptionKey(callingUserId);
                 }
diff --git a/services/usage/java/com/android/server/usage/StorageStatsService.java b/services/usage/java/com/android/server/usage/StorageStatsService.java
index 2ebf5fc..e13665b 100644
--- a/services/usage/java/com/android/server/usage/StorageStatsService.java
+++ b/services/usage/java/com/android/server/usage/StorageStatsService.java
@@ -157,7 +157,7 @@
 
     @Override
     public long getTotalBytes(String volumeUuid, String callingPackage) {
-        enforcePermission(Binder.getCallingUid(), callingPackage);
+        // NOTE: No permissions required
 
         if (volumeUuid == StorageManager.UUID_PRIVATE_INTERNAL) {
             return FileUtils.roundStorageSize(mStorage.getPrimaryStorageSize());
@@ -173,7 +173,7 @@
 
     @Override
     public long getFreeBytes(String volumeUuid, String callingPackage) {
-        enforcePermission(Binder.getCallingUid(), callingPackage);
+        // NOTE: No permissions required
 
         long cacheBytes = 0;
         final long token = Binder.clearCallingIdentity();
@@ -187,14 +187,14 @@
         }
 
         if (volumeUuid == StorageManager.UUID_PRIVATE_INTERNAL) {
-            return Environment.getDataDirectory().getUsableSpace() + cacheBytes;
+            return Environment.getDataDirectory().getFreeSpace() + cacheBytes;
         } else {
             final VolumeInfo vol = mStorage.findVolumeByUuid(volumeUuid);
             if (vol == null) {
                 throw new ParcelableException(
                         new IOException("Failed to find storage device for UUID " + volumeUuid));
             }
-            return vol.getPath().getUsableSpace() + cacheBytes;
+            return vol.getPath().getFreeSpace() + cacheBytes;
         }
     }
 
@@ -213,7 +213,6 @@
     @Override
     public StorageStats queryStatsForPackage(String volumeUuid, String packageName, int userId,
             String callingPackage) {
-        enforcePermission(Binder.getCallingUid(), callingPackage);
         if (userId != UserHandle.getCallingUserId()) {
             mContext.enforceCallingOrSelfPermission(
                     android.Manifest.permission.INTERACT_ACROSS_USERS, TAG);
@@ -227,6 +226,12 @@
             throw new ParcelableException(e);
         }
 
+        if (Binder.getCallingUid() == appInfo.uid) {
+            // No permissions required when asking about themselves
+        } else {
+            enforcePermission(Binder.getCallingUid(), callingPackage);
+        }
+
         if (mPackage.getPackagesForUid(appInfo.uid).length == 1) {
             // Only one package inside UID means we can fast-path
             return queryStatsForUid(volumeUuid, appInfo.uid, callingPackage);
@@ -257,14 +262,19 @@
 
     @Override
     public StorageStats queryStatsForUid(String volumeUuid, int uid, String callingPackage) {
-        enforcePermission(Binder.getCallingUid(), callingPackage);
-        if (UserHandle.getUserId(uid) != UserHandle.getCallingUserId()) {
+        final int userId = UserHandle.getUserId(uid);
+        final int appId = UserHandle.getAppId(uid);
+
+        if (userId != UserHandle.getCallingUserId()) {
             mContext.enforceCallingOrSelfPermission(
                     android.Manifest.permission.INTERACT_ACROSS_USERS, TAG);
         }
 
-        final int userId = UserHandle.getUserId(uid);
-        final int appId = UserHandle.getAppId(uid);
+        if (Binder.getCallingUid() == uid) {
+            // No permissions required when asking about themselves
+        } else {
+            enforcePermission(Binder.getCallingUid(), callingPackage);
+        }
 
         final String[] packageNames = mPackage.getPackagesForUid(uid);
         final long[] ceDataInodes = new long[packageNames.length];
@@ -304,12 +314,14 @@
 
     @Override
     public StorageStats queryStatsForUser(String volumeUuid, int userId, String callingPackage) {
-        enforcePermission(Binder.getCallingUid(), callingPackage);
         if (userId != UserHandle.getCallingUserId()) {
             mContext.enforceCallingOrSelfPermission(
                     android.Manifest.permission.INTERACT_ACROSS_USERS, TAG);
         }
 
+        // Always require permission to see user-level stats
+        enforcePermission(Binder.getCallingUid(), callingPackage);
+
         final int[] appIds = getAppIds(userId);
         final PackageStats stats = new PackageStats(TAG);
         try {
@@ -329,12 +341,14 @@
     @Override
     public ExternalStorageStats queryExternalStatsForUser(String volumeUuid, int userId,
             String callingPackage) {
-        enforcePermission(Binder.getCallingUid(), callingPackage);
         if (userId != UserHandle.getCallingUserId()) {
             mContext.enforceCallingOrSelfPermission(
                     android.Manifest.permission.INTERACT_ACROSS_USERS, TAG);
         }
 
+        // Always require permission to see user-level stats
+        enforcePermission(Binder.getCallingUid(), callingPackage);
+
         final int[] appIds = getAppIds(userId);
         final long[] stats;
         try {
diff --git a/tools/aapt2/Main.cpp b/tools/aapt2/Main.cpp
index 87fda16..1965ad9 100644
--- a/tools/aapt2/Main.cpp
+++ b/tools/aapt2/Main.cpp
@@ -19,6 +19,8 @@
 
 #include "androidfw/StringPiece.h"
 
+#include "Diagnostics.h"
+
 namespace aapt {
 
 // DO NOT UPDATE, this is more of a marketing version.
@@ -33,8 +35,8 @@
   return 0;
 }
 
-extern int Compile(const std::vector<android::StringPiece>& args);
-extern int Link(const std::vector<android::StringPiece>& args);
+extern int Compile(const std::vector<android::StringPiece>& args, IDiagnostics* diagnostics);
+extern int Link(const std::vector<android::StringPiece>& args, IDiagnostics* diagnostics);
 extern int Dump(const std::vector<android::StringPiece>& args);
 extern int Diff(const std::vector<android::StringPiece>& args);
 extern int Optimize(const std::vector<android::StringPiece>& args);
@@ -53,9 +55,11 @@
 
     android::StringPiece command(argv[0]);
     if (command == "compile" || command == "c") {
-      return aapt::Compile(args);
+      aapt::StdErrDiagnostics diagnostics;
+      return aapt::Compile(args, &diagnostics);
     } else if (command == "link" || command == "l") {
-      return aapt::Link(args);
+      aapt::StdErrDiagnostics diagnostics;
+      return aapt::Link(args, &diagnostics);
     } else if (command == "dump" || command == "d") {
       return aapt::Dump(args);
     } else if (command == "diff") {
diff --git a/tools/aapt2/cmd/Compile.cpp b/tools/aapt2/cmd/Compile.cpp
index b93c6ec..5413b33 100644
--- a/tools/aapt2/cmd/Compile.cpp
+++ b/tools/aapt2/cmd/Compile.cpp
@@ -598,6 +598,9 @@
 
 class CompileContext : public IAaptContext {
  public:
+  CompileContext(IDiagnostics* diagnostics) : diagnostics_(diagnostics) {
+  }
+
   PackageType GetPackageType() override {
     // Every compilation unit starts as an app and then gets linked as potentially something else.
     return PackageType::kApp;
@@ -612,7 +615,7 @@
   }
 
   IDiagnostics* GetDiagnostics() override {
-    return &diagnostics_;
+    return diagnostics_;
   }
 
   NameMangler* GetNameMangler() override {
@@ -639,7 +642,7 @@
   }
 
  private:
-  StdErrDiagnostics diagnostics_;
+  IDiagnostics* diagnostics_;
   bool verbose_ = false;
 };
 
@@ -647,8 +650,8 @@
  * Entry point for compilation phase. Parses arguments and dispatches to the
  * correct steps.
  */
-int Compile(const std::vector<StringPiece>& args) {
-  CompileContext context;
+int Compile(const std::vector<StringPiece>& args, IDiagnostics* diagnostics) {
+  CompileContext context(diagnostics);
   CompileOptions options;
 
   bool verbose = false;
diff --git a/tools/aapt2/cmd/Link.cpp b/tools/aapt2/cmd/Link.cpp
index 258516d..93748d3 100644
--- a/tools/aapt2/cmd/Link.cpp
+++ b/tools/aapt2/cmd/Link.cpp
@@ -118,7 +118,8 @@
 
 class LinkContext : public IAaptContext {
  public:
-  LinkContext() : name_mangler_({}), symbols_(&name_mangler_) {
+  LinkContext(IDiagnostics* diagnostics)
+      : diagnostics_(diagnostics), name_mangler_({}), symbols_(&name_mangler_) {
   }
 
   PackageType GetPackageType() override {
@@ -130,7 +131,7 @@
   }
 
   IDiagnostics* GetDiagnostics() override {
-    return &diagnostics_;
+    return diagnostics_;
   }
 
   NameMangler* GetNameMangler() override {
@@ -181,7 +182,7 @@
   DISALLOW_COPY_AND_ASSIGN(LinkContext);
 
   PackageType package_type_ = PackageType::kApp;
-  StdErrDiagnostics diagnostics_;
+  IDiagnostics* diagnostics_;
   NameMangler name_mangler_;
   std::string compilation_package_;
   uint8_t package_id_ = 0x0;
@@ -1736,8 +1737,8 @@
   std::map<size_t, std::string> shared_libs_;
 };
 
-int Link(const std::vector<StringPiece>& args) {
-  LinkContext context;
+int Link(const std::vector<StringPiece>& args, IDiagnostics* diagnostics) {
+  LinkContext context(diagnostics);
   LinkOptions options;
   std::vector<std::string> overlay_arg_list;
   std::vector<std::string> extra_java_packages;
diff --git a/tools/aapt2/jni/aapt2_jni.cpp b/tools/aapt2/jni/aapt2_jni.cpp
index ce3d282..ad5ad4c 100644
--- a/tools/aapt2/jni/aapt2_jni.cpp
+++ b/tools/aapt2/jni/aapt2_jni.cpp
@@ -24,13 +24,14 @@
 #include "android-base/logging.h"
 #include "ScopedUtfChars.h"
 
+#include "Diagnostics.h"
 #include "util/Util.h"
 
 using android::StringPiece;
 
 namespace aapt {
-extern int Compile(const std::vector<StringPiece> &args);
-extern int Link(const std::vector<StringPiece> &args);
+extern int Compile(const std::vector<StringPiece>& args, IDiagnostics* iDiagnostics);
+extern int Link(const std::vector<StringPiece>& args, IDiagnostics* iDiagnostics);
 }
 
 /*
@@ -77,20 +78,66 @@
   return pieces;
 }
 
+class JniDiagnostics : public aapt::IDiagnostics {
+ public:
+  JniDiagnostics(JNIEnv* env, jobject diagnostics_obj)
+      : env_(env), diagnostics_obj_(diagnostics_obj) {
+    mid_ = NULL;
+  }
+
+  void Log(Level level, aapt::DiagMessageActual& actual_msg) override {
+    jint level_value;
+    switch (level) {
+      case Level::Error:
+        level_value = 3;
+        break;
+
+      case Level::Warn:
+        level_value = 2;
+        break;
+
+      case Level::Note:
+        level_value = 1;
+        break;
+    }
+    jstring message = env_->NewStringUTF(actual_msg.message.c_str());
+    jstring path = env_->NewStringUTF(actual_msg.source.path.c_str());
+    jlong line = -1;
+    if (actual_msg.source.line) {
+      line = actual_msg.source.line.value();
+    }
+    if (!mid_) {
+      jclass diagnostics_cls = env_->GetObjectClass(diagnostics_obj_);
+      mid_ = env_->GetMethodID(diagnostics_cls, "log", "(ILjava/lang/String;JLjava/lang/String;)V");
+    }
+    env_->CallVoidMethod(diagnostics_obj_, mid_, level_value, path, line, message);
+  }
+
+ private:
+  JNIEnv* env_;
+  jobject diagnostics_obj_;
+  jmethodID mid_;
+  DISALLOW_COPY_AND_ASSIGN(JniDiagnostics);
+};
+
 JNIEXPORT jint JNICALL Java_com_android_tools_aapt2_Aapt2Jni_nativeCompile(
-    JNIEnv *env, jclass aapt_obj, jobject arguments_obj) {
+    JNIEnv* env, jclass aapt_obj, jobject arguments_obj, jobject diagnostics_obj) {
   std::vector<ScopedUtfChars> compile_args_jni =
       list_to_utfchars(env, arguments_obj);
   std::vector<StringPiece> compile_args = extract_pieces(compile_args_jni);
-  return aapt::Compile(compile_args);
+  JniDiagnostics diagnostics(env, diagnostics_obj);
+  return aapt::Compile(compile_args, &diagnostics);
 }
 
-JNIEXPORT jint JNICALL Java_com_android_tools_aapt2_Aapt2Jni_nativeLink(
-    JNIEnv *env, jclass aapt_obj, jobject arguments_obj) {
+JNIEXPORT jint JNICALL Java_com_android_tools_aapt2_Aapt2Jni_nativeLink(JNIEnv* env,
+                                                                        jclass aapt_obj,
+                                                                        jobject arguments_obj,
+                                                                        jobject diagnostics_obj) {
   std::vector<ScopedUtfChars> link_args_jni =
       list_to_utfchars(env, arguments_obj);
   std::vector<StringPiece> link_args = extract_pieces(link_args_jni);
-  return aapt::Link(link_args);
+  JniDiagnostics diagnostics(env, diagnostics_obj);
+  return aapt::Link(link_args, &diagnostics);
 }
 
 JNIEXPORT void JNICALL Java_com_android_tools_aapt2_Aapt2Jni_ping(
diff --git a/tools/aapt2/jni/com_android_tools_aapt2_Aapt2Jni.h b/tools/aapt2/jni/com_android_tools_aapt2_Aapt2Jni.h
index 90150b4..3cd9865 100644
--- a/tools/aapt2/jni/com_android_tools_aapt2_Aapt2Jni.h
+++ b/tools/aapt2/jni/com_android_tools_aapt2_Aapt2Jni.h
@@ -18,18 +18,18 @@
 /*
  * Class:     com_android_tools_aapt2_Aapt2Jni
  * Method:    nativeCompile
- * Signature: (Ljava/util/List;)I
+ * Signature: (Ljava/util/List;Lcom/android/tools/aapt2/Aapt2JniDiagnostics;)I
  */
-JNIEXPORT jint JNICALL Java_com_android_tools_aapt2_Aapt2Jni_nativeCompile
-  (JNIEnv *, jclass, jobject);
+JNIEXPORT jint JNICALL Java_com_android_tools_aapt2_Aapt2Jni_nativeCompile(JNIEnv*, jclass, jobject,
+                                                                           jobject);
 
 /*
  * Class:     com_android_tools_aapt2_Aapt2Jni
  * Method:    nativeLink
- * Signature: (Ljava/util/List;)I
+ * Signature: (Ljava/util/List;Lcom/android/tools/aapt2/Aapt2JniDiagnostics;)I
  */
-JNIEXPORT jint JNICALL Java_com_android_tools_aapt2_Aapt2Jni_nativeLink
-  (JNIEnv *, jclass, jobject);
+JNIEXPORT jint JNICALL Java_com_android_tools_aapt2_Aapt2Jni_nativeLink(JNIEnv*, jclass, jobject,
+                                                                        jobject);
 
 #ifdef __cplusplus
 }