Apply override scale from entry points on client
This provides a sandbox-like scaled environment on client side.
- This prevents the metrics and config from being scaled multiple
times because the entry points are only called from server side,
there won't have reentrancy for applying the scale.
- App's configuration callback method can get scaled config.
- If override scale is enabled, the legacy compat mode will be
skipped. That avoids mixing different approaches of scaling.
- Legacy compat mode is to simulate a 320dp x 480dp screen
size with density 160 (the surface scale and config scale
are different).
- Override scale is to downscale the app for better performance
(the surface scale and config scale are the same).
Bug: 238416387
Bug: 240335717
Test: atest ActivityThreadTest#testOverrideScale
Test: atest CtsWindowManagerDeviceTestCases:CompatScaleTests
Test: am compat enable DOWNSCALED $pkg
am compat enable DOWNSCALE_50 $pkg
Change-Id: I0ddf333996f229063511273f8aeb3867c9ba8bda
This commit is contained in:
@@ -723,9 +723,9 @@ public final class DisplayInfo implements Parcelable {
|
||||
outMetrics.noncompatWidthPixels = outMetrics.widthPixels = width;
|
||||
outMetrics.noncompatHeightPixels = outMetrics.heightPixels = height;
|
||||
|
||||
if (!compatInfo.equals(CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO)) {
|
||||
compatInfo.applyToDisplayMetrics(outMetrics);
|
||||
}
|
||||
// Apply to size if the configuration is EMPTY because the size is from real display info.
|
||||
final boolean applyToSize = configuration != null && appBounds == null;
|
||||
compatInfo.applyDisplayMetricsIfNeeded(outMetrics, applyToSize);
|
||||
}
|
||||
|
||||
// For debugging purposes
|
||||
|
||||
@@ -1787,6 +1787,7 @@ public final class ViewRootImpl implements ViewParent,
|
||||
|
||||
final ClientWindowFrames frames = (ClientWindowFrames) args.arg1;
|
||||
final MergedConfiguration mergedConfiguration = (MergedConfiguration) args.arg2;
|
||||
CompatibilityInfo.applyOverrideScaleIfNeeded(mergedConfiguration);
|
||||
final boolean forceNextWindowRelayout = args.argi1 != 0;
|
||||
final int displayId = args.argi3;
|
||||
final int resizeMode = args.argi5;
|
||||
@@ -8242,6 +8243,7 @@ public final class ViewRootImpl implements ViewParent,
|
||||
mTranslator.translateSourceControlsInScreenToAppWindow(mTempControls);
|
||||
}
|
||||
mInvSizeCompatScale = 1f / mTmpFrames.sizeCompatScale;
|
||||
CompatibilityInfo.applyOverrideScaleIfNeeded(mPendingMergedConfiguration);
|
||||
mInsetsController.onStateChanged(mTempInsets);
|
||||
mInsetsController.onControlsChanged(mTempControls);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user