Merge "Fix multi-window assiststructure trashing" into nyc-dev
diff --git a/api/current.txt b/api/current.txt
index d380e70..e9d5c3d 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -6417,22 +6417,6 @@
field public static final android.os.Parcelable.Creator<android.app.usage.ConfigurationStats> CREATOR;
}
- public class DataUsagePolicy {
- field public final int networkType;
- field public final java.lang.String[] subscriberIds;
- field public final long thresholdInBytes;
- field public final int[] uids;
- }
-
- public static class DataUsagePolicy.Builder {
- ctor public DataUsagePolicy.Builder();
- method public android.app.usage.DataUsagePolicy.Builder addSubscriberId(java.lang.String);
- method public android.app.usage.DataUsagePolicy.Builder addUid(int);
- method public android.app.usage.DataUsagePolicy build();
- method public android.app.usage.DataUsagePolicy.Builder setNetworkType(int);
- method public android.app.usage.DataUsagePolicy.Builder setThreshold(long);
- }
-
public final class NetworkStats implements java.lang.AutoCloseable {
method public void close();
method public boolean getNextBucket(android.app.usage.NetworkStats.Bucket);
@@ -6457,8 +6441,7 @@
field public static final int STATE_ALL = -1; // 0xffffffff
field public static final int STATE_DEFAULT = 1; // 0x1
field public static final int STATE_FOREGROUND = 2; // 0x2
- field public static final int TAG_ALL = 0; // 0x0
- field public static final int TAG_ANY = -1; // 0xffffffff
+ field public static final int TAG_NONE = 0; // 0x0
field public static final int UID_ALL = -1; // 0xffffffff
field public static final int UID_REMOVED = -4; // 0xfffffffc
field public static final int UID_TETHERING = -5; // 0xfffffffb
@@ -6467,20 +6450,18 @@
public class NetworkStatsManager {
method public android.app.usage.NetworkStats queryDetails(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
method public android.app.usage.NetworkStats queryDetailsForUid(int, java.lang.String, long, long, int) throws android.os.RemoteException, java.lang.SecurityException;
- method public android.app.usage.NetworkStats queryDetailsForUidTag(int, java.lang.String, long, long, int, int) throws android.os.RemoteException, java.lang.SecurityException;
+ method public android.app.usage.NetworkStats queryDetailsForUidTag(int, java.lang.String, long, long, int, int);
method public android.app.usage.NetworkStats querySummary(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
- method public android.app.usage.NetworkStats querySummary(int, java.lang.String, long, long, boolean) throws android.os.RemoteException, java.lang.SecurityException;
method public android.app.usage.NetworkStats.Bucket querySummaryForDevice(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
method public android.app.usage.NetworkStats.Bucket querySummaryForUser(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
- method public android.app.usage.NetworkStats.Bucket querySummaryForUser(int, java.lang.String, long, long, boolean) throws android.os.RemoteException, java.lang.SecurityException;
- method public void registerDataUsageCallback(android.app.usage.DataUsagePolicy, android.app.usage.NetworkStatsManager.DataUsageCallback);
- method public void registerDataUsageCallback(android.app.usage.DataUsagePolicy, android.app.usage.NetworkStatsManager.DataUsageCallback, android.os.Handler);
- method public void unregisterDataUsageCallback(android.app.usage.NetworkStatsManager.DataUsageCallback);
+ method public void registerUsageCallback(int, java.lang.String, long, android.app.usage.NetworkStatsManager.UsageCallback);
+ method public void registerUsageCallback(int, java.lang.String, long, android.app.usage.NetworkStatsManager.UsageCallback, android.os.Handler);
+ method public void unregisterUsageCallback(android.app.usage.NetworkStatsManager.UsageCallback);
}
- public static class NetworkStatsManager.DataUsageCallback {
- ctor public NetworkStatsManager.DataUsageCallback();
- method public void onLimitReached();
+ public static abstract class NetworkStatsManager.UsageCallback {
+ ctor public NetworkStatsManager.UsageCallback();
+ method public abstract void onThresholdReached(int, java.lang.String);
}
public final class UsageEvents implements android.os.Parcelable {
@@ -23538,12 +23519,6 @@
method public int getUid();
}
- public final class DataUsageRequest implements android.os.Parcelable {
- method public int describeContents();
- method public void writeToParcel(android.os.Parcel, int);
- field public static final android.os.Parcelable.Creator<android.net.DataUsageRequest> CREATOR;
- }
-
public class DhcpInfo implements android.os.Parcelable {
ctor public DhcpInfo();
method public int describeContents();
diff --git a/api/removed.txt b/api/removed.txt
index f9fce40..2673a82 100644
--- a/api/removed.txt
+++ b/api/removed.txt
@@ -17,6 +17,37 @@
}
+package android.app.usage {
+
+ public class DataUsagePolicy {
+ field public final int networkType;
+ field public final java.lang.String[] subscriberIds;
+ field public final long thresholdInBytes;
+ field public final int[] uids;
+ }
+
+ public static class DataUsagePolicy.Builder {
+ ctor public DataUsagePolicy.Builder();
+ method public android.app.usage.DataUsagePolicy.Builder addSubscriberId(java.lang.String);
+ method public android.app.usage.DataUsagePolicy.Builder addUid(int);
+ method public android.app.usage.DataUsagePolicy build();
+ method public android.app.usage.DataUsagePolicy.Builder setNetworkType(int);
+ method public android.app.usage.DataUsagePolicy.Builder setThreshold(long);
+ }
+
+ public class NetworkStatsManager {
+ method public void registerDataUsageCallback(android.app.usage.DataUsagePolicy, android.app.usage.NetworkStatsManager.DataUsageCallback, android.os.Handler);
+ method public void registerDataUsageCallback(android.app.usage.DataUsagePolicy, android.app.usage.NetworkStatsManager.UsageCallback, android.os.Handler);
+ method public void unregisterDataUsageCallback(android.app.usage.NetworkStatsManager.DataUsageCallback);
+ }
+
+ public static abstract class NetworkStatsManager.DataUsageCallback {
+ ctor public NetworkStatsManager.DataUsageCallback();
+ method public deprecated void onLimitReached();
+ }
+
+}
+
package android.content {
public abstract class Context {
diff --git a/api/system-current.txt b/api/system-current.txt
index dbbefbf..e5c88cc 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -6698,22 +6698,6 @@
field public static final android.os.Parcelable.Creator<android.app.usage.ConfigurationStats> CREATOR;
}
- public class DataUsagePolicy {
- field public final int networkType;
- field public final java.lang.String[] subscriberIds;
- field public final long thresholdInBytes;
- field public final int[] uids;
- }
-
- public static class DataUsagePolicy.Builder {
- ctor public DataUsagePolicy.Builder();
- method public android.app.usage.DataUsagePolicy.Builder addSubscriberId(java.lang.String);
- method public android.app.usage.DataUsagePolicy.Builder addUid(int);
- method public android.app.usage.DataUsagePolicy build();
- method public android.app.usage.DataUsagePolicy.Builder setNetworkType(int);
- method public android.app.usage.DataUsagePolicy.Builder setThreshold(long);
- }
-
public final class NetworkStats implements java.lang.AutoCloseable {
method public void close();
method public boolean getNextBucket(android.app.usage.NetworkStats.Bucket);
@@ -6738,8 +6722,7 @@
field public static final int STATE_ALL = -1; // 0xffffffff
field public static final int STATE_DEFAULT = 1; // 0x1
field public static final int STATE_FOREGROUND = 2; // 0x2
- field public static final int TAG_ALL = 0; // 0x0
- field public static final int TAG_ANY = -1; // 0xffffffff
+ field public static final int TAG_NONE = 0; // 0x0
field public static final int UID_ALL = -1; // 0xffffffff
field public static final int UID_REMOVED = -4; // 0xfffffffc
field public static final int UID_TETHERING = -5; // 0xfffffffb
@@ -6748,20 +6731,18 @@
public class NetworkStatsManager {
method public android.app.usage.NetworkStats queryDetails(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
method public android.app.usage.NetworkStats queryDetailsForUid(int, java.lang.String, long, long, int) throws android.os.RemoteException, java.lang.SecurityException;
- method public android.app.usage.NetworkStats queryDetailsForUidTag(int, java.lang.String, long, long, int, int) throws android.os.RemoteException, java.lang.SecurityException;
+ method public android.app.usage.NetworkStats queryDetailsForUidTag(int, java.lang.String, long, long, int, int);
method public android.app.usage.NetworkStats querySummary(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
- method public android.app.usage.NetworkStats querySummary(int, java.lang.String, long, long, boolean) throws android.os.RemoteException, java.lang.SecurityException;
method public android.app.usage.NetworkStats.Bucket querySummaryForDevice(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
method public android.app.usage.NetworkStats.Bucket querySummaryForUser(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
- method public android.app.usage.NetworkStats.Bucket querySummaryForUser(int, java.lang.String, long, long, boolean) throws android.os.RemoteException, java.lang.SecurityException;
- method public void registerDataUsageCallback(android.app.usage.DataUsagePolicy, android.app.usage.NetworkStatsManager.DataUsageCallback);
- method public void registerDataUsageCallback(android.app.usage.DataUsagePolicy, android.app.usage.NetworkStatsManager.DataUsageCallback, android.os.Handler);
- method public void unregisterDataUsageCallback(android.app.usage.NetworkStatsManager.DataUsageCallback);
+ method public void registerUsageCallback(int, java.lang.String, long, android.app.usage.NetworkStatsManager.UsageCallback);
+ method public void registerUsageCallback(int, java.lang.String, long, android.app.usage.NetworkStatsManager.UsageCallback, android.os.Handler);
+ method public void unregisterUsageCallback(android.app.usage.NetworkStatsManager.UsageCallback);
}
- public static class NetworkStatsManager.DataUsageCallback {
- ctor public NetworkStatsManager.DataUsageCallback();
- method public void onLimitReached();
+ public static abstract class NetworkStatsManager.UsageCallback {
+ ctor public NetworkStatsManager.UsageCallback();
+ method public abstract void onThresholdReached(int, java.lang.String);
}
public final class UsageEvents implements android.os.Parcelable {
@@ -25364,12 +25345,6 @@
method public int getUid();
}
- public final class DataUsageRequest implements android.os.Parcelable {
- method public int describeContents();
- method public void writeToParcel(android.os.Parcel, int);
- field public static final android.os.Parcelable.Creator<android.net.DataUsageRequest> CREATOR;
- }
-
public class DhcpInfo implements android.os.Parcelable {
ctor public DhcpInfo();
method public int describeContents();
diff --git a/api/system-removed.txt b/api/system-removed.txt
index 6897ce0..7f2c2d6 100644
--- a/api/system-removed.txt
+++ b/api/system-removed.txt
@@ -15,6 +15,37 @@
}
+package android.app.usage {
+
+ public class DataUsagePolicy {
+ field public final int networkType;
+ field public final java.lang.String[] subscriberIds;
+ field public final long thresholdInBytes;
+ field public final int[] uids;
+ }
+
+ public static class DataUsagePolicy.Builder {
+ ctor public DataUsagePolicy.Builder();
+ method public android.app.usage.DataUsagePolicy.Builder addSubscriberId(java.lang.String);
+ method public android.app.usage.DataUsagePolicy.Builder addUid(int);
+ method public android.app.usage.DataUsagePolicy build();
+ method public android.app.usage.DataUsagePolicy.Builder setNetworkType(int);
+ method public android.app.usage.DataUsagePolicy.Builder setThreshold(long);
+ }
+
+ public class NetworkStatsManager {
+ method public void registerDataUsageCallback(android.app.usage.DataUsagePolicy, android.app.usage.NetworkStatsManager.DataUsageCallback, android.os.Handler);
+ method public void registerDataUsageCallback(android.app.usage.DataUsagePolicy, android.app.usage.NetworkStatsManager.UsageCallback, android.os.Handler);
+ method public void unregisterDataUsageCallback(android.app.usage.NetworkStatsManager.DataUsageCallback);
+ }
+
+ public static abstract class NetworkStatsManager.DataUsageCallback {
+ ctor public NetworkStatsManager.DataUsageCallback();
+ method public deprecated void onLimitReached();
+ }
+
+}
+
package android.content {
public abstract class Context {
diff --git a/api/test-current.txt b/api/test-current.txt
index acd7299..ff2a41c 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -6422,22 +6422,6 @@
field public static final android.os.Parcelable.Creator<android.app.usage.ConfigurationStats> CREATOR;
}
- public class DataUsagePolicy {
- field public final int networkType;
- field public final java.lang.String[] subscriberIds;
- field public final long thresholdInBytes;
- field public final int[] uids;
- }
-
- public static class DataUsagePolicy.Builder {
- ctor public DataUsagePolicy.Builder();
- method public android.app.usage.DataUsagePolicy.Builder addSubscriberId(java.lang.String);
- method public android.app.usage.DataUsagePolicy.Builder addUid(int);
- method public android.app.usage.DataUsagePolicy build();
- method public android.app.usage.DataUsagePolicy.Builder setNetworkType(int);
- method public android.app.usage.DataUsagePolicy.Builder setThreshold(long);
- }
-
public final class NetworkStats implements java.lang.AutoCloseable {
method public void close();
method public boolean getNextBucket(android.app.usage.NetworkStats.Bucket);
@@ -6462,8 +6446,7 @@
field public static final int STATE_ALL = -1; // 0xffffffff
field public static final int STATE_DEFAULT = 1; // 0x1
field public static final int STATE_FOREGROUND = 2; // 0x2
- field public static final int TAG_ALL = 0; // 0x0
- field public static final int TAG_ANY = -1; // 0xffffffff
+ field public static final int TAG_NONE = 0; // 0x0
field public static final int UID_ALL = -1; // 0xffffffff
field public static final int UID_REMOVED = -4; // 0xfffffffc
field public static final int UID_TETHERING = -5; // 0xfffffffb
@@ -6472,20 +6455,18 @@
public class NetworkStatsManager {
method public android.app.usage.NetworkStats queryDetails(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
method public android.app.usage.NetworkStats queryDetailsForUid(int, java.lang.String, long, long, int) throws android.os.RemoteException, java.lang.SecurityException;
- method public android.app.usage.NetworkStats queryDetailsForUidTag(int, java.lang.String, long, long, int, int) throws android.os.RemoteException, java.lang.SecurityException;
+ method public android.app.usage.NetworkStats queryDetailsForUidTag(int, java.lang.String, long, long, int, int);
method public android.app.usage.NetworkStats querySummary(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
- method public android.app.usage.NetworkStats querySummary(int, java.lang.String, long, long, boolean) throws android.os.RemoteException, java.lang.SecurityException;
method public android.app.usage.NetworkStats.Bucket querySummaryForDevice(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
method public android.app.usage.NetworkStats.Bucket querySummaryForUser(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
- method public android.app.usage.NetworkStats.Bucket querySummaryForUser(int, java.lang.String, long, long, boolean) throws android.os.RemoteException, java.lang.SecurityException;
- method public void registerDataUsageCallback(android.app.usage.DataUsagePolicy, android.app.usage.NetworkStatsManager.DataUsageCallback);
- method public void registerDataUsageCallback(android.app.usage.DataUsagePolicy, android.app.usage.NetworkStatsManager.DataUsageCallback, android.os.Handler);
- method public void unregisterDataUsageCallback(android.app.usage.NetworkStatsManager.DataUsageCallback);
+ method public void registerUsageCallback(int, java.lang.String, long, android.app.usage.NetworkStatsManager.UsageCallback);
+ method public void registerUsageCallback(int, java.lang.String, long, android.app.usage.NetworkStatsManager.UsageCallback, android.os.Handler);
+ method public void unregisterUsageCallback(android.app.usage.NetworkStatsManager.UsageCallback);
}
- public static class NetworkStatsManager.DataUsageCallback {
- ctor public NetworkStatsManager.DataUsageCallback();
- method public void onLimitReached();
+ public static abstract class NetworkStatsManager.UsageCallback {
+ ctor public NetworkStatsManager.UsageCallback();
+ method public abstract void onThresholdReached(int, java.lang.String);
}
public final class UsageEvents implements android.os.Parcelable {
@@ -23607,12 +23588,6 @@
method public int getUid();
}
- public final class DataUsageRequest implements android.os.Parcelable {
- method public int describeContents();
- method public void writeToParcel(android.os.Parcel, int);
- field public static final android.os.Parcelable.Creator<android.net.DataUsageRequest> CREATOR;
- }
-
public class DhcpInfo implements android.os.Parcelable {
ctor public DhcpInfo();
method public int describeContents();
diff --git a/api/test-removed.txt b/api/test-removed.txt
index f9fce40..2673a82 100644
--- a/api/test-removed.txt
+++ b/api/test-removed.txt
@@ -17,6 +17,37 @@
}
+package android.app.usage {
+
+ public class DataUsagePolicy {
+ field public final int networkType;
+ field public final java.lang.String[] subscriberIds;
+ field public final long thresholdInBytes;
+ field public final int[] uids;
+ }
+
+ public static class DataUsagePolicy.Builder {
+ ctor public DataUsagePolicy.Builder();
+ method public android.app.usage.DataUsagePolicy.Builder addSubscriberId(java.lang.String);
+ method public android.app.usage.DataUsagePolicy.Builder addUid(int);
+ method public android.app.usage.DataUsagePolicy build();
+ method public android.app.usage.DataUsagePolicy.Builder setNetworkType(int);
+ method public android.app.usage.DataUsagePolicy.Builder setThreshold(long);
+ }
+
+ public class NetworkStatsManager {
+ method public void registerDataUsageCallback(android.app.usage.DataUsagePolicy, android.app.usage.NetworkStatsManager.DataUsageCallback, android.os.Handler);
+ method public void registerDataUsageCallback(android.app.usage.DataUsagePolicy, android.app.usage.NetworkStatsManager.UsageCallback, android.os.Handler);
+ method public void unregisterDataUsageCallback(android.app.usage.NetworkStatsManager.DataUsageCallback);
+ }
+
+ public static abstract class NetworkStatsManager.DataUsageCallback {
+ ctor public NetworkStatsManager.DataUsageCallback();
+ method public deprecated void onLimitReached();
+ }
+
+}
+
package android.content {
public abstract class Context {
diff --git a/core/java/android/accessibilityservice/AccessibilityService.java b/core/java/android/accessibilityservice/AccessibilityService.java
index 8b277b2..ae78e218 100644
--- a/core/java/android/accessibilityservice/AccessibilityService.java
+++ b/core/java/android/accessibilityservice/AccessibilityService.java
@@ -949,7 +949,7 @@
mService.mConnectionId);
if (connection != null) {
try {
- return connection.getMagnifiedRegion();
+ return connection.getMagnificationRegion();
} catch (RemoteException re) {
Log.w(LOG_TAG, "Failed to obtain magnified region", re);
re.rethrowFromSystemServer();
diff --git a/core/java/android/accessibilityservice/IAccessibilityServiceConnection.aidl b/core/java/android/accessibilityservice/IAccessibilityServiceConnection.aidl
index 3783fca..7a55079 100644
--- a/core/java/android/accessibilityservice/IAccessibilityServiceConnection.aidl
+++ b/core/java/android/accessibilityservice/IAccessibilityServiceConnection.aidl
@@ -75,7 +75,7 @@
float getMagnificationCenterY();
- Region getMagnifiedRegion();
+ Region getMagnificationRegion();
boolean resetMagnification(boolean animate);
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 9b4c8bd..07d3b8a 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -1879,14 +1879,9 @@
*
* @param isInMultiWindowMode True if the activity is in multi-window mode.
*/
- @CallSuper
public void onMultiWindowModeChanged(boolean isInMultiWindowMode) {
- if (DEBUG_LIFECYCLE) Slog.v(TAG,
- "onMultiWindowModeChanged " + this + ": " + isInMultiWindowMode);
- mFragments.dispatchMultiWindowModeChanged(isInMultiWindowMode);
- if (mWindow != null) {
- mWindow.onMultiWindowModeChanged();
- }
+ // Left deliberately empty. There should be no side effects if a direct
+ // subclass of Activity does not call super.
}
/**
@@ -1909,11 +1904,9 @@
*
* @param isInPictureInPictureMode True if the activity is in picture-in-picture mode.
*/
- @CallSuper
public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode) {
- if (DEBUG_LIFECYCLE) Slog.v(TAG,
- "onPictureInPictureModeChanged " + this + ": " + isInPictureInPictureMode);
- mFragments.dispatchPictureInPictureModeChanged(isInPictureInPictureMode);
+ // Left deliberately empty. There should be no side effects if a direct
+ // subclass of Activity does not call super.
}
/**
@@ -6875,6 +6868,23 @@
}
}
+ final void dispatchMultiWindowModeChanged(boolean isInMultiWindowMode) {
+ if (DEBUG_LIFECYCLE) Slog.v(TAG,
+ "dispatchMultiWindowModeChanged " + this + ": " + isInMultiWindowMode);
+ mFragments.dispatchMultiWindowModeChanged(isInMultiWindowMode);
+ if (mWindow != null) {
+ mWindow.onMultiWindowModeChanged();
+ }
+ onMultiWindowModeChanged(isInMultiWindowMode);
+ }
+
+ final void dispatchPictureInPictureModeChanged(boolean isInPictureInPictureMode) {
+ if (DEBUG_LIFECYCLE) Slog.v(TAG,
+ "dispatchPictureInPictureModeChanged " + this + ": " + isInPictureInPictureMode);
+ mFragments.dispatchPictureInPictureModeChanged(isInPictureInPictureMode);
+ onPictureInPictureModeChanged(isInPictureInPictureMode);
+ }
+
/**
* @hide
*/
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index ff8cf66..8a92b54 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -901,7 +901,7 @@
*/
static public int getMaxRecentTasksStatic() {
if (gMaxRecentTasks < 0) {
- return gMaxRecentTasks = isLowRamDeviceStatic() ? 50 : 100;
+ return gMaxRecentTasks = isLowRamDeviceStatic() ? 36 : 48;
}
return gMaxRecentTasks;
}
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index a39dbcb..061d924 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -558,7 +558,7 @@
return;
}
try {
- int bufferSize = SystemProperties.getInt("debug.traceview-buffer-size-in-mb", 8);
+ int bufferSize = SystemProperties.getInt("debug.traceview-buffer-size-mb", 8);
VMDebug.startMethodTracing(profileFile, profileFd.getFileDescriptor(),
bufferSize * 1024 * 1024, 0, samplingInterval != 0, samplingInterval);
profiling = true;
@@ -2915,14 +2915,14 @@
private void handleMultiWindowModeChanged(IBinder token, boolean isInMultiWindowMode) {
final ActivityClientRecord r = mActivities.get(token);
if (r != null) {
- r.activity.onMultiWindowModeChanged(isInMultiWindowMode);
+ r.activity.dispatchMultiWindowModeChanged(isInMultiWindowMode);
}
}
private void handlePictureInPictureModeChanged(IBinder token, boolean isInPipMode) {
final ActivityClientRecord r = mActivities.get(token);
if (r != null) {
- r.activity.onPictureInPictureModeChanged(isInPipMode);
+ r.activity.dispatchPictureInPictureModeChanged(isInPipMode);
}
}
diff --git a/core/java/android/app/LoadedApk.java b/core/java/android/app/LoadedApk.java
index e60712a..752dc1e 100644
--- a/core/java/android/app/LoadedApk.java
+++ b/core/java/android/app/LoadedApk.java
@@ -466,11 +466,7 @@
final boolean isBundledApp = mApplicationInfo.isSystemApp()
&& !mApplicationInfo.isUpdatedSystemApp();
- // Apps are allowed to open any native library under /data
- // TODO (dimitry):This is something which could be limited to apps own directory
- // later on but currently there are number of apps relying on this.
- // (see http://b/27588281 and http://b/26954419 for examples)
- String libraryPermittedPath = "/data";
+ String libraryPermittedPath = mDataDir;
if (isBundledApp) {
// This is necessary to grant bundled apps access to
// libraries located in subdirectories of /system/lib
diff --git a/core/java/android/app/usage/DataUsagePolicy.java b/core/java/android/app/usage/DataUsagePolicy.java
index 5a5dcbc..ee6b60c 100644
--- a/core/java/android/app/usage/DataUsagePolicy.java
+++ b/core/java/android/app/usage/DataUsagePolicy.java
@@ -29,6 +29,7 @@
/**
* Defines a policy for data usage callbacks, made through {@link DataUsagePolicy.Builder} and used
* to be notified on data usage via {@link NetworkStatsManager#registerDataUsageCallback}.
+ * @removed
*/
public class DataUsagePolicy {
diff --git a/core/java/android/app/usage/NetworkStats.java b/core/java/android/app/usage/NetworkStats.java
index 9963eab..226aa8f 100644
--- a/core/java/android/app/usage/NetworkStats.java
+++ b/core/java/android/app/usage/NetworkStats.java
@@ -193,14 +193,9 @@
public static final int ROAMING_YES = 0x2;
/**
- * Special TAG value matching any tag.
- */
- public static final int TAG_ANY = android.net.NetworkStats.TAG_ALL;
-
- /**
* Special TAG value for total data across all tags
*/
- public static final int TAG_ALL = android.net.NetworkStats.TAG_NONE;
+ public static final int TAG_NONE = android.net.NetworkStats.TAG_NONE;
private int mUid;
private int mTag;
@@ -232,8 +227,7 @@
private static int convertTag(int tag) {
switch (tag) {
- case android.net.NetworkStats.TAG_ALL: return TAG_ANY;
- case android.net.NetworkStats.TAG_NONE: return TAG_ALL;
+ case android.net.NetworkStats.TAG_NONE: return TAG_NONE;
}
return tag;
}
@@ -417,9 +411,9 @@
* Collects summary results and sets summary enumeration mode.
* @throws RemoteException
*/
- void startSummaryEnumeration(boolean includeTags) throws RemoteException {
+ void startSummaryEnumeration() throws RemoteException {
mSummary = mSession.getSummaryForAllUid(mTemplate, mStartTimeStamp, mEndTimeStamp,
- includeTags);
+ false /* includeTags */);
mEnumerationIndex = 0;
}
diff --git a/core/java/android/app/usage/NetworkStatsManager.java b/core/java/android/app/usage/NetworkStatsManager.java
index 2e3aca4..4a28117 100644
--- a/core/java/android/app/usage/NetworkStatsManager.java
+++ b/core/java/android/app/usage/NetworkStatsManager.java
@@ -106,7 +106,7 @@
* device. Result is a single Bucket aggregated over time, state, uid, tag and roaming. This
* means the bucket's start and end timestamp are going to be the same as the 'startTime' and
* 'endTime' parameters. State is going to be {@link NetworkStats.Bucket#STATE_ALL}, uid
- * {@link NetworkStats.Bucket#UID_ALL}, tag {@link NetworkStats.Bucket#TAG_ALL}
+ * {@link NetworkStats.Bucket#UID_ALL}, tag {@link NetworkStats.Bucket#TAG_NONE}
* and roaming {@link NetworkStats.Bucket#ROAMING_ALL}.
*
* @param networkType As defined in {@link ConnectivityManager}, e.g.
@@ -122,8 +122,11 @@
*/
public Bucket querySummaryForDevice(int networkType, String subscriberId,
long startTime, long endTime) throws SecurityException, RemoteException {
- NetworkTemplate template = createTemplate(networkType, subscriberId);
- if (template == null) {
+ NetworkTemplate template;
+ try {
+ template = createTemplate(networkType, subscriberId);
+ } catch (IllegalArgumentException e) {
+ if (DBG) Log.e(TAG, "Cannot create template", e);
return null;
}
@@ -136,21 +139,10 @@
}
/**
- * Query network usage statistics summaries aggregated across tags.
- *
- * #see querySummaryForUser(int, String, long, long, boolean)
- */
- public Bucket querySummaryForUser(int networkType, String subscriberId, long startTime,
- long endTime) throws SecurityException, RemoteException {
- return querySummaryForUser(networkType, subscriberId, startTime, endTime,
- false /* includeTags */);
- }
-
- /**
* Query network usage statistics summaries. Result is summarised data usage for all uids
* belonging to calling user. Result is a single Bucket aggregated over time, state and uid.
* This means the bucket's start and end timestamp are going to be the same as the 'startTime'
- * and 'endTime' parameters. State is going to be {@link NetworkStats.Bucket#STATE_ALL} and uid
+ * and 'endTime' parameters, state is going to be {@link NetworkStats.Bucket#STATE_ALL} and uid
* {@link NetworkStats.Bucket#UID_ALL}.
*
* @param networkType As defined in {@link ConnectivityManager}, e.g.
@@ -161,42 +153,33 @@
* {@link java.lang.System#currentTimeMillis}.
* @param endTime End of period. Defined in terms of "Unix time", see
* {@link java.lang.System#currentTimeMillis}.
- * @param includeTags whether to include network tags. If {@code true}, tags will be returned
- * and history retention may be shorter.
* @return Bucket object or null if permissions are insufficient or error happened during
* statistics collection.
*/
public Bucket querySummaryForUser(int networkType, String subscriberId, long startTime,
- long endTime, boolean includeTags) throws SecurityException, RemoteException {
- NetworkTemplate template = createTemplate(networkType, subscriberId);
- if (template == null) {
+ long endTime) throws SecurityException, RemoteException {
+ NetworkTemplate template;
+ try {
+ template = createTemplate(networkType, subscriberId);
+ } catch (IllegalArgumentException e) {
+ if (DBG) Log.e(TAG, "Cannot create template", e);
return null;
}
NetworkStats stats;
stats = new NetworkStats(mContext, template, startTime, endTime);
- stats.startSummaryEnumeration(includeTags);
+ stats.startSummaryEnumeration();
stats.close();
return stats.getSummaryAggregate();
}
/**
- * Query network usage statistics summaries aggregated across tags.
- *
- * #see querySummary(int, String, long, long, boolean)
- */
- public NetworkStats querySummary(int networkType, String subscriberId, long startTime,
- long endTime) throws SecurityException, RemoteException {
- return querySummary(networkType, subscriberId, startTime, endTime, false /* includeTags */);
- }
-
- /**
* Query network usage statistics summaries. Result filtered to include only uids belonging to
* calling user. Result is aggregated over time, hence all buckets will have the same start and
- * end timestamps. Not aggregated over state or uid or tag. This means buckets' start and end
- * timestamps are going to be the same as the 'startTime' and 'endTime' parameters. State,
- * uid and tag are going to vary.
+ * end timestamps. Not aggregated over state or uid. This means buckets' start and end
+ * timestamps are going to be the same as the 'startTime' and 'endTime' parameters.
+ * State and uid are going to vary, and tag is going to be the same.
*
* @param networkType As defined in {@link ConnectivityManager}, e.g.
* {@link ConnectivityManager#TYPE_MOBILE}, {@link ConnectivityManager#TYPE_WIFI}
@@ -206,21 +189,22 @@
* {@link java.lang.System#currentTimeMillis}.
* @param endTime End of period. Defined in terms of "Unix time", see
* {@link java.lang.System#currentTimeMillis}.
- * @param includeTags whether to include network tags. If {@code true}, tags will be returned
- * and history retention may be shorter.
* @return Statistics object or null if permissions are insufficient or error happened during
* statistics collection.
*/
public NetworkStats querySummary(int networkType, String subscriberId, long startTime,
- long endTime, boolean includeTags) throws SecurityException, RemoteException {
- NetworkTemplate template = createTemplate(networkType, subscriberId);
- if (template == null) {
+ long endTime) throws SecurityException, RemoteException {
+ NetworkTemplate template;
+ try {
+ template = createTemplate(networkType, subscriberId);
+ } catch (IllegalArgumentException e) {
+ if (DBG) Log.e(TAG, "Cannot create template", e);
return null;
}
NetworkStats result;
result = new NetworkStats(mContext, template, startTime, endTime);
- result.startSummaryEnumeration(includeTags);
+ result.startSummaryEnumeration();
return result;
}
@@ -233,7 +217,7 @@
public NetworkStats queryDetailsForUid(int networkType, String subscriberId,
long startTime, long endTime, int uid) throws SecurityException, RemoteException {
return queryDetailsForUidTag(networkType, subscriberId, startTime, endTime, uid,
- NetworkStats.Bucket.TAG_ALL);
+ NetworkStats.Bucket.TAG_NONE);
}
/**
@@ -255,22 +239,28 @@
* @param endTime End of period. Defined in terms of "Unix time", see
* {@link java.lang.System#currentTimeMillis}.
* @param uid UID of app
- * @param tag TAG of interest. Use {@link NetworkStats.Bucket#TAG_ANY} for any tags, use
- * {@link NetworkStats.Bucket#TAG_ALL} to aggregate over tags.
+ * @param tag TAG of interest. Use {@link NetworkStats.Bucket#TAG_NONE} for no tags.
* @return Statistics object or null if permissions are insufficient or error happened during
* statistics collection.
*/
public NetworkStats queryDetailsForUidTag(int networkType, String subscriberId,
- long startTime, long endTime, int uid, int tag) throws SecurityException,
- RemoteException {
- NetworkTemplate template = createTemplate(networkType, subscriberId);
- if (template == null) {
+ long startTime, long endTime, int uid, int tag) {
+ NetworkTemplate template;
+ try {
+ template = createTemplate(networkType, subscriberId);
+ } catch (IllegalArgumentException e) {
+ if (DBG) Log.e(TAG, "Cannot create template", e);
return null;
}
NetworkStats result;
- result = new NetworkStats(mContext, template, startTime, endTime);
- result.startHistoryEnumeration(uid, tag);
+ try {
+ result = new NetworkStats(mContext, template, startTime, endTime);
+ result.startHistoryEnumeration(uid, tag);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error while querying stats for uid=" + uid + " tag=" + tag, e);
+ return null;
+ }
return result;
}
@@ -280,7 +270,7 @@
* calling user. Result is aggregated over state but not aggregated over time or uid. This means
* buckets' start and end timestamps are going to be between 'startTime' and 'endTime'
* parameters. State is going to be {@link NetworkStats.Bucket#STATE_ALL}, uid will vary,
- * tag {@link NetworkStats.Bucket#TAG_ALL} and roaming is going to be
+ * tag {@link NetworkStats.Bucket#TAG_NONE} and roaming is going to be
* {@link NetworkStats.Bucket#ROAMING_ALL}.
* <p>Only includes buckets that atomically occur in the inclusive time range. Doesn't
* interpolate across partial buckets. Since bucket length is in the order of hours, this
@@ -299,44 +289,59 @@
*/
public NetworkStats queryDetails(int networkType, String subscriberId, long startTime,
long endTime) throws SecurityException, RemoteException {
- NetworkTemplate template = createTemplate(networkType, subscriberId);
- if (template == null) {
+ NetworkTemplate template;
+ try {
+ template = createTemplate(networkType, subscriberId);
+ } catch (IllegalArgumentException e) {
+ if (DBG) Log.e(TAG, "Cannot create template", e);
return null;
}
+
NetworkStats result;
result = new NetworkStats(mContext, template, startTime, endTime);
result.startUserUidEnumeration();
return result;
}
+ /** @removed */
+ public void registerDataUsageCallback(DataUsagePolicy policy, DataUsageCallback callback,
+ @Nullable Handler handler) {}
+
+ /** @removed */
+ public void registerDataUsageCallback(DataUsagePolicy policy, UsageCallback callback,
+ @Nullable Handler handler) {}
+
+ /** @removed */
+ public void unregisterDataUsageCallback(DataUsageCallback callback) {}
+
/**
- * Registers to receive notifications about data usage on specified networks and uids.
- * The callbacks will continue to be called as long as the process is live or
- * {@link #unregisterDataUsageCallback} is called.
+ * Registers to receive notifications about data usage on specified networks.
*
- * @param policy {@link DataUsagePolicy} describing this request.
- * @param callback The {@link DataUsageCallback} that the system will call when data usage
- * has exceeded the specified threshold.
+ * #see registerUsageCallback(int, String[], long, UsageCallback, Handler)
*/
- public void registerDataUsageCallback(DataUsagePolicy policy, DataUsageCallback callback) {
- registerDataUsageCallback(policy, callback, null /* handler */);
+ public void registerUsageCallback(int networkType, String subscriberId, long thresholdBytes,
+ UsageCallback callback) {
+ registerUsageCallback(networkType, subscriberId, thresholdBytes, null /* handler */);
}
/**
- * Registers to receive notifications about data usage on specified networks and uids.
- * The callbacks will continue to be called as long as the process is live or
- * {@link #unregisterDataUsageCallback} is called.
+ * Registers to receive notifications about data usage on specified networks.
*
- * @param policy {@link DataUsagePolicy} describing this request.
- * @param callback The {@link DataUsageCallback} that the system will call when data usage
+ * <p>The callbacks will continue to be called as long as the process is live or
+ * {@link #unregisterUsageCallback} is called.
+ *
+ * @param networkType Type of network to monitor. Either
+ {@link ConnectivityManager#TYPE_MOBILE} or {@link ConnectivityManager#TYPE_WIFI}.
+ * @param subscriberId If applicable, the subscriber id of the network interface.
+ * @param thresholdBytes Threshold in bytes to be notified on.
+ * @param callback The {@link UsageCallback} that the system will call when data usage
* has exceeded the specified threshold.
* @param handler to dispatch callback events through, otherwise if {@code null} it uses
* the calling thread.
*/
- public void registerDataUsageCallback(DataUsagePolicy policy, DataUsageCallback callback,
- @Nullable Handler handler) {
- checkNotNull(policy, "DataUsagePolicy cannot be null");
- checkNotNull(callback, "DataUsageCallback cannot be null");
+ public void registerUsageCallback(int networkType, String subscriberId, long thresholdBytes,
+ UsageCallback callback, @Nullable Handler handler) {
+ checkNotNull(callback, "UsageCallback cannot be null");
final Looper looper;
if (handler == null) {
@@ -345,62 +350,72 @@
looper = handler.getLooper();
}
- if (DBG) Log.d(TAG, "registerDataUsageCallback called with " + policy);
-
- NetworkTemplate[] templates;
- if (policy.subscriberIds == null || policy.subscriberIds.length == 0) {
- templates = new NetworkTemplate[1];
- templates[0] = createTemplate(policy.networkType, null /* subscriberId */);
- } else {
- templates = new NetworkTemplate[policy.subscriberIds.length];
- for (int i = 0; i < policy.subscriberIds.length; i++) {
- templates[i] = createTemplate(policy.networkType, policy.subscriberIds[i]);
- }
+ if (DBG) {
+ Log.d(TAG, "registerUsageCallback called with: {"
+ + " networkType=" + networkType
+ + " subscriberId=" + subscriberId
+ + " thresholdBytes=" + thresholdBytes
+ + " }");
}
+
+ NetworkTemplate template = createTemplate(networkType, subscriberId);
DataUsageRequest request = new DataUsageRequest(DataUsageRequest.REQUEST_ID_UNSET,
- templates, policy.uids, policy.thresholdInBytes);
+ template, thresholdBytes);
try {
- CallbackHandler callbackHandler = new CallbackHandler(looper, callback);
- callback.request = mService.registerDataUsageCallback(
+ CallbackHandler callbackHandler = new CallbackHandler(looper, networkType,
+ subscriberId, callback);
+ callback.request = mService.registerUsageCallback(
mContext.getOpPackageName(), request, new Messenger(callbackHandler),
new Binder());
- if (DBG) Log.d(TAG, "registerDataUsageCallback returned " + callback.request);
+ if (DBG) Log.d(TAG, "registerUsageCallback returned " + callback.request);
if (callback.request == null) {
Log.e(TAG, "Request from callback is null; should not happen");
}
} catch (RemoteException e) {
if (DBG) Log.d(TAG, "Remote exception when registering callback");
+ throw e.rethrowFromSystemServer();
}
}
/**
* Unregisters callbacks on data usage.
*
- * @param callback The {@link DataUsageCallback} used when registering.
+ * @param callback The {@link UsageCallback} used when registering.
*/
- public void unregisterDataUsageCallback(DataUsageCallback callback) {
+ public void unregisterUsageCallback(UsageCallback callback) {
if (callback == null || callback.request == null
|| callback.request.requestId == DataUsageRequest.REQUEST_ID_UNSET) {
- throw new IllegalArgumentException("Invalid DataUsageCallback");
+ throw new IllegalArgumentException("Invalid UsageCallback");
}
try {
- mService.unregisterDataUsageRequest(callback.request);
+ mService.unregisterUsageRequest(callback.request);
} catch (RemoteException e) {
if (DBG) Log.d(TAG, "Remote exception when unregistering callback");
+ throw e.rethrowFromSystemServer();
}
}
- /**
- * Base class for data usage callbacks. Should be extended by applications wanting
- * notifications.
- */
- public static class DataUsageCallback {
- /**
- * Called when data usage has reached the given policy threshold.
- */
+ /** @removed */
+ public static abstract class DataUsageCallback {
+ /** @removed */
+ @Deprecated
public void onLimitReached() {}
+ }
+ /**
+ * Base class for usage callbacks. Should be extended by applications wanting notifications.
+ */
+ public static abstract class UsageCallback {
+
+ /**
+ * Called when data usage has reached the given threshold.
+ */
+ public abstract void onThresholdReached(int networkType, String subscriberId);
+
+ /**
+ * @hide used for internal bookkeeping
+ */
private DataUsageRequest request;
}
@@ -414,18 +429,24 @@
template = NetworkTemplate.buildTemplateWifiWildcard();
} break;
default: {
- Log.w(TAG, "Cannot create template for network type " + networkType
- + ", subscriberId '" + NetworkIdentity.scrubSubscriberId(subscriberId) +
- "'.");
+ throw new IllegalArgumentException("Cannot create template for network type "
+ + networkType + ", subscriberId '"
+ + NetworkIdentity.scrubSubscriberId(subscriberId) + "'.");
}
}
return template;
}
private static class CallbackHandler extends Handler {
- private DataUsageCallback mCallback;
- CallbackHandler(Looper looper, DataUsageCallback callback) {
+ private final int mNetworkType;
+ private final String mSubscriberId;
+ private UsageCallback mCallback;
+
+ CallbackHandler(Looper looper, int networkType, String subscriberId,
+ UsageCallback callback) {
super(looper);
+ mNetworkType = networkType;
+ mSubscriberId = subscriberId;
mCallback = callback;
}
@@ -437,7 +458,7 @@
switch (message.what) {
case CALLBACK_LIMIT_REACHED: {
if (mCallback != null) {
- mCallback.onLimitReached();
+ mCallback.onThresholdReached(mNetworkType, mSubscriberId);
} else {
Log.e(TAG, "limit reached with released callback for " + request);
}
diff --git a/core/java/android/net/DataUsageRequest.java b/core/java/android/net/DataUsageRequest.java
index 8526584..ac9a5a3 100644
--- a/core/java/android/net/DataUsageRequest.java
+++ b/core/java/android/net/DataUsageRequest.java
@@ -20,7 +20,6 @@
import android.os.Parcel;
import android.os.Parcelable;
-import java.util.Arrays;
import java.util.Objects;
/**
@@ -28,56 +27,33 @@
* {@link android.app.usage.NetworkStatsManager#registerDataUsageCallback}.
* If no {@code uid}s are set, callbacks are restricted to device-owners,
* carrier-privileged apps, or system apps.
+ *
+ * @hide
*/
public final class DataUsageRequest implements Parcelable {
- /**
- * @hide
- */
public static final String PARCELABLE_KEY = "DataUsageRequest";
-
- /**
- * @hide
- */
public static final int REQUEST_ID_UNSET = 0;
/**
* Identifies the request. {@link DataUsageRequest}s should only be constructed by
* the Framework and it is used internally to identify the request.
- * @hide
*/
public final int requestId;
/**
- * Set of {@link NetworkTemplate}s describing the networks to monitor.
- * @hide
+ * {@link NetworkTemplate} describing the network to monitor.
*/
- public final NetworkTemplate[] templates;
-
- /**
- * Set of UIDs of which to monitor data usage.
- *
- * <p>If not {@code null}, the caller will be notified when any of the uids exceed
- * the given threshold. If {@code null} all uids for which the calling process has access
- * to stats will be monitored.
- * @hide
- */
- public final int[] uids;
+ public final NetworkTemplate template;
/**
* Threshold in bytes to be notified on.
- * @hide
*/
public final long thresholdInBytes;
- /**
- * @hide
- */
- public DataUsageRequest(int requestId, NetworkTemplate[] templates, int[] uids,
- long thresholdInBytes) {
+ public DataUsageRequest(int requestId, NetworkTemplate template, long thresholdInBytes) {
this.requestId = requestId;
- this.templates = templates;
- this.uids = uids;
+ this.template = template;
this.thresholdInBytes = thresholdInBytes;
}
@@ -89,8 +65,7 @@
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(requestId);
- dest.writeTypedArray(templates, flags);
- dest.writeIntArray(uids);
+ dest.writeParcelable(template, flags);
dest.writeLong(thresholdInBytes);
}
@@ -99,11 +74,10 @@
@Override
public DataUsageRequest createFromParcel(Parcel in) {
int requestId = in.readInt();
- NetworkTemplate[] templates = in.createTypedArray(NetworkTemplate.CREATOR);
- int[] uids = in.createIntArray();
+ NetworkTemplate template = in.readParcelable(null);
long thresholdInBytes = in.readLong();
- DataUsageRequest result = new DataUsageRequest(requestId,
- templates, uids, thresholdInBytes);
+ DataUsageRequest result = new DataUsageRequest(requestId, template,
+ thresholdInBytes);
return result;
}
@@ -116,8 +90,7 @@
@Override
public String toString() {
return "DataUsageRequest [ requestId=" + requestId
- + ", networkTemplates=" + Arrays.toString(templates)
- + ", uids=" + Arrays.toString(uids)
+ + ", networkTemplate=" + template
+ ", thresholdInBytes=" + thresholdInBytes + " ]";
}
@@ -126,23 +99,13 @@
if (obj instanceof DataUsageRequest == false) return false;
DataUsageRequest that = (DataUsageRequest) obj;
return that.requestId == this.requestId
- && Arrays.deepEquals(that.templates, this.templates)
- && Arrays.equals(that.uids, this.uids)
+ && Objects.equals(that.template, this.template)
&& that.thresholdInBytes == this.thresholdInBytes;
}
@Override
public int hashCode() {
- // Start with a non-zero constant.
- int result = 17;
-
- // Include a hash for each field.
- result = 31 * result + requestId;
- result = 31 * result + Arrays.deepHashCode(templates);
- result = 31 * result + Arrays.hashCode(uids);
- result = 31 * result + (int) (thresholdInBytes ^ (thresholdInBytes >>> 32));
-
- return result;
+ return Objects.hash(requestId, template, thresholdInBytes);
}
}
diff --git a/core/java/android/net/INetworkStatsService.aidl b/core/java/android/net/INetworkStatsService.aidl
index 2eea940..e693009 100644
--- a/core/java/android/net/INetworkStatsService.aidl
+++ b/core/java/android/net/INetworkStatsService.aidl
@@ -61,10 +61,10 @@
void advisePersistThreshold(long thresholdBytes);
/** Registers a callback on data usage. */
- DataUsageRequest registerDataUsageCallback(String callingPackage,
+ DataUsageRequest registerUsageCallback(String callingPackage,
in DataUsageRequest request, in Messenger messenger, in IBinder binder);
/** Unregisters a callback on data usage. */
- void unregisterDataUsageRequest(in DataUsageRequest request);
+ void unregisterUsageRequest(in DataUsageRequest request);
}
diff --git a/core/java/android/os/storage/IMountService.java b/core/java/android/os/storage/IMountService.java
index b9bcd1c..3915b02 100644
--- a/core/java/android/os/storage/IMountService.java
+++ b/core/java/android/os/storage/IMountService.java
@@ -1233,8 +1233,8 @@
}
@Override
- public void addUserKeyAuth(int userId, int serialNumber,
- byte[] token, byte[] secret) throws RemoteException {
+ public void changeUserKey(int userId, int serialNumber,
+ byte[] token, byte[] oldSecret, byte[] newSecret) throws RemoteException {
Parcel _data = Parcel.obtain();
Parcel _reply = Parcel.obtain();
try {
@@ -1242,23 +1242,9 @@
_data.writeInt(userId);
_data.writeInt(serialNumber);
_data.writeByteArray(token);
- _data.writeByteArray(secret);
- mRemote.transact(Stub.TRANSACTION_addUserKeyAuth, _data, _reply, 0);
- _reply.readException();
- } finally {
- _reply.recycle();
- _data.recycle();
- }
- }
-
- @Override
- public void fixateNewestUserKeyAuth(int userId) throws RemoteException {
- Parcel _data = Parcel.obtain();
- Parcel _reply = Parcel.obtain();
- try {
- _data.writeInterfaceToken(DESCRIPTOR);
- _data.writeInt(userId);
- mRemote.transact(Stub.TRANSACTION_fixateNewestUserKeyAuth, _data, _reply, 0);
+ _data.writeByteArray(oldSecret);
+ _data.writeByteArray(newSecret);
+ mRemote.transact(Stub.TRANSACTION_changeUserKey, _data, _reply, 0);
_reply.readException();
} finally {
_reply.recycle();
@@ -1503,9 +1489,7 @@
static final int TRANSACTION_mountAppFuse = IBinder.FIRST_CALL_TRANSACTION + 69;
- static final int TRANSACTION_addUserKeyAuth = IBinder.FIRST_CALL_TRANSACTION + 70;
-
- static final int TRANSACTION_fixateNewestUserKeyAuth = IBinder.FIRST_CALL_TRANSACTION + 71;
+ static final int TRANSACTION_changeUserKey = IBinder.FIRST_CALL_TRANSACTION + 70;
/**
* Cast an IBinder object into an IMountService interface, generating a
@@ -2085,20 +2069,14 @@
reply.writeNoException();
return true;
}
- case TRANSACTION_addUserKeyAuth: {
+ case TRANSACTION_changeUserKey: {
data.enforceInterface(DESCRIPTOR);
int userId = data.readInt();
int serialNumber = data.readInt();
byte[] token = data.createByteArray();
- byte[] secret = data.createByteArray();
- addUserKeyAuth(userId, serialNumber, token, secret);
- reply.writeNoException();
- return true;
- }
- case TRANSACTION_fixateNewestUserKeyAuth: {
- data.enforceInterface(DESCRIPTOR);
- int userId = data.readInt();
- fixateNewestUserKeyAuth(userId);
+ byte[] oldSecret = data.createByteArray();
+ byte[] newSecret = data.createByteArray();
+ changeUserKey(userId, serialNumber, token, oldSecret, newSecret);
reply.writeNoException();
return true;
}
@@ -2474,9 +2452,8 @@
public void createUserKey(int userId, int serialNumber, boolean ephemeral)
throws RemoteException;
public void destroyUserKey(int userId) throws RemoteException;
- public void addUserKeyAuth(int userId, int serialNumber,
- byte[] token, byte[] secret) throws RemoteException;
- public void fixateNewestUserKeyAuth(int userId) throws RemoteException;
+ public void changeUserKey(int userId, int serialNumber,
+ byte[] token, byte[] oldSecret, byte[] newSecret) throws RemoteException;
public void unlockUserKey(int userId, int serialNumber,
byte[] token, byte[] secret) throws RemoteException;
diff --git a/core/java/android/text/StaticLayout.java b/core/java/android/text/StaticLayout.java
index 239f2d0..bb131a0 100644
--- a/core/java/android/text/StaticLayout.java
+++ b/core/java/android/text/StaticLayout.java
@@ -754,15 +754,21 @@
&& ellipsize != TextUtils.TruncateAt.MARQUEE));
if (remainingLineCount > 0 && remainingLineCount < breakCount &&
ellipsisMayBeApplied) {
- // Treat the last line and overflowed lines as a single line.
- breaks[remainingLineCount - 1] = breaks[breakCount - 1];
// Calculate width and flag.
float width = 0;
int flag = 0;
for (int i = remainingLineCount - 1; i < breakCount; i++) {
- width += lineWidths[i];
+ if (i == breakCount - 1) {
+ width += lineWidths[i];
+ } else {
+ for (int j = (i == 0 ? 0 : breaks[i - 1]); j < breaks[i]; j++) {
+ width += widths[j];
+ }
+ }
flag |= flags[i] & TAB_MASK;
}
+ // Treat the last line and overflowed lines as a single line.
+ breaks[remainingLineCount - 1] = breaks[breakCount - 1];
lineWidths[remainingLineCount - 1] = width;
flags[remainingLineCount - 1] = flag;
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 8cabf42..130b440 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -125,6 +125,7 @@
private static final boolean DEBUG_CONFIGURATION = false || LOCAL_LOGV;
private static final boolean DEBUG_FPS = false;
private static final boolean DEBUG_INPUT_STAGES = false || LOCAL_LOGV;
+ private static final boolean DEBUG_KEEP_SCREEN_ON = false || LOCAL_LOGV;
/**
* Set to false if we do not want to use the multi threaded renderer. Note that by disabling
@@ -563,9 +564,10 @@
attrs = mWindowAttributes;
setTag();
- if ((mClientWindowLayoutFlags&WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) != 0
+ if (DEBUG_KEEP_SCREEN_ON && (mClientWindowLayoutFlags
+ & WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) != 0
&& (attrs.flags&WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) == 0) {
- Slog.d(mTag, "setView: FLAG_KEEP_SCREEN_ON changed from true to false!!!");
+ Slog.d(mTag, "setView: FLAG_KEEP_SCREEN_ON changed from true to false!");
}
// Keep track of the actual window flags supplied by the client.
mClientWindowLayoutFlags = attrs.flags;
@@ -894,9 +896,11 @@
final int oldInsetBottom = mWindowAttributes.surfaceInsets.bottom;
final int oldSoftInputMode = mWindowAttributes.softInputMode;
final boolean oldHasManualSurfaceInsets = mWindowAttributes.hasManualSurfaceInsets;
- if ((mClientWindowLayoutFlags&WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) != 0
+
+ if (DEBUG_KEEP_SCREEN_ON && (mClientWindowLayoutFlags
+ & WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) != 0
&& (attrs.flags&WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) == 0) {
- Slog.d(mTag, "setLayoutParams: FLAG_KEEP_SCREEN_ON from true to false!!!");
+ Slog.d(mTag, "setLayoutParams: FLAG_KEEP_SCREEN_ON from true to false!");
}
// Keep track of the actual window flags supplied by the client.
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index e68d8a6..c2ff4ef 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -2420,7 +2420,10 @@
android:protectionLevel="signature|privileged" />
<!-- @SystemApi Allows an application to delete packages.
- <p>Not for use by third-party applications. -->
+ <p>Not for use by third-party applications.
+ <p>Starting in {@link android.os.Build.VERSION_CODES#N}, user confirmation is requested
+ when the application deleting the package is not the same application that installed the
+ package. -->
<permission android:name="android.permission.DELETE_PACKAGES"
android:protectionLevel="signature|privileged" />
diff --git a/docs/html/_redirects.yaml b/docs/html/_redirects.yaml
index efe0f8a..d13a635 100644
--- a/docs/html/_redirects.yaml
+++ b/docs/html/_redirects.yaml
@@ -1128,7 +1128,7 @@
- from: /installing/studio-androidview.html
to: /studio/projects/index.html
- from: /installing/studio-tips.html
- to: /studio/guide/guide-intro.html
+ to: /studio/intro/index.html
- from: /tools/help/ddms.html
to: /studio/profile/ddms.html
- from: /tools/revisions/index.html
diff --git a/media/jni/android_media_Utils.cpp b/media/jni/android_media_Utils.cpp
index 62685c9..359ebad 100644
--- a/media/jni/android_media_Utils.cpp
+++ b/media/jni/android_media_Utils.cpp
@@ -31,7 +31,7 @@
namespace android {
AssetStream::AssetStream(SkStream* stream)
- : mStream(stream) {
+ : mStream(stream), mPosition(0) {
}
AssetStream::~AssetStream() {
@@ -48,7 +48,7 @@
// Read bytes.
size_t size = mStream->read((void*)data, length);
- mPosition += size;
+ mPosition = offset + size;
return size == length ? piex::Error::kOk : piex::Error::kFail;
}
diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
index e1695e0..7f977dd 100644
--- a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
+++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
@@ -1737,7 +1737,7 @@
}
if (userState.mIsDisplayMagnificationEnabled ||
- userHasMagnificationServicesLocked(userState)) {
+ userHasListeningMagnificationServicesLocked(userState)) {
// Initialize the magnification controller if necessary
getMagnificationController();
mMagnificationController.register();
@@ -1761,6 +1761,22 @@
return false;
}
+ /**
+ * Returns whether the specified user has any services that are capable of
+ * controlling magnification and are actively listening for magnification updates.
+ */
+ private boolean userHasListeningMagnificationServicesLocked(UserState userState) {
+ final List<Service> services = userState.mBoundServices;
+ for (int i = 0, count = services.size(); i < count; i++) {
+ final Service service = services.get(i);
+ if (mSecurityPolicy.canControlMagnification(service)
+ && service.mInvocationHandler.mIsMagnificationCallbackEnabled) {
+ return true;
+ }
+ }
+ return false;
+ }
+
private void updateSoftKeyboardShowModeLocked(UserState userState) {
final int userId = userState.mUserId;
// Only check whether we need to reset the soft keyboard mode if it is not set to the
@@ -2864,19 +2880,28 @@
}
@Override
- public Region getMagnifiedRegion() {
+ public Region getMagnificationRegion() {
synchronized (mLock) {
- if (!isCalledForCurrentUserLocked()) {
- return Region.obtain();
- }
- }
- final long identity = Binder.clearCallingIdentity();
- try {
final Region region = Region.obtain();
- getMagnificationController().getMagnificationRegion(region);
- return region;
- } finally {
- Binder.restoreCallingIdentity(identity);
+ if (!isCalledForCurrentUserLocked()) {
+ return region;
+ }
+ MagnificationController magnificationController = getMagnificationController();
+ boolean forceRegistration = mSecurityPolicy.canControlMagnification(this);
+ boolean initiallyRegistered = magnificationController.isRegisteredLocked();
+ if (!initiallyRegistered && forceRegistration) {
+ magnificationController.register();
+ }
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ magnificationController.getMagnificationRegion(region);
+ return region;
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ if (!initiallyRegistered && forceRegistration) {
+ magnificationController.unregister();
+ }
+ }
}
}
@@ -2940,13 +2965,17 @@
if (!permissionGranted) {
return false;
}
- }
- final long identity = Binder.clearCallingIdentity();
- try {
- return getMagnificationController().setScaleAndCenter(
- scale, centerX, centerY, animate, mId);
- } finally {
- Binder.restoreCallingIdentity(identity);
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ MagnificationController magnificationController = getMagnificationController();
+ if (!magnificationController.isRegisteredLocked()) {
+ magnificationController.register();
+ }
+ return magnificationController
+ .setScaleAndCenter(scale, centerX, centerY, animate, mId);
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
}
}
diff --git a/services/accessibility/java/com/android/server/accessibility/MagnificationController.java b/services/accessibility/java/com/android/server/accessibility/MagnificationController.java
index 027b6e2..7886b9e 100644
--- a/services/accessibility/java/com/android/server/accessibility/MagnificationController.java
+++ b/services/accessibility/java/com/android/server/accessibility/MagnificationController.java
@@ -151,6 +151,15 @@
}
}
+ /**
+ * Check if we are registered. Note that we may be planning to unregister at any moment.
+ *
+ * @return {@code true} if the controller is registered. {@code false} otherwise.
+ */
+ public boolean isRegisteredLocked() {
+ return mRegistered;
+ }
+
private void unregisterInternalLocked() {
if (mRegistered) {
mSpecAnimationBridge.setEnabled(false);
@@ -179,6 +188,10 @@
*/
private void onMagnificationRegionChanged(Region magnified, boolean updateSpec) {
synchronized (mLock) {
+ if (!mRegistered) {
+ // Don't update if we've unregistered
+ return;
+ }
boolean magnificationChanged = false;
boolean boundsChanged = false;
diff --git a/services/core/java/com/android/server/LockSettingsService.java b/services/core/java/com/android/server/LockSettingsService.java
index c2a1c50..5b6117d 100644
--- a/services/core/java/com/android/server/LockSettingsService.java
+++ b/services/core/java/com/android/server/LockSettingsService.java
@@ -340,8 +340,9 @@
}
public void onUnlockUser(int userId) {
- tieManagedProfileLockIfNecessary(userId, null);
+ // Hide notification first, as tie managed profile lock takes time
hideEncryptionNotification(new UserHandle(userId));
+ tieManagedProfileLockIfNecessary(userId, null);
// Now we have unlocked the parent user we should show notifications
// about any profiles that exist.
@@ -789,11 +790,10 @@
if (isSecure) {
tieManagedProfileLockIfNecessary(managedUserId, null);
} else {
- clearUserKeyProtection(managedUserId);
getGateKeeperService().clearSecureUserId(managedUserId);
mStorage.writePatternHash(null, managedUserId);
setKeystorePassword(null, managedUserId);
- fixateNewestUserKeyAuth(managedUserId);
+ clearUserKeyProtection(managedUserId);
mStorage.removeChildProfileLock(managedUserId);
removeKeystoreProfileKey(managedUserId);
}
@@ -828,11 +828,10 @@
byte[] currentHandle = getCurrentHandle(userId);
if (pattern == null) {
- clearUserKeyProtection(userId);
getGateKeeperService().clearSecureUserId(userId);
mStorage.writePatternHash(null, userId);
setKeystorePassword(null, userId);
- fixateNewestUserKeyAuth(userId);
+ clearUserKeyProtection(userId);
onUserLockChanged(userId);
return;
}
@@ -862,12 +861,8 @@
byte[] enrolledHandle = enrollCredential(currentHandle, savedCredential, pattern, userId);
if (enrolledHandle != null) {
- CredentialHash willStore
- = new CredentialHash(enrolledHandle, CredentialHash.VERSION_GATEKEEPER);
- setUserKeyProtection(userId, pattern,
- doVerifyPattern(pattern, willStore, true, 0, userId));
mStorage.writePatternHash(enrolledHandle, userId);
- fixateNewestUserKeyAuth(userId);
+ setUserKeyProtection(userId, pattern, verifyPattern(pattern, 0, userId));
onUserLockChanged(userId);
} else {
throw new RemoteException("Failed to enroll pattern");
@@ -890,11 +885,10 @@
throws RemoteException {
byte[] currentHandle = getCurrentHandle(userId);
if (password == null) {
- clearUserKeyProtection(userId);
getGateKeeperService().clearSecureUserId(userId);
mStorage.writePasswordHash(null, userId);
setKeystorePassword(null, userId);
- fixateNewestUserKeyAuth(userId);
+ clearUserKeyProtection(userId);
onUserLockChanged(userId);
return;
}
@@ -922,12 +916,8 @@
byte[] enrolledHandle = enrollCredential(currentHandle, savedCredential, password, userId);
if (enrolledHandle != null) {
- CredentialHash willStore
- = new CredentialHash(enrolledHandle, CredentialHash.VERSION_GATEKEEPER);
- setUserKeyProtection(userId, password,
- doVerifyPassword(password, willStore, true, 0, userId));
mStorage.writePasswordHash(enrolledHandle, userId);
- fixateNewestUserKeyAuth(userId);
+ setUserKeyProtection(userId, password, verifyPassword(password, 0, userId));
onUserLockChanged(userId);
} else {
throw new RemoteException("Failed to enroll password");
@@ -1032,11 +1022,11 @@
if (token == null) {
throw new RemoteException("Empty payload verifying a credential we just set");
}
- addUserKeyAuth(userId, token, secretFromCredential(credential));
+ changeUserKey(userId, token, secretFromCredential(credential));
}
private void clearUserKeyProtection(int userId) throws RemoteException {
- addUserKeyAuth(userId, null, null);
+ changeUserKey(userId, null, null);
}
private static byte[] secretFromCredential(String credential) throws RemoteException {
@@ -1055,23 +1045,18 @@
}
}
- private void addUserKeyAuth(int userId, byte[] token, byte[] secret)
+ private void changeUserKey(int userId, byte[] token, byte[] secret)
throws RemoteException {
final UserInfo userInfo = UserManager.get(mContext).getUserInfo(userId);
final IMountService mountService = getMountService();
final long callingId = Binder.clearCallingIdentity();
try {
- mountService.addUserKeyAuth(userId, userInfo.serialNumber, token, secret);
+ mountService.changeUserKey(userId, userInfo.serialNumber, token, null, secret);
} finally {
Binder.restoreCallingIdentity(callingId);
}
}
- private void fixateNewestUserKeyAuth(int userId)
- throws RemoteException {
- getMountService().fixateNewestUserKeyAuth(userId);
- }
-
@Override
public VerifyCredentialResponse checkPattern(String pattern, int userId) throws RemoteException {
return doVerifyPattern(pattern, false, 0, userId);
@@ -1087,11 +1072,6 @@
long challenge, int userId) throws RemoteException {
checkPasswordReadPermission(userId);
CredentialHash storedHash = mStorage.readPatternHash(userId);
- return doVerifyPattern(pattern, storedHash, hasChallenge, challenge, userId);
- }
-
- private VerifyCredentialResponse doVerifyPattern(String pattern, CredentialHash storedHash,
- boolean hasChallenge, long challenge, int userId) throws RemoteException {
boolean shouldReEnrollBaseZero = storedHash != null && storedHash.isBaseZeroPattern;
String patternToVerify;
@@ -1129,6 +1109,7 @@
}
return response;
+
}
@Override
@@ -1178,11 +1159,6 @@
long challenge, int userId) throws RemoteException {
checkPasswordReadPermission(userId);
CredentialHash storedHash = mStorage.readPasswordHash(userId);
- return doVerifyPassword(password, storedHash, hasChallenge, challenge, userId);
- }
-
- private VerifyCredentialResponse doVerifyPassword(String password, CredentialHash storedHash,
- boolean hasChallenge, long challenge, int userId) throws RemoteException {
return verifyCredential(userId, storedHash, password, hasChallenge, challenge,
new CredentialUtil() {
@Override
diff --git a/services/core/java/com/android/server/LockSettingsStorage.java b/services/core/java/com/android/server/LockSettingsStorage.java
index ab91a73..9ab6300 100644
--- a/services/core/java/com/android/server/LockSettingsStorage.java
+++ b/services/core/java/com/android/server/LockSettingsStorage.java
@@ -74,7 +74,7 @@
private SparseArray<Integer> mStoredCredentialType;
- static class CredentialHash {
+ class CredentialHash {
static final int TYPE_NONE = -1;
static final int TYPE_PATTERN = 1;
static final int TYPE_PASSWORD = 2;
diff --git a/services/core/java/com/android/server/MountService.java b/services/core/java/com/android/server/MountService.java
index c89b6ea..25ce485 100644
--- a/services/core/java/com/android/server/MountService.java
+++ b/services/core/java/com/android/server/MountService.java
@@ -2816,36 +2816,15 @@
}
}
- /*
- * Add this token/secret pair to the set of ways we can recover a disk encryption key.
- * Changing the token/secret for a disk encryption key is done in two phases: first, adding
- * a new token/secret pair with this call, then delting all other pairs with
- * fixateNewestUserKeyAuth. This allows other places where a credential is used, such as
- * Gatekeeper, to be updated between the two calls.
- */
@Override
- public void addUserKeyAuth(int userId, int serialNumber, byte[] token, byte[] secret) {
+ public void changeUserKey(int userId, int serialNumber,
+ byte[] token, byte[] oldSecret, byte[] newSecret) {
enforcePermission(android.Manifest.permission.STORAGE_INTERNAL);
waitForReady();
try {
- mCryptConnector.execute("cryptfs", "add_user_key_auth", userId, serialNumber,
- encodeBytes(token), encodeBytes(secret));
- } catch (NativeDaemonConnectorException e) {
- throw e.rethrowAsParcelableException();
- }
- }
-
- /*
- * Delete all disk encryption token/secret pairs except the most recently added one
- */
- @Override
- public void fixateNewestUserKeyAuth(int userId) {
- enforcePermission(android.Manifest.permission.STORAGE_INTERNAL);
- waitForReady();
-
- try {
- mCryptConnector.execute("cryptfs", "fixate_newest_user_key_auth", userId);
+ mCryptConnector.execute("cryptfs", "change_user_key", userId, serialNumber,
+ encodeBytes(token), encodeBytes(oldSecret), encodeBytes(newSecret));
} catch (NativeDaemonConnectorException e) {
throw e.rethrowAsParcelableException();
}
diff --git a/services/core/java/com/android/server/am/ServiceRecord.java b/services/core/java/com/android/server/am/ServiceRecord.java
index bc297de..0a081e9 100644
--- a/services/core/java/com/android/server/am/ServiceRecord.java
+++ b/services/core/java/com/android/server/am/ServiceRecord.java
@@ -441,7 +441,7 @@
Notification localForegroundNoti = _foregroundNoti;
try {
if (localForegroundNoti.getSmallIcon() == null) {
- // It is not correct for the caller to supply a notification
+ // It is not correct for the caller to not supply a notification
// icon, but this used to be able to slip through, so for
// those dirty apps we will create a notification clearly
// blaming the app.
@@ -458,8 +458,8 @@
}
Context ctx = null;
try {
- ctx = ams.mContext.createPackageContext(
- appInfo.packageName, 0);
+ ctx = ams.mContext.createPackageContextAsUser(
+ appInfo.packageName, 0, new UserHandle(userId));
Notification.Builder notiBuilder = new Notification.Builder(ctx);
diff --git a/services/core/java/com/android/server/net/NetworkStatsObservers.java b/services/core/java/com/android/server/net/NetworkStatsObservers.java
index 6f781b3..230c2e9 100644
--- a/services/core/java/com/android/server/net/NetworkStatsObservers.java
+++ b/services/core/java/com/android/server/net/NetworkStatsObservers.java
@@ -81,8 +81,6 @@
*/
public DataUsageRequest register(DataUsageRequest inputRequest, Messenger messenger,
IBinder binder, int callingUid, @NetworkStatsAccess.Level int accessLevel) {
- checkVisibilityUids(callingUid, accessLevel, inputRequest.uids);
-
DataUsageRequest request = buildRequest(inputRequest);
RequestInfo requestInfo = buildRequestInfo(request, messenger, binder, callingUid,
accessLevel);
@@ -211,14 +209,13 @@
+ ". Overriding to a safer default of " + thresholdInBytes + " bytes");
}
return new DataUsageRequest(mNextDataUsageRequestId.incrementAndGet(),
- request.templates, request.uids, thresholdInBytes);
+ request.template, thresholdInBytes);
}
private RequestInfo buildRequestInfo(DataUsageRequest request,
Messenger messenger, IBinder binder, int callingUid,
@NetworkStatsAccess.Level int accessLevel) {
- if (accessLevel <= NetworkStatsAccess.Level.USER
- || request.uids != null && request.uids.length > 0) {
+ if (accessLevel <= NetworkStatsAccess.Level.USER) {
return new UserUsageRequestInfo(this, request, messenger, binder, callingUid,
accessLevel);
} else {
@@ -229,19 +226,6 @@
}
}
- private void checkVisibilityUids(int callingUid, @NetworkStatsAccess.Level int accessLevel,
- int[] uids) {
- if (uids == null) {
- return;
- }
- for (int i = 0; i < uids.length; i++) {
- if (!NetworkStatsAccess.isAccessibleToUser(uids[i], callingUid, accessLevel)) {
- throw new SecurityException("Caller " + callingUid + " cannot monitor network stats"
- + " for uid " + uids[i] + " with accessLevel " + accessLevel);
- }
- }
- }
-
/**
* Tracks information relevant to a data usage observer.
* It will notice when the calling process dies so we can self-expire.
@@ -359,15 +343,13 @@
@Override
protected boolean checkStats() {
- for (int i = 0; i < mRequest.templates.length; i++) {
- long bytesSoFar = getTotalBytesForNetwork(mRequest.templates[i]);
- if (LOGV) {
- Slog.v(TAG, bytesSoFar + " bytes so far since notification for "
- + mRequest.templates[i]);
- }
- if (bytesSoFar > mRequest.thresholdInBytes) {
- return true;
- }
+ long bytesSoFar = getTotalBytesForNetwork(mRequest.template);
+ if (LOGV) {
+ Slog.v(TAG, bytesSoFar + " bytes so far since notification for "
+ + mRequest.template);
+ }
+ if (bytesSoFar > mRequest.thresholdInBytes) {
+ return true;
}
return false;
}
@@ -405,20 +387,17 @@
@Override
protected boolean checkStats() {
- int[] uidsToMonitor = getUidsToMonitor();
+ int[] uidsToMonitor = mCollection.getRelevantUids(mAccessLevel, mCallingUid);
- for (int i = 0; i < mRequest.templates.length; i++) {
- for (int j = 0; j < uidsToMonitor.length; j++) {
- long bytesSoFar = getTotalBytesForNetworkUid(mRequest.templates[i],
- uidsToMonitor[j]);
+ for (int i = 0; i < uidsToMonitor.length; i++) {
+ long bytesSoFar = getTotalBytesForNetworkUid(mRequest.template, uidsToMonitor[i]);
- if (LOGV) {
- Slog.v(TAG, bytesSoFar + " bytes so far since notification for "
- + mRequest.templates[i] + " for uid=" + uidsToMonitor[j]);
- }
- if (bytesSoFar > mRequest.thresholdInBytes) {
- return true;
- }
+ if (LOGV) {
+ Slog.v(TAG, bytesSoFar + " bytes so far since notification for "
+ + mRequest.template + " for uid=" + uidsToMonitor[i]);
+ }
+ if (bytesSoFar > mRequest.thresholdInBytes) {
+ return true;
}
}
return false;
@@ -453,21 +432,6 @@
return 0;
}
}
-
- private int[] getUidsToMonitor() {
- if (mRequest.uids == null || mRequest.uids.length == 0) {
- return mCollection.getRelevantUids(mAccessLevel, mCallingUid);
- }
- // Pick only uids from the request that are currently accessible to the user
- IntArray accessibleUids = new IntArray(mRequest.uids.length);
- for (int i = 0; i < mRequest.uids.length; i++) {
- int uid = mRequest.uids[i];
- if (NetworkStatsAccess.isAccessibleToUser(uid, mCallingUid, mAccessLevel)) {
- accessibleUids.add(uid);
- }
- }
- return accessibleUids.toArray();
- }
}
private static class StatsContext {
diff --git a/services/core/java/com/android/server/net/NetworkStatsService.java b/services/core/java/com/android/server/net/NetworkStatsService.java
index 2c2e9b9..8610fa1 100644
--- a/services/core/java/com/android/server/net/NetworkStatsService.java
+++ b/services/core/java/com/android/server/net/NetworkStatsService.java
@@ -578,9 +578,12 @@
if (tag == TAG_NONE) {
return getUidComplete().getHistory(template, uid, set, tag, fields, start, end,
accessLevel);
- } else {
+ } else if (uid == Binder.getCallingUid()) {
return getUidTagComplete().getHistory(template, uid, set, tag, fields,
start, end, accessLevel);
+ } else {
+ throw new SecurityException("Calling package " + mCallingPackage
+ + " cannot access tag information from a different uid");
}
}
@@ -761,12 +764,11 @@
}
@Override
- public DataUsageRequest registerDataUsageCallback(String callingPackage,
+ public DataUsageRequest registerUsageCallback(String callingPackage,
DataUsageRequest request, Messenger messenger, IBinder binder) {
checkNotNull(callingPackage, "calling package is null");
checkNotNull(request, "DataUsageRequest is null");
- checkNotNull(request.templates, "NetworkTemplate is null");
- checkArgument(request.templates.length > 0);
+ checkNotNull(request.template, "NetworkTemplate is null");
checkNotNull(messenger, "messenger is null");
checkNotNull(binder, "binder is null");
@@ -788,7 +790,7 @@
}
@Override
- public void unregisterDataUsageRequest(DataUsageRequest request) {
+ public void unregisterUsageRequest(DataUsageRequest request) {
checkNotNull(request, "DataUsageRequest is null");
int callingUid = Binder.getCallingUid();
diff --git a/services/core/java/com/android/server/wm/AppWindowAnimator.java b/services/core/java/com/android/server/wm/AppWindowAnimator.java
index 49dab0a..a37b65a 100644
--- a/services/core/java/com/android/server/wm/AppWindowAnimator.java
+++ b/services/core/java/com/android/server/wm/AppWindowAnimator.java
@@ -185,8 +185,7 @@
clearThumbnail();
setNullAnimation();
if (mAppToken.deferClearAllDrawn) {
- mAppToken.allDrawn = false;
- mAppToken.deferClearAllDrawn = false;
+ mAppToken.clearAllDrawn();
}
mStackClip = STACK_CLIP_BEFORE_ANIM;
}
diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java
index de613aa..a234241 100644
--- a/services/core/java/com/android/server/wm/AppWindowToken.java
+++ b/services/core/java/com/android/server/wm/AppWindowToken.java
@@ -27,6 +27,7 @@
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import static com.android.server.wm.WindowManagerService.WINDOW_REPLACEMENT_TIMEOUT_DURATION;
+import static com.android.server.wm.WindowManagerService.H.NOTIFY_ACTIVITY_DRAWN;
import com.android.server.input.InputApplicationHandle;
import com.android.server.wm.WindowManagerService.H;
@@ -65,10 +66,6 @@
final boolean voiceInteraction;
- // Whether we're performing an entering animation with a saved surface.
- boolean mAnimatingWithSavedSurface;
-
-
Task mTask;
boolean appFullscreen;
int requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
@@ -160,6 +157,13 @@
}
}
+ void setVisibleBeforeClientHidden() {
+ for (int i = allAppWindows.size() - 1; i >= 0; i--) {
+ final WindowState w = allAppWindows.get(i);
+ w.setVisibleBeforeClientHidden();
+ }
+ }
+
void onFirstWindowDrawn(WindowState win, WindowStateAnimator winAnimator) {
firstWindowDrawn = true;
@@ -295,7 +299,7 @@
// If we're animating with a saved surface, we're already visible.
// Return true so that the alpha doesn't get cleared.
if (!win.mAppFreezing
- && (win.mViewVisibility == View.VISIBLE || mAnimatingWithSavedSurface
+ && (win.mViewVisibility == View.VISIBLE || win.isAnimatingWithSavedSurface()
|| (win.mWinAnimator.isAnimationSet()
&& !service.mAppTransition.isTransitionSet()))
&& !win.mDestroying
@@ -347,7 +351,6 @@
win.destroyOrSaveSurface();
if (win.mRemoveOnExit) {
- win.mAnimatingExit = false;
service.removeWindowInnerLocked(win);
}
final DisplayContent displayContent = win.getDisplayContent();
@@ -391,43 +394,56 @@
return allDrawn;
}
- boolean hasSavedSurface() {
+ boolean canRestoreSurfaces() {
for (int i = allAppWindows.size() -1; i >= 0; i--) {
- final WindowState ws = allAppWindows.get(i);
- if (ws.hasSavedSurface()) {
+ final WindowState w = allAppWindows.get(i);
+ if (w.canRestoreSurface()) {
return true;
}
}
return false;
}
+ void clearVisibleBeforeClientHidden() {
+ for (int i = allAppWindows.size() - 1; i >= 0; i--) {
+ final WindowState w = allAppWindows.get(i);
+ w.clearVisibleBeforeClientHidden();
+ }
+ }
+
void restoreSavedSurfaces() {
- if (!hasSavedSurface()) {
+ if (!canRestoreSurfaces()) {
+ clearVisibleBeforeClientHidden();
return;
}
- mAnimatingWithSavedSurface = true;
-
// Check if we have enough drawn windows to mark allDrawn= true.
int numInteresting = 0;
int numDrawn = 0;
for (int i = allAppWindows.size() - 1; i >= 0; i--) {
WindowState w = allAppWindows.get(i);
- if (w.hasSavedSurface()) {
- w.restoreSavedSurface();
- }
- if (w != startingWindow && !w.mAppDied
+ if (w != startingWindow && !w.mAppDied && w.wasVisibleBeforeClientHidden()
&& (!mAppAnimator.freezingScreen || !w.mAppFreezing)) {
numInteresting++;
+ if (w.hasSavedSurface()) {
+ w.restoreSavedSurface();
+ }
if (w.isDrawnLw()) {
numDrawn++;
}
}
}
- allDrawn |= (numInteresting > 0) && (numInteresting == numDrawn);
+ if (!allDrawn) {
+ allDrawn = (numInteresting > 0) && (numInteresting == numDrawn);
+ if (allDrawn) {
+ service.mH.obtainMessage(NOTIFY_ACTIVITY_DRAWN, token).sendToTarget();
+ }
+ }
+ clearVisibleBeforeClientHidden();
if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.d(TAG,
- "restoreSavedSurfaces: " + appWindowToken + " allDrawn=" + allDrawn);
+ "restoreSavedSurfaces: " + appWindowToken + " allDrawn=" + allDrawn
+ + " numInteresting=" + numInteresting + " numDrawn=" + numDrawn);
}
void destroySavedSurfaces() {
@@ -435,7 +451,11 @@
WindowState win = allAppWindows.get(i);
win.destroySavedSurface();
}
- mAnimatingWithSavedSurface = false;
+ }
+
+ void clearAllDrawn() {
+ allDrawn = false;
+ deferClearAllDrawn = false;
}
@Override
diff --git a/services/core/java/com/android/server/wm/DockedStackDividerController.java b/services/core/java/com/android/server/wm/DockedStackDividerController.java
index ca68d55..6142511 100644
--- a/services/core/java/com/android/server/wm/DockedStackDividerController.java
+++ b/services/core/java/com/android/server/wm/DockedStackDividerController.java
@@ -377,6 +377,10 @@
checkMinimizeChanged(true /* animate */);
}
+ boolean isMinimizedDock() {
+ return mMinimizedDock;
+ }
+
private void checkMinimizeChanged(boolean animate) {
if (mDisplayContent.getDockedStackVisibleForUserLocked() == null) {
return;
diff --git a/services/core/java/com/android/server/wm/WindowManagerDebugConfig.java b/services/core/java/com/android/server/wm/WindowManagerDebugConfig.java
index 5d3cc16..f11281e 100644
--- a/services/core/java/com/android/server/wm/WindowManagerDebugConfig.java
+++ b/services/core/java/com/android/server/wm/WindowManagerDebugConfig.java
@@ -75,5 +75,5 @@
static final boolean DEBUG_WINDOW_CROP = false;
static final String TAG_KEEP_SCREEN_ON = "DebugKeepScreenOn";
- static final boolean DEBUG_KEEP_SCREEN_ON = true;
+ static final boolean DEBUG_KEEP_SCREEN_ON = false;
}
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index be888fe..a0b8c35 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -2170,7 +2170,7 @@
* Returns true if we're done setting up any transitions.
*/
private boolean prepareWindowReplacementTransition(AppWindowToken atoken) {
- atoken.allDrawn = false;
+ atoken.clearAllDrawn();
WindowState replacedWindow = null;
for (int i = atoken.windows.size() - 1; i >= 0 && replacedWindow == null; i--) {
WindowState candidate = atoken.windows.get(i);
@@ -2316,7 +2316,7 @@
if (DEBUG_ADD_REMOVE) Slog.v(TAG_WM, "Preserving " + win + " until the new one is "
+ "added");
// TODO: We are overloading mAnimatingExit flag to prevent the window state from
- // been removed. We probably need another falg to indicate that window removal
+ // been removed. We probably need another flag to indicate that window removal
// should be deffered vs. overloading the flag that says we are playing an exit
// animation.
win.mAnimatingExit = true;
@@ -2464,7 +2464,7 @@
mTokenMap.remove(token.token);
} else if (atoken != null) {
atoken.firstWindowDrawn = false;
- atoken.allDrawn = false;
+ atoken.clearAllDrawn();
}
}
@@ -4423,6 +4423,7 @@
// Now that the app is going invisible, we can remove it. It will be restarted
// if made visible again.
wtoken.removeAllDeadWindows();
+ wtoken.setVisibleBeforeClientHidden();
} else if (visible) {
if (!mAppTransition.isTransitionSet() && mAppTransition.isReady()) {
// Add the app mOpeningApps if transition is unset but ready. This means
@@ -4434,8 +4435,7 @@
// If the token is currently hidden (should be the common case), or has been
// stopped, then we need to set up to wait for its windows to be ready.
if (wtoken.hidden || wtoken.mAppStopped) {
- wtoken.allDrawn = false;
- wtoken.deferClearAllDrawn = false;
+ wtoken.clearAllDrawn();
// If the app was already visible, don't reset the waitingToShow state.
if (wtoken.hidden) {
@@ -7534,6 +7534,7 @@
imeTargetStack.getDockSide() : DOCKED_INVALID;
final boolean imeOnTop = (imeDockSide == DOCKED_TOP);
final boolean imeOnBottom = (imeDockSide == DOCKED_BOTTOM);
+ final boolean dockMinimized = displayContent.mDividerControllerLocked.isMinimizedDock();
// The divider could be adjusted for IME position, or be thinner than usual,
// or both. There are three possible cases:
@@ -7541,7 +7542,7 @@
// - If IME is visible, and focus is on bottom, divider is moved for IME and thinner.
// - If IME is not visible, divider is not moved and is normal width.
- if (imeVisible && dockVisible && (imeOnTop || imeOnBottom)) {
+ if (imeVisible && dockVisible && (imeOnTop || imeOnBottom) && !dockMinimized) {
final ArrayList<TaskStack> stacks = displayContent.getStacks();
for (int i = stacks.size() - 1; i >= 0; --i) {
final TaskStack stack = stacks.get(i);
@@ -9233,8 +9234,7 @@
}
winAnimator.mDrawState = DRAW_PENDING;
if (w.mAppToken != null) {
- w.mAppToken.allDrawn = false;
- w.mAppToken.deferClearAllDrawn = false;
+ w.mAppToken.clearAllDrawn();
}
}
if (!mResizingWindows.contains(w)) {
@@ -9391,7 +9391,7 @@
Slog.w(TAG_WM, "LEAKED SURFACE (app token hidden): "
+ ws + " surface=" + wsa.mSurfaceController
+ " token=" + ws.mAppToken
- + " saved=" + ws.mAppToken.hasSavedSurface());
+ + " saved=" + ws.hasSavedSurface());
if (SHOW_TRANSACTIONS) logSurface(ws, "LEAK DESTROY", false);
wsa.destroySurface();
leakedSurface = true;
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index a89b4aa..b66de89 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -435,7 +435,15 @@
// Whether the window has a saved surface from last pause, which can be
// used to start an entering animation earlier.
- public boolean mSurfaceSaved = false;
+ private boolean mSurfaceSaved = false;
+
+ // Whether we're performing an entering animation with a saved surface.
+ private boolean mAnimatingWithSavedSurface;
+
+ // Whether the window was visible when we set the app to invisible last time. WM uses
+ // this as a hint to restore the surface (if available) for early animation next time
+ // the app is brought visible.
+ boolean mWasVisibleBeforeClientHidden;
// This window will be replaced due to relaunch. This allows window manager
// to differentiate between simple removal of a window and replacement. In the latter case it
@@ -1949,7 +1957,20 @@
}
boolean isAnimatingWithSavedSurface() {
- return mAppToken != null && mAppToken.mAnimatingWithSavedSurface;
+ return mAnimatingWithSavedSurface;
+ }
+
+ public void setVisibleBeforeClientHidden() {
+ mWasVisibleBeforeClientHidden |=
+ (mViewVisibility == View.VISIBLE || mAnimatingWithSavedSurface);
+ }
+
+ public void clearVisibleBeforeClientHidden() {
+ mWasVisibleBeforeClientHidden = false;
+ }
+
+ public boolean wasVisibleBeforeClientHidden() {
+ return mWasVisibleBeforeClientHidden;
}
private boolean shouldSaveSurface() {
@@ -1958,6 +1979,10 @@
return false;
}
+ if (!mWasVisibleBeforeClientHidden) {
+ return false;
+ }
+
if ((mAttrs.flags & FLAG_SECURE) != 0) {
// We don't save secure surfaces since their content shouldn't be shown while the app
// isn't on screen and content might leak through during the transition animation with
@@ -2020,18 +2045,22 @@
} else {
mWinAnimator.destroySurfaceLocked();
}
+ // Clear animating flags now, since the surface is now gone. (Note this is true even
+ // if the surface is saved, to outside world the surface is still NO_SURFACE.)
+ mAnimatingExit = false;
}
- public void destroySavedSurface() {
+ void destroySavedSurface() {
if (mSurfaceSaved) {
if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) {
Slog.v(TAG, "Destroying saved surface: " + this);
}
mWinAnimator.destroySurfaceLocked();
}
+ mWasVisibleBeforeClientHidden = false;
}
- public void restoreSavedSurface() {
+ void restoreSavedSurface() {
if (!mSurfaceSaved) {
return;
}
@@ -2039,6 +2068,7 @@
if (mWinAnimator.mSurfaceController != null) {
setHasSurface(true);
mWinAnimator.mDrawState = WindowStateAnimator.READY_TO_SHOW;
+ mAnimatingWithSavedSurface = true;
if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) {
Slog.v(TAG, "Restoring saved surface: " + this);
@@ -2051,10 +2081,30 @@
}
}
- public boolean hasSavedSurface() {
+ boolean canRestoreSurface() {
+ return mWasVisibleBeforeClientHidden && mSurfaceSaved;
+ }
+
+ boolean hasSavedSurface() {
return mSurfaceSaved;
}
+ void clearHasSavedSurface() {
+ mSurfaceSaved = false;
+ mAnimatingWithSavedSurface = false;
+ mWasVisibleBeforeClientHidden = false;
+ }
+
+ void clearAnimatingWithSavedSurface() {
+ if (mAnimatingWithSavedSurface) {
+ // App has drawn something to its windows, we're no longer animating with
+ // the saved surfaces.
+ if (DEBUG_ANIM) Slog.d(TAG,
+ "clearAnimatingWithSavedSurface(): win=" + this);
+ mAnimatingWithSavedSurface = false;
+ }
+ }
+
@Override
public boolean isDefaultDisplay() {
final DisplayContent displayContent = getDisplayContent();
diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java
index f88e30b..f0bba4a 100644
--- a/services/core/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java
@@ -584,14 +584,8 @@
+ drawStateToString());
}
- if (mWin.mAppToken != null && mWin.mAppToken.mAnimatingWithSavedSurface) {
- // App has drawn something to its windows, we're no longer animating with
- // the saved surfaces. If the user exits now, we only want to save again
- // if allDrawn is true.
- if (DEBUG_ANIM) Slog.d(TAG,
- "finishDrawingLocked: mAnimatingWithSavedSurface=false " + mWin);
- mWin.mAppToken.mAnimatingWithSavedSurface = false;
- }
+ mWin.clearAnimatingWithSavedSurface();
+
if (mDrawState == DRAW_PENDING) {
if (DEBUG_SURFACE_TRACE || DEBUG_ANIM || SHOW_TRANSACTIONS || DEBUG_ORIENTATION)
Slog.v(TAG, "finishDrawingLocked: mDrawState=COMMIT_DRAW_PENDING " + mWin + " in "
@@ -687,8 +681,7 @@
mDrawState = DRAW_PENDING;
if (w.mAppToken != null) {
if (w.mAppToken.mAppAnimator.animation == null) {
- w.mAppToken.allDrawn = false;
- w.mAppToken.deferClearAllDrawn = false;
+ w.mAppToken.clearAllDrawn();
} else {
// Currently animating, persist current state of allDrawn until animation
// is complete.
@@ -840,20 +833,19 @@
}
boolean hasSurface() {
- return !mWin.mSurfaceSaved
+ return !mWin.hasSavedSurface()
&& mSurfaceController != null && mSurfaceController.hasSurface();
}
void destroySurfaceLocked() {
final AppWindowToken wtoken = mWin.mAppToken;
if (wtoken != null) {
- wtoken.mAnimatingWithSavedSurface = false;
if (mWin == wtoken.startingWindow) {
wtoken.startingDisplayed = false;
}
}
- mWin.mSurfaceSaved = false;
+ mWin.clearHasSavedSurface();
if (mSurfaceController == null) {
return;
diff --git a/services/tests/servicestests/src/com/android/server/net/NetworkStatsObserversTest.java b/services/tests/servicestests/src/com/android/server/net/NetworkStatsObserversTest.java
index cff5876..21560ac 100644
--- a/services/tests/servicestests/src/com/android/server/net/NetworkStatsObserversTest.java
+++ b/services/tests/servicestests/src/com/android/server/net/NetworkStatsObserversTest.java
@@ -56,7 +56,7 @@
import com.android.server.net.NetworkStatsServiceTest.LatchedHandler;
import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.Objects;
import java.util.List;
import junit.framework.TestCase;
@@ -91,7 +91,6 @@
private static final long BASE_BYTES = 7 * MB_IN_BYTES;
private static final int INVALID_TYPE = -1;
- private static final int[] NO_UIDS = null;
private static final VpnInfo[] VPN_INFO = new VpnInfo[0];
private long mElapsedRealtime;
@@ -134,112 +133,60 @@
public void testRegister_thresholdTooLow_setsDefaultThreshold() throws Exception {
long thresholdTooLowBytes = 1L;
- NetworkTemplate[] templates = new NetworkTemplate[] { sTemplateWifi };
DataUsageRequest inputRequest = new DataUsageRequest(
- DataUsageRequest.REQUEST_ID_UNSET, templates, NO_UIDS, thresholdTooLowBytes);
+ DataUsageRequest.REQUEST_ID_UNSET, sTemplateWifi, thresholdTooLowBytes);
DataUsageRequest request = mStatsObservers.register(inputRequest, mMessenger, mockBinder,
Process.SYSTEM_UID, NetworkStatsAccess.Level.DEVICE);
assertTrue(request.requestId > 0);
- assertTrue(Arrays.deepEquals(templates, request.templates));
- assertNull(request.uids);
+ assertTrue(Objects.equals(sTemplateWifi, request.template));
assertEquals(THRESHOLD_BYTES, request.thresholdInBytes);
}
public void testRegister_highThreshold_accepted() throws Exception {
long highThresholdBytes = 2 * THRESHOLD_BYTES;
- NetworkTemplate[] templates = new NetworkTemplate[] { sTemplateWifi };
DataUsageRequest inputRequest = new DataUsageRequest(
- DataUsageRequest.REQUEST_ID_UNSET, templates, NO_UIDS, highThresholdBytes);
+ DataUsageRequest.REQUEST_ID_UNSET, sTemplateWifi, highThresholdBytes);
DataUsageRequest request = mStatsObservers.register(inputRequest, mMessenger, mockBinder,
Process.SYSTEM_UID, NetworkStatsAccess.Level.DEVICE);
assertTrue(request.requestId > 0);
- assertTrue(Arrays.deepEquals(templates, request.templates));
- assertNull(request.uids);
+ assertTrue(Objects.equals(sTemplateWifi, request.template));
assertEquals(highThresholdBytes, request.thresholdInBytes);
}
public void testRegister_twoRequests_twoIds() throws Exception {
- NetworkTemplate[] templates = new NetworkTemplate[] { sTemplateWifi };
DataUsageRequest inputRequest = new DataUsageRequest(
- DataUsageRequest.REQUEST_ID_UNSET, templates, NO_UIDS, THRESHOLD_BYTES);
+ DataUsageRequest.REQUEST_ID_UNSET, sTemplateWifi, THRESHOLD_BYTES);
DataUsageRequest request1 = mStatsObservers.register(inputRequest, mMessenger, mockBinder,
Process.SYSTEM_UID, NetworkStatsAccess.Level.DEVICE);
assertTrue(request1.requestId > 0);
- assertTrue(Arrays.deepEquals(templates, request1.templates));
- assertNull(request1.uids);
+ assertTrue(Objects.equals(sTemplateWifi, request1.template));
assertEquals(THRESHOLD_BYTES, request1.thresholdInBytes);
DataUsageRequest request2 = mStatsObservers.register(inputRequest, mMessenger, mockBinder,
Process.SYSTEM_UID, NetworkStatsAccess.Level.DEVICE);
assertTrue(request2.requestId > request1.requestId);
- assertTrue(Arrays.deepEquals(templates, request2.templates));
- assertNull(request2.uids);
+ assertTrue(Objects.equals(sTemplateWifi, request2.template));
assertEquals(THRESHOLD_BYTES, request2.thresholdInBytes);
}
- public void testRegister_defaultAccess_otherUids_securityException() throws Exception {
- NetworkTemplate[] templates = new NetworkTemplate[] { sTemplateImsi1 };
- int[] uids = new int[] { UID_RED, UID_BLUE, UID_GREEN };
- DataUsageRequest inputRequest = new DataUsageRequest(
- DataUsageRequest.REQUEST_ID_UNSET, templates, uids, THRESHOLD_BYTES);
-
- try {
- mStatsObservers.register(inputRequest, mMessenger, mockBinder, UID_RED,
- NetworkStatsAccess.Level.DEFAULT);
- fail("Should have denied access");
- } catch (SecurityException expected) {}
- }
-
- public void testRegister_userAccess_otherUidsSameUser()
- throws Exception {
- NetworkTemplate[] templates = new NetworkTemplate[] { sTemplateImsi1 };
- int[] uids = new int[] { UID_RED, UID_BLUE, UID_GREEN };
- DataUsageRequest inputRequest = new DataUsageRequest(
- DataUsageRequest.REQUEST_ID_UNSET, templates, uids, THRESHOLD_BYTES);
-
- DataUsageRequest request = mStatsObservers.register(inputRequest, mMessenger, mockBinder,
- UID_RED, NetworkStatsAccess.Level.USER);
- assertTrue(request.requestId > 0);
- assertTrue(Arrays.deepEquals(templates, request.templates));
- assertTrue(Arrays.equals(uids, request.uids));
- assertEquals(THRESHOLD_BYTES, request.thresholdInBytes);
- }
-
- public void testRegister_defaultAccess_sameUid() throws Exception {
- NetworkTemplate[] templates = new NetworkTemplate[] { sTemplateImsi1 };
- int[] uids = new int[] { UID_RED };
- DataUsageRequest inputRequest = new DataUsageRequest(
- DataUsageRequest.REQUEST_ID_UNSET, templates, uids, THRESHOLD_BYTES);
-
- DataUsageRequest request = mStatsObservers.register(inputRequest, mMessenger, mockBinder,
- UID_RED, NetworkStatsAccess.Level.DEFAULT);
- assertTrue(request.requestId > 0);
- assertTrue(Arrays.deepEquals(templates, request.templates));
- assertTrue(Arrays.equals(uids, request.uids));
- assertEquals(THRESHOLD_BYTES, request.thresholdInBytes);
- }
-
public void testUnregister_unknownRequest_noop() throws Exception {
- NetworkTemplate[] templates = new NetworkTemplate[] { sTemplateWifi };
DataUsageRequest unknownRequest = new DataUsageRequest(
- 123456 /* id */, templates, NO_UIDS, THRESHOLD_BYTES);
+ 123456 /* id */, sTemplateWifi, THRESHOLD_BYTES);
mStatsObservers.unregister(unknownRequest, UID_RED);
}
public void testUnregister_knownRequest_releasesCaller() throws Exception {
- NetworkTemplate[] templates = new NetworkTemplate[] { sTemplateImsi1 };
DataUsageRequest inputRequest = new DataUsageRequest(
- DataUsageRequest.REQUEST_ID_UNSET, templates, NO_UIDS, THRESHOLD_BYTES);
+ DataUsageRequest.REQUEST_ID_UNSET, sTemplateImsi1, THRESHOLD_BYTES);
DataUsageRequest request = mStatsObservers.register(inputRequest, mMessenger, mockBinder,
Process.SYSTEM_UID, NetworkStatsAccess.Level.DEVICE);
assertTrue(request.requestId > 0);
- assertTrue(Arrays.deepEquals(templates, request.templates));
- assertNull(request.uids);
+ assertTrue(Objects.equals(sTemplateImsi1, request.template));
assertEquals(THRESHOLD_BYTES, request.thresholdInBytes);
Mockito.verify(mockBinder).linkToDeath(any(IBinder.DeathRecipient.class), anyInt());
@@ -250,15 +197,13 @@
}
public void testUnregister_knownRequest_invalidUid_doesNotUnregister() throws Exception {
- NetworkTemplate[] templates = new NetworkTemplate[] { sTemplateImsi1 };
DataUsageRequest inputRequest = new DataUsageRequest(
- DataUsageRequest.REQUEST_ID_UNSET, templates, NO_UIDS, THRESHOLD_BYTES);
+ DataUsageRequest.REQUEST_ID_UNSET, sTemplateImsi1, THRESHOLD_BYTES);
DataUsageRequest request = mStatsObservers.register(inputRequest, mMessenger, mockBinder,
UID_RED, NetworkStatsAccess.Level.DEVICE);
assertTrue(request.requestId > 0);
- assertTrue(Arrays.deepEquals(templates, request.templates));
- assertNull(request.uids);
+ assertTrue(Objects.equals(sTemplateImsi1, request.template));
assertEquals(THRESHOLD_BYTES, request.thresholdInBytes);
Mockito.verify(mockBinder).linkToDeath(any(IBinder.DeathRecipient.class), anyInt());
@@ -269,15 +214,13 @@
}
public void testUpdateStats_initialSample_doesNotNotify() throws Exception {
- NetworkTemplate[] templates = new NetworkTemplate[] { sTemplateImsi1 };
DataUsageRequest inputRequest = new DataUsageRequest(
- DataUsageRequest.REQUEST_ID_UNSET, templates, NO_UIDS, THRESHOLD_BYTES);
+ DataUsageRequest.REQUEST_ID_UNSET, sTemplateImsi1, THRESHOLD_BYTES);
DataUsageRequest request = mStatsObservers.register(inputRequest, mMessenger, mockBinder,
Process.SYSTEM_UID, NetworkStatsAccess.Level.DEVICE);
assertTrue(request.requestId > 0);
- assertTrue(Arrays.deepEquals(templates, request.templates));
- assertNull(request.uids);
+ assertTrue(Objects.equals(sTemplateImsi1, request.template));
assertEquals(THRESHOLD_BYTES, request.thresholdInBytes);
NetworkIdentitySet identSet = new NetworkIdentitySet();
@@ -301,15 +244,13 @@
}
public void testUpdateStats_belowThreshold_doesNotNotify() throws Exception {
- NetworkTemplate[] templates = new NetworkTemplate[] { sTemplateImsi1 };
DataUsageRequest inputRequest = new DataUsageRequest(
- DataUsageRequest.REQUEST_ID_UNSET, templates, NO_UIDS, THRESHOLD_BYTES);
+ DataUsageRequest.REQUEST_ID_UNSET, sTemplateImsi1, THRESHOLD_BYTES);
DataUsageRequest request = mStatsObservers.register(inputRequest, mMessenger, mockBinder,
Process.SYSTEM_UID, NetworkStatsAccess.Level.DEVICE);
assertTrue(request.requestId > 0);
- assertTrue(Arrays.deepEquals(templates, request.templates));
- assertNull(request.uids);
+ assertTrue(Objects.equals(sTemplateImsi1, request.template));
assertEquals(THRESHOLD_BYTES, request.thresholdInBytes);
NetworkIdentitySet identSet = new NetworkIdentitySet();
@@ -339,16 +280,14 @@
assertEquals(INVALID_TYPE, mHandler.mLastMessageType);
}
- public void testUpdateStats_aboveThresholdNetwork_notifies() throws Exception {
- NetworkTemplate[] templates = new NetworkTemplate[] { sTemplateImsi1 };
+ public void testUpdateStats_deviceAccess_notifies() throws Exception {
DataUsageRequest inputRequest = new DataUsageRequest(
- DataUsageRequest.REQUEST_ID_UNSET, templates, NO_UIDS, THRESHOLD_BYTES);
+ DataUsageRequest.REQUEST_ID_UNSET, sTemplateImsi1, THRESHOLD_BYTES);
DataUsageRequest request = mStatsObservers.register(inputRequest, mMessenger, mockBinder,
Process.SYSTEM_UID, NetworkStatsAccess.Level.DEVICE);
assertTrue(request.requestId > 0);
- assertTrue(Arrays.deepEquals(templates, request.templates));
- assertNull(request.uids);
+ assertTrue(Objects.equals(sTemplateImsi1, request.template));
assertEquals(THRESHOLD_BYTES, request.thresholdInBytes);
NetworkIdentitySet identSet = new NetworkIdentitySet();
@@ -378,104 +317,14 @@
assertEquals(NetworkStatsManager.CALLBACK_LIMIT_REACHED, mHandler.mLastMessageType);
}
- public void testUpdateStats_aboveThresholdMultipleNetwork_notifies() throws Exception {
- NetworkTemplate[] templates = new NetworkTemplate[] { sTemplateImsi1, sTemplateImsi2 };
+ public void testUpdateStats_defaultAccess_notifiesSameUid() throws Exception {
DataUsageRequest inputRequest = new DataUsageRequest(
- DataUsageRequest.REQUEST_ID_UNSET, templates, NO_UIDS, THRESHOLD_BYTES);
-
- DataUsageRequest request = mStatsObservers.register(inputRequest, mMessenger, mockBinder,
- UID_RED, NetworkStatsAccess.Level.DEVICESUMMARY);
- assertTrue(request.requestId > 0);
- assertTrue(Arrays.deepEquals(templates, request.templates));
- assertNull(request.uids);
- assertEquals(THRESHOLD_BYTES, request.thresholdInBytes);
-
- NetworkIdentitySet identSet1 = new NetworkIdentitySet();
- identSet1.add(new NetworkIdentity(
- TYPE_MOBILE, TelephonyManager.NETWORK_TYPE_UNKNOWN,
- IMSI_1, null /* networkId */, false /* roaming */, true /* metered */));
- mActiveIfaces.put(TEST_IFACE, identSet1);
-
- NetworkIdentitySet identSet2 = new NetworkIdentitySet();
- identSet2.add(new NetworkIdentity(
- TYPE_MOBILE, TelephonyManager.NETWORK_TYPE_UNKNOWN,
- IMSI_2, null /* networkId */, false /* roaming */, true /* metered */));
- mActiveIfaces.put(TEST_IFACE2, identSet2);
-
- // Baseline
- NetworkStats xtSnapshot = new NetworkStats(TEST_START, 1 /* initialSize */)
- .addIfaceValues(TEST_IFACE, BASE_BYTES, 8L, BASE_BYTES, 16L)
- .addIfaceValues(TEST_IFACE2, BASE_BYTES + 1234L, 18L, BASE_BYTES, 12L);
- NetworkStats uidSnapshot = null;
- mStatsObservers.updateStats(
- xtSnapshot, uidSnapshot, mActiveIfaces, mActiveUidIfaces,
- VPN_INFO, TEST_START);
-
- // Delta - traffic on IMSI2
- xtSnapshot = new NetworkStats(TEST_START + MINUTE_IN_MILLIS, 1 /* initialSize */)
- .addIfaceValues(TEST_IFACE, BASE_BYTES, 8L, BASE_BYTES, 16L)
- .addIfaceValues(TEST_IFACE2, BASE_BYTES + THRESHOLD_BYTES, 22L,
- BASE_BYTES + THRESHOLD_BYTES, 24L);
- mStatsObservers.updateStats(
- xtSnapshot, uidSnapshot, mActiveIfaces, mActiveUidIfaces,
- VPN_INFO, TEST_START);
- waitForObserverToIdle();
-
- assertTrue(mCv.block(WAIT_TIMEOUT));
- assertEquals(NetworkStatsManager.CALLBACK_LIMIT_REACHED, mHandler.mLastMessageType);
- }
-
- public void testUpdateStats_aboveThresholdUid_notifies() throws Exception {
- NetworkTemplate[] templates = new NetworkTemplate[] { sTemplateImsi1 };
- int[] uids = new int[] { UID_RED, UID_BLUE, UID_GREEN };
- DataUsageRequest inputRequest = new DataUsageRequest(
- DataUsageRequest.REQUEST_ID_UNSET, templates, uids, THRESHOLD_BYTES);
-
- DataUsageRequest request = mStatsObservers.register(inputRequest, mMessenger, mockBinder,
- Process.SYSTEM_UID, NetworkStatsAccess.Level.DEVICE);
- assertTrue(request.requestId > 0);
- assertTrue(Arrays.deepEquals(templates, request.templates));
- assertTrue(Arrays.equals(uids,request.uids));
- assertEquals(THRESHOLD_BYTES, request.thresholdInBytes);
-
- NetworkIdentitySet identSet = new NetworkIdentitySet();
- identSet.add(new NetworkIdentity(
- TYPE_MOBILE, TelephonyManager.NETWORK_TYPE_UNKNOWN,
- IMSI_1, null /* networkId */, false /* roaming */, true /* metered */));
- mActiveUidIfaces.put(TEST_IFACE, identSet);
-
- // Baseline
- NetworkStats xtSnapshot = null;
- NetworkStats uidSnapshot = new NetworkStats(TEST_START, 2 /* initialSize */)
- .addValues(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE, ROAMING_NO,
- BASE_BYTES, 2L, BASE_BYTES, 2L, 0L);
- mStatsObservers.updateStats(
- xtSnapshot, uidSnapshot, mActiveIfaces, mActiveUidIfaces,
- VPN_INFO, TEST_START);
-
- // Delta
- uidSnapshot = new NetworkStats(TEST_START+ 2 * MINUTE_IN_MILLIS, 2 /* initialSize */)
- .addValues(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE, ROAMING_NO,
- BASE_BYTES + THRESHOLD_BYTES, 2L, BASE_BYTES + THRESHOLD_BYTES, 2L, 0L);
- mStatsObservers.updateStats(
- xtSnapshot, uidSnapshot, mActiveIfaces, mActiveUidIfaces,
- VPN_INFO, TEST_START);
- waitForObserverToIdle();
-
- assertTrue(mCv.block(WAIT_TIMEOUT));
- assertEquals(NetworkStatsManager.CALLBACK_LIMIT_REACHED, mHandler.mLastMessageType);
- }
-
- public void testUpdateStats_defaultAccess_noUid_notifiesSameUid() throws Exception {
- NetworkTemplate[] templates = new NetworkTemplate[] { sTemplateImsi1 };
- DataUsageRequest inputRequest = new DataUsageRequest(
- DataUsageRequest.REQUEST_ID_UNSET, templates, NO_UIDS, THRESHOLD_BYTES);
+ DataUsageRequest.REQUEST_ID_UNSET, sTemplateImsi1, THRESHOLD_BYTES);
DataUsageRequest request = mStatsObservers.register(inputRequest, mMessenger, mockBinder,
UID_RED, NetworkStatsAccess.Level.DEFAULT);
assertTrue(request.requestId > 0);
- assertTrue(Arrays.deepEquals(templates, request.templates));
- assertNull(request.uids);
+ assertTrue(Objects.equals(sTemplateImsi1, request.template));
assertEquals(THRESHOLD_BYTES, request.thresholdInBytes);
NetworkIdentitySet identSet = new NetworkIdentitySet();
@@ -494,7 +343,7 @@
VPN_INFO, TEST_START);
// Delta
- uidSnapshot = new NetworkStats(TEST_START+ 2 * MINUTE_IN_MILLIS, 2 /* initialSize */)
+ uidSnapshot = new NetworkStats(TEST_START + 2 * MINUTE_IN_MILLIS, 2 /* initialSize */)
.addValues(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE, ROAMING_NO,
BASE_BYTES + THRESHOLD_BYTES, 2L, BASE_BYTES + THRESHOLD_BYTES, 2L, 0L);
mStatsObservers.updateStats(
@@ -506,16 +355,14 @@
assertEquals(NetworkStatsManager.CALLBACK_LIMIT_REACHED, mHandler.mLastMessageType);
}
- public void testUpdateStats_defaultAccess_noUid_usageOtherUid_doesNotNotify() throws Exception {
- NetworkTemplate[] templates = new NetworkTemplate[] { sTemplateImsi1 };
+ public void testUpdateStats_defaultAccess_usageOtherUid_doesNotNotify() throws Exception {
DataUsageRequest inputRequest = new DataUsageRequest(
- DataUsageRequest.REQUEST_ID_UNSET, templates, NO_UIDS, THRESHOLD_BYTES);
+ DataUsageRequest.REQUEST_ID_UNSET, sTemplateImsi1, THRESHOLD_BYTES);
DataUsageRequest request = mStatsObservers.register(inputRequest, mMessenger, mockBinder,
UID_BLUE, NetworkStatsAccess.Level.DEFAULT);
assertTrue(request.requestId > 0);
- assertTrue(Arrays.deepEquals(templates, request.templates));
- assertNull(request.uids);
+ assertTrue(Objects.equals(sTemplateImsi1, request.template));
assertEquals(THRESHOLD_BYTES, request.thresholdInBytes);
NetworkIdentitySet identSet = new NetworkIdentitySet();
@@ -534,7 +381,7 @@
VPN_INFO, TEST_START);
// Delta
- uidSnapshot = new NetworkStats(TEST_START+ 2 * MINUTE_IN_MILLIS, 2 /* initialSize */)
+ uidSnapshot = new NetworkStats(TEST_START + 2 * MINUTE_IN_MILLIS, 2 /* initialSize */)
.addValues(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE, ROAMING_NO,
BASE_BYTES + THRESHOLD_BYTES, 2L, BASE_BYTES + THRESHOLD_BYTES, 2L, 0L);
mStatsObservers.updateStats(
@@ -547,15 +394,13 @@
}
public void testUpdateStats_userAccess_usageSameUser_notifies() throws Exception {
- NetworkTemplate[] templates = new NetworkTemplate[] { sTemplateImsi1 };
DataUsageRequest inputRequest = new DataUsageRequest(
- DataUsageRequest.REQUEST_ID_UNSET, templates, NO_UIDS, THRESHOLD_BYTES);
+ DataUsageRequest.REQUEST_ID_UNSET, sTemplateImsi1, THRESHOLD_BYTES);
DataUsageRequest request = mStatsObservers.register(inputRequest, mMessenger, mockBinder,
UID_BLUE, NetworkStatsAccess.Level.USER);
assertTrue(request.requestId > 0);
- assertTrue(Arrays.deepEquals(templates, request.templates));
- assertNull(request.uids);
+ assertTrue(Objects.equals(sTemplateImsi1, request.template));
assertEquals(THRESHOLD_BYTES, request.thresholdInBytes);
NetworkIdentitySet identSet = new NetworkIdentitySet();
@@ -574,7 +419,7 @@
VPN_INFO, TEST_START);
// Delta
- uidSnapshot = new NetworkStats(TEST_START+ 2 * MINUTE_IN_MILLIS, 2 /* initialSize */)
+ uidSnapshot = new NetworkStats(TEST_START + 2 * MINUTE_IN_MILLIS, 2 /* initialSize */)
.addValues(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE, ROAMING_NO,
BASE_BYTES + THRESHOLD_BYTES, 2L, BASE_BYTES + THRESHOLD_BYTES, 2L, 0L);
mStatsObservers.updateStats(
@@ -587,15 +432,13 @@
}
public void testUpdateStats_userAccess_usageAnotherUser_doesNotNotify() throws Exception {
- NetworkTemplate[] templates = new NetworkTemplate[] { sTemplateImsi1 };
DataUsageRequest inputRequest = new DataUsageRequest(
- DataUsageRequest.REQUEST_ID_UNSET, templates, NO_UIDS, THRESHOLD_BYTES);
+ DataUsageRequest.REQUEST_ID_UNSET, sTemplateImsi1, THRESHOLD_BYTES);
DataUsageRequest request = mStatsObservers.register(inputRequest, mMessenger, mockBinder,
UID_RED, NetworkStatsAccess.Level.USER);
assertTrue(request.requestId > 0);
- assertTrue(Arrays.deepEquals(templates, request.templates));
- assertNull(request.uids);
+ assertTrue(Objects.equals(sTemplateImsi1, request.template));
assertEquals(THRESHOLD_BYTES, request.thresholdInBytes);
NetworkIdentitySet identSet = new NetworkIdentitySet();
@@ -614,7 +457,7 @@
VPN_INFO, TEST_START);
// Delta
- uidSnapshot = new NetworkStats(TEST_START+ 2 * MINUTE_IN_MILLIS, 2 /* initialSize */)
+ uidSnapshot = new NetworkStats(TEST_START + 2 * MINUTE_IN_MILLIS, 2 /* initialSize */)
.addValues(TEST_IFACE, UID_ANOTHER_USER, SET_DEFAULT, TAG_NONE, ROAMING_NO,
BASE_BYTES + THRESHOLD_BYTES, 2L, BASE_BYTES + THRESHOLD_BYTES, 2L, 0L);
mStatsObservers.updateStats(
diff --git a/services/tests/servicestests/src/com/android/server/net/NetworkStatsServiceTest.java b/services/tests/servicestests/src/com/android/server/net/NetworkStatsServiceTest.java
index 74c1984..94c6711 100644
--- a/services/tests/servicestests/src/com/android/server/net/NetworkStatsServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/net/NetworkStatsServiceTest.java
@@ -100,7 +100,7 @@
import java.io.File;
import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.Objects;
import java.util.List;
/**
@@ -887,7 +887,7 @@
}
- public void testRegisterDataUsageCallback_network() throws Exception {
+ public void testRegisterUsageCallback() throws Exception {
// pretend that wifi network comes online; service should ask about full
// network state, and poll any existing interfaces before updating.
expectCurrentTime();
@@ -907,9 +907,8 @@
String callingPackage = "the.calling.package";
long thresholdInBytes = 1L; // very small; should be overriden by framework
- NetworkTemplate[] templates = new NetworkTemplate[] { sTemplateWifi };
DataUsageRequest inputRequest = new DataUsageRequest(
- DataUsageRequest.REQUEST_ID_UNSET, templates, null /* uids */, thresholdInBytes);
+ DataUsageRequest.REQUEST_ID_UNSET, sTemplateWifi, thresholdInBytes);
// Create a messenger that waits for callback activity
ConditionVariable cv = new ConditionVariable(false);
@@ -931,11 +930,10 @@
// Register and verify request and that binder was called
DataUsageRequest request =
- mService.registerDataUsageCallback(callingPackage, inputRequest,
+ mService.registerUsageCallback(callingPackage, inputRequest,
messenger, mockBinder);
assertTrue(request.requestId > 0);
- assertTrue(Arrays.deepEquals(templates, request.templates));
- assertNull(request.uids);
+ assertTrue(Objects.equals(sTemplateWifi, request.template));
long minThresholdInBytes = 2 * 1024 * 1024; // 2 MB
assertEquals(minThresholdInBytes, request.thresholdInBytes);
@@ -997,7 +995,7 @@
EasyMock.replay(mockBinder);
// Unregister request
- mService.unregisterDataUsageRequest(request);
+ mService.unregisterUsageRequest(request);
// Wait for the caller to ack receipt of CALLBACK_RELEASED
assertTrue(cv.block(WAIT_TIMEOUT));
@@ -1007,157 +1005,13 @@
EasyMock.verify(mockBinder);
}
- public void testRegisterDataUsageCallback_uids() throws Exception {
- // pretend that network comes online
- expectCurrentTime();
- expectDefaultSettings();
- expectNetworkState(buildMobile3gState(IMSI_1, true /* isRoaming */));
- expectNetworkStatsSummary(buildEmptyStats());
- expectNetworkStatsUidDetail(buildEmptyStats());
- expectNetworkStatsPoll();
- expectBandwidthControlCheck();
-
- replay();
- mService.forceUpdateIfaces();
- verifyAndReset();
-
+ public void testUnregisterUsageCallback_unknown_noop() throws Exception {
String callingPackage = "the.calling.package";
long thresholdInBytes = 10 * 1024 * 1024; // 10 MB
- NetworkTemplate[] templates = new NetworkTemplate[] { sTemplateImsi1, sTemplateImsi2 };
- int[] uids = new int[] { UID_RED };
- DataUsageRequest inputRequest = new DataUsageRequest(
- DataUsageRequest.REQUEST_ID_UNSET, templates, uids, thresholdInBytes);
-
- // Create a messenger that waits for callback activity
- ConditionVariable cv = new ConditionVariable(false);
- cv.close();
- LatchedHandler latchedHandler = new LatchedHandler(Looper.getMainLooper(), cv);
- Messenger messenger = new Messenger(latchedHandler);
-
- // Allow binder to connect
- IBinder mockBinder = createMock(IBinder.class);
- mockBinder.linkToDeath((IBinder.DeathRecipient) anyObject(), anyInt());
- EasyMock.replay(mockBinder);
-
- // Force poll
- expectCurrentTime();
- expectDefaultSettings();
- expectNetworkStatsSummary(buildEmptyStats());
- expectNetworkStatsUidDetail(buildEmptyStats());
- expectNetworkStatsPoll();
- replay();
-
- // Register and verify request and that binder was called
- DataUsageRequest request =
- mService.registerDataUsageCallback(callingPackage, inputRequest,
- messenger, mockBinder);
- assertTrue(request.requestId > 0);
- assertTrue(Arrays.deepEquals(templates, request.templates));
- assertTrue(Arrays.equals(uids, request.uids));
- assertEquals(thresholdInBytes, request.thresholdInBytes);
-
- // Wait for service to handle internal MSG_REGISTER_DATA_USAGE_LISTENER
- mHandler.sendMessage(mHandler.obtainMessage(-1));
- mHandlerThread.waitForIdle(WAIT_TIMEOUT);
-
- verifyAndReset();
-
- // Make sure that the caller binder gets connected
- EasyMock.verify(mockBinder);
- EasyMock.reset(mockBinder);
-
- // modify some number on mobile interface, and trigger poll event
- // not enough traffic to call data usage callback
- incrementCurrentTime(HOUR_IN_MILLIS);
- expectCurrentTime();
- expectDefaultSettings();
- expectNetworkStatsSummary(buildEmptyStats());
- expectNetworkStatsUidDetail(new NetworkStats(getElapsedRealtime(), 1)
- .addValues(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE, ROAMING_NO, 128L, 2L,
- 128L, 2L, 0L)
- .addValues(TEST_IFACE, UID_RED, SET_DEFAULT, 0xF00D, ROAMING_NO, 64L, 1L, 64L,
- 1L, 0L));
- expectNetworkStatsPoll();
-
- replay();
- forcePollAndWaitForIdle();
-
- // verify service recorded history
- assertUidTotal(sTemplateImsi1, UID_RED, 128L, 2L, 128L, 2L, 0);
-
- // verify entire history present
- NetworkStats stats = mSession.getSummaryForAllUid(
- sTemplateImsi1, Long.MIN_VALUE, Long.MAX_VALUE, true);
- assertEquals(2, stats.size());
- assertValues(stats, IFACE_ALL, UID_RED, SET_DEFAULT, TAG_NONE, ROAMING_YES, 128L, 2L,
- 128L, 2L, 0);
- assertValues(stats, IFACE_ALL, UID_RED, SET_DEFAULT, 0xF00D, ROAMING_YES, 64L, 1L, 64L,
- 1L, 0);
-
- verifyAndReset();
-
- // make sure callback has not being called
- assertEquals(INVALID_TYPE, latchedHandler.mLastMessageType);
-
- // and bump forward again, with counters going higher. this is
- // important, since it will trigger the data usage callback
- incrementCurrentTime(DAY_IN_MILLIS);
- expectCurrentTime();
- expectDefaultSettings();
- expectNetworkStatsSummary(buildEmptyStats());
- expectNetworkStatsUidDetail(new NetworkStats(getElapsedRealtime(), 1)
- .addValues(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE, ROAMING_NO,
- 128000000L, 2L, 128000000L, 2L, 0L)
- .addValues(TEST_IFACE, UID_RED, SET_DEFAULT, 0xF00D, ROAMING_NO,
- 64000000L, 1L, 64000000L, 1L, 0L));
- expectNetworkStatsPoll();
-
- replay();
- forcePollAndWaitForIdle();
-
- // verify service recorded history
- assertUidTotal(sTemplateImsi1, UID_RED, 128000000L, 2L, 128000000L, 2L, 0);
-
- // verify entire history present
- stats = mSession.getSummaryForAllUid(
- sTemplateImsi1, Long.MIN_VALUE, Long.MAX_VALUE, true);
- assertEquals(2, stats.size());
- assertValues(stats, IFACE_ALL, UID_RED, SET_DEFAULT, TAG_NONE, ROAMING_YES,
- 128000000L, 2L, 128000000L, 2L, 0);
- assertValues(stats, IFACE_ALL, UID_RED, SET_DEFAULT, 0xF00D, ROAMING_YES,
- 64000000L, 1L, 64000000L, 1L, 0);
-
- verifyAndReset();
-
- // Wait for the caller to ack receipt of CALLBACK_LIMIT_REACHED
- assertTrue(cv.block(WAIT_TIMEOUT));
- assertEquals(NetworkStatsManager.CALLBACK_LIMIT_REACHED, latchedHandler.mLastMessageType);
- cv.close();
-
- // Allow binder to disconnect
- expect(mockBinder.unlinkToDeath((IBinder.DeathRecipient) anyObject(), anyInt()))
- .andReturn(true);
- EasyMock.replay(mockBinder);
-
- // Unregister request
- mService.unregisterDataUsageRequest(request);
-
- // Wait for the caller to ack receipt of CALLBACK_RELEASED
- assertTrue(cv.block(WAIT_TIMEOUT));
- assertEquals(NetworkStatsManager.CALLBACK_RELEASED, latchedHandler.mLastMessageType);
-
- // Make sure that the caller binder gets disconnected
- EasyMock.verify(mockBinder);
- }
-
- public void testUnregisterDataUsageCallback_unknown_noop() throws Exception {
- String callingPackage = "the.calling.package";
- long thresholdInBytes = 10 * 1024 * 1024; // 10 MB
- NetworkTemplate[] templates = new NetworkTemplate[] { sTemplateImsi1, sTemplateImsi2 };
DataUsageRequest unknownRequest = new DataUsageRequest(
- 2, templates, null /* uids */, thresholdInBytes);
+ 2 /* requestId */, sTemplateImsi1, thresholdInBytes);
- mService.unregisterDataUsageRequest(unknownRequest);
+ mService.unregisterUsageRequest(unknownRequest);
}
private static File getBaseDir(File statsDir) {
diff --git a/tools/fonts/fontchain_lint.py b/tools/fonts/fontchain_lint.py
index fe7c3b9..ea36e2c 100755
--- a/tools/fonts/fontchain_lint.py
+++ b/tools/fonts/fontchain_lint.py
@@ -412,8 +412,9 @@
path.join(ucd_path, 'emoji-zwj-sequences.txt'))
# filter modern pentathlon, as it seems likely to be removed from final spec
+ # also filter rifle
def is_excluded(n):
- return n == 0x1f93b
+ return n in [0x1f93b, 0x1f946]
def contains_excluded(t):
if type(t) == int: