mWindowManager.setSupportsPictureInPicture(mSupportsPictureInPicture);
mWindowManager.setSupportsFreeformWindowManagement(mSupportsFreeformWindowManagement);
mWindowManager.setIsPc(isPc);
+ mWindowManager.mRoot.onSettingsRetrieved();
// This happens before any activities are started, so we can change global configuration
// in-place.
updateConfigurationLocked(configuration, null, true);
dc.mDisplayScalingDisabled = entry.mForcedScalingMode == FORCE_SCALING_MODE_DISABLED;
}
+ /**
+ * Updates settings for the given display after system features are loaded into window manager
+ * service, e.g. if this device is PC and if this device supports freeform.
+ *
+ * @param dc the given display.
+ * @return {@code true} if any settings for this display has changed; {@code false} if nothing
+ * changed.
+ */
+ boolean updateSettingsForDisplay(DisplayContent dc) {
+ if (dc.getWindowingMode() != getWindowingModeLocked(dc)) {
+ // For the time being the only thing that may change is windowing mode, so just update
+ // that.
+ dc.setWindowingMode(getWindowingModeLocked(dc));
+ return true;
+ }
+ return false;
+ }
+
private void readSettings() {
FileInputStream stream;
try {
return dc;
}
+ /**
+ * Called when DisplayWindowSettings values may change.
+ */
+ void onSettingsRetrieved() {
+ final int numDisplays = mChildren.size();
+ for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
+ final DisplayContent displayContent = mChildren.get(displayNdx);
+ final boolean changed = mWmService.mDisplayWindowSettings.updateSettingsForDisplay(
+ displayContent);
+ if (!changed) {
+ continue;
+ }
+
+ displayContent.initializeDisplayOverrideConfiguration();
+ mWmService.reconfigureDisplayLocked(displayContent);
+
+ // We need to update global configuration as well if config of default display has
+ // changed. Do it inline because ATMS#retrieveSettings() will soon update the
+ // configuration inline, which will overwrite the new windowing mode.
+ if (displayContent.isDefaultDisplay) {
+ final Configuration newConfig = mWmService.computeNewConfiguration(
+ displayContent.getDisplayId());
+ mWmService.mAtmService.updateConfigurationLocked(newConfig, null /* starting */,
+ false /* initLocale */);
+ }
+ }
+ }
+
boolean isLayoutNeeded() {
final int numDisplays = mChildren.size();
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
}
@Test
+ public void testPrimaryDisplayUpdateToFreeform_HasFreeformSupport_IsPc() {
+ mTarget.applySettingsToDisplayLocked(mPrimaryDisplay);
+
+ mWm.setSupportsFreeformWindowManagement(true);
+ mWm.setIsPc(true);
+
+ mTarget.updateSettingsForDisplay(mPrimaryDisplay);
+
+ assertEquals(WindowConfiguration.WINDOWING_MODE_FREEFORM,
+ mPrimaryDisplay.getWindowingMode());
+ }
+
+ @Test
public void testSecondaryDisplayDefaultToFullscreen_NoFreeformSupport() {
mTarget.applySettingsToDisplayLocked(mSecondaryDisplay);
import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR;
import static android.view.WindowManager.LayoutParams.TYPE_TOAST;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import android.app.WindowConfiguration;
import android.platform.test.annotations.Presubmit;
import androidx.test.filters.SmallTest;
assertFalse(app.isVisible());
assertFalse(mWm.mRoot.isAnyNonToastWindowVisibleForUid(FAKE_CALLING_UID));
}
+
+ @Test
+ public void testUpdateDefaultDisplayWindowingModeOnSettingsRetrieved() {
+ synchronized (mWm.mGlobalLock) {
+ assertEquals(WindowConfiguration.WINDOWING_MODE_FULLSCREEN,
+ mWm.getDefaultDisplayContentLocked().getWindowingMode());
+
+ mWm.mIsPc = true;
+ mWm.mSupportsFreeformWindowManagement = true;
+
+ mWm.mRoot.onSettingsRetrieved();
+
+ assertEquals(WindowConfiguration.WINDOWING_MODE_FREEFORM,
+ mWm.getDefaultDisplayContentLocked().getWindowingMode());
+ }
+ }
}