Merge "Simplify handling activity config a bit"
This commit is contained in:
@@ -271,9 +271,6 @@ public final class ActivityThread extends ClientTransactionHandler {
|
||||
/** Type for IActivityManager.serviceDoneExecuting: done stopping (destroying) service */
|
||||
public static final int SERVICE_DONE_EXECUTING_STOP = 2;
|
||||
|
||||
// Whether to invoke an activity callback after delivering new configuration.
|
||||
private static final boolean REPORT_TO_ACTIVITY = true;
|
||||
|
||||
/** Use foreground GC policy (less pause time) and higher JIT weight. */
|
||||
private static final int VM_PROCESS_STATE_JANK_PERCEPTIBLE = 0;
|
||||
/** Use background GC policy and default JIT threshold. */
|
||||
@@ -5539,18 +5536,14 @@ public final class ActivityThread extends ClientTransactionHandler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the configuration for an Activity. The ActivityClientRecord's
|
||||
* {@link ActivityClientRecord#overrideConfig} is used to compute the final Configuration for
|
||||
* that Activity. {@link ActivityClientRecord#tmpConfig} is used as a temporary for delivering
|
||||
* the updated Configuration.
|
||||
* @param r ActivityClientRecord representing the Activity.
|
||||
* @param newBaseConfig The new configuration to use. This may be augmented with
|
||||
* {@link ActivityClientRecord#overrideConfig}.
|
||||
* Updates the configuration for an Activity in its current display.
|
||||
*
|
||||
* @see #performConfigurationChangedForActivity(ActivityClientRecord, Configuration, int,
|
||||
* boolean)
|
||||
*/
|
||||
private void performConfigurationChangedForActivity(ActivityClientRecord r,
|
||||
Configuration newBaseConfig) {
|
||||
performConfigurationChangedForActivity(r, newBaseConfig, r.activity.getDisplayId(),
|
||||
false /* movedToDifferentDisplay */);
|
||||
performConfigurationChangedForActivity(r, newBaseConfig, r.activity.getDisplayId());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5562,17 +5555,16 @@ public final class ActivityThread extends ClientTransactionHandler {
|
||||
* @param newBaseConfig The new configuration to use. This may be augmented with
|
||||
* {@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 Configuration performConfigurationChangedForActivity(ActivityClientRecord r,
|
||||
Configuration newBaseConfig, int displayId, boolean movedToDifferentDisplay) {
|
||||
Configuration newBaseConfig, int displayId) {
|
||||
r.tmpConfig.setTo(newBaseConfig);
|
||||
if (r.overrideConfig != null) {
|
||||
r.tmpConfig.updateFrom(r.overrideConfig);
|
||||
}
|
||||
final Configuration reportedConfig = performActivityConfigurationChanged(r.activity,
|
||||
r.tmpConfig, r.overrideConfig, displayId, movedToDifferentDisplay);
|
||||
r.tmpConfig, r.overrideConfig, displayId);
|
||||
freeTextLayoutCachesIfNeeded(r.activity.mCurrentConfig.diff(r.tmpConfig));
|
||||
return reportedConfig;
|
||||
}
|
||||
@@ -5599,10 +5591,6 @@ public final class ActivityThread extends ClientTransactionHandler {
|
||||
* @param newConfig The new configuration.
|
||||
*/
|
||||
private void performConfigurationChanged(ComponentCallbacks2 cb, Configuration newConfig) {
|
||||
if (!REPORT_TO_ACTIVITY) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ContextThemeWrappers may override the configuration for that context. We must check and
|
||||
// apply any overrides defined.
|
||||
Configuration contextThemeWrapperOverrideConfig = null;
|
||||
@@ -5627,12 +5615,10 @@ public final class ActivityThread extends ClientTransactionHandler {
|
||||
* from the base global configuration. This is supplied by
|
||||
* 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 Configuration performActivityConfigurationChanged(Activity activity,
|
||||
Configuration newConfig, Configuration amOverrideConfig, int displayId,
|
||||
boolean movedToDifferentDisplay) {
|
||||
Configuration newConfig, Configuration amOverrideConfig, int displayId) {
|
||||
if (activity == null) {
|
||||
throw new IllegalArgumentException("No activity provided.");
|
||||
}
|
||||
@@ -5645,6 +5631,7 @@ public final class ActivityThread extends ClientTransactionHandler {
|
||||
// callback, see also PinnedStackTests#testConfigurationChangeOrderDuringTransition
|
||||
handleWindowingModeChangeIfNeeded(activity, newConfig);
|
||||
|
||||
final boolean movedToDifferentDisplay = isDifferentDisplay(activity, displayId);
|
||||
boolean shouldReportChange = false;
|
||||
if (activity.mCurrentConfig == null) {
|
||||
shouldReportChange = true;
|
||||
@@ -5658,8 +5645,7 @@ public final class ActivityThread extends ClientTransactionHandler {
|
||||
amOverrideConfig)) {
|
||||
// Nothing significant, don't proceed with updating and reporting.
|
||||
return null;
|
||||
} else if ((~activity.mActivityInfo.getRealConfigChanged() & diff) == 0
|
||||
|| !REPORT_TO_ACTIVITY) {
|
||||
} else if ((~activity.mActivityInfo.getRealConfigChanged() & diff) == 0) {
|
||||
// If this activity doesn't handle any of the config changes, then don't bother
|
||||
// calling onConfigurationChanged. Otherwise, report to the activity for the
|
||||
// changes.
|
||||
@@ -5693,11 +5679,6 @@ public final class ActivityThread extends ClientTransactionHandler {
|
||||
final Configuration configToReport = createNewConfigAndUpdateIfNotNull(newConfig,
|
||||
contextThemeWrapperOverrideConfig);
|
||||
|
||||
if (!REPORT_TO_ACTIVITY) {
|
||||
// Not configured to report to activity.
|
||||
return configToReport;
|
||||
}
|
||||
|
||||
if (movedToDifferentDisplay) {
|
||||
activity.dispatchMovedToDisplay(displayId, configToReport);
|
||||
}
|
||||
@@ -5990,8 +5971,6 @@ public final class ActivityThread extends ClientTransactionHandler {
|
||||
if (DEBUG_CONFIGURATION) Slog.w(TAG, "Not found target activity to report to: " + r);
|
||||
return;
|
||||
}
|
||||
final boolean movedToDifferentDisplay = displayId != INVALID_DISPLAY
|
||||
&& displayId != r.activity.getDisplayId();
|
||||
|
||||
synchronized (r) {
|
||||
if (overrideConfig.isOtherSeqNewer(r.mPendingOverrideConfig)) {
|
||||
@@ -6005,6 +5984,7 @@ public final class ActivityThread extends ClientTransactionHandler {
|
||||
r.mPendingOverrideConfig = null;
|
||||
}
|
||||
|
||||
final boolean movedToDifferentDisplay = isDifferentDisplay(r.activity, displayId);
|
||||
if (r.overrideConfig != null && !r.overrideConfig.isOtherSeqNewer(overrideConfig)
|
||||
&& !movedToDifferentDisplay) {
|
||||
if (DEBUG_CONFIGURATION) {
|
||||
@@ -6020,29 +6000,34 @@ public final class ActivityThread extends ClientTransactionHandler {
|
||||
final ViewRootImpl viewRoot = r.activity.mDecor != null
|
||||
? r.activity.mDecor.getViewRootImpl() : null;
|
||||
|
||||
if (movedToDifferentDisplay) {
|
||||
if (DEBUG_CONFIGURATION) Slog.v(TAG, "Handle activity moved to display, activity:"
|
||||
+ r.activityInfo.name + ", displayId=" + displayId
|
||||
if (DEBUG_CONFIGURATION) {
|
||||
Slog.v(TAG, "Handle activity config changed, activity:"
|
||||
+ r.activityInfo.name + ", displayId=" + r.activity.getDisplayId()
|
||||
+ (movedToDifferentDisplay ? (", newDisplayId=" + displayId) : "")
|
||||
+ ", config=" + overrideConfig);
|
||||
|
||||
final Configuration reportedConfig = performConfigurationChangedForActivity(r,
|
||||
mCompatConfiguration, displayId, true /* movedToDifferentDisplay */);
|
||||
if (viewRoot != null) {
|
||||
viewRoot.onMovedToDisplay(displayId, reportedConfig);
|
||||
}
|
||||
} else {
|
||||
if (DEBUG_CONFIGURATION) Slog.v(TAG, "Handle activity config changed: "
|
||||
+ r.activityInfo.name + ", config=" + overrideConfig);
|
||||
performConfigurationChangedForActivity(r, mCompatConfiguration);
|
||||
}
|
||||
final Configuration reportedConfig = performConfigurationChangedForActivity(r,
|
||||
mCompatConfiguration,
|
||||
movedToDifferentDisplay ? displayId : r.activity.getDisplayId());
|
||||
// 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) {
|
||||
if (movedToDifferentDisplay) {
|
||||
viewRoot.onMovedToDisplay(displayId, reportedConfig);
|
||||
}
|
||||
viewRoot.updateConfiguration(displayId);
|
||||
}
|
||||
mSomeActivitiesChanged = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the display id of activity is different from the given one. Note that
|
||||
* {@link #INVALID_DISPLAY} means no difference.
|
||||
*/
|
||||
private static boolean isDifferentDisplay(@NonNull Activity activity, int displayId) {
|
||||
return displayId != INVALID_DISPLAY && displayId != activity.getDisplayId();
|
||||
}
|
||||
|
||||
final void handleProfilerControl(boolean start, ProfilerInfo profilerInfo, int profileType) {
|
||||
if (start) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user