Clean up no-op methods of display configuration
The parameter newConfiguration of
RWC#setDisplayOverrideConfigurationIfNeeded is always the reference
of displayContent.getRequestedOverrideConfiguration() which is from
DC#onRequestedOverrideConfigurationChanged (since commit 562659d).
It means that the method always diff the same config instance, which
is no-op. The concept of "Override configuration of the default display
duplicates global config." is still done by DisplayContent#
updateDisplayOverrideConfigurationLocked. So the methods on the path
of WMS#setNewDisplayOverrideConfiguration can be removed.
Bug: 163976519
Test: atest DisplayContentTests#testDefaultDisplayOverrideConfigUpdate
Change-Id: I6d6f44d1a5ef0c8180b1dbbc4755b0299d65dd4d
This commit is contained in:
@@ -5722,7 +5722,10 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
mCurrentOverrideConfigurationChanges = currOverrideConfig.diff(overrideConfiguration);
|
||||
super.onRequestedOverrideConfigurationChanged(overrideConfiguration);
|
||||
mCurrentOverrideConfigurationChanges = 0;
|
||||
mWmService.setNewDisplayOverrideConfiguration(currOverrideConfig, this);
|
||||
if (mWaitingForConfig) {
|
||||
mWaitingForConfig = false;
|
||||
mWmService.mLastFinishedFreezeSource = "new-config";
|
||||
}
|
||||
mAtmService.addWindowLayoutReasons(
|
||||
ActivityTaskManagerService.LAYOUT_REASON_CONFIG_CHANGED);
|
||||
}
|
||||
|
||||
@@ -639,36 +639,6 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set new display override config. If called for the default display, global configuration
|
||||
* will also be updated.
|
||||
*/
|
||||
void setDisplayOverrideConfigurationIfNeeded(Configuration newConfiguration,
|
||||
@NonNull DisplayContent displayContent) {
|
||||
|
||||
final Configuration currentConfig = displayContent.getRequestedOverrideConfiguration();
|
||||
final boolean configChanged = currentConfig.diff(newConfiguration) != 0;
|
||||
if (!configChanged) {
|
||||
return;
|
||||
}
|
||||
|
||||
displayContent.onRequestedOverrideConfigurationChanged(newConfiguration);
|
||||
|
||||
if (displayContent.getDisplayId() == DEFAULT_DISPLAY) {
|
||||
// Override configuration of the default display duplicates global config. In this case
|
||||
// we also want to update the global config.
|
||||
setGlobalConfigurationIfNeeded(newConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
private void setGlobalConfigurationIfNeeded(Configuration newConfiguration) {
|
||||
final boolean configChanged = getConfiguration().diff(newConfiguration) != 0;
|
||||
if (!configChanged) {
|
||||
return;
|
||||
}
|
||||
onConfigurationChanged(newConfiguration);
|
||||
}
|
||||
|
||||
@Override
|
||||
void dispatchConfigurationToChild(DisplayContent child, Configuration config) {
|
||||
if (child.isDefaultDisplay) {
|
||||
|
||||
@@ -2910,16 +2910,6 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
}
|
||||
}
|
||||
|
||||
void setNewDisplayOverrideConfiguration(Configuration overrideConfig,
|
||||
@NonNull DisplayContent dc) {
|
||||
if (dc.mWaitingForConfig) {
|
||||
dc.mWaitingForConfig = false;
|
||||
mLastFinishedFreezeSource = "new-config";
|
||||
}
|
||||
|
||||
mRoot.setDisplayOverrideConfigurationIfNeeded(overrideConfig, dc);
|
||||
}
|
||||
|
||||
// TODO(multi-display): remove when no default display use case.
|
||||
void prepareAppTransitionNone() {
|
||||
if (!checkCallingPermission(MANAGE_APP_TOKENS, "prepareAppTransition()")) {
|
||||
|
||||
@@ -446,25 +446,6 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
assertEquals(mDisplayContent, activity.getDisplayContent());
|
||||
}
|
||||
|
||||
/**
|
||||
* This tests override configuration updates for display content.
|
||||
*/
|
||||
@Test
|
||||
public void testDisplayOverrideConfigUpdate() {
|
||||
final Configuration currentOverrideConfig =
|
||||
mDisplayContent.getRequestedOverrideConfiguration();
|
||||
|
||||
// Create new, slightly changed override configuration and apply it to the display.
|
||||
final Configuration newOverrideConfig = new Configuration(currentOverrideConfig);
|
||||
newOverrideConfig.densityDpi += 120;
|
||||
newOverrideConfig.fontScale += 0.3;
|
||||
|
||||
mWm.setNewDisplayOverrideConfiguration(newOverrideConfig, mDisplayContent);
|
||||
|
||||
// Check that override config is applied.
|
||||
assertEquals(newOverrideConfig, mDisplayContent.getRequestedOverrideConfiguration());
|
||||
}
|
||||
|
||||
/**
|
||||
* This tests global configuration updates when default display config is updated.
|
||||
*/
|
||||
@@ -478,7 +459,8 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
newOverrideConfig.densityDpi += 120;
|
||||
newOverrideConfig.fontScale += 0.3;
|
||||
|
||||
mWm.setNewDisplayOverrideConfiguration(newOverrideConfig, defaultDisplay);
|
||||
defaultDisplay.updateDisplayOverrideConfigurationLocked(newOverrideConfig,
|
||||
null /* starting */, false /* deferResume */, null /* result */);
|
||||
|
||||
// Check that global configuration is updated, as we've updated default display's config.
|
||||
Configuration globalConfig = mWm.mRoot.getConfiguration();
|
||||
@@ -486,7 +468,8 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
assertEquals(newOverrideConfig.fontScale, globalConfig.fontScale, 0.1 /* delta */);
|
||||
|
||||
// Return back to original values.
|
||||
mWm.setNewDisplayOverrideConfiguration(currentConfig, defaultDisplay);
|
||||
defaultDisplay.updateDisplayOverrideConfigurationLocked(currentConfig,
|
||||
null /* starting */, false /* deferResume */, null /* result */);
|
||||
globalConfig = mWm.mRoot.getConfiguration();
|
||||
assertEquals(currentConfig.densityDpi, globalConfig.densityDpi);
|
||||
assertEquals(currentConfig.fontScale, globalConfig.fontScale, 0.1 /* delta */);
|
||||
|
||||
Reference in New Issue
Block a user