Merge "Change string connected_via_network_scorer_default." into oc-dev
diff --git a/api/current.txt b/api/current.txt
index 8d27905..d10797c 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -3673,7 +3673,7 @@
method public void onLowMemory();
method public boolean onMenuItemSelected(int, android.view.MenuItem);
method public boolean onMenuOpened(int, android.view.Menu);
- method public void onMovedToDisplay(int);
+ method public void onMovedToDisplay(int, android.content.res.Configuration);
method public void onMultiWindowModeChanged(boolean);
method public boolean onNavigateUp();
method public boolean onNavigateUpFromChild(android.app.Activity);
@@ -12695,7 +12695,7 @@
enum_constant public static final android.graphics.Canvas.VertexMode TRIANGLE_STRIP;
}
- public class Color {
+ public final class Color {
ctor public Color();
method public static int HSVToColor(float[]);
method public static int HSVToColor(int, float[]);
@@ -12720,6 +12720,7 @@
method public float getComponent(int);
method public int getComponentCount();
method public float[] getComponents();
+ method public float[] getComponents(float[]);
method public android.graphics.ColorSpace.Model getModel();
method public float green();
method public static float green(long);
@@ -24559,6 +24560,7 @@
field public static final java.lang.String COLUMN_REVIEW_RATING_STYLE = "review_rating_style";
field public static final java.lang.String COLUMN_STARTING_PRICE = "starting_price";
field public static final java.lang.String COLUMN_THUMBNAIL_ASPECT_RATIO = "poster_thumbnail_aspect_ratio";
+ field public static final java.lang.String COLUMN_TRANSIENT = "transient";
field public static final java.lang.String COLUMN_TYPE = "type";
field public static final java.lang.String INTERACTION_TYPE_FANS = "INTERACTION_TYPE_FANS";
field public static final java.lang.String INTERACTION_TYPE_FOLLOWERS = "INTERACTION_TYPE_FOLLOWERS";
@@ -24636,6 +24638,7 @@
field public static final java.lang.String COLUMN_SEARCHABLE = "searchable";
field public static final java.lang.String COLUMN_SERVICE_ID = "service_id";
field public static final java.lang.String COLUMN_SERVICE_TYPE = "service_type";
+ field public static final java.lang.String COLUMN_TRANSIENT = "transient";
field public static final java.lang.String COLUMN_TRANSPORT_STREAM_ID = "transport_stream_id";
field public static final java.lang.String COLUMN_TYPE = "type";
field public static final java.lang.String COLUMN_VERSION_NUMBER = "version_number";
@@ -45488,7 +45491,7 @@
method public boolean onKeyUp(int, android.view.KeyEvent);
method protected void onLayout(boolean, int, int, int, int);
method protected void onMeasure(int, int);
- method public void onMovedToDisplay(int);
+ method public void onMovedToDisplay(int, android.content.res.Configuration);
method protected void onOverScrolled(int, int, boolean, boolean);
method public void onPointerCaptureChange(boolean);
method public void onPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent);
diff --git a/api/system-current.txt b/api/system-current.txt
index badd31e..c7b377e 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -3799,7 +3799,7 @@
method public void onLowMemory();
method public boolean onMenuItemSelected(int, android.view.MenuItem);
method public boolean onMenuOpened(int, android.view.Menu);
- method public void onMovedToDisplay(int);
+ method public void onMovedToDisplay(int, android.content.res.Configuration);
method public void onMultiWindowModeChanged(boolean);
method public boolean onNavigateUp();
method public boolean onNavigateUpFromChild(android.app.Activity);
@@ -11172,6 +11172,7 @@
method public abstract byte[] getInstantAppCookie();
method public abstract int getInstantAppCookieMaxSize();
method public abstract android.graphics.drawable.Drawable getInstantAppIcon(java.lang.String);
+ method public abstract android.content.ComponentName getInstantAppResolverSettingsComponent();
method public abstract java.util.List<android.content.pm.InstantAppInfo> getInstantApps();
method public abstract android.content.pm.InstrumentationInfo getInstrumentationInfo(android.content.ComponentName, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public abstract java.util.List<android.content.pm.IntentFilterVerificationInfo> getIntentFilterVerifications(java.lang.String);
@@ -11421,6 +11422,7 @@
field public static final int MATCH_DIRECT_BOOT_UNAWARE = 262144; // 0x40000
field public static final int MATCH_DISABLED_COMPONENTS = 512; // 0x200
field public static final int MATCH_DISABLED_UNTIL_USED_COMPONENTS = 32768; // 0x8000
+ field public static final int MATCH_FACTORY_ONLY = 2097152; // 0x200000
field public static final int MATCH_INSTANT = 8388608; // 0x800000
field public static final int MATCH_SYSTEM_ONLY = 1048576; // 0x100000
field public static final int MATCH_UNINSTALLED_PACKAGES = 8192; // 0x2000
@@ -13421,7 +13423,7 @@
enum_constant public static final android.graphics.Canvas.VertexMode TRIANGLE_STRIP;
}
- public class Color {
+ public final class Color {
ctor public Color();
method public static int HSVToColor(float[]);
method public static int HSVToColor(int, float[]);
@@ -13446,6 +13448,7 @@
method public float getComponent(int);
method public int getComponentCount();
method public float[] getComponents();
+ method public float[] getComponents(float[]);
method public android.graphics.ColorSpace.Model getModel();
method public float green();
method public static float green(long);
@@ -44214,6 +44217,7 @@
method public byte[] getInstantAppCookie();
method public int getInstantAppCookieMaxSize();
method public android.graphics.drawable.Drawable getInstantAppIcon(java.lang.String);
+ method public android.content.ComponentName getInstantAppResolverSettingsComponent();
method public java.util.List<android.content.pm.InstantAppInfo> getInstantApps();
method public android.content.pm.InstrumentationInfo getInstrumentationInfo(android.content.ComponentName, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public java.util.List<android.content.pm.IntentFilterVerificationInfo> getIntentFilterVerifications(java.lang.String);
@@ -48942,7 +48946,7 @@
method public boolean onKeyUp(int, android.view.KeyEvent);
method protected void onLayout(boolean, int, int, int, int);
method protected void onMeasure(int, int);
- method public void onMovedToDisplay(int);
+ method public void onMovedToDisplay(int, android.content.res.Configuration);
method protected void onOverScrolled(int, int, boolean, boolean);
method public void onPointerCaptureChange(boolean);
method public void onPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent);
diff --git a/api/test-current.txt b/api/test-current.txt
index 3a23cd9..882e9bb 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -3675,7 +3675,7 @@
method public void onLowMemory();
method public boolean onMenuItemSelected(int, android.view.MenuItem);
method public boolean onMenuOpened(int, android.view.Menu);
- method public void onMovedToDisplay(int);
+ method public void onMovedToDisplay(int, android.content.res.Configuration);
method public void onMultiWindowModeChanged(boolean);
method public boolean onNavigateUp();
method public boolean onNavigateUpFromChild(android.app.Activity);
@@ -12745,7 +12745,7 @@
enum_constant public static final android.graphics.Canvas.VertexMode TRIANGLE_STRIP;
}
- public class Color {
+ public final class Color {
ctor public Color();
method public static int HSVToColor(float[]);
method public static int HSVToColor(int, float[]);
@@ -12770,6 +12770,7 @@
method public float getComponent(int);
method public int getComponentCount();
method public float[] getComponents();
+ method public float[] getComponents(float[]);
method public android.graphics.ColorSpace.Model getModel();
method public float green();
method public static float green(long);
@@ -24672,6 +24673,7 @@
field public static final java.lang.String COLUMN_REVIEW_RATING_STYLE = "review_rating_style";
field public static final java.lang.String COLUMN_STARTING_PRICE = "starting_price";
field public static final java.lang.String COLUMN_THUMBNAIL_ASPECT_RATIO = "poster_thumbnail_aspect_ratio";
+ field public static final java.lang.String COLUMN_TRANSIENT = "transient";
field public static final java.lang.String COLUMN_TYPE = "type";
field public static final java.lang.String INTERACTION_TYPE_FANS = "INTERACTION_TYPE_FANS";
field public static final java.lang.String INTERACTION_TYPE_FOLLOWERS = "INTERACTION_TYPE_FOLLOWERS";
@@ -24749,6 +24751,7 @@
field public static final java.lang.String COLUMN_SEARCHABLE = "searchable";
field public static final java.lang.String COLUMN_SERVICE_ID = "service_id";
field public static final java.lang.String COLUMN_SERVICE_TYPE = "service_type";
+ field public static final java.lang.String COLUMN_TRANSIENT = "transient";
field public static final java.lang.String COLUMN_TRANSPORT_STREAM_ID = "transport_stream_id";
field public static final java.lang.String COLUMN_TYPE = "type";
field public static final java.lang.String COLUMN_VERSION_NUMBER = "version_number";
@@ -45863,7 +45866,7 @@
method public boolean onKeyUp(int, android.view.KeyEvent);
method protected void onLayout(boolean, int, int, int, int);
method protected void onMeasure(int, int);
- method public void onMovedToDisplay(int);
+ method public void onMovedToDisplay(int, android.content.res.Configuration);
method protected void onOverScrolled(int, int, boolean, boolean);
method public void onPointerCaptureChange(boolean);
method public void onPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent);
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index fa1de03..bace226 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -1990,27 +1990,32 @@
}
}
- void dispatchMovedToDisplay(int displayId) {
+ void dispatchMovedToDisplay(int displayId, Configuration config) {
updateDisplay(displayId);
- onMovedToDisplay(displayId);
+ onMovedToDisplay(displayId, config);
}
/**
* Called by the system when the activity is moved from one display to another without
* recreation. This means that this activity is declared to handle all changes to configuration
* that happened when it was switched to another display, so it wasn't destroyed and created
- * again. This call will be followed by {@link #onConfigurationChanged(Configuration)} if the
- * applied configuration actually changed.
+ * again.
+ *
+ * <p>This call will be followed by {@link #onConfigurationChanged(Configuration)} if the
+ * applied configuration actually changed. It is up to app developer to choose whether to handle
+ * the change in this method or in the following {@link #onConfigurationChanged(Configuration)}
+ * call.
*
* <p>Use this callback to track changes to the displays if some activity functionality relies
* on an association with some display properties.
*
* @param displayId The id of the display to which activity was moved.
+ * @param config Configuration of the activity resources on new display after move.
*
* @see #onConfigurationChanged(Configuration)
- * @see View#onMovedToDisplay(int)
+ * @see View#onMovedToDisplay(int, Configuration)
*/
- public void onMovedToDisplay(int displayId) {
+ public void onMovedToDisplay(int displayId, Configuration config) {
}
/**
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index e89dc0b..b5d1fa8 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -4801,16 +4801,18 @@
* {@link ActivityClientRecord#overrideConfig}.
* @param displayId The id of the display where the Activity currently resides.
* @param movedToDifferentDisplay Indicates if the activity was moved to different display.
+ * @return {@link Configuration} instance sent to client, null if not sent.
*/
- private void performConfigurationChangedForActivity(ActivityClientRecord r,
+ private Configuration performConfigurationChangedForActivity(ActivityClientRecord r,
Configuration newBaseConfig, int displayId, boolean movedToDifferentDisplay) {
r.tmpConfig.setTo(newBaseConfig);
if (r.overrideConfig != null) {
r.tmpConfig.updateFrom(r.overrideConfig);
}
- performActivityConfigurationChanged(r.activity, r.tmpConfig, r.overrideConfig, displayId,
- movedToDifferentDisplay);
+ final Configuration reportedConfig = performActivityConfigurationChanged(r.activity,
+ r.tmpConfig, r.overrideConfig, displayId, movedToDifferentDisplay);
freeTextLayoutCachesIfNeeded(r.activity.mCurrentConfig.diff(r.tmpConfig));
+ return reportedConfig;
}
/**
@@ -4864,9 +4866,11 @@
* ActivityManager.
* @param displayId Id of the display where activity currently resides.
* @param movedToDifferentDisplay Indicates if the activity was moved to different display.
+ * @return Configuration sent to client, null if no changes and not moved to different display.
*/
- private void performActivityConfigurationChanged(Activity activity, Configuration newConfig,
- Configuration amOverrideConfig, int displayId, boolean movedToDifferentDisplay) {
+ private Configuration performActivityConfigurationChanged(Activity activity,
+ Configuration newConfig, Configuration amOverrideConfig, int displayId,
+ boolean movedToDifferentDisplay) {
if (activity == null) {
throw new IllegalArgumentException("No activity provided.");
}
@@ -4897,7 +4901,7 @@
}
if (!shouldChangeConfig && !movedToDifferentDisplay) {
// Nothing significant, don't proceed with updating and reporting.
- return;
+ return null;
}
// Propagate the configuration change to ResourcesManager and Activity.
@@ -4920,22 +4924,22 @@
activity.mConfigChangeFlags = 0;
activity.mCurrentConfig = new Configuration(newConfig);
+ // Apply the ContextThemeWrapper override if necessary.
+ // NOTE: Make sure the configurations are not modified, as they are treated as immutable
+ // in many places.
+ final Configuration configToReport = createNewConfigAndUpdateIfNotNull(newConfig,
+ contextThemeWrapperOverrideConfig);
+
if (!REPORT_TO_ACTIVITY) {
// Not configured to report to activity.
- return;
+ return configToReport;
}
if (movedToDifferentDisplay) {
- activity.dispatchMovedToDisplay(displayId);
+ activity.dispatchMovedToDisplay(displayId, configToReport);
}
if (shouldChangeConfig) {
- // Apply the ContextThemeWrapper override if necessary.
- // NOTE: Make sure the configurations are not modified, as they are treated as immutable
- // in many places.
- final Configuration configToReport = createNewConfigAndUpdateIfNotNull(
- newConfig, contextThemeWrapperOverrideConfig);
-
activity.mCalled = false;
activity.onConfigurationChanged(configToReport);
if (!activity.mCalled) {
@@ -4943,6 +4947,8 @@
" did not call through to super.onConfigurationChanged()");
}
}
+
+ return configToReport;
}
public final void applyConfigurationToResources(Configuration config) {
@@ -5115,10 +5121,10 @@
+ r.activityInfo.name + ", displayId=" + displayId
+ ", config=" + data.overrideConfig);
- performConfigurationChangedForActivity(r, mCompatConfiguration, displayId,
- true /* movedToDifferentDisplay */);
+ final Configuration reportedConfig = performConfigurationChangedForActivity(r,
+ mCompatConfiguration, displayId, true /* movedToDifferentDisplay */);
if (viewRoot != null) {
- viewRoot.onMovedToDisplay(displayId);
+ viewRoot.onMovedToDisplay(displayId, reportedConfig);
}
} else {
if (DEBUG_CONFIGURATION) Slog.v(TAG, "Handle activity config changed: "
@@ -5128,7 +5134,7 @@
// Notify the ViewRootImpl instance about configuration changes. It may have initiated this
// update to make sure that resources are updated before updating itself.
if (viewRoot != null) {
- viewRoot.updateConfiguration();
+ viewRoot.updateConfiguration(displayId);
}
mSomeActivitiesChanged = true;
}
diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java
index 286f8570..461f9cc 100644
--- a/core/java/android/app/ApplicationPackageManager.java
+++ b/core/java/android/app/ApplicationPackageManager.java
@@ -2630,4 +2630,13 @@
throw e.rethrowAsRuntimeException();
}
}
+
+ @Override
+ public ComponentName getInstantAppResolverSettingsComponent() {
+ try {
+ return mPM.getInstantAppResolverSettingsComponent();
+ } catch (RemoteException e) {
+ throw e.rethrowAsRuntimeException();
+ }
+ }
}
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index fb86791..7890a96 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -1532,6 +1532,19 @@
= "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";
/**
+ * Activity Action: Launch ephemeral settings.
+ *
+ * <p class="note">
+ * This is a protected intent that can only be sent by the system.
+ * </p>
+ *
+ * @hide
+ */
+ @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
+ public static final String ACTION_EPHEMERAL_RESOLVER_SETTINGS
+ = "android.intent.action.EPHEMERAL_RESOLVER_SETTINGS";
+
+ /**
* Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
* package. Specifies the installer package name; this package will receive the
* {@link #ACTION_APP_ERROR} intent.
diff --git a/core/java/android/content/pm/IPackageManager.aidl b/core/java/android/content/pm/IPackageManager.aidl
index 59b022d..147df76 100644
--- a/core/java/android/content/pm/IPackageManager.aidl
+++ b/core/java/android/content/pm/IPackageManager.aidl
@@ -630,4 +630,6 @@
boolean canRequestPackageInstalls(String packageName, int userId);
void deletePreloadsFileCache();
+
+ ComponentName getInstantAppResolverSettingsComponent();
}
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index 71db5d3..136c13b 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -153,6 +153,7 @@
MATCH_UNINSTALLED_PACKAGES,
MATCH_SYSTEM_ONLY,
MATCH_DEBUG_TRIAGED_MISSING,
+ MATCH_DISABLED_COMPONENTS,
MATCH_DISABLED_UNTIL_USED_COMPONENTS,
MATCH_INSTANT,
GET_DISABLED_UNTIL_USED_COMPONENTS,
@@ -431,6 +432,7 @@
* This will not return information on any unbundled update to system components.
* @hide
*/
+ @SystemApi
public static final int MATCH_FACTORY_ONLY = 0x00200000;
/**
@@ -3730,6 +3732,7 @@
*
* @param flags Additional option flags. Use any combination of
* {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
+ * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}
* {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES}
* to modify the data returned.
*
@@ -3743,6 +3746,7 @@
*
* @see #GET_META_DATA
* @see #GET_SHARED_LIBRARY_FILES
+ * @see #MATCH_DISABLED_COMPONENTS
* @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
* @see #MATCH_SYSTEM_ONLY
* @see #MATCH_UNINSTALLED_PACKAGES
@@ -3757,6 +3761,7 @@
*
* @param flags Additional option flags. Use any combination of
* {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
+ * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}
* {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES}
* to modify the data returned.
* @param userId The user for whom the installed applications are to be listed
@@ -3772,6 +3777,7 @@
*
* @see #GET_META_DATA
* @see #GET_SHARED_LIBRARY_FILES
+ * @see #MATCH_DISABLED_COMPONENTS
* @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
* @see #MATCH_SYSTEM_ONLY
* @see #MATCH_UNINSTALLED_PACKAGES
@@ -6233,4 +6239,14 @@
* @see {@link android.provider.Settings#ACTION_MANAGE_EXTERNAL_SOURCES}
*/
public abstract boolean canRequestPackageInstalls();
+
+ /**
+ * Return the {@link ComponentName} of the activity providing Settings for the Instant App
+ * resolver.
+ *
+ * @see {@link android.content.intent#ACTION_EPHEMERAL_RESOLVER_SETTINGS}
+ * @hide
+ */
+ @SystemApi
+ public abstract ComponentName getInstantAppResolverSettingsComponent();
}
diff --git a/core/java/android/content/pm/PackageManagerInternal.java b/core/java/android/content/pm/PackageManagerInternal.java
index b3e25d1..370af17 100644
--- a/core/java/android/content/pm/PackageManagerInternal.java
+++ b/core/java/android/content/pm/PackageManagerInternal.java
@@ -242,6 +242,7 @@
public abstract void grantEphemeralAccess(int userId, Intent intent,
int targetAppId, int ephemeralAppId);
+ public abstract boolean isInstantAppInstallerComponent(ComponentName component);
/**
* Prunes instant apps and state associated with uninstalled
* instant apps according to the current platform policy.
diff --git a/core/java/android/os/Looper.java b/core/java/android/os/Looper.java
index 63d3e7a..44dbcfb 100644
--- a/core/java/android/os/Looper.java
+++ b/core/java/android/os/Looper.java
@@ -21,6 +21,7 @@
import android.os.LooperProto;
import android.util.Log;
import android.util.Printer;
+import android.util.Slog;
import android.util.proto.ProtoOutputStream;
/**
@@ -76,6 +77,9 @@
private Printer mLogging;
private long mTraceTag;
+ /* If set, the looper will show a warning log if a message dispatch takes longer than time. */
+ private long mSlowDispatchThresholdMs;
+
/** Initialize the current thread as a looper.
* This gives you a chance to create handlers that then reference
* this looper, before actually starting the loop. Be sure to call
@@ -148,17 +152,30 @@
msg.callback + ": " + msg.what);
}
+ final long slowDispatchThresholdMs = me.mSlowDispatchThresholdMs;
+
final long traceTag = me.mTraceTag;
if (traceTag != 0 && Trace.isTagEnabled(traceTag)) {
Trace.traceBegin(traceTag, msg.target.getTraceName(msg));
}
+ final long start = (slowDispatchThresholdMs == 0) ? 0 : SystemClock.uptimeMillis();
+ final long end;
try {
msg.target.dispatchMessage(msg);
+ end = (slowDispatchThresholdMs == 0) ? 0 : SystemClock.uptimeMillis();
} finally {
if (traceTag != 0) {
Trace.traceEnd(traceTag);
}
}
+ if (slowDispatchThresholdMs > 0) {
+ final long time = end - start;
+ if (time > slowDispatchThresholdMs) {
+ Slog.w(TAG, "Dispatch took " + time + "ms on "
+ + Thread.currentThread().getName() + ", h=" +
+ msg.target + " cb=" + msg.callback + " msg=" + msg.what);
+ }
+ }
if (logging != null) {
logging.println("<<<<< Finished to " + msg.target + " " + msg.callback);
@@ -226,6 +243,11 @@
mTraceTag = traceTag;
}
+ /** {@hide} */
+ public void setSlowDispatchThresholdMs(long slowDispatchThresholdMs) {
+ mSlowDispatchThresholdMs = slowDispatchThresholdMs;
+ }
+
/**
* Quits the looper.
* <p>
diff --git a/core/java/android/os/RecoverySystem.java b/core/java/android/os/RecoverySystem.java
index ef5bc5c..5fa2461 100644
--- a/core/java/android/os/RecoverySystem.java
+++ b/core/java/android/os/RecoverySystem.java
@@ -483,7 +483,7 @@
}
final String filenameArg = "--update_package=" + filename + "\n";
- final String localeArg = "--locale=" + Locale.getDefault().toString() + "\n";
+ final String localeArg = "--locale=" + Locale.getDefault().toLanguageTag() + "\n";
final String securityArg = "--security\n";
String command = filenameArg + localeArg;
@@ -531,7 +531,7 @@
}
final String filenameArg = "--update_package=" + filename + "\n";
- final String localeArg = "--locale=" + Locale.getDefault().toString() + "\n";
+ final String localeArg = "--locale=" + Locale.getDefault().toLanguageTag() + "\n";
final String securityArg = "--security\n";
String command = filenameArg + localeArg;
@@ -647,7 +647,7 @@
reasonArg = "--reason=" + sanitizeArg(reason);
}
- final String localeArg = "--locale=" + Locale.getDefault().toString();
+ final String localeArg = "--locale=" + Locale.getDefault().toLanguageTag() ;
bootCommand(context, shutdownArg, "--wipe_data", reasonArg, localeArg);
}
@@ -678,7 +678,7 @@
reasonArg = "--reason=" + sanitizeArg(reason);
}
- final String localeArg = "--locale=" + Locale.getDefault().toString();
+ final String localeArg = "--locale=" + Locale.getDefault().toLanguageTag() ;
bootCommand(context, "--wipe_cache", reasonArg, localeArg);
}
@@ -703,7 +703,7 @@
final String filename = packageFile.getCanonicalPath();
final String filenameArg = "--wipe_package=" + filename;
- final String localeArg = "--locale=" + Locale.getDefault().toString();
+ final String localeArg = "--locale=" + Locale.getDefault().toLanguageTag() ;
bootCommand(context, "--wipe_ab", filenameArg, reasonArg, localeArg);
}
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 6c73b9b..3f52a9d 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -16457,29 +16457,34 @@
}
/**
- * @see #onMovedToDisplay(int)
+ * @see #onMovedToDisplay(int, Configuration)
*/
- void dispatchMovedToDisplay(Display display) {
+ void dispatchMovedToDisplay(Display display, Configuration config) {
mAttachInfo.mDisplay = display;
mAttachInfo.mDisplayState = display.getState();
- onMovedToDisplay(display.getDisplayId());
+ onMovedToDisplay(display.getDisplayId(), config);
}
/**
* Called by the system when the hosting activity is moved from one display to another without
* recreation. This means that the activity is declared to handle all changes to configuration
* that happened when it was switched to another display, so it wasn't destroyed and created
- * again. This call will be followed by {@link #onConfigurationChanged(Configuration)} if the
- * applied configuration actually changed.
+ * again.
+ *
+ * <p>This call will be followed by {@link #onConfigurationChanged(Configuration)} if the
+ * applied configuration actually changed. It is up to app developer to choose whether to handle
+ * the change in this method or in the following {@link #onConfigurationChanged(Configuration)}
+ * call.
*
* <p>Use this callback to track changes to the displays if some functionality relies on an
* association with some display properties.
*
* @param displayId The id of the display to which the view was moved.
+ * @param config Configuration of the resources on new display after move.
*
* @see #onConfigurationChanged(Configuration)
*/
- public void onMovedToDisplay(int displayId) {
+ public void onMovedToDisplay(int displayId, Configuration config) {
}
/**
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index de0ec40..7921938 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -3281,13 +3281,13 @@
}
@Override
- void dispatchMovedToDisplay(Display display) {
- super.dispatchMovedToDisplay(display);
+ void dispatchMovedToDisplay(Display display, Configuration config) {
+ super.dispatchMovedToDisplay(display, config);
final int count = mChildrenCount;
final View[] children = mChildren;
for (int i = 0; i < count; i++) {
- children[i].dispatchMovedToDisplay(display);
+ children[i].dispatchMovedToDisplay(display, config);
}
}
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 1681787..cf52c60 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -1106,10 +1106,11 @@
/**
* Notify about move to a different display.
* @param displayId The id of the display where this view root is moved to.
+ * @param config Configuration of the resources on new display after move.
*
* @hide
*/
- public void onMovedToDisplay(int displayId) {
+ public void onMovedToDisplay(int displayId, Configuration config) {
if (mDisplay.getDisplayId() == displayId) {
return;
}
@@ -1120,7 +1121,7 @@
mView.getResources());
mAttachInfo.mDisplayState = mDisplay.getState();
// Internal state updated, now notify the view hierarchy.
- mView.dispatchMovedToDisplay(mDisplay);
+ mView.dispatchMovedToDisplay(mDisplay, config);
}
void pokeDrawLockIfNeeded() {
@@ -3485,15 +3486,16 @@
mActivityConfigCallback.onConfigurationChanged(overrideConfig, newDisplayId);
} else {
// There is no activity callback - update the configuration right away.
- updateConfiguration();
+ updateConfiguration(newDisplayId);
}
mForceNextConfigUpdate = false;
}
/**
* Update display and views if last applied merged configuration changed.
+ * @param newDisplayId Id of new display if moved, {@link Display#INVALID_DISPLAY} otherwise.
*/
- public void updateConfiguration() {
+ public void updateConfiguration(int newDisplayId) {
if (mView == null) {
return;
}
@@ -3503,6 +3505,13 @@
// the one in them which may be newer.
final Resources localResources = mView.getResources();
final Configuration config = localResources.getConfiguration();
+
+ // Handle move to display.
+ if (newDisplayId != INVALID_DISPLAY) {
+ onMovedToDisplay(newDisplayId, config);
+ }
+
+ // Handle configuration change.
if (mForceNextConfigUpdate || mLastConfigurationFromResources.diff(config) != 0) {
// Update the display with new DisplayAdjustments.
mDisplay = ResourcesManager.getInstance().getAdjustedDisplay(
@@ -3674,15 +3683,17 @@
SomeArgs args = (SomeArgs) msg.obj;
final int displayId = args.argi3;
- final boolean displayChanged = mDisplay.getDisplayId() != displayId;
- if (displayChanged) {
- onMovedToDisplay(displayId);
- }
-
final MergedConfiguration mergedConfiguration = (MergedConfiguration) args.arg4;
+ final boolean displayChanged = mDisplay.getDisplayId() != displayId;
+
if (mergedConfiguration != null) {
+ // If configuration changed - notify about that and, maybe, about move to
+ // display.
performConfigurationChange(mergedConfiguration, false /* force */,
displayChanged ? displayId : INVALID_DISPLAY /* same display */);
+ } else if (displayChanged) {
+ // Moved to display without config change - report last applied one.
+ onMovedToDisplay(displayId, mLastConfigurationFromResources);
}
final boolean framesChanged = !mWinFrame.equals(args.arg1)
diff --git a/core/java/android/widget/ListPopupWindow.java b/core/java/android/widget/ListPopupWindow.java
index 78d18fd..ab4cce4 100644
--- a/core/java/android/widget/ListPopupWindow.java
+++ b/core/java/android/widget/ListPopupWindow.java
@@ -523,9 +523,17 @@
/**
* Sets the height of the popup window in pixels. Can also be {@link #MATCH_PARENT}.
*
- * @param height Height of the popup window.
+ * @param height Height of the popup window must be a positive value,
+ * {@link #MATCH_PARENT}, or {@link #WRAP_CONTENT}.
+ *
+ * @throws IllegalArgumentException if height is set to negative value
*/
public void setHeight(int height) {
+ if (height < 0 && ViewGroup.LayoutParams.WRAP_CONTENT != height
+ && ViewGroup.LayoutParams.MATCH_PARENT != height) {
+ throw new IllegalArgumentException(
+ "Invalid height. Must be a positive value, MATCH_PARENT, or WRAP_CONTENT.");
+ }
mDropDownHeight = height;
}
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 7704519..db234e7 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -2801,4 +2801,9 @@
<!-- Colon separated list of package names that should be granted Notification Listener access -->
<string name="config_defaultListenerAccessPackages" translatable="false"></string>
+
+ <!-- Maximum size, specified in pixels, to restrain the display space width to. Height and
+ density will be scaled accordingly to maintain aspect ratio. A value of 0 indicates no
+ constraint will be enforced. -->
+ <integer name="config_maxUiWidth">0</integer>
</resources>
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 868e256..4afa8dc 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -189,22 +189,23 @@
<!-- Displayed to tell the user that they cannot change the caller ID setting. -->
<string name="CLIRPermanent">You can\'t change the caller ID setting.</string>
- <!-- Displayed to tell the user that data service is blocked by access control. -->
- <string name="RestrictedOnData">Data service is blocked.</string>
- <!-- Displayed to tell the user that emergency service is blocked by access control. -->
- <string name="RestrictedOnEmergency">Emergency service is blocked.</string>
- <!-- Displayed to tell the user that normal service is blocked by access control. -->
- <string name="RestrictedOnNormal">Voice service is blocked.</string>
- <!-- Displayed to tell the user that all emergency and normal voice services are blocked by access control. -->
- <string name="RestrictedOnAllVoice">All voice services are blocked.</string>
- <!-- Displayed to tell the user that sms service is blocked by access control. -->
- <string name="RestrictedOnSms">SMS service is blocked.</string>
- <!-- Displayed to tell the user that voice/data service is blocked by access control. -->
- <string name="RestrictedOnVoiceData">Voice/data services are blocked.</string>
- <!-- Displayed to tell the user that voice and sms service are blocked by access control. -->
- <string name="RestrictedOnVoiceSms">Voice/SMS services are blocked.</string>
- <!-- Displayed to tell the user that all service is blocked by access control. -->
- <string name="RestrictedOnAll">All voice/data/SMS services are blocked.</string>
+ <!-- Notification title to tell the user that data service is blocked by access control. -->
+ <string name="RestrictedOnDataTitle">No data service</string>
+ <!-- Notification title to tell the user that emergency service is blocked by access control. -->
+ <string name="RestrictedOnEmergencyTitle">No emergency service</string>
+ <!-- Notification title to tell the user that normal service is blocked by access control. -->
+ <string name="RestrictedOnNormalTitle">No voice service</string>
+ <!-- Notification title to tell the user that all emergency and normal voice services are blocked by access control. -->
+ <string name="RestrictedOnAllVoiceTitle">No voice/emergency service</string>
+
+ <!-- Notification content to tell the user that data service is blocked by access control. -->
+ <string name="RestrictedOnDataContent">Your carrier has temporarily suspended data service at this location</string>
+ <!-- Notification content to tell the user that emergency service is blocked by access control. -->
+ <string name="RestrictedOnEmergencyContent">Your carrier has temporarily suspended emergency calls at this location</string>
+ <!-- Notification content to tell the user that normal service is blocked by access control. -->
+ <string name="RestrictedOnNormalContent">Your carrier has temporarily suspended voice calls at this location</string>
+ <!-- Notification content to tell the user that all emergency and normal voice services are blocked by access control. -->
+ <string name="RestrictedOnAllVoiceContent">Your carrier has temporarily suspended voice and emergency calls at this location</string>
<!-- Displayed to tell the user that they should switch their network preference. -->
<string name="NetworkPreferenceSwitchTitle">Can\u2019t reach network</string>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index b23c96c..92436f4 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -507,12 +507,16 @@
<java-symbol type="string" name="Noon" />
<java-symbol type="string" name="PinMmi" />
<java-symbol type="string" name="PwdMmi" />
- <java-symbol type="string" name="RestrictedOnAllVoice" />
- <java-symbol type="string" name="RestrictedOnData" />
- <java-symbol type="string" name="RestrictedOnEmergency" />
- <java-symbol type="string" name="RestrictedOnNormal" />
<java-symbol type="string" name="NetworkPreferenceSwitchSummary" />
<java-symbol type="string" name="NetworkPreferenceSwitchTitle" />
+ <java-symbol type="string" name="RestrictedOnAllVoiceTitle" />
+ <java-symbol type="string" name="RestrictedOnDataTitle" />
+ <java-symbol type="string" name="RestrictedOnEmergencyTitle" />
+ <java-symbol type="string" name="RestrictedOnNormalTitle" />
+ <java-symbol type="string" name="RestrictedOnAllVoiceContent" />
+ <java-symbol type="string" name="RestrictedOnDataContent" />
+ <java-symbol type="string" name="RestrictedOnEmergencyContent" />
+ <java-symbol type="string" name="RestrictedOnNormalContent" />
<java-symbol type="string" name="SetupCallDefault" />
<java-symbol type="string" name="accept" />
<java-symbol type="string" name="activity_chooser_view_see_all" />
@@ -2919,6 +2923,9 @@
<!-- Colon separated list of package names that should be granted Notification Listener access -->
<java-symbol type="string" name="config_defaultListenerAccessPackages" />
+ <!-- maximum width of the display -->
+ <java-symbol type="integer" name="config_maxUiWidth" />
+
<!-- system notification channels -->
<java-symbol type="string" name="notification_channel_virtual_keyboard" />
<java-symbol type="string" name="notification_channel_physical_keyboard" />
diff --git a/graphics/java/android/graphics/Color.java b/graphics/java/android/graphics/Color.java
index 33d19d4..d69f67d 100644
--- a/graphics/java/android/graphics/Color.java
+++ b/graphics/java/android/graphics/Color.java
@@ -22,6 +22,7 @@
import android.annotation.HalfFloat;
import android.annotation.IntRange;
import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.annotation.Size;
import android.util.Half;
@@ -288,7 +289,7 @@
* and <code>(1.0, 0.0, 0.0, 0.5)</code>.</p>
*/
@AnyThread
-public class Color {
+public final class Color {
@ColorInt public static final int BLACK = 0xFF000000;
@ColorInt public static final int DKGRAY = 0xFF444444;
@ColorInt public static final int GRAY = 0xFF888888;
@@ -415,7 +416,7 @@
* to this color space's color model, plus one extra component for
* alpha.
*
- * @return An integer between 4 and 5
+ * @return The integer 4 or 5
*/
@IntRange(from = 4, to = 5)
public int getComponentCount() {
@@ -560,7 +561,37 @@
@NonNull
@Size(min = 4, max = 5)
public float[] getComponents() {
- return Arrays.copyOf(mComponents, mColorSpace.getComponentCount() + 1);
+ return Arrays.copyOf(mComponents, mComponents.length);
+ }
+
+ /**
+ * Copies this color's components in the supplied array. The last element of the
+ * array is always the alpha component.
+ *
+ * @param components An array of floats whose size must be at least
+ * {@link #getComponentCount()}, can be null
+ * @return The array passed as a parameter if not null, or a new array of length
+ * {@link #getComponentCount()}
+ *
+ * @see #getComponent(int)
+ *
+ * @throws IllegalArgumentException If the specified array's length is less than
+ * {@link #getComponentCount()}
+ */
+ @NonNull
+ @Size(min = 4)
+ public float[] getComponents(@Nullable @Size(min = 4) float[] components) {
+ if (components == null) {
+ return Arrays.copyOf(mComponents, mComponents.length);
+ }
+
+ if (components.length < mComponents.length) {
+ throw new IllegalArgumentException("The specified array's length must be at "
+ + "least " + mComponents.length);
+ }
+
+ System.arraycopy(mComponents, 0, components, 0, mComponents.length);
+ return components;
}
/**
@@ -570,7 +601,7 @@
*
* <p>If the requested component index is {@link #getComponentCount()},
* this method returns the alpha component, always in the range
- * \([0..1\).</p>
+ * \([0..1]\).</p>
*
* @see #getComponents()
*
diff --git a/media/java/android/media/tv/TvContract.java b/media/java/android/media/tv/TvContract.java
index 6808b57..7bf69c0 100644
--- a/media/java/android/media/tv/TvContract.java
+++ b/media/java/android/media/tv/TvContract.java
@@ -1321,9 +1321,7 @@
*
* <p>Type: INTEGER (boolean)
* @see Channels#COLUMN_TRANSIENT
- * @hide
*/
- @SystemApi
public static final String COLUMN_TRANSIENT = "transient";
/**
@@ -2164,10 +2162,9 @@
* specified, this value is set to 0 (not transient) by default.
*
* <p>Type: INTEGER (boolean)
- * @see Programs#COLUMN_TRANSIENT
- * @hide
+ * @see PreviewPrograms#COLUMN_TRANSIENT
+ * @see WatchNextPrograms#COLUMN_TRANSIENT
*/
- @SystemApi
public static final String COLUMN_TRANSIENT = "transient";
/**
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index 64cac3c..f15475c 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -106,7 +106,7 @@
<!-- The default tiles to display in QuickSettings -->
<string name="quick_settings_tiles_default" translatable="false">
- wifi,cell,bt,dnd,flashlight,rotation,battery,airplane
+ wifi,bt,dnd,flashlight,rotation,battery,cell,airplane,cast
</string>
<!-- Tiles native to System UI. Order should match "quick_settings_tiles_default" -->
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSFooter.java b/packages/SystemUI/src/com/android/systemui/qs/QSFooter.java
index 716816d..d51fe8a 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSFooter.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSFooter.java
@@ -51,6 +51,7 @@
import com.android.systemui.statusbar.phone.ExpandableIndicator;
import com.android.systemui.statusbar.phone.MultiUserSwitch;
import com.android.systemui.statusbar.phone.SettingsButton;
+import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.statusbar.policy.NetworkController;
import com.android.systemui.statusbar.policy.NetworkController.EmergencyListener;
import com.android.systemui.statusbar.policy.NetworkController.SignalCallback;
@@ -337,6 +338,11 @@
@Override
public void onClick(View v) {
if (v == mSettingsButton) {
+ if (!Dependency.get(DeviceProvisionedController.class).isCurrentUserSetup()) {
+ // If user isn't setup just unlock the device and dump them back at SUW.
+ mActivityStarter.postQSRunnableDismissingKeyguard(() -> { });
+ return;
+ }
MetricsLogger.action(mContext,
mExpanded ? MetricsProto.MetricsEvent.ACTION_QS_EXPANDED_SETTINGS_LAUNCH
: MetricsProto.MetricsEvent.ACTION_QS_COLLAPSED_SETTINGS_LAUNCH);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
index 3f7e340..a5d7c57 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -417,7 +417,10 @@
getHomeButton().setImageDrawable(mHomeDefaultIcon);
}
- final boolean showImeButton = ((hints & StatusBarManager.NAVIGATION_HINT_IME_SHOWN) != 0);
+ // The Accessibility button always overrides the appearance of the IME switcher
+ final boolean showImeButton =
+ !mShowAccessibilityButton && ((hints & StatusBarManager.NAVIGATION_HINT_IME_SHOWN)
+ != 0);
getImeSwitchButton().setVisibility(showImeButton ? View.VISIBLE : View.INVISIBLE);
getImeSwitchButton().setImageDrawable(mImeIcon);
@@ -545,8 +548,9 @@
mShowAccessibilityButton = visible;
mLongClickableAccessibilityButton = longClickable;
if (visible) {
- // Accessibility button overrides Menu button.
+ // Accessibility button overrides Menu and IME switcher buttons.
setMenuVisibility(false, true);
+ getImeSwitchButton().setVisibility(View.INVISIBLE);
}
getAccessibilityButton().setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeviceProvisionedController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeviceProvisionedController.java
index 21f9a79..cae76b4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeviceProvisionedController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeviceProvisionedController.java
@@ -24,6 +24,10 @@
boolean isUserSetup(int currentUser);
int getCurrentUser();
+ default boolean isCurrentUserSetup() {
+ return isUserSetup(getCurrentUser());
+ }
+
interface DeviceProvisionedListener {
default void onDeviceProvisionedChanged() { }
default void onUserSwitched() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSFooterTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSFooterTest.java
new file mode 100644
index 0000000..778ab8e
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSFooterTest.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package com.android.systemui.qs;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.testing.AndroidTestingRunner;
+import android.testing.TestableLooper;
+import android.testing.TestableLooper.RunWithLooper;
+import android.view.LayoutInflater;
+import android.view.View;
+
+import com.android.systemui.R;
+import com.android.systemui.R.id;
+import com.android.systemui.plugins.ActivityStarter;
+import com.android.systemui.statusbar.policy.DeviceProvisionedController;
+import com.android.systemui.utils.leaks.LeakCheckedTest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidTestingRunner.class)
+@RunWithLooper
+public class QSFooterTest extends LeakCheckedTest {
+
+ private QSFooter mFooter;
+ private ActivityStarter mActivityStarter;
+ private DeviceProvisionedController mDeviceProvisionedController;
+
+ @Before
+ public void setup() throws Exception {
+ injectLeakCheckedDependencies(ALL_SUPPORTED_CLASSES);
+ mActivityStarter = mDependency.injectMockDependency(ActivityStarter.class);
+ mDeviceProvisionedController = mDependency.injectMockDependency(
+ DeviceProvisionedController.class);
+ TestableLooper.get(this).runWithLooper(() -> {
+ mFooter = (QSFooter) LayoutInflater.from(mContext).inflate(R.layout.qs_footer, null);
+ });
+ }
+
+ @Test
+ public void testSettings_UserNotSetup() {
+ View settingsButton = mFooter.findViewById(id.settings_button);
+ when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(false);
+
+ mFooter.onClick(settingsButton);
+ // Verify Settings wasn't launched.
+ verify(mActivityStarter, never()).startActivity(any(), anyBoolean());
+ }
+}
diff --git a/services/core/java/com/android/server/UiThread.java b/services/core/java/com/android/server/UiThread.java
index 1bc6250..fd88d26 100644
--- a/services/core/java/com/android/server/UiThread.java
+++ b/services/core/java/com/android/server/UiThread.java
@@ -17,6 +17,7 @@
package com.android.server;
import android.os.Handler;
+import android.os.Looper;
import android.os.Process;
import android.os.Trace;
@@ -26,20 +27,28 @@
* on it to avoid UI jank.
*/
public final class UiThread extends ServiceThread {
+ private static final long SLOW_DISPATCH_THRESHOLD_MS = 100;
private static UiThread sInstance;
private static Handler sHandler;
private UiThread() {
super("android.ui", Process.THREAD_PRIORITY_FOREGROUND, false /*allowIo*/);
+ }
+
+ @Override
+ public void run() {
// Make sure UiThread is in the fg stune boost group
Process.setThreadGroup(Process.myTid(), Process.THREAD_GROUP_TOP_APP);
+ super.run();
}
private static void ensureThreadLocked() {
if (sInstance == null) {
sInstance = new UiThread();
sInstance.start();
- sInstance.getLooper().setTraceTag(Trace.TRACE_TAG_ACTIVITY_MANAGER);
+ final Looper looper = sInstance.getLooper();
+ looper.setTraceTag(Trace.TRACE_TAG_ACTIVITY_MANAGER);
+ looper.setSlowDispatchThresholdMs(SLOW_DISPATCH_THRESHOLD_MS);
sHandler = new Handler(sInstance.getLooper());
}
}
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index ce9a904..ead1b26 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -3929,8 +3929,13 @@
if ((app.info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
// Debuggable apps may include a wrapper script with their library directory.
String wrapperFileName = app.info.nativeLibraryDir + "/wrap.sh";
- if (new File(wrapperFileName).exists()) {
- invokeWith = "/system/bin/logwrapper " + wrapperFileName;
+ StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
+ try {
+ if (new File(wrapperFileName).exists()) {
+ invokeWith = "/system/bin/logwrapper " + wrapperFileName;
+ }
+ } finally {
+ StrictMode.setThreadPolicy(oldPolicy);
}
}
diff --git a/services/core/java/com/android/server/am/ActivityStarter.java b/services/core/java/com/android/server/am/ActivityStarter.java
index 4bd06b7..9258539 100644
--- a/services/core/java/com/android/server/am/ActivityStarter.java
+++ b/services/core/java/com/android/server/am/ActivityStarter.java
@@ -640,6 +640,18 @@
final Intent ephemeralIntent = new Intent(intent);
// Don't modify the client's object!
intent = new Intent(intent);
+ if (componentSpecified
+ && intent.getData() != null
+ && Intent.ACTION_VIEW.equals(intent.getAction())
+ && intent.hasCategory(Intent.CATEGORY_BROWSABLE)
+ && mService.getPackageManagerInternalLocked()
+ .isInstantAppInstallerComponent(intent.getComponent())) {
+ // intercept intents targeted directly to the ephemeral installer the
+ // ephemeral installer should never be started with a raw URL; instead
+ // adjust the intent so it looks like a "normal" instant app launch
+ intent.setComponent(null /*component*/);
+ componentSpecified = false;
+ }
ResolveInfo rInfo = mSupervisor.resolveIntent(intent, resolvedType, userId);
if (rInfo == null) {
@@ -1453,6 +1465,12 @@
return intentActivity;
}
+ /**
+ * Figure out which task and activity to bring to front when we have found an existing matching
+ * activity record in history. May also clear the task if needed.
+ * @param intentActivity Existing matching activity.
+ * @return {@link ActivityRecord} brought to front.
+ */
private ActivityRecord setTargetStackAndMoveToFrontIfNeeded(ActivityRecord intentActivity) {
mTargetStack = intentActivity.getStack();
mTargetStack.mLastPausedActivity = null;
@@ -1514,6 +1532,14 @@
"bringToFrontInsteadOfAdjacentLaunch");
}
mMovedToFront = true;
+ } else if (launchStack.mDisplayId != mTargetStack.mDisplayId) {
+ // Target and computed stacks are on different displays and we've
+ // found a matching task - move the existing instance to that display and
+ // move it to front.
+ intentActivity.task.reparent(launchStack.mStackId, ON_TOP,
+ REPARENT_MOVE_STACK_TO_FRONT, ANIMATE, DEFER_RESUME,
+ "reparentToDisplay");
+ mMovedToFront = true;
}
mOptions = null;
diff --git a/services/core/java/com/android/server/media/MediaSessionRecord.java b/services/core/java/com/android/server/media/MediaSessionRecord.java
index 7f75c83..53a8092 100644
--- a/services/core/java/com/android/server/media/MediaSessionRecord.java
+++ b/services/core/java/com/android/server/media/MediaSessionRecord.java
@@ -772,7 +772,12 @@
private final class SessionStub extends ISession.Stub {
@Override
public void destroy() {
- mService.destroySession(MediaSessionRecord.this);
+ final long token = Binder.clearCallingIdentity();
+ try {
+ mService.destroySession(MediaSessionRecord.this);
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
}
@Override
diff --git a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
index fc45344..b165d34 100644
--- a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
+++ b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
@@ -75,6 +75,9 @@
import static android.net.wifi.WifiManager.EXTRA_NETWORK_INFO;
import static android.net.wifi.WifiManager.EXTRA_WIFI_CONFIGURATION;
import static android.net.wifi.WifiManager.EXTRA_WIFI_INFO;
+import static android.telephony.CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED;
+import static android.telephony.CarrierConfigManager.DATA_CYCLE_USE_PLATFORM_DEFAULT;
+import static android.telephony.CarrierConfigManager.DATA_CYCLE_THRESHOLD_DISABLED;
import static android.text.format.DateUtils.DAY_IN_MILLIS;
import static com.android.internal.util.ArrayUtils.appendInt;
@@ -141,6 +144,7 @@
import android.os.INetworkManagementService;
import android.os.Message;
import android.os.MessageQueue.IdleHandler;
+import android.os.PersistableBundle;
import android.os.PowerManager;
import android.os.PowerManagerInternal;
import android.os.Process;
@@ -153,6 +157,7 @@
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
+import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
@@ -174,12 +179,14 @@
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.notification.SystemNotificationChannels;
+import com.android.internal.telephony.PhoneConstants;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.FastXmlSerializer;
import com.android.internal.util.IndentingPrintWriter;
import com.android.server.DeviceIdleController;
import com.android.server.EventLogTags;
import com.android.server.LocalServices;
+import com.android.server.ServiceThread;
import com.android.server.SystemConfig;
import com.android.server.power.BatterySaverPolicy.ServiceType;
@@ -204,6 +211,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Calendar;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -310,6 +318,9 @@
private static final int MSG_SET_FIREWALL_RULES = 14;
private static final int MSG_RESET_FIREWALL_RULES_BY_UID = 15;
+ private static final int UID_MSG_STATE_CHANGED = 100;
+ private static final int UID_MSG_GONE = 101;
+
private final Context mContext;
private final IActivityManager mActivityManager;
private final INetworkStatsService mNetworkStats;
@@ -317,6 +328,7 @@
private UsageStatsManagerInternal mUsageStats;
private final TrustedTime mTime;
private final UserManager mUserManager;
+ private final CarrierConfigManager mCarrierConfigManager;
private IConnectivityManager mConnManager;
private INotificationManager mNotifManager;
@@ -420,6 +432,9 @@
mListeners = new RemoteCallbackList<>();
final Handler mHandler;
+ final Handler mUidEventHandler;
+
+ private final ServiceThread mUidEventThread;
@GuardedBy("allLocks")
private final AtomicFile mPolicyFile;
@@ -465,12 +480,19 @@
Context.DEVICE_IDLE_CONTROLLER));
mTime = checkNotNull(time, "missing TrustedTime");
mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
+ mCarrierConfigManager = mContext.getSystemService(CarrierConfigManager.class);
mIPm = pm;
HandlerThread thread = new HandlerThread(TAG);
thread.start();
mHandler = new Handler(thread.getLooper(), mHandlerCallback);
+ // We create another thread for the UID events, which are more time-critical.
+ mUidEventThread = new ServiceThread(TAG + ".uid", Process.THREAD_PRIORITY_FOREGROUND,
+ /*allowIo=*/ false);
+ mUidEventThread.start();
+ mUidEventHandler = new Handler(mUidEventThread.getLooper(), mUidEventHandlerCallback);
+
mSuppressDefaultPolicy = suppressDefaultPolicy;
mPolicyFile = new AtomicFile(new File(systemDir, "netpolicy.xml"));
@@ -743,6 +765,11 @@
WifiManager.NETWORK_STATE_CHANGED_ACTION);
mContext.registerReceiver(mWifiStateReceiver, wifiStateFilter, null, mHandler);
+ // listen for carrier config changes to update data cycle information
+ final IntentFilter carrierConfigFilter = new IntentFilter(
+ ACTION_CARRIER_CONFIG_CHANGED);
+ mContext.registerReceiver(mCarrierConfigReceiver, carrierConfigFilter, null, mHandler);
+
mUsageStats.addAppIdleStateChangeListener(new AppIdleStateChangeListener());
// tell systemReady() that the service has been initialized
initCompleteSignal.countDown();
@@ -774,26 +801,12 @@
final private IUidObserver mUidObserver = new IUidObserver.Stub() {
@Override public void onUidStateChanged(int uid, int procState,
long procStateSeq) throws RemoteException {
- Trace.traceBegin(Trace.TRACE_TAG_NETWORK, "onUidStateChanged");
- try {
- synchronized (mUidRulesFirstLock) {
- // We received a uid state change callback, add it to the history so that it
- // will be useful for debugging.
- mObservedHistory.addProcStateSeqUL(uid, procStateSeq);
- // Now update the network policy rules as per the updated uid state.
- updateUidStateUL(uid, procState);
- // Updating the network rules is done, so notify AMS about this.
- mActivityManagerInternal.notifyNetworkPolicyRulesUpdated(uid, procStateSeq);
- }
- } finally {
- Trace.traceEnd(Trace.TRACE_TAG_NETWORK);
- }
+ mUidEventHandler.obtainMessage(UID_MSG_STATE_CHANGED,
+ uid, procState, procStateSeq).sendToTarget();
}
@Override public void onUidGone(int uid, boolean disabled) throws RemoteException {
- synchronized (mUidRulesFirstLock) {
- removeUidStateUL(uid);
- }
+ mUidEventHandler.obtainMessage(UID_MSG_GONE, uid, 0).sendToTarget();
}
@Override public void onUidActive(int uid) throws RemoteException {
@@ -1293,6 +1306,213 @@
};
/**
+ * Update mobile policies with data cycle information from {@link CarrierConfigManager}
+ * if necessary.
+ *
+ * @param subId that has its associated NetworkPolicy updated if necessary
+ * @return if any policies were updated
+ */
+ private boolean maybeUpdateMobilePolicyCycleNL(int subId) {
+ if (LOGV) Slog.v(TAG, "maybeUpdateMobilePolicyCycleNL()");
+ final PersistableBundle config = mCarrierConfigManager.getConfigForSubId(subId);
+
+ if (config == null) {
+ return false;
+ }
+
+ boolean policyUpdated = false;
+ final String subscriberId = TelephonyManager.from(mContext).getSubscriberId(subId);
+
+ // find and update the mobile NetworkPolicy for this subscriber id
+ final NetworkIdentity probeIdent = new NetworkIdentity(TYPE_MOBILE,
+ TelephonyManager.NETWORK_TYPE_UNKNOWN, subscriberId, null, false, true);
+ for (int i = mNetworkPolicy.size() - 1; i >= 0; i--) {
+ final NetworkTemplate template = mNetworkPolicy.keyAt(i);
+ if (template.matches(probeIdent)) {
+ NetworkPolicy policy = mNetworkPolicy.valueAt(i);
+
+ // only update the policy if the user didn't change any of the defaults.
+ if (!policy.inferred) {
+ // TODO: inferred could be split, so that if a user changes their data limit or
+ // warning, it doesn't prevent their cycle date from being updated.
+ if (LOGD) Slog.v(TAG, "Didn't update NetworkPolicy because policy.inferred");
+ continue;
+ }
+
+ final int cycleDay = getCycleDayFromCarrierConfig(config, policy.cycleDay);
+ final long warningBytes = getWarningBytesFromCarrierConfig(config,
+ policy.warningBytes);
+ final long limitBytes = getLimitBytesFromCarrierConfig(config,
+ policy.limitBytes);
+
+ if (policy.cycleDay == cycleDay &&
+ policy.warningBytes == warningBytes &&
+ policy.limitBytes == limitBytes) {
+ continue;
+ }
+
+ policyUpdated = true;
+ policy.cycleDay = cycleDay;
+ policy.warningBytes = warningBytes;
+ policy.limitBytes = limitBytes;
+
+ if (LOGD) {
+ Slog.d(TAG, "Updated NetworkPolicy " + policy + " which matches subscriber "
+ + NetworkIdentity.scrubSubscriberId(subscriberId)
+ + " from CarrierConfigManager");
+ }
+ }
+ }
+
+ return policyUpdated;
+ }
+
+ /**
+ * Returns the cycle day that should be used for a mobile NetworkPolicy.
+ *
+ * It attempts to get an appropriate cycle day from the passed in CarrierConfig. If it's unable
+ * to do so, it returns the fallback value.
+ *
+ * @param config The CarrierConfig to read the value from.
+ * @param fallbackCycleDay to return if the CarrierConfig can't be read.
+ * @return cycleDay to use in the mobile NetworkPolicy.
+ */
+ @VisibleForTesting
+ public int getCycleDayFromCarrierConfig(@Nullable PersistableBundle config,
+ int fallbackCycleDay) {
+ if (config == null) {
+ return fallbackCycleDay;
+ }
+ int cycleDay =
+ config.getInt(CarrierConfigManager.KEY_MONTHLY_DATA_CYCLE_DAY_INT);
+ if (cycleDay == DATA_CYCLE_USE_PLATFORM_DEFAULT) {
+ return fallbackCycleDay;
+ }
+ // validate cycleDay value
+ final Calendar cal = Calendar.getInstance();
+ if (cycleDay < cal.getMinimum(Calendar.DAY_OF_MONTH) ||
+ cycleDay > cal.getMaximum(Calendar.DAY_OF_MONTH)) {
+ Slog.e(TAG, "Invalid date in "
+ + "CarrierConfigManager.KEY_MONTHLY_DATA_CYCLE_DAY_INT: " + cycleDay);
+ return fallbackCycleDay;
+ }
+ return cycleDay;
+ }
+
+ /**
+ * Returns the warning bytes that should be used for a mobile NetworkPolicy.
+ *
+ * It attempts to get an appropriate value from the passed in CarrierConfig. If it's unable
+ * to do so, it returns the fallback value.
+ *
+ * @param config The CarrierConfig to read the value from.
+ * @param fallbackWarningBytes to return if the CarrierConfig can't be read.
+ * @return warningBytes to use in the mobile NetworkPolicy.
+ */
+ @VisibleForTesting
+ public long getWarningBytesFromCarrierConfig(@Nullable PersistableBundle config,
+ long fallbackWarningBytes) {
+ if (config == null) {
+ return fallbackWarningBytes;
+ }
+ long warningBytes =
+ config.getLong(CarrierConfigManager.KEY_DATA_WARNING_THRESHOLD_BYTES_LONG);
+
+ if (warningBytes == DATA_CYCLE_THRESHOLD_DISABLED) {
+ return WARNING_DISABLED;
+ } else if (warningBytes == DATA_CYCLE_USE_PLATFORM_DEFAULT) {
+ return getPlatformDefaultWarningBytes();
+ } else if (warningBytes < 0) {
+ Slog.e(TAG, "Invalid value in "
+ + "CarrierConfigManager.KEY_DATA_WARNING_THRESHOLD_BYTES_LONG; expected a "
+ + "non-negative value but got: " + warningBytes);
+ return fallbackWarningBytes;
+ }
+
+ return warningBytes;
+ }
+
+ /**
+ * Returns the limit bytes that should be used for a mobile NetworkPolicy.
+ *
+ * It attempts to get an appropriate value from the passed in CarrierConfig. If it's unable
+ * to do so, it returns the fallback value.
+ *
+ * @param config The CarrierConfig to read the value from.
+ * @param fallbackLimitBytes to return if the CarrierConfig can't be read.
+ * @return limitBytes to use in the mobile NetworkPolicy.
+ */
+ @VisibleForTesting
+ public long getLimitBytesFromCarrierConfig(@Nullable PersistableBundle config,
+ long fallbackLimitBytes) {
+ if (config == null) {
+ return fallbackLimitBytes;
+ }
+ long limitBytes =
+ config.getLong(CarrierConfigManager.KEY_DATA_LIMIT_THRESHOLD_BYTES_LONG);
+
+ if (limitBytes == DATA_CYCLE_THRESHOLD_DISABLED) {
+ return LIMIT_DISABLED;
+ } else if (limitBytes == DATA_CYCLE_USE_PLATFORM_DEFAULT) {
+ return getPlatformDefaultLimitBytes();
+ } else if (limitBytes < 0) {
+ Slog.e(TAG, "Invalid value in "
+ + "CarrierConfigManager.KEY_DATA_LIMIT_THRESHOLD_BYTES_LONG; expected a "
+ + "non-negative value but got: " + limitBytes);
+ return fallbackLimitBytes;
+ }
+ return limitBytes;
+ }
+
+ /**
+ * Receiver that watches for {@link CarrierConfigManager} to be changed.
+ */
+ private BroadcastReceiver mCarrierConfigReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ // No need to do a permission check, because the ACTION_CARRIER_CONFIG_CHANGED
+ // broadcast is protected and can't be spoofed. Runs on a background handler thread.
+
+ if (!intent.hasExtra(PhoneConstants.SUBSCRIPTION_KEY)) {
+ return;
+ }
+ final int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY, -1);
+ final TelephonyManager tele = TelephonyManager.from(mContext);
+ final String subscriberId = tele.getSubscriberId(subId);
+
+ maybeRefreshTrustedTime();
+ synchronized (mUidRulesFirstLock) {
+ synchronized (mNetworkPoliciesSecondLock) {
+ final boolean added = ensureActiveMobilePolicyNL(subId, subscriberId);
+ if (added) return;
+ final boolean updated = maybeUpdateMobilePolicyCycleNL(subId);
+ if (!updated) return;
+ // update network and notification rules, as the data cycle changed and it's
+ // possible that we should be triggering warnings/limits now
+ handleNetworkPoliciesUpdateAL(true);
+ }
+ }
+ }
+ };
+
+ /**
+ * Handles all tasks that need to be run after a new network policy has been set, or an existing
+ * one has been updated.
+ *
+ * @param shouldNormalizePolicies true iff network policies need to be normalized after the
+ * update.
+ */
+ void handleNetworkPoliciesUpdateAL(boolean shouldNormalizePolicies) {
+ if (shouldNormalizePolicies) {
+ normalizePoliciesNL();
+ }
+ updateNetworkEnabledNL();
+ updateNetworkRulesNL();
+ updateNotificationsNL();
+ writePolicyAL();
+ }
+
+ /**
* Proactively control network data connections when they exceed
* {@link NetworkPolicy#limitBytes}.
*/
@@ -1517,11 +1737,19 @@
final int[] subIds = sub.getActiveSubscriptionIdList();
for (int subId : subIds) {
final String subscriberId = tele.getSubscriberId(subId);
- ensureActiveMobilePolicyNL(subscriberId);
+ ensureActiveMobilePolicyNL(subId, subscriberId);
}
}
- private void ensureActiveMobilePolicyNL(String subscriberId) {
+ /**
+ * Once any {@link #mNetworkPolicy} are loaded from disk, ensure that we
+ * have at least a default mobile policy defined.
+ *
+ * @param subId to build a default policy for
+ * @param subscriberId that we check for an existing policy
+ * @return true if a mobile network policy was added, or false one already existed.
+ */
+ private boolean ensureActiveMobilePolicyNL(int subId, String subscriberId) {
// Poke around to see if we already have a policy
final NetworkIdentity probeIdent = new NetworkIdentity(TYPE_MOBILE,
TelephonyManager.NETWORK_TYPE_UNKNOWN, subscriberId, null, false, true);
@@ -1532,33 +1760,51 @@
Slog.d(TAG, "Found template " + template + " which matches subscriber "
+ NetworkIdentity.scrubSubscriberId(subscriberId));
}
- return;
+ return false;
}
}
Slog.i(TAG, "No policy for subscriber " + NetworkIdentity.scrubSubscriberId(subscriberId)
+ "; generating default policy");
+ final NetworkPolicy policy = buildDefaultMobilePolicy(subId, subscriberId);
+ addNetworkPolicyNL(policy);
+ return true;
+ }
- // Build default mobile policy, and assume usage cycle starts today
+ private long getPlatformDefaultWarningBytes() {
final int dataWarningConfig = mContext.getResources().getInteger(
com.android.internal.R.integer.config_networkPolicyDefaultWarning);
- final long warningBytes;
if (dataWarningConfig == WARNING_DISABLED) {
- warningBytes = WARNING_DISABLED;
+ return WARNING_DISABLED;
} else {
- warningBytes = dataWarningConfig * MB_IN_BYTES;
+ return dataWarningConfig * MB_IN_BYTES;
}
+ }
+ private long getPlatformDefaultLimitBytes() {
+ return LIMIT_DISABLED;
+ }
+
+ @VisibleForTesting
+ public NetworkPolicy buildDefaultMobilePolicy(int subId, String subscriberId) {
+ PersistableBundle config = mCarrierConfigManager.getConfigForSubId(subId);
+
+ // assume usage cycle starts today
final Time time = new Time();
time.setToNow();
- final int cycleDay = time.monthDay;
final String cycleTimezone = time.timezone;
+ final int cycleDay = getCycleDayFromCarrierConfig(config, time.monthDay);
+ final long warningBytes = getWarningBytesFromCarrierConfig(config,
+ getPlatformDefaultWarningBytes());
+ final long limitBytes = getLimitBytesFromCarrierConfig(config,
+ getPlatformDefaultLimitBytes());
+
final NetworkTemplate template = buildTemplateMobileAll(subscriberId);
final NetworkPolicy policy = new NetworkPolicy(template, cycleDay, cycleTimezone,
- warningBytes, LIMIT_DISABLED, SNOOZE_NEVER, SNOOZE_NEVER, true, true);
- addNetworkPolicyNL(policy);
+ warningBytes, limitBytes, SNOOZE_NEVER, SNOOZE_NEVER, true, true);
+ return policy;
}
private void readPolicyAL() {
@@ -2026,10 +2272,7 @@
synchronized (mUidRulesFirstLock) {
synchronized (mNetworkPoliciesSecondLock) {
normalizePoliciesNL(policies);
- updateNetworkEnabledNL();
- updateNetworkRulesNL();
- updateNotificationsNL();
- writePolicyAL();
+ handleNetworkPoliciesUpdateAL(false);
}
}
} finally {
@@ -2126,11 +2369,7 @@
throw new IllegalArgumentException("unexpected type");
}
- normalizePoliciesNL();
- updateNetworkEnabledNL();
- updateNetworkRulesNL();
- updateNotificationsNL();
- writePolicyAL();
+ handleNetworkPoliciesUpdateAL(true);
}
}
}
@@ -2361,11 +2600,7 @@
mNetworkPolicy.valueAt(i).clearSnooze();
}
- normalizePoliciesNL();
- updateNetworkEnabledNL();
- updateNetworkRulesNL();
- updateNotificationsNL();
- writePolicyAL();
+ handleNetworkPoliciesUpdateAL(true);
fout.println("Cleared snooze timestamps");
return;
@@ -3317,7 +3552,7 @@
}
}
- private Handler.Callback mHandlerCallback = new Handler.Callback() {
+ private final Handler.Callback mHandlerCallback = new Handler.Callback() {
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
@@ -3441,9 +3676,61 @@
}
}
}
+ };
+
+ private final Handler.Callback mUidEventHandlerCallback = new Handler.Callback() {
+ @Override
+ public boolean handleMessage(Message msg) {
+ switch (msg.what) {
+ case UID_MSG_STATE_CHANGED: {
+ final int uid = msg.arg1;
+ final int procState = msg.arg2;
+ final long procStateSeq = (Long) msg.obj;
+
+ handleUidChanged(uid, procState, procStateSeq);
+ return true;
+ }
+ case UID_MSG_GONE: {
+ final int uid = msg.arg1;
+ handleUidGone(uid);
+ return true;
+ }
+ default: {
+ return false;
+ }
+ }
+ }
};
+ void handleUidChanged(int uid, int procState, long procStateSeq) {
+ Trace.traceBegin(Trace.TRACE_TAG_NETWORK, "onUidStateChanged");
+ try {
+ synchronized (mUidRulesFirstLock) {
+ // We received a uid state change callback, add it to the history so that it
+ // will be useful for debugging.
+ mObservedHistory.addProcStateSeqUL(uid, procStateSeq);
+ // Now update the network policy rules as per the updated uid state.
+ updateUidStateUL(uid, procState);
+ // Updating the network rules is done, so notify AMS about this.
+ mActivityManagerInternal.notifyNetworkPolicyRulesUpdated(uid, procStateSeq);
+ }
+ } finally {
+ Trace.traceEnd(Trace.TRACE_TAG_NETWORK);
+ }
+ }
+
+ void handleUidGone(int uid) {
+ Trace.traceBegin(Trace.TRACE_TAG_NETWORK, "onUidGone");
+ try {
+ synchronized (mUidRulesFirstLock) {
+ removeUidStateUL(uid);
+ }
+ } finally {
+ Trace.traceEnd(Trace.TRACE_TAG_NETWORK);
+ }
+ }
+
private void broadcastRestrictBackgroundChanged(int uid, Boolean changed) {
final PackageManager pm = mContext.getPackageManager();
final String[] packages = pm.getPackagesForUid(uid);
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 8cc9375..621e37b 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -842,6 +842,8 @@
/** Component used to install ephemeral applications */
ComponentName mInstantAppInstallerComponent;
+ /** Component used to show resolver settings for Instant Apps */
+ ComponentName mInstantAppResolverSettingsComponent;
ActivityInfo mInstantAppInstallerActivity;
final ResolveInfo mInstantAppInstallerInfo = new ResolveInfo();
@@ -2890,6 +2892,7 @@
mInstantAppResolverConnection = null;
}
updateInstantAppInstallerLocked();
+ mInstantAppResolverSettingsComponent = getEphemeralResolverSettingsLPr();
// Read and update the usage of dex files.
// Do this at the end of PM init so that all the packages have their
@@ -3196,6 +3199,37 @@
}
}
+ private @Nullable ComponentName getEphemeralResolverSettingsLPr() {
+ final Intent intent = new Intent(Intent.ACTION_EPHEMERAL_RESOLVER_SETTINGS);
+ intent.addCategory(Intent.CATEGORY_DEFAULT);
+ final int resolveFlags =
+ MATCH_DIRECT_BOOT_AWARE
+ | MATCH_DIRECT_BOOT_UNAWARE
+ | (!Build.IS_DEBUGGABLE ? MATCH_SYSTEM_ONLY : 0);
+ final List<ResolveInfo> matches = queryIntentActivitiesInternal(intent, null,
+ resolveFlags, UserHandle.USER_SYSTEM);
+ Iterator<ResolveInfo> iter = matches.iterator();
+ while (iter.hasNext()) {
+ final ResolveInfo rInfo = iter.next();
+ final PackageSetting ps = mSettings.mPackages.get(rInfo.activityInfo.packageName);
+ if (ps != null) {
+ final PermissionsState permissionsState = ps.getPermissionsState();
+ if (permissionsState.hasPermission(Manifest.permission.ACCESS_INSTANT_APPS, 0)) {
+ continue;
+ }
+ }
+ iter.remove();
+ }
+ if (matches.size() == 0) {
+ return null;
+ } else if (matches.size() == 1) {
+ return matches.get(0).getComponentInfo().getComponentName();
+ } else {
+ throw new RuntimeException(
+ "There must be at most one ephemeral resolver settings; found " + matches);
+ }
+ }
+
private void primeDomainVerificationsLPw(int userId) {
if (DEBUG_DOMAIN_VERIFICATION) {
Slog.d(TAG, "Priming domain verifications in user " + userId);
@@ -5788,6 +5822,10 @@
return false;
}
if (ps.getInstantApp(userId)) {
+ if (DEBUG_EPHEMERAL) {
+ Slog.v(TAG, "DENY instant app installed;"
+ + " pkg: " + packageName);
+ }
return false;
}
}
@@ -6267,7 +6305,6 @@
intent, resolvedType, flags, userId), userId);
addEphemeral = !ephemeralDisabled
&& isEphemeralAllowed(intent, result, userId, false /*skipPackageCheck*/);
-
// Check for cross profile results.
boolean hasNonNegativePriorityResult = hasNonNegativePriority(result);
xpResolveInfo = queryCrossProfileIntents(
@@ -6323,7 +6360,7 @@
} else {
// the caller wants to resolve for a particular package; however, there
// were no installed results, so, try to find an ephemeral result
- addEphemeral = !ephemeralDisabled
+ addEphemeral = !ephemeralDisabled
&& isEphemeralAllowed(
intent, null /*result*/, userId, true /*skipPackageCheck*/);
result = new ArrayList<ResolveInfo>();
@@ -23073,6 +23110,13 @@
}
@Override
+ public boolean isInstantAppInstallerComponent(ComponentName component) {
+ synchronized (mPackages) {
+ return component != null && component.equals(mInstantAppInstallerComponent);
+ }
+ }
+
+ @Override
public void pruneInstantApps() {
synchronized (mPackages) {
mInstantAppRegistry.pruneInstantAppsLPw();
@@ -23313,4 +23357,9 @@
}
return checkUidPermission(appOpPermission, uid) == PERMISSION_GRANTED;
}
+
+ @Override
+ public ComponentName getInstantAppResolverSettingsComponent() {
+ return mInstantAppResolverSettingsComponent;
+ }
}
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index 8f391a7..aa85574 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -175,6 +175,7 @@
private boolean mTmpRecoveringMemory;
private boolean mUpdateImeTarget;
private boolean mTmpInitial;
+ private int mMaxUiWidth;
// Mapping from a token IBinder to a WindowToken object on this display.
private final HashMap<IBinder, WindowToken> mTokenMap = new HashMap();
@@ -1559,6 +1560,39 @@
}
}
+ /** Sets the maximum width the screen resolution can be */
+ void setMaxUiWidth(int width) {
+ if (DEBUG_DISPLAY) {
+ Slog.v(TAG_WM, "Setting max ui width:" + width + " on display:" + getDisplayId());
+ }
+
+ mMaxUiWidth = width;
+
+ // Update existing metrics.
+ updateBaseDisplayMetrics(mBaseDisplayWidth, mBaseDisplayHeight, mBaseDisplayDensity);
+ }
+
+ /** Update base (override) display metrics. */
+ void updateBaseDisplayMetrics(int baseWidth, int baseHeight, int baseDensity) {
+ mBaseDisplayWidth = baseWidth;
+ mBaseDisplayHeight = baseHeight;
+ mBaseDisplayDensity = baseDensity;
+
+ if (mMaxUiWidth > 0 && mBaseDisplayWidth > mMaxUiWidth) {
+ mBaseDisplayHeight = (mMaxUiWidth * mBaseDisplayHeight) / mBaseDisplayWidth;
+ mBaseDisplayDensity = (mMaxUiWidth * mBaseDisplayDensity) / mBaseDisplayWidth;
+ mBaseDisplayWidth = mMaxUiWidth;
+
+ if (DEBUG_DISPLAY) {
+ Slog.v(TAG_WM, "Applying config restraints:" + mBaseDisplayWidth + "x"
+ + mBaseDisplayHeight + " at density:" + mBaseDisplayDensity
+ + " on display:" + getDisplayId());
+ }
+ }
+
+ mBaseDisplayRect.set(0, 0, mBaseDisplayWidth, mBaseDisplayHeight);
+ }
+
void getContentRect(Rect out) {
out.set(mContentRect);
}
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index fa9c2a7..0dc74d7 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -385,6 +385,7 @@
final boolean mAllowBootMessages;
final boolean mLimitedAlphaCompositing;
+ final int mMaxUiWidth;
final WindowManagerPolicy mPolicy;
@@ -949,6 +950,8 @@
com.android.internal.R.integer.config_drawLockTimeoutMillis);
mAllowAnimationsInLowPowerMode = context.getResources().getBoolean(
com.android.internal.R.bool.config_allowAnimationsInLowPowerMode);
+ mMaxUiWidth = context.getResources().getInteger(
+ com.android.internal.R.integer.config_maxUiWidth);
mInputManager = inputManager; // Must be before createDisplayContentLocked.
mDisplayManagerInternal = LocalServices.getService(DisplayManagerInternal.class);
mDisplaySettings = new DisplaySettings();
@@ -4572,6 +4575,9 @@
synchronized(mWindowMap) {
final DisplayContent displayContent = getDefaultDisplayContentLocked();
+ if (mMaxUiWidth > 0) {
+ displayContent.setMaxUiWidth(mMaxUiWidth);
+ }
readForcedDisplayPropertiesLocked(displayContent);
mDisplayReady = true;
}
diff --git a/services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java
index 29c6f89..dbba727 100644
--- a/services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java
@@ -19,6 +19,7 @@
import static android.net.ConnectivityManager.CONNECTIVITY_ACTION;
import static android.net.ConnectivityManager.TYPE_WIFI;
import static android.net.NetworkPolicy.LIMIT_DISABLED;
+import static android.net.NetworkPolicy.SNOOZE_NEVER;
import static android.net.NetworkPolicy.WARNING_DISABLED;
import static android.net.NetworkPolicyManager.POLICY_ALLOW_METERED_BACKGROUND;
import static android.net.NetworkPolicyManager.POLICY_NONE;
@@ -26,8 +27,15 @@
import static android.net.NetworkPolicyManager.computeLastCycleBoundary;
import static android.net.NetworkPolicyManager.computeNextCycleBoundary;
import static android.net.NetworkPolicyManager.uidPoliciesToString;
+import static android.net.NetworkTemplate.buildTemplateMobileAll;
import static android.net.TrafficStats.KB_IN_BYTES;
import static android.net.TrafficStats.MB_IN_BYTES;
+import static android.telephony.CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED;
+import static android.telephony.CarrierConfigManager.DATA_CYCLE_USE_PLATFORM_DEFAULT;
+import static android.telephony.CarrierConfigManager.DATA_CYCLE_THRESHOLD_DISABLED;
+import static android.telephony.CarrierConfigManager.KEY_DATA_LIMIT_THRESHOLD_BYTES_LONG;
+import static android.telephony.CarrierConfigManager.KEY_DATA_WARNING_THRESHOLD_BYTES_LONG;
+import static android.telephony.CarrierConfigManager.KEY_MONTHLY_DATA_CYCLE_DAY_INT;
import static android.text.format.DateUtils.DAY_IN_MILLIS;
import static android.text.format.DateUtils.MINUTE_IN_MILLIS;
import static android.text.format.Time.TIMEZONE_UTC;
@@ -94,18 +102,24 @@
import android.net.NetworkTemplate;
import android.os.Binder;
import android.os.INetworkManagementService;
+import android.os.PersistableBundle;
import android.os.PowerManagerInternal;
import android.os.PowerSaveState;
+import android.os.RemoteException;
import android.os.UserHandle;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.MediumTest;
import android.support.test.runner.AndroidJUnit4;
+import android.telephony.CarrierConfigManager;
+import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.text.format.Time;
import android.util.Log;
import android.util.TrustedTime;
import com.android.internal.util.IndentingPrintWriter;
+import com.android.internal.telephony.PhoneConstants;
import com.android.internal.util.test.BroadcastInterceptingContext;
import com.android.internal.util.test.BroadcastInterceptingContext.FutureIntent;
import com.android.server.net.NetworkPolicyManagerInternal;
@@ -143,6 +157,7 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.Arrays;
+import java.util.Calendar;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.concurrent.CountDownLatch;
@@ -200,6 +215,9 @@
private @Mock INotificationManager mNotifManager;
private @Mock PackageManager mPackageManager;
private @Mock IPackageManager mIpm;
+ private @Mock SubscriptionManager mSubscriptionManager;
+ private @Mock CarrierConfigManager mCarrierConfigManager;
+ private @Mock TelephonyManager mTelephonyManager;
private static ActivityManagerInternal mActivityManagerInternal;
@@ -214,6 +232,12 @@
private long mElapsedRealtime;
private static final int USER_ID = 0;
+ private static final int FAKE_SUB_ID = 3737373;
+ private static final String FAKE_SUBSCRIBER_ID = "FAKE_SUB_ID";
+ private static final int DEFAULT_CYCLE_DAY = 1;
+ private static final int INVALID_CARRIER_CONFIG_VALUE = -9999;
+ private long mDefaultWarningBytes; // filled in with the actual default before tests are run
+ private long mDefaultLimitBytes; // filled in with the actual default before tests are run
private static final int APP_ID_A = android.os.Process.FIRST_APPLICATION_UID + 4;
private static final int APP_ID_B = android.os.Process.FIRST_APPLICATION_UID + 8;
@@ -235,6 +259,8 @@
@BeforeClass
public static void registerLocalServices() {
+ final PowerManagerInternal powerManager = addLocalServiceMock(PowerManagerInternal.class);
+ when(powerManager.getLowPowerState(anyInt())).thenReturn(mock(PowerSaveState.class));
addLocalServiceMock(DeviceIdleController.LocalService.class);
final UsageStatsManagerInternal usageStats =
addLocalServiceMock(UsageStatsManagerInternal.class);
@@ -255,7 +281,8 @@
setCurrentTimeMillis(TEST_START);
- // intercept various broadcasts, and pretend that uids have packages
+ // Intercept various broadcasts, and pretend that uids have packages.
+ // Also return mock service instances for a few critical services.
mServiceContext = new BroadcastInterceptingContext(context) {
@Override
public PackageManager getPackageManager() {
@@ -266,6 +293,20 @@
public void startActivity(Intent intent) {
// ignored
}
+
+ @Override
+ public Object getSystemService(String name) {
+ switch (name) {
+ case Context.TELEPHONY_SUBSCRIPTION_SERVICE:
+ return mSubscriptionManager;
+ case Context.CARRIER_CONFIG_SERVICE:
+ return mCarrierConfigManager;
+ case Context.TELEPHONY_SERVICE:
+ return mTelephonyManager;
+ default:
+ return super.getSystemService(name);
+ }
+ }
};
setNetpolicyXml(context);
@@ -321,6 +362,10 @@
ArgumentCaptor.forClass(INetworkManagementEventObserver.class);
verify(mNetworkManager).registerObserver(networkObserver.capture());
mNetworkObserver = networkObserver.getValue();
+
+ NetworkPolicy defaultPolicy = mService.buildDefaultMobilePolicy(0, "");
+ mDefaultWarningBytes = defaultPolicy.warningBytes;
+ mDefaultLimitBytes = defaultPolicy.limitBytes;
}
@After
@@ -1132,6 +1177,269 @@
}
}
+ private void assertCycleDayAsExpected(PersistableBundle config, int carrierCycleDay,
+ boolean expectValid) {
+ config.putInt(KEY_MONTHLY_DATA_CYCLE_DAY_INT, carrierCycleDay);
+ int actualCycleDay = mService.getCycleDayFromCarrierConfig(config,
+ INVALID_CARRIER_CONFIG_VALUE);
+ if (expectValid) {
+ assertEquals(carrierCycleDay, actualCycleDay);
+ } else {
+ // INVALID_CARRIER_CONFIG_VALUE is returned for invalid values
+ assertEquals(INVALID_CARRIER_CONFIG_VALUE, actualCycleDay);
+ }
+ }
+
+ @Test
+ public void testGetCycleDayFromCarrierConfig() {
+ PersistableBundle config = CarrierConfigManager.getDefaultConfig();
+ final Calendar cal = Calendar.getInstance();
+ int actualCycleDay;
+
+ config.putInt(KEY_MONTHLY_DATA_CYCLE_DAY_INT, DATA_CYCLE_USE_PLATFORM_DEFAULT);
+ actualCycleDay = mService.getCycleDayFromCarrierConfig(config, DEFAULT_CYCLE_DAY);
+ assertEquals(DEFAULT_CYCLE_DAY, actualCycleDay);
+
+ // null config returns a default value
+ actualCycleDay = mService.getCycleDayFromCarrierConfig(null, DEFAULT_CYCLE_DAY);
+ assertEquals(DEFAULT_CYCLE_DAY, actualCycleDay);
+
+ // Sane, non-default values
+ assertCycleDayAsExpected(config, 1, true);
+ assertCycleDayAsExpected(config, cal.getMaximum(Calendar.DAY_OF_MONTH), true);
+ assertCycleDayAsExpected(config, cal.getMinimum(Calendar.DAY_OF_MONTH), true);
+
+ // Invalid values
+ assertCycleDayAsExpected(config, 0, false);
+ assertCycleDayAsExpected(config, DATA_CYCLE_THRESHOLD_DISABLED, false);
+ assertCycleDayAsExpected(config, cal.getMaximum(Calendar.DAY_OF_MONTH) + 1, false);
+ assertCycleDayAsExpected(config, cal.getMinimum(Calendar.DAY_OF_MONTH) - 5, false);
+ }
+
+ private void assertWarningBytesAsExpected(PersistableBundle config, long carrierWarningBytes,
+ long expected) {
+ config.putLong(KEY_DATA_WARNING_THRESHOLD_BYTES_LONG, carrierWarningBytes);
+ long actualWarning = mService.getWarningBytesFromCarrierConfig(config,
+ INVALID_CARRIER_CONFIG_VALUE);
+ assertEquals(expected, actualWarning);
+ }
+
+ @Test
+ public void testGetWarningBytesFromCarrierConfig() {
+ PersistableBundle config = CarrierConfigManager.getDefaultConfig();
+ long actualWarningBytes;
+
+ assertWarningBytesAsExpected(config, DATA_CYCLE_USE_PLATFORM_DEFAULT,
+ mDefaultWarningBytes);
+ assertWarningBytesAsExpected(config, DATA_CYCLE_THRESHOLD_DISABLED, WARNING_DISABLED);
+ assertWarningBytesAsExpected(config, 0, 0);
+ // not a valid value
+ assertWarningBytesAsExpected(config, -1000, INVALID_CARRIER_CONFIG_VALUE);
+
+ // null config returns a default value
+ actualWarningBytes = mService.getWarningBytesFromCarrierConfig(null, mDefaultWarningBytes);
+ assertEquals(mDefaultWarningBytes, actualWarningBytes);
+ }
+
+ private void assertLimitBytesAsExpected(PersistableBundle config, long carrierWarningBytes,
+ long expected) {
+ config.putLong(KEY_DATA_LIMIT_THRESHOLD_BYTES_LONG, carrierWarningBytes);
+ long actualWarning = mService.getLimitBytesFromCarrierConfig(config,
+ INVALID_CARRIER_CONFIG_VALUE);
+ assertEquals(expected, actualWarning);
+ }
+
+ @Test
+ public void testGetLimitBytesFromCarrierConfig() {
+ PersistableBundle config = CarrierConfigManager.getDefaultConfig();
+ long actualLimitBytes;
+
+ assertLimitBytesAsExpected(config, DATA_CYCLE_USE_PLATFORM_DEFAULT,
+ mDefaultLimitBytes);
+ assertLimitBytesAsExpected(config, DATA_CYCLE_THRESHOLD_DISABLED, LIMIT_DISABLED);
+ assertLimitBytesAsExpected(config, 0, 0);
+ // not a valid value
+ assertLimitBytesAsExpected(config, -1000, INVALID_CARRIER_CONFIG_VALUE);
+
+ // null config returns a default value
+ actualLimitBytes = mService.getWarningBytesFromCarrierConfig(null, mDefaultLimitBytes);
+ assertEquals(mDefaultLimitBytes, actualLimitBytes);
+ }
+
+ private PersistableBundle setupUpdateMobilePolicyCycleTests() throws RemoteException {
+ when(mConnManager.getAllNetworkState()).thenReturn(new NetworkState[0]);
+ when(mSubscriptionManager.getActiveSubscriptionIdList()).thenReturn(new int[]{FAKE_SUB_ID});
+ when(mTelephonyManager.getSubscriberId(FAKE_SUB_ID)).thenReturn(FAKE_SUBSCRIBER_ID);
+ PersistableBundle bundle = CarrierConfigManager.getDefaultConfig();
+ when(mCarrierConfigManager.getConfigForSubId(FAKE_SUB_ID)).thenReturn(bundle);
+ setNetworkPolicies(buildDefaultFakeMobilePolicy());
+ return bundle;
+ }
+
+ @Test
+ public void testUpdateMobilePolicyCycleWithNullConfig() throws RemoteException {
+ when(mConnManager.getAllNetworkState()).thenReturn(new NetworkState[0]);
+ when(mSubscriptionManager.getActiveSubscriptionIdList()).thenReturn(new int[]{FAKE_SUB_ID});
+ when(mTelephonyManager.getSubscriberId(FAKE_SUB_ID)).thenReturn(FAKE_SUBSCRIBER_ID);
+ when(mCarrierConfigManager.getConfigForSubId(FAKE_SUB_ID)).thenReturn(null);
+ setNetworkPolicies(buildDefaultFakeMobilePolicy());
+ // smoke test to make sure no errors are raised
+ mServiceContext.sendBroadcast(
+ new Intent(ACTION_CARRIER_CONFIG_CHANGED)
+ .putExtra(PhoneConstants.SUBSCRIPTION_KEY, FAKE_SUB_ID)
+ );
+ assertNetworkPolicyEquals(DEFAULT_CYCLE_DAY, mDefaultWarningBytes, mDefaultLimitBytes,
+ true);
+ }
+
+ @Test
+ public void testUpdateMobilePolicyCycleWithInvalidConfig() throws RemoteException {
+ PersistableBundle bundle = setupUpdateMobilePolicyCycleTests();
+ // Test with an invalid CarrierConfig, there should be no changes or crashes.
+ bundle.putInt(CarrierConfigManager.KEY_MONTHLY_DATA_CYCLE_DAY_INT, -100);
+ bundle.putLong(CarrierConfigManager.KEY_DATA_WARNING_THRESHOLD_BYTES_LONG, -100);
+ bundle.putLong(CarrierConfigManager.KEY_DATA_LIMIT_THRESHOLD_BYTES_LONG, -100);
+ mServiceContext.sendBroadcast(
+ new Intent(ACTION_CARRIER_CONFIG_CHANGED)
+ .putExtra(PhoneConstants.SUBSCRIPTION_KEY, FAKE_SUB_ID)
+ );
+
+ assertNetworkPolicyEquals(DEFAULT_CYCLE_DAY, mDefaultWarningBytes, mDefaultLimitBytes,
+ true);
+ }
+
+ @Test
+ public void testUpdateMobilePolicyCycleWithDefaultConfig() throws RemoteException {
+ PersistableBundle bundle = setupUpdateMobilePolicyCycleTests();
+ // Test that we respect the platform values when told to
+ bundle.putInt(CarrierConfigManager.KEY_MONTHLY_DATA_CYCLE_DAY_INT,
+ DATA_CYCLE_USE_PLATFORM_DEFAULT);
+ bundle.putLong(CarrierConfigManager.KEY_DATA_WARNING_THRESHOLD_BYTES_LONG,
+ DATA_CYCLE_USE_PLATFORM_DEFAULT);
+ bundle.putLong(CarrierConfigManager.KEY_DATA_LIMIT_THRESHOLD_BYTES_LONG,
+ DATA_CYCLE_USE_PLATFORM_DEFAULT);
+ mServiceContext.sendBroadcast(
+ new Intent(ACTION_CARRIER_CONFIG_CHANGED)
+ .putExtra(PhoneConstants.SUBSCRIPTION_KEY, FAKE_SUB_ID)
+ );
+
+ assertNetworkPolicyEquals(DEFAULT_CYCLE_DAY, mDefaultWarningBytes, mDefaultLimitBytes,
+ true);
+ }
+
+ @Test
+ public void testUpdateMobilePolicyCycleWithUserOverrides() throws RemoteException {
+ PersistableBundle bundle = setupUpdateMobilePolicyCycleTests();
+
+ // inferred = false implies that a user manually modified this policy.
+ NetworkPolicy policy = buildDefaultFakeMobilePolicy();
+ policy.inferred = false;
+ setNetworkPolicies(policy);
+
+ bundle.putInt(CarrierConfigManager.KEY_MONTHLY_DATA_CYCLE_DAY_INT, 31);
+ bundle.putLong(CarrierConfigManager.KEY_DATA_WARNING_THRESHOLD_BYTES_LONG, 9999);
+ bundle.putLong(CarrierConfigManager.KEY_DATA_LIMIT_THRESHOLD_BYTES_LONG,
+ DATA_CYCLE_THRESHOLD_DISABLED);
+ mServiceContext.sendBroadcast(
+ new Intent(ACTION_CARRIER_CONFIG_CHANGED)
+ .putExtra(PhoneConstants.SUBSCRIPTION_KEY, FAKE_SUB_ID)
+ );
+
+ // The policy still shouldn't change, because we don't want to overwrite user settings.
+ assertNetworkPolicyEquals(DEFAULT_CYCLE_DAY, mDefaultWarningBytes, mDefaultLimitBytes,
+ false);
+ }
+
+ @Test
+ public void testUpdateMobilePolicyCycleUpdatesDataCycle() throws RemoteException {
+ PersistableBundle bundle = setupUpdateMobilePolicyCycleTests();
+
+ bundle.putInt(CarrierConfigManager.KEY_MONTHLY_DATA_CYCLE_DAY_INT, 31);
+ bundle.putLong(CarrierConfigManager.KEY_DATA_WARNING_THRESHOLD_BYTES_LONG, 9999);
+ bundle.putLong(CarrierConfigManager.KEY_DATA_LIMIT_THRESHOLD_BYTES_LONG, 9999);
+ mServiceContext.sendBroadcast(
+ new Intent(ACTION_CARRIER_CONFIG_CHANGED)
+ .putExtra(PhoneConstants.SUBSCRIPTION_KEY, FAKE_SUB_ID)
+ );
+
+ assertNetworkPolicyEquals(31, 9999, 9999, true);
+ }
+
+ @Test
+ public void testUpdateMobilePolicyCycleDisableThresholds() throws RemoteException {
+ PersistableBundle bundle = setupUpdateMobilePolicyCycleTests();
+
+ bundle.putInt(CarrierConfigManager.KEY_MONTHLY_DATA_CYCLE_DAY_INT, 31);
+ bundle.putLong(CarrierConfigManager.KEY_DATA_WARNING_THRESHOLD_BYTES_LONG,
+ DATA_CYCLE_THRESHOLD_DISABLED);
+ bundle.putLong(CarrierConfigManager.KEY_DATA_LIMIT_THRESHOLD_BYTES_LONG,
+ DATA_CYCLE_THRESHOLD_DISABLED);
+ mServiceContext.sendBroadcast(
+ new Intent(ACTION_CARRIER_CONFIG_CHANGED)
+ .putExtra(PhoneConstants.SUBSCRIPTION_KEY, FAKE_SUB_ID)
+ );
+
+ assertNetworkPolicyEquals(31, WARNING_DISABLED, LIMIT_DISABLED, true);
+ }
+
+ @Test
+ public void testUpdateMobilePolicyCycleRevertsToDefault() throws RemoteException {
+ PersistableBundle bundle = setupUpdateMobilePolicyCycleTests();
+
+ bundle.putInt(CarrierConfigManager.KEY_MONTHLY_DATA_CYCLE_DAY_INT, 31);
+ bundle.putLong(CarrierConfigManager.KEY_DATA_WARNING_THRESHOLD_BYTES_LONG,
+ DATA_CYCLE_THRESHOLD_DISABLED);
+ bundle.putLong(CarrierConfigManager.KEY_DATA_LIMIT_THRESHOLD_BYTES_LONG,
+ DATA_CYCLE_THRESHOLD_DISABLED);
+ mServiceContext.sendBroadcast(
+ new Intent(ACTION_CARRIER_CONFIG_CHANGED)
+ .putExtra(PhoneConstants.SUBSCRIPTION_KEY, FAKE_SUB_ID)
+ );
+ assertNetworkPolicyEquals(31, WARNING_DISABLED, LIMIT_DISABLED, true);
+
+ // If the user switches carriers to one that doesn't use a CarrierConfig, we should revert
+ // to the default data limit and warning. The cycle date doesn't need to revert as it's
+ // arbitrary anyways.
+ bundle.putInt(CarrierConfigManager.KEY_MONTHLY_DATA_CYCLE_DAY_INT,
+ DATA_CYCLE_USE_PLATFORM_DEFAULT);
+ bundle.putLong(CarrierConfigManager.KEY_DATA_WARNING_THRESHOLD_BYTES_LONG,
+ DATA_CYCLE_USE_PLATFORM_DEFAULT);
+ bundle.putLong(CarrierConfigManager.KEY_DATA_LIMIT_THRESHOLD_BYTES_LONG,
+ DATA_CYCLE_USE_PLATFORM_DEFAULT);
+ mServiceContext.sendBroadcast(
+ new Intent(ACTION_CARRIER_CONFIG_CHANGED)
+ .putExtra(PhoneConstants.SUBSCRIPTION_KEY, FAKE_SUB_ID)
+ );
+
+ assertNetworkPolicyEquals(31, mDefaultWarningBytes, mDefaultLimitBytes,
+ true);
+ }
+
+ private NetworkPolicy buildDefaultFakeMobilePolicy() {
+ NetworkPolicy p = mService.buildDefaultMobilePolicy(FAKE_SUB_ID, FAKE_SUBSCRIBER_ID);
+ // set a deterministic cycle date
+ p.cycleDay = DEFAULT_CYCLE_DAY;
+ return p;
+ }
+
+ private static NetworkPolicy buildFakeMobilePolicy(int cycleDay, long warningBytes,
+ long limitBytes, boolean inferred){
+ final NetworkTemplate template = buildTemplateMobileAll(FAKE_SUBSCRIBER_ID);
+ return new NetworkPolicy(template, cycleDay, "America/Los_Angeles", warningBytes,
+ limitBytes, SNOOZE_NEVER, SNOOZE_NEVER, true, inferred);
+ }
+
+ private void assertNetworkPolicyEquals(int expectedCycleDay, long expectedWarningBytes,
+ long expectedLimitBytes, boolean expectedInferred) {
+ NetworkPolicy[] policies = mService.getNetworkPolicies(
+ mServiceContext.getOpPackageName());
+ assertEquals("Unexpected number of network policies", 1, policies.length);
+ NetworkPolicy actualPolicy = policies[0];
+ NetworkPolicy expectedPolicy = buildFakeMobilePolicy(expectedCycleDay, expectedWarningBytes,
+ expectedLimitBytes, expectedInferred);
+ assertEquals(expectedPolicy, actualPolicy);
+ }
+
private static long parseTime(String time) {
final Time result = new Time();
result.parse3339(time);
diff --git a/services/tests/servicestests/src/com/android/server/wm/DisplayContentTests.java b/services/tests/servicestests/src/com/android/server/wm/DisplayContentTests.java
index dd94a21..1729cee 100644
--- a/services/tests/servicestests/src/com/android/server/wm/DisplayContentTests.java
+++ b/services/tests/servicestests/src/com/android/server/wm/DisplayContentTests.java
@@ -254,6 +254,48 @@
assertEquals(window1, sWm.mRoot.computeFocusedWindow());
}
+ /**
+ * This tests setting the maximum ui width on a display.
+ */
+ @Test
+ public void testMaxUiWidth() throws Exception {
+ final int baseWidth = 1440;
+ final int baseHeight = 2560;
+ final int baseDensity = 300;
+
+ sDisplayContent.updateBaseDisplayMetrics(baseWidth, baseHeight, baseDensity);
+
+ final int maxWidth = 300;
+ final int resultingHeight = (maxWidth * baseHeight) / baseWidth;
+ final int resultingDensity = (maxWidth * baseDensity) / baseWidth;
+
+ sDisplayContent.setMaxUiWidth(maxWidth);
+ verifySizes(sDisplayContent, maxWidth, resultingHeight, resultingDensity);
+
+ // Assert setting values again does not change;
+ sDisplayContent.updateBaseDisplayMetrics(baseWidth, baseHeight, baseDensity);
+ verifySizes(sDisplayContent, maxWidth, resultingHeight, resultingDensity);
+
+ final int smallerWidth = 200;
+ final int smallerHeight = 400;
+ final int smallerDensity = 100;
+
+ // Specify smaller dimension, verify that it is honored
+ sDisplayContent.updateBaseDisplayMetrics(smallerWidth, smallerHeight, smallerDensity);
+ verifySizes(sDisplayContent, smallerWidth, smallerHeight, smallerDensity);
+
+ // Verify that setting the max width to a greater value than the base width has no effect
+ sDisplayContent.setMaxUiWidth(maxWidth);
+ verifySizes(sDisplayContent, smallerWidth, smallerHeight, smallerDensity);
+ }
+
+ private static void verifySizes(DisplayContent displayContent, int expectedBaseWidth,
+ int expectedBaseHeight, int expectedBaseDensity) {
+ assertEquals(displayContent.mBaseDisplayWidth, expectedBaseWidth);
+ assertEquals(displayContent.mBaseDisplayHeight, expectedBaseHeight);
+ assertEquals(displayContent.mBaseDisplayDensity, expectedBaseDensity);
+ }
+
private void assertForAllWindowsOrder(List<WindowState> expectedWindows) {
final LinkedList<WindowState> actualWindows = new LinkedList();
diff --git a/test-runner/src/android/test/mock/MockPackageManager.java b/test-runner/src/android/test/mock/MockPackageManager.java
index 506f406..960a2d9 100644
--- a/test-runner/src/android/test/mock/MockPackageManager.java
+++ b/test-runner/src/android/test/mock/MockPackageManager.java
@@ -1118,4 +1118,12 @@
public int getInstallReason(String packageName, UserHandle user) {
throw new UnsupportedOperationException();
}
+
+ /**
+ * @hide
+ */
+ @Override
+ public ComponentName getInstantAppResolverSettingsComponent() {
+ throw new UnsupportedOperationException();
+ }
}
diff --git a/tools/aapt/Resource.cpp b/tools/aapt/Resource.cpp
index 3330b1a..2bf5206 100644
--- a/tools/aapt/Resource.cpp
+++ b/tools/aapt/Resource.cpp
@@ -1403,7 +1403,8 @@
String8 src = it.getFile()->getPrintableSource();
err = compileXmlFile(bundle, assets, String16(it.getBaseName()),
it.getFile(), &table, xmlFlags);
- if (err == NO_ERROR) {
+ // Only verify IDs if there was no error and the file is non-empty.
+ if (err == NO_ERROR && it.getFile()->hasData()) {
ResXMLTree block;
block.setTo(it.getFile()->getData(), it.getFile()->getSize(), true);
checkForIds(src, block);
@@ -1550,7 +1551,7 @@
String8 src = it.getFile()->getPrintableSource();
err = compileXmlFile(bundle, assets, String16(it.getBaseName()),
it.getFile(), &table, xmlFlags);
- if (err == NO_ERROR) {
+ if (err == NO_ERROR && it.getFile()->hasData()) {
ResXMLTree block;
block.setTo(it.getFile()->getData(), it.getFile()->getSize(), true);
checkForIds(src, block);
@@ -1598,7 +1599,7 @@
err = compileXmlFile(bundle, assets, workItem.resourceName, workItem.xmlRoot,
workItem.file, &table, xmlCompilationFlags);
- if (err == NO_ERROR) {
+ if (err == NO_ERROR && workItem.file->hasData()) {
assets->addResource(workItem.resPath.getPathLeaf(),
workItem.resPath,
workItem.file,
diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp
index 391aa47..221f3c2 100644
--- a/tools/aapt/ResourceTable.cpp
+++ b/tools/aapt/ResourceTable.cpp
@@ -78,6 +78,17 @@
ResourceTable* table,
int options)
{
+ if (table->versionForCompat(bundle, resourceName, target, root)) {
+ // The file was versioned, so stop processing here.
+ // The resource entry has already been removed and the new one added.
+ // Remove the assets entry.
+ sp<AaptDir> resDir = assets->getDirs().valueFor(String8("res"));
+ sp<AaptDir> dir = resDir->getDirs().valueFor(target->getGroupEntry().toDirName(
+ target->getResourceType()));
+ dir->removeFile(target->getPath().getPathLeaf());
+ return NO_ERROR;
+ }
+
if ((options&XML_COMPILE_STRIP_WHITESPACE) != 0) {
root->removeWhitespace(true, NULL);
} else if ((options&XML_COMPILE_COMPACT_WHITESPACE) != 0) {
@@ -4758,6 +4769,77 @@
return false;
}
+bool ResourceTable::versionForCompat(const Bundle* bundle, const String16& resourceName,
+ const sp<AaptFile>& target, const sp<XMLNode>& root) {
+ XMLNode* node = root.get();
+ while (node->getType() != XMLNode::TYPE_ELEMENT) {
+ // We're assuming the root element is what we're looking for, which can only be under a
+ // bunch of namespace declarations.
+ if (node->getChildren().size() != 1) {
+ // Not sure what to do, bail.
+ return false;
+ }
+ node = node->getChildren().itemAt(0).get();
+ }
+
+ if (node->getElementNamespace().size() != 0) {
+ // Not something we care about.
+ return false;
+ }
+
+ int versionedSdk = 0;
+ if (node->getElementName() == String16("adaptive-icon")) {
+ versionedSdk = SDK_O;
+ }
+
+ const int minSdkVersion = getMinSdkVersion(bundle);
+ const ConfigDescription config(target->getGroupEntry().toParams());
+ if (versionedSdk <= minSdkVersion || versionedSdk <= config.sdkVersion) {
+ return false;
+ }
+
+ sp<ConfigList> cl = getConfigList(String16(mAssets->getPackage()),
+ String16(target->getResourceType()), resourceName);
+ if (!shouldGenerateVersionedResource(cl, config, versionedSdk)) {
+ return false;
+ }
+
+ // Remove the original entry.
+ cl->removeEntry(config);
+
+ // We need to wholesale version this file.
+ ConfigDescription newConfig(config);
+ newConfig.sdkVersion = versionedSdk;
+ sp<AaptFile> newFile = new AaptFile(target->getSourceFile(),
+ AaptGroupEntry(newConfig), target->getResourceType());
+ String8 resPath = String8::format("res/%s/%s.xml",
+ newFile->getGroupEntry().toDirName(target->getResourceType()).string(),
+ String8(resourceName).string());
+ resPath.convertToResPath();
+
+ // Add a resource table entry.
+ addEntry(SourcePos(),
+ String16(mAssets->getPackage()),
+ String16(target->getResourceType()),
+ resourceName,
+ String16(resPath),
+ NULL,
+ &newConfig);
+
+ // Schedule this to be compiled.
+ CompileResourceWorkItem item;
+ item.resourceName = resourceName;
+ item.resPath = resPath;
+ item.file = newFile;
+ item.xmlRoot = root->clone();
+ item.needsCompiling = false; // This step occurs after we parse/assign, so we don't need
+ // to do it again.
+ mWorkQueue.push(item);
+
+ // Now mark the old entry as deleted.
+ return true;
+}
+
status_t ResourceTable::modifyForCompat(const Bundle* bundle,
const String16& resourceName,
const sp<AaptFile>& target,
diff --git a/tools/aapt/ResourceTable.h b/tools/aapt/ResourceTable.h
index cf1e992..aff22d4 100644
--- a/tools/aapt/ResourceTable.h
+++ b/tools/aapt/ResourceTable.h
@@ -203,6 +203,9 @@
size_t numLocalResources() const;
bool hasResources() const;
+ bool versionForCompat(const Bundle* bundle, const String16& resourceName,
+ const sp<AaptFile>& file, const sp<XMLNode>& root);
+
status_t modifyForCompat(const Bundle* bundle);
status_t modifyForCompat(const Bundle* bundle,
const String16& resourceName,
@@ -431,6 +434,10 @@
mEntries.add(config, entry);
}
+ void removeEntry(const ResTable_config& config) {
+ mEntries.removeItem(config);
+ }
+
const DefaultKeyedVector<ConfigDescription, sp<Entry> >& getEntries() const { return mEntries; }
private:
const String16 mName;
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePackageManager.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePackageManager.java
index 906ebb1..53c3f90 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePackageManager.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePackageManager.java
@@ -916,4 +916,9 @@
public boolean canRequestPackageInstalls() {
return false;
}
+
+ @Override
+ public ComponentName getInstantAppResolverSettingsComponent() {
+ return null;
+ }
}
diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl
index 10ffd8a..1852feb 100644
--- a/wifi/java/android/net/wifi/IWifiManager.aidl
+++ b/wifi/java/android/net/wifi/IWifiManager.aidl
@@ -81,8 +81,6 @@
boolean disableNetwork(int netId);
- boolean pingSupplicant();
-
void startScan(in ScanSettings requested, in WorkSource ws);
List<ScanResult> getScanResults(String callingPackage);