1 /* 2 * Copyright (C) 2013 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.server.wm; 18 19 import static android.view.WindowManager.DISPLAY_IME_POLICY_FALLBACK_DISPLAY; 20 import static android.view.WindowManager.DISPLAY_IME_POLICY_LOCAL; 21 import static android.view.WindowManager.REMOVE_CONTENT_MODE_DESTROY; 22 import static android.view.WindowManager.REMOVE_CONTENT_MODE_MOVE_TO_PRIMARY; 23 import static android.view.WindowManager.REMOVE_CONTENT_MODE_UNDEFINED; 24 25 import static com.android.server.wm.DisplayContent.FORCE_SCALING_MODE_AUTO; 26 import static com.android.server.wm.DisplayContent.FORCE_SCALING_MODE_DISABLED; 27 28 import android.annotation.NonNull; 29 import android.annotation.Nullable; 30 import android.app.WindowConfiguration; 31 import android.provider.Settings; 32 import android.view.Display; 33 import android.view.DisplayInfo; 34 import android.view.IWindowManager; 35 import android.view.Surface; 36 import android.view.WindowManager.DisplayImePolicy; 37 38 import com.android.server.policy.WindowManagerPolicy; 39 import com.android.server.wm.DisplayContent.ForceScalingMode; 40 41 import java.util.Objects; 42 43 /** 44 * Current persistent settings about a display. Provides policies for display settings and 45 * delegates the persistence and lookup of settings values to the supplied {@link SettingsProvider}. 46 */ 47 class DisplayWindowSettings { 48 private final WindowManagerService mService; 49 private final SettingsProvider mSettingsProvider; 50 DisplayWindowSettings(WindowManagerService service, SettingsProvider settingsProvider)51 DisplayWindowSettings(WindowManagerService service, SettingsProvider settingsProvider) { 52 mService = service; 53 mSettingsProvider = settingsProvider; 54 } 55 setUserRotation(DisplayContent displayContent, int rotationMode, int rotation)56 void setUserRotation(DisplayContent displayContent, int rotationMode, int rotation) { 57 final DisplayInfo displayInfo = displayContent.getDisplayInfo(); 58 final SettingsProvider.SettingsEntry overrideSettings = 59 mSettingsProvider.getOverrideSettings(displayInfo); 60 overrideSettings.mUserRotationMode = rotationMode; 61 overrideSettings.mUserRotation = rotation; 62 mSettingsProvider.updateOverrideSettings(displayInfo, overrideSettings); 63 } 64 setForcedSize(DisplayContent displayContent, int width, int height)65 void setForcedSize(DisplayContent displayContent, int width, int height) { 66 if (displayContent.isDefaultDisplay) { 67 final String sizeString = (width == 0 || height == 0) ? "" : (width + "," + height); 68 Settings.Global.putString(mService.mContext.getContentResolver(), 69 Settings.Global.DISPLAY_SIZE_FORCED, sizeString); 70 } 71 72 final DisplayInfo displayInfo = displayContent.getDisplayInfo(); 73 final SettingsProvider.SettingsEntry overrideSettings = 74 mSettingsProvider.getOverrideSettings(displayInfo); 75 overrideSettings.mForcedWidth = width; 76 overrideSettings.mForcedHeight = height; 77 mSettingsProvider.updateOverrideSettings(displayInfo, overrideSettings); 78 } 79 setForcedDensity(DisplayContent displayContent, int density, int userId)80 void setForcedDensity(DisplayContent displayContent, int density, int userId) { 81 if (displayContent.isDefaultDisplay) { 82 final String densityString = density == 0 ? "" : Integer.toString(density); 83 Settings.Secure.putStringForUser(mService.mContext.getContentResolver(), 84 Settings.Secure.DISPLAY_DENSITY_FORCED, densityString, userId); 85 } 86 87 final DisplayInfo displayInfo = displayContent.getDisplayInfo(); 88 final SettingsProvider.SettingsEntry overrideSettings = 89 mSettingsProvider.getOverrideSettings(displayInfo); 90 overrideSettings.mForcedDensity = density; 91 mSettingsProvider.updateOverrideSettings(displayInfo, overrideSettings); 92 } 93 setForcedScalingMode(DisplayContent displayContent, @ForceScalingMode int mode)94 void setForcedScalingMode(DisplayContent displayContent, @ForceScalingMode int mode) { 95 if (displayContent.isDefaultDisplay) { 96 Settings.Global.putInt(mService.mContext.getContentResolver(), 97 Settings.Global.DISPLAY_SCALING_FORCE, mode); 98 } 99 100 final DisplayInfo displayInfo = displayContent.getDisplayInfo(); 101 final SettingsProvider.SettingsEntry overrideSettings = 102 mSettingsProvider.getOverrideSettings(displayInfo); 103 overrideSettings.mForcedScalingMode = mode; 104 mSettingsProvider.updateOverrideSettings(displayInfo, overrideSettings); 105 } 106 setFixedToUserRotation(DisplayContent displayContent, int fixedToUserRotation)107 void setFixedToUserRotation(DisplayContent displayContent, int fixedToUserRotation) { 108 final DisplayInfo displayInfo = displayContent.getDisplayInfo(); 109 final SettingsProvider.SettingsEntry overrideSettings = 110 mSettingsProvider.getOverrideSettings(displayInfo); 111 overrideSettings.mFixedToUserRotation = fixedToUserRotation; 112 mSettingsProvider.updateOverrideSettings(displayInfo, overrideSettings); 113 } 114 setIgnoreOrientationRequest( DisplayContent displayContent, boolean ignoreOrientationRequest)115 void setIgnoreOrientationRequest( 116 DisplayContent displayContent, boolean ignoreOrientationRequest) { 117 final DisplayInfo displayInfo = displayContent.getDisplayInfo(); 118 final SettingsProvider.SettingsEntry overrideSettings = 119 mSettingsProvider.getOverrideSettings(displayInfo); 120 overrideSettings.mIgnoreOrientationRequest = ignoreOrientationRequest; 121 mSettingsProvider.updateOverrideSettings(displayInfo, overrideSettings); 122 } 123 getWindowingModeLocked(SettingsProvider.SettingsEntry settings, DisplayContent dc)124 private int getWindowingModeLocked(SettingsProvider.SettingsEntry settings, DisplayContent dc) { 125 int windowingMode = settings.mWindowingMode; 126 // This display used to be in freeform, but we don't support freeform anymore, so fall 127 // back to fullscreen. 128 if (windowingMode == WindowConfiguration.WINDOWING_MODE_FREEFORM 129 && !mService.mAtmService.mSupportsFreeformWindowManagement) { 130 return WindowConfiguration.WINDOWING_MODE_FULLSCREEN; 131 } 132 // No record is present so use default windowing mode policy. 133 if (windowingMode == WindowConfiguration.WINDOWING_MODE_UNDEFINED) { 134 windowingMode = mService.mAtmService.mSupportsFreeformWindowManagement 135 && (mService.mIsPc || dc.forceDesktopMode()) 136 ? WindowConfiguration.WINDOWING_MODE_FREEFORM 137 : WindowConfiguration.WINDOWING_MODE_FULLSCREEN; 138 } 139 return windowingMode; 140 } 141 getWindowingModeLocked(DisplayContent dc)142 int getWindowingModeLocked(DisplayContent dc) { 143 final DisplayInfo displayInfo = dc.getDisplayInfo(); 144 final SettingsProvider.SettingsEntry settings = mSettingsProvider.getSettings(displayInfo); 145 return getWindowingModeLocked(settings, dc); 146 } 147 setWindowingModeLocked(DisplayContent dc, int mode)148 void setWindowingModeLocked(DisplayContent dc, int mode) { 149 final DisplayInfo displayInfo = dc.getDisplayInfo(); 150 final SettingsProvider.SettingsEntry overrideSettings = 151 mSettingsProvider.getOverrideSettings(displayInfo); 152 overrideSettings.mWindowingMode = mode; 153 dc.setWindowingMode(mode); 154 mSettingsProvider.updateOverrideSettings(displayInfo, overrideSettings); 155 } 156 getRemoveContentModeLocked(DisplayContent dc)157 int getRemoveContentModeLocked(DisplayContent dc) { 158 final DisplayInfo displayInfo = dc.getDisplayInfo(); 159 final SettingsProvider.SettingsEntry settings = mSettingsProvider.getSettings(displayInfo); 160 if (settings.mRemoveContentMode == REMOVE_CONTENT_MODE_UNDEFINED) { 161 if (dc.isPrivate()) { 162 // For private displays by default content is destroyed on removal. 163 return REMOVE_CONTENT_MODE_DESTROY; 164 } 165 // For other displays by default content is moved to primary on removal. 166 return REMOVE_CONTENT_MODE_MOVE_TO_PRIMARY; 167 } 168 return settings.mRemoveContentMode; 169 } 170 setRemoveContentModeLocked(DisplayContent dc, int mode)171 void setRemoveContentModeLocked(DisplayContent dc, int mode) { 172 final DisplayInfo displayInfo = dc.getDisplayInfo(); 173 final SettingsProvider.SettingsEntry overrideSettings = 174 mSettingsProvider.getOverrideSettings(displayInfo); 175 overrideSettings.mRemoveContentMode = mode; 176 mSettingsProvider.updateOverrideSettings(displayInfo, overrideSettings); 177 } 178 shouldShowWithInsecureKeyguardLocked(DisplayContent dc)179 boolean shouldShowWithInsecureKeyguardLocked(DisplayContent dc) { 180 final DisplayInfo displayInfo = dc.getDisplayInfo(); 181 final SettingsProvider.SettingsEntry settings = mSettingsProvider.getSettings(displayInfo); 182 return settings.mShouldShowWithInsecureKeyguard != null 183 ? settings.mShouldShowWithInsecureKeyguard : false; 184 } 185 setShouldShowWithInsecureKeyguardLocked(DisplayContent dc, boolean shouldShow)186 void setShouldShowWithInsecureKeyguardLocked(DisplayContent dc, boolean shouldShow) { 187 if (!dc.isPrivate() && shouldShow) { 188 throw new IllegalArgumentException("Public display can't be allowed to show content" 189 + " when locked"); 190 } 191 192 final DisplayInfo displayInfo = dc.getDisplayInfo(); 193 final SettingsProvider.SettingsEntry overrideSettings = 194 mSettingsProvider.getOverrideSettings(displayInfo); 195 overrideSettings.mShouldShowWithInsecureKeyguard = shouldShow; 196 mSettingsProvider.updateOverrideSettings(displayInfo, overrideSettings); 197 } 198 setDontMoveToTop(DisplayContent dc, boolean dontMoveToTop)199 void setDontMoveToTop(DisplayContent dc, boolean dontMoveToTop) { 200 DisplayInfo displayInfo = dc.getDisplayInfo(); 201 SettingsProvider.SettingsEntry overrideSettings = 202 mSettingsProvider.getSettings(displayInfo); 203 overrideSettings.mDontMoveToTop = dontMoveToTop; 204 mSettingsProvider.updateOverrideSettings(displayInfo, overrideSettings); 205 } 206 shouldShowSystemDecorsLocked(DisplayContent dc)207 boolean shouldShowSystemDecorsLocked(DisplayContent dc) { 208 if (dc.getDisplayId() == Display.DEFAULT_DISPLAY) { 209 // Default display should show system decors. 210 return true; 211 } 212 213 final DisplayInfo displayInfo = dc.getDisplayInfo(); 214 final SettingsProvider.SettingsEntry settings = mSettingsProvider.getSettings(displayInfo); 215 return settings.mShouldShowSystemDecors != null ? settings.mShouldShowSystemDecors : false; 216 } 217 setShouldShowSystemDecorsLocked(DisplayContent dc, boolean shouldShow)218 void setShouldShowSystemDecorsLocked(DisplayContent dc, boolean shouldShow) { 219 final DisplayInfo displayInfo = dc.getDisplayInfo(); 220 final SettingsProvider.SettingsEntry overrideSettings = 221 mSettingsProvider.getOverrideSettings(displayInfo); 222 overrideSettings.mShouldShowSystemDecors = shouldShow; 223 mSettingsProvider.updateOverrideSettings(displayInfo, overrideSettings); 224 } 225 getImePolicyLocked(DisplayContent dc)226 @DisplayImePolicy int getImePolicyLocked(DisplayContent dc) { 227 if (dc.getDisplayId() == Display.DEFAULT_DISPLAY) { 228 // Default display should show IME. 229 return DISPLAY_IME_POLICY_LOCAL; 230 } 231 232 final DisplayInfo displayInfo = dc.getDisplayInfo(); 233 final SettingsProvider.SettingsEntry settings = mSettingsProvider.getSettings(displayInfo); 234 return settings.mImePolicy != null ? settings.mImePolicy 235 : DISPLAY_IME_POLICY_FALLBACK_DISPLAY; 236 } 237 setDisplayImePolicy(DisplayContent dc, @DisplayImePolicy int imePolicy)238 void setDisplayImePolicy(DisplayContent dc, @DisplayImePolicy int imePolicy) { 239 final DisplayInfo displayInfo = dc.getDisplayInfo(); 240 final SettingsProvider.SettingsEntry overrideSettings = 241 mSettingsProvider.getOverrideSettings(displayInfo); 242 overrideSettings.mImePolicy = imePolicy; 243 mSettingsProvider.updateOverrideSettings(displayInfo, overrideSettings); 244 } 245 applySettingsToDisplayLocked(DisplayContent dc)246 void applySettingsToDisplayLocked(DisplayContent dc) { 247 final DisplayInfo displayInfo = dc.getDisplayInfo(); 248 final SettingsProvider.SettingsEntry settings = mSettingsProvider.getSettings(displayInfo); 249 250 // Setting windowing mode first, because it may override overscan values later. 251 final int windowingMode = getWindowingModeLocked(settings, dc); 252 dc.setWindowingMode(windowingMode); 253 254 final int userRotationMode = settings.mUserRotationMode != null 255 ? settings.mUserRotationMode : WindowManagerPolicy.USER_ROTATION_FREE; 256 final int userRotation = settings.mUserRotation != null 257 ? settings.mUserRotation : Surface.ROTATION_0; 258 final int mFixedToUserRotation = settings.mFixedToUserRotation != null 259 ? settings.mFixedToUserRotation : IWindowManager.FIXED_TO_USER_ROTATION_DEFAULT; 260 dc.getDisplayRotation().restoreSettings(userRotationMode, userRotation, 261 mFixedToUserRotation); 262 263 final boolean hasDensityOverride = settings.mForcedDensity != 0; 264 final boolean hasSizeOverride = settings.mForcedWidth != 0 && settings.mForcedHeight != 0; 265 dc.mIsDensityForced = hasDensityOverride; 266 dc.mIsSizeForced = hasSizeOverride; 267 268 final boolean ignoreOrientationRequest = settings.mIgnoreOrientationRequest != null 269 ? settings.mIgnoreOrientationRequest : false; 270 dc.setIgnoreOrientationRequest(ignoreOrientationRequest); 271 272 final boolean ignoreDisplayCutout = settings.mIgnoreDisplayCutout != null 273 ? settings.mIgnoreDisplayCutout : false; 274 dc.mIgnoreDisplayCutout = ignoreDisplayCutout; 275 276 final int width = hasSizeOverride ? settings.mForcedWidth : dc.mInitialDisplayWidth; 277 final int height = hasSizeOverride ? settings.mForcedHeight : dc.mInitialDisplayHeight; 278 final int density = hasDensityOverride ? settings.mForcedDensity 279 : dc.mInitialDisplayDensity; 280 dc.updateBaseDisplayMetrics(width, height, density); 281 282 final int forcedScalingMode = settings.mForcedScalingMode != null 283 ? settings.mForcedScalingMode : FORCE_SCALING_MODE_AUTO; 284 dc.mDisplayScalingDisabled = forcedScalingMode == FORCE_SCALING_MODE_DISABLED; 285 286 boolean dontMoveToTop = settings.mDontMoveToTop != null 287 ? settings.mDontMoveToTop : false; 288 dc.mDontMoveToTop = dontMoveToTop; 289 } 290 291 /** 292 * Updates settings for the given display after system features are loaded into window manager 293 * service, e.g. if this device is PC and if this device supports freeform. 294 * 295 * @param dc the given display. 296 * @return {@code true} if any settings for this display has changed; {@code false} if nothing 297 * changed. 298 */ updateSettingsForDisplay(DisplayContent dc)299 boolean updateSettingsForDisplay(DisplayContent dc) { 300 if (dc.getWindowingMode() != getWindowingModeLocked(dc)) { 301 // For the time being the only thing that may change is windowing mode, so just update 302 // that. 303 dc.setWindowingMode(getWindowingModeLocked(dc)); 304 return true; 305 } 306 return false; 307 } 308 309 /** 310 * Provides the functionality to lookup the {@link SettingsEntry settings} for a given 311 * {@link DisplayInfo}. 312 * <p> 313 * NOTE: All interactions with implementations of this provider <b>must</b> be thread-safe 314 * externally. 315 */ 316 interface SettingsProvider { 317 /** 318 * Returns the {@link SettingsEntry} for a given {@link DisplayInfo}. The values for the 319 * returned settings are guaranteed to match those previously set with 320 * {@link #updateOverrideSettings(DisplayInfo, SettingsEntry)} with all other values left 321 * to the implementation to determine. 322 */ 323 @NonNull getSettings(@onNull DisplayInfo info)324 SettingsEntry getSettings(@NonNull DisplayInfo info); 325 326 /** 327 * Returns the existing override settings for the given {@link DisplayInfo}. All calls to 328 * {@link #getSettings(DisplayInfo)} for the provided {@code info} are required to have 329 * their values overridden with all set values from the returned {@link SettingsEntry}. 330 * 331 * @see #getSettings(DisplayInfo) 332 * @see #updateOverrideSettings(DisplayInfo, SettingsEntry) 333 */ 334 @NonNull getOverrideSettings(@onNull DisplayInfo info)335 SettingsEntry getOverrideSettings(@NonNull DisplayInfo info); 336 337 /** 338 * Updates the override settings for a given {@link DisplayInfo}. All subsequent calls to 339 * {@link #getSettings(DisplayInfo)} for the provided {@link DisplayInfo} are required to 340 * have their values match all set values in {@code overrides}. 341 * 342 * @see #getSettings(DisplayInfo) 343 */ updateOverrideSettings(@onNull DisplayInfo info, @NonNull SettingsEntry overrides)344 void updateOverrideSettings(@NonNull DisplayInfo info, @NonNull SettingsEntry overrides); 345 346 /** 347 * Settings for a display. 348 */ 349 class SettingsEntry { 350 int mWindowingMode = WindowConfiguration.WINDOWING_MODE_UNDEFINED; 351 @Nullable 352 Integer mUserRotationMode; 353 @Nullable 354 Integer mUserRotation; 355 int mForcedWidth; 356 int mForcedHeight; 357 int mForcedDensity; 358 @Nullable 359 Integer mForcedScalingMode; 360 int mRemoveContentMode = REMOVE_CONTENT_MODE_UNDEFINED; 361 @Nullable 362 Boolean mShouldShowWithInsecureKeyguard; 363 @Nullable 364 Boolean mShouldShowSystemDecors; 365 @Nullable 366 Integer mImePolicy; 367 @Nullable 368 Integer mFixedToUserRotation; 369 @Nullable 370 Boolean mIgnoreOrientationRequest; 371 @Nullable 372 Boolean mIgnoreDisplayCutout; 373 @Nullable 374 Boolean mDontMoveToTop; 375 SettingsEntry()376 SettingsEntry() {} 377 SettingsEntry(SettingsEntry copyFrom)378 SettingsEntry(SettingsEntry copyFrom) { 379 setTo(copyFrom); 380 } 381 382 /** 383 * Copies all fields from {@code delta} into this {@link SettingsEntry} object, keeping 384 * track of whether a change has occurred. 385 * 386 * @return {@code true} if this settings have changed as a result of the copy, 387 * {@code false} otherwise. 388 * 389 * @see #updateFrom(SettingsEntry) 390 */ setTo(@onNull SettingsEntry other)391 boolean setTo(@NonNull SettingsEntry other) { 392 boolean changed = false; 393 if (other.mWindowingMode != mWindowingMode) { 394 mWindowingMode = other.mWindowingMode; 395 changed = true; 396 } 397 if (!Objects.equals(other.mUserRotationMode, mUserRotationMode)) { 398 mUserRotationMode = other.mUserRotationMode; 399 changed = true; 400 } 401 if (!Objects.equals(other.mUserRotation, mUserRotation)) { 402 mUserRotation = other.mUserRotation; 403 changed = true; 404 } 405 if (other.mForcedWidth != mForcedWidth) { 406 mForcedWidth = other.mForcedWidth; 407 changed = true; 408 } 409 if (other.mForcedHeight != mForcedHeight) { 410 mForcedHeight = other.mForcedHeight; 411 changed = true; 412 } 413 if (other.mForcedDensity != mForcedDensity) { 414 mForcedDensity = other.mForcedDensity; 415 changed = true; 416 } 417 if (!Objects.equals(other.mForcedScalingMode, mForcedScalingMode)) { 418 mForcedScalingMode = other.mForcedScalingMode; 419 changed = true; 420 } 421 if (other.mRemoveContentMode != mRemoveContentMode) { 422 mRemoveContentMode = other.mRemoveContentMode; 423 changed = true; 424 } 425 if (other.mShouldShowWithInsecureKeyguard != mShouldShowWithInsecureKeyguard) { 426 mShouldShowWithInsecureKeyguard = other.mShouldShowWithInsecureKeyguard; 427 changed = true; 428 } 429 if (other.mShouldShowSystemDecors != mShouldShowSystemDecors) { 430 mShouldShowSystemDecors = other.mShouldShowSystemDecors; 431 changed = true; 432 } 433 if (!Objects.equals(other.mImePolicy, mImePolicy)) { 434 mImePolicy = other.mImePolicy; 435 changed = true; 436 } 437 if (!Objects.equals(other.mFixedToUserRotation, mFixedToUserRotation)) { 438 mFixedToUserRotation = other.mFixedToUserRotation; 439 changed = true; 440 } 441 if (other.mIgnoreOrientationRequest != mIgnoreOrientationRequest) { 442 mIgnoreOrientationRequest = other.mIgnoreOrientationRequest; 443 changed = true; 444 } 445 if (other.mIgnoreDisplayCutout != mIgnoreDisplayCutout) { 446 mIgnoreDisplayCutout = other.mIgnoreDisplayCutout; 447 changed = true; 448 } 449 if (other.mDontMoveToTop != mDontMoveToTop) { 450 mDontMoveToTop = other.mDontMoveToTop; 451 changed = true; 452 } 453 return changed; 454 } 455 456 /** 457 * Copies the fields from {@code delta} into this {@link SettingsEntry} object, keeping 458 * track of whether a change has occurred. Any undefined fields in {@code delta} are 459 * ignored and not copied into the current {@link SettingsEntry}. 460 * 461 * @return {@code true} if this settings have changed as a result of the copy, 462 * {@code false} otherwise. 463 * 464 * @see #setTo(SettingsEntry) 465 */ updateFrom(@onNull SettingsEntry delta)466 boolean updateFrom(@NonNull SettingsEntry delta) { 467 boolean changed = false; 468 if (delta.mWindowingMode != WindowConfiguration.WINDOWING_MODE_UNDEFINED 469 && delta.mWindowingMode != mWindowingMode) { 470 mWindowingMode = delta.mWindowingMode; 471 changed = true; 472 } 473 if (delta.mUserRotationMode != null 474 && !Objects.equals(delta.mUserRotationMode, mUserRotationMode)) { 475 mUserRotationMode = delta.mUserRotationMode; 476 changed = true; 477 } 478 if (delta.mUserRotation != null 479 && !Objects.equals(delta.mUserRotation, mUserRotation)) { 480 mUserRotation = delta.mUserRotation; 481 changed = true; 482 } 483 if (delta.mForcedWidth != 0 && delta.mForcedWidth != mForcedWidth) { 484 mForcedWidth = delta.mForcedWidth; 485 changed = true; 486 } 487 if (delta.mForcedHeight != 0 && delta.mForcedHeight != mForcedHeight) { 488 mForcedHeight = delta.mForcedHeight; 489 changed = true; 490 } 491 if (delta.mForcedDensity != 0 && delta.mForcedDensity != mForcedDensity) { 492 mForcedDensity = delta.mForcedDensity; 493 changed = true; 494 } 495 if (delta.mForcedScalingMode != null 496 && !Objects.equals(delta.mForcedScalingMode, mForcedScalingMode)) { 497 mForcedScalingMode = delta.mForcedScalingMode; 498 changed = true; 499 } 500 if (delta.mRemoveContentMode != REMOVE_CONTENT_MODE_UNDEFINED 501 && delta.mRemoveContentMode != mRemoveContentMode) { 502 mRemoveContentMode = delta.mRemoveContentMode; 503 changed = true; 504 } 505 if (delta.mShouldShowWithInsecureKeyguard != null 506 && delta.mShouldShowWithInsecureKeyguard 507 != mShouldShowWithInsecureKeyguard) { 508 mShouldShowWithInsecureKeyguard = delta.mShouldShowWithInsecureKeyguard; 509 changed = true; 510 } 511 if (delta.mShouldShowSystemDecors != null 512 && delta.mShouldShowSystemDecors != mShouldShowSystemDecors) { 513 mShouldShowSystemDecors = delta.mShouldShowSystemDecors; 514 changed = true; 515 } 516 if (delta.mImePolicy != null 517 && !Objects.equals(delta.mImePolicy, mImePolicy)) { 518 mImePolicy = delta.mImePolicy; 519 changed = true; 520 } 521 if (delta.mFixedToUserRotation != null 522 && !Objects.equals(delta.mFixedToUserRotation, mFixedToUserRotation)) { 523 mFixedToUserRotation = delta.mFixedToUserRotation; 524 changed = true; 525 } 526 if (delta.mIgnoreOrientationRequest != null 527 && delta.mIgnoreOrientationRequest != mIgnoreOrientationRequest) { 528 mIgnoreOrientationRequest = delta.mIgnoreOrientationRequest; 529 changed = true; 530 } 531 if (delta.mIgnoreDisplayCutout != null 532 && delta.mIgnoreDisplayCutout != mIgnoreDisplayCutout) { 533 mIgnoreDisplayCutout = delta.mIgnoreDisplayCutout; 534 changed = true; 535 } 536 if (delta.mDontMoveToTop != null 537 && delta.mDontMoveToTop != mDontMoveToTop) { 538 mDontMoveToTop = delta.mDontMoveToTop; 539 changed = true; 540 } 541 return changed; 542 } 543 544 /** @return {@code true} if all values are unset. */ isEmpty()545 boolean isEmpty() { 546 return mWindowingMode == WindowConfiguration.WINDOWING_MODE_UNDEFINED 547 && mUserRotationMode == null 548 && mUserRotation == null 549 && mForcedWidth == 0 && mForcedHeight == 0 && mForcedDensity == 0 550 && mForcedScalingMode == null 551 && mRemoveContentMode == REMOVE_CONTENT_MODE_UNDEFINED 552 && mShouldShowWithInsecureKeyguard == null 553 && mShouldShowSystemDecors == null 554 && mImePolicy == null 555 && mFixedToUserRotation == null 556 && mIgnoreOrientationRequest == null 557 && mIgnoreDisplayCutout == null 558 && mDontMoveToTop == null; 559 } 560 561 @Override equals(@ullable Object o)562 public boolean equals(@Nullable Object o) { 563 if (this == o) return true; 564 if (o == null || getClass() != o.getClass()) return false; 565 SettingsEntry that = (SettingsEntry) o; 566 return mWindowingMode == that.mWindowingMode 567 && mForcedWidth == that.mForcedWidth 568 && mForcedHeight == that.mForcedHeight 569 && mForcedDensity == that.mForcedDensity 570 && mRemoveContentMode == that.mRemoveContentMode 571 && Objects.equals(mUserRotationMode, that.mUserRotationMode) 572 && Objects.equals(mUserRotation, that.mUserRotation) 573 && Objects.equals(mForcedScalingMode, that.mForcedScalingMode) 574 && Objects.equals(mShouldShowWithInsecureKeyguard, 575 that.mShouldShowWithInsecureKeyguard) 576 && Objects.equals(mShouldShowSystemDecors, that.mShouldShowSystemDecors) 577 && Objects.equals(mImePolicy, that.mImePolicy) 578 && Objects.equals(mFixedToUserRotation, that.mFixedToUserRotation) 579 && Objects.equals(mIgnoreOrientationRequest, that.mIgnoreOrientationRequest) 580 && Objects.equals(mIgnoreDisplayCutout, that.mIgnoreDisplayCutout) 581 && Objects.equals(mDontMoveToTop, that.mDontMoveToTop); 582 } 583 584 @Override hashCode()585 public int hashCode() { 586 return Objects.hash(mWindowingMode, mUserRotationMode, mUserRotation, mForcedWidth, 587 mForcedHeight, mForcedDensity, mForcedScalingMode, mRemoveContentMode, 588 mShouldShowWithInsecureKeyguard, mShouldShowSystemDecors, mImePolicy, 589 mFixedToUserRotation, mIgnoreOrientationRequest, mIgnoreDisplayCutout, 590 mDontMoveToTop); 591 } 592 593 @Override toString()594 public String toString() { 595 return "SettingsEntry{" 596 + "mWindowingMode=" + mWindowingMode 597 + ", mUserRotationMode=" + mUserRotationMode 598 + ", mUserRotation=" + mUserRotation 599 + ", mForcedWidth=" + mForcedWidth 600 + ", mForcedHeight=" + mForcedHeight 601 + ", mForcedDensity=" + mForcedDensity 602 + ", mForcedScalingMode=" + mForcedScalingMode 603 + ", mRemoveContentMode=" + mRemoveContentMode 604 + ", mShouldShowWithInsecureKeyguard=" + mShouldShowWithInsecureKeyguard 605 + ", mShouldShowSystemDecors=" + mShouldShowSystemDecors 606 + ", mShouldShowIme=" + mImePolicy 607 + ", mFixedToUserRotation=" + mFixedToUserRotation 608 + ", mIgnoreOrientationRequest=" + mIgnoreOrientationRequest 609 + ", mIgnoreDisplayCutout=" + mIgnoreDisplayCutout 610 + ", mDontMoveToTop=" + mDontMoveToTop 611 + '}'; 612 } 613 } 614 } 615 } 616