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);
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);
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);
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);
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);
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);
}
}
- 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) {
}
/**
* {@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;
}
/**
* 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.");
}
}
if (!shouldChangeConfig && !movedToDifferentDisplay) {
// Nothing significant, don't proceed with updating and reporting.
- return;
+ return null;
}
// Propagate the configuration change to ResourcesManager and Activity.
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) {
" did not call through to super.onConfigurationChanged()");
}
}
+
+ return configToReport;
}
public final void applyConfigurationToResources(Configuration config) {
+ 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: "
// 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;
}
}
/**
- * @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) {
}
/**
}
@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);
}
}
/**
* 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;
}
mView.getResources());
mAttachInfo.mDisplayState = mDisplay.getState();
// Internal state updated, now notify the view hierarchy.
- mView.dispatchMovedToDisplay(mDisplay);
+ mView.dispatchMovedToDisplay(mDisplay, config);
}
void pokeDrawLockIfNeeded() {
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;
}
// 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(
SomeArgs args = (SomeArgs) msg.obj;
final int displayId = args.argi3;
+ final MergedConfiguration mergedConfiguration = (MergedConfiguration) args.arg4;
final boolean displayChanged = mDisplay.getDisplayId() != displayId;
- if (displayChanged) {
- onMovedToDisplay(displayId);
- }
- final MergedConfiguration mergedConfiguration = (MergedConfiguration) args.arg4;
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)