summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcore/java/android/provider/Settings.java17
-rw-r--r--services/core/java/com/android/server/wm/WindowManagerService.java78
2 files changed, 60 insertions, 35 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index dfc86012c810..7830142d4e4b 100755
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -3869,7 +3869,6 @@ public final class Settings {
MOVED_TO_GLOBAL.add(Settings.Global.DATA_ROAMING);
MOVED_TO_GLOBAL.add(Settings.Global.DEVELOPMENT_SETTINGS_ENABLED);
MOVED_TO_GLOBAL.add(Settings.Global.DEVICE_PROVISIONED);
- MOVED_TO_GLOBAL.add(Settings.Global.DISPLAY_DENSITY_FORCED);
MOVED_TO_GLOBAL.add(Settings.Global.DISPLAY_SIZE_FORCED);
MOVED_TO_GLOBAL.add(Settings.Global.DOWNLOAD_MAX_BYTES_OVER_MOBILE);
MOVED_TO_GLOBAL.add(Settings.Global.DOWNLOAD_RECOMMENDED_MAX_BYTES_OVER_MOBILE);
@@ -5104,6 +5103,15 @@ public final class Settings {
"disabled_print_services";
/**
+ * The saved value for WindowManagerService.setForcedDisplayDensity()
+ * formatted as a single integer representing DPI. If unset, then use
+ * the real display density.
+ *
+ * @hide
+ */
+ public static final String DISPLAY_DENSITY_FORCED = "display_density_forced";
+
+ /**
* Setting to always use the default text-to-speech settings regardless
* of the application settings.
* 1 = override application settings,
@@ -6535,13 +6543,6 @@ public final class Settings {
public static final String DEVICE_PROVISIONED = "device_provisioned";
/**
- * The saved value for WindowManagerService.setForcedDisplayDensity().
- * One integer in dpi. If unset, then use the real display density.
- * @hide
- */
- public static final String DISPLAY_DENSITY_FORCED = "display_density_forced";
-
- /**
* The saved value for WindowManagerService.setForcedDisplaySize().
* Two integers separated by a comma. If unset, then use the real display size.
* @hide
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index f9a37903f2b5..ae6c89a4d610 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -5364,8 +5364,18 @@ public class WindowManagerService extends IWindowManager.Stub
mWindowPlacerLocked.performSurfacePlacement();
// Notify whether the docked stack exists for the current user
- getDefaultDisplayContentLocked().mDividerControllerLocked
+ final DisplayContent displayContent = getDefaultDisplayContentLocked();
+ displayContent.mDividerControllerLocked
.notifyDockedStackExistsChanged(hasDockedTasksForUser(newUserId));
+
+ // If the display is already prepared, update the density.
+ // Otherwise, we'll update it when it's prepared.
+ if (mDisplayReady) {
+ final int forcedDensity = getForcedDisplayDensityForUserLocked(newUserId);
+ final int targetDensity = forcedDensity != 0 ? forcedDensity
+ : displayContent.mInitialDisplayDensity;
+ setForcedDisplayDensityLocked(displayContent, targetDensity);
+ }
}
}
@@ -8361,21 +8371,9 @@ public class WindowManagerService extends IWindowManager.Stub
}
// Display density.
- String densityStr = Settings.Global.getString(mContext.getContentResolver(),
- Settings.Global.DISPLAY_DENSITY_FORCED);
- if (densityStr == null || densityStr.length() == 0) {
- densityStr = SystemProperties.get(DENSITY_OVERRIDE, null);
- }
- if (densityStr != null && densityStr.length() > 0) {
- int density;
- try {
- density = Integer.parseInt(densityStr);
- if (displayContent.mBaseDisplayDensity != density) {
- Slog.i(TAG_WM, "FORCED DISPLAY DENSITY: " + density);
- displayContent.mBaseDisplayDensity = density;
- }
- } catch (NumberFormatException ex) {
- }
+ final int density = getForcedDisplayDensityForUserLocked(mCurrentUserId);
+ if (density != 0) {
+ displayContent.mBaseDisplayDensity = density;
}
// Display scaling mode.
@@ -8461,8 +8459,9 @@ public class WindowManagerService extends IWindowManager.Stub
final DisplayContent displayContent = getDisplayContentLocked(displayId);
if (displayContent != null) {
setForcedDisplayDensityLocked(displayContent, density);
- Settings.Global.putString(mContext.getContentResolver(),
- Settings.Global.DISPLAY_DENSITY_FORCED, Integer.toString(density));
+ Settings.Secure.putStringForUser(mContext.getContentResolver(),
+ Settings.Secure.DISPLAY_DENSITY_FORCED,
+ Integer.toString(density), mCurrentUserId);
}
}
} finally {
@@ -8470,13 +8469,6 @@ public class WindowManagerService extends IWindowManager.Stub
}
}
- // displayContent must not be null
- private void setForcedDisplayDensityLocked(DisplayContent displayContent, int density) {
- Slog.i(TAG_WM, "Using new display density: " + density);
- displayContent.mBaseDisplayDensity = density;
- reconfigureDisplayLocked(displayContent);
- }
-
@Override
public void clearForcedDisplayDensity(int displayId) {
if (mContext.checkCallingOrSelfPermission(
@@ -8495,8 +8487,8 @@ public class WindowManagerService extends IWindowManager.Stub
if (displayContent != null) {
setForcedDisplayDensityLocked(displayContent,
displayContent.mInitialDisplayDensity);
- Settings.Global.putString(mContext.getContentResolver(),
- Settings.Global.DISPLAY_DENSITY_FORCED, "");
+ Settings.Secure.putStringForUser(mContext.getContentResolver(),
+ Settings.Secure.DISPLAY_DENSITY_FORCED, "", mCurrentUserId);
}
}
} finally {
@@ -8504,6 +8496,38 @@ public class WindowManagerService extends IWindowManager.Stub
}
}
+ /**
+ * @param userId the ID of the user
+ * @return the forced display density for the specified user, if set, or
+ * {@code 0} if not set
+ */
+ private int getForcedDisplayDensityForUserLocked(int userId) {
+ String densityStr = Settings.Secure.getStringForUser(mContext.getContentResolver(),
+ Settings.Secure.DISPLAY_DENSITY_FORCED, userId);
+ if (densityStr == null || densityStr.length() == 0) {
+ densityStr = SystemProperties.get(DENSITY_OVERRIDE, null);
+ }
+ if (densityStr != null && densityStr.length() > 0) {
+ try {
+ return Integer.parseInt(densityStr);
+ } catch (NumberFormatException ex) {
+ }
+ }
+ return 0;
+ }
+
+ /**
+ * Forces the given display to the use the specified density.
+ *
+ * @param displayContent the display to modify
+ * @param density the density in DPI to use
+ */
+ private void setForcedDisplayDensityLocked(@NonNull DisplayContent displayContent,
+ int density) {
+ displayContent.mBaseDisplayDensity = density;
+ reconfigureDisplayLocked(displayContent);
+ }
+
// displayContent must not be null
private void reconfigureDisplayLocked(DisplayContent displayContent) {
// TODO: Multidisplay: for now only use with default display.