Merge "Override application display adjustments while launching activity" into rvc-dev am: 1421b3dace
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11716091 Change-Id: I81195b7c5e33160659704d7b7dcf27c203ce7f4c
This commit is contained in:
@@ -3252,18 +3252,56 @@ public final class ActivityThread extends ClientTransactionHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void handleFixedRotationAdjustments(@NonNull IBinder token,
|
public void handleFixedRotationAdjustments(@NonNull IBinder token,
|
||||||
@Nullable FixedRotationAdjustments fixedRotationAdjustments) {
|
@Nullable FixedRotationAdjustments fixedRotationAdjustments) {
|
||||||
final Consumer<DisplayAdjustments> override = fixedRotationAdjustments != null
|
handleFixedRotationAdjustments(token, fixedRotationAdjustments, null /* overrideConfig */);
|
||||||
? displayAdjustments -> displayAdjustments.setFixedRotationAdjustments(
|
}
|
||||||
fixedRotationAdjustments)
|
|
||||||
: null;
|
/**
|
||||||
|
* Applies the rotation adjustments to override display information in resources belong to the
|
||||||
|
* provided token. If the token is activity token, the adjustments also apply to application
|
||||||
|
* because the appearance of activity is usually more sensitive to the application resources.
|
||||||
|
*
|
||||||
|
* @param token The token to apply the adjustments.
|
||||||
|
* @param fixedRotationAdjustments The information to override the display adjustments of
|
||||||
|
* corresponding resources. If it is null, the exiting override
|
||||||
|
* will be cleared.
|
||||||
|
* @param overrideConfig The override configuration of activity. It is used to override
|
||||||
|
* application configuration. If it is non-null, it means the token is
|
||||||
|
* confirmed as activity token. Especially when launching new activity,
|
||||||
|
* {@link #mActivities} hasn't put the new token.
|
||||||
|
*/
|
||||||
|
private void handleFixedRotationAdjustments(@NonNull IBinder token,
|
||||||
|
@Nullable FixedRotationAdjustments fixedRotationAdjustments,
|
||||||
|
@Nullable Configuration overrideConfig) {
|
||||||
|
// The element of application configuration override is set only if the application
|
||||||
|
// adjustments are needed, because activity already has its own override configuration.
|
||||||
|
final Configuration[] appConfigOverride;
|
||||||
|
final Consumer<DisplayAdjustments> override;
|
||||||
|
if (fixedRotationAdjustments != null) {
|
||||||
|
appConfigOverride = new Configuration[1];
|
||||||
|
override = displayAdjustments -> {
|
||||||
|
displayAdjustments.setFixedRotationAdjustments(fixedRotationAdjustments);
|
||||||
|
if (appConfigOverride[0] != null) {
|
||||||
|
displayAdjustments.getConfiguration().updateFrom(appConfigOverride[0]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
appConfigOverride = null;
|
||||||
|
override = null;
|
||||||
|
}
|
||||||
if (!mResourcesManager.overrideTokenDisplayAdjustments(token, override)) {
|
if (!mResourcesManager.overrideTokenDisplayAdjustments(token, override)) {
|
||||||
// No resources are associated with the token.
|
// No resources are associated with the token.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mActivities.get(token) == null) {
|
if (overrideConfig == null) {
|
||||||
// Only apply the override to application for activity token because the appearance of
|
final ActivityClientRecord r = mActivities.get(token);
|
||||||
// activity is usually more sensitive to the application resources.
|
if (r == null) {
|
||||||
return;
|
// It is not an activity token. Nothing to do for application.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
overrideConfig = r.overrideConfig;
|
||||||
|
}
|
||||||
|
if (appConfigOverride != null) {
|
||||||
|
appConfigOverride[0] = overrideConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply the last override to application resources for compatibility. Because the Resources
|
// Apply the last override to application resources for compatibility. Because the Resources
|
||||||
@@ -3503,7 +3541,8 @@ public final class ActivityThread extends ClientTransactionHandler {
|
|||||||
// The rotation adjustments must be applied before creating the activity, so the activity
|
// The rotation adjustments must be applied before creating the activity, so the activity
|
||||||
// can get the adjusted display info during creation.
|
// can get the adjusted display info during creation.
|
||||||
if (r.mPendingFixedRotationAdjustments != null) {
|
if (r.mPendingFixedRotationAdjustments != null) {
|
||||||
handleFixedRotationAdjustments(r.token, r.mPendingFixedRotationAdjustments);
|
handleFixedRotationAdjustments(r.token, r.mPendingFixedRotationAdjustments,
|
||||||
|
r.overrideConfig);
|
||||||
r.mPendingFixedRotationAdjustments = null;
|
r.mPendingFixedRotationAdjustments = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user