summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmds/wm/src/com/android/commands/wm/Wm.java7
-rw-r--r--core/java/android/view/IWindowManager.aidl4
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/display/DisplayDensityUtils.java39
-rw-r--r--services/core/java/com/android/server/wm/WindowManagerService.java27
-rw-r--r--tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java5
5 files changed, 49 insertions, 33 deletions
diff --git a/cmds/wm/src/com/android/commands/wm/Wm.java b/cmds/wm/src/com/android/commands/wm/Wm.java
index f7f7c887aeb0..383cd01ddcd6 100644
--- a/cmds/wm/src/com/android/commands/wm/Wm.java
+++ b/cmds/wm/src/com/android/commands/wm/Wm.java
@@ -23,6 +23,7 @@ import android.graphics.Point;
import android.graphics.Rect;
import android.os.RemoteException;
import android.os.ServiceManager;
+import android.os.UserHandle;
import android.util.AndroidException;
import android.util.DisplayMetrics;
import android.view.Display;
@@ -201,9 +202,11 @@ public class Wm extends BaseCommand {
try {
if (density > 0) {
// TODO(multidisplay): For now Configuration only applies to main screen.
- mWm.setForcedDisplayDensity(Display.DEFAULT_DISPLAY, density);
+ mWm.setForcedDisplayDensityForUser(Display.DEFAULT_DISPLAY, density,
+ UserHandle.USER_CURRENT);
} else {
- mWm.clearForcedDisplayDensity(Display.DEFAULT_DISPLAY);
+ mWm.clearForcedDisplayDensityForUser(Display.DEFAULT_DISPLAY,
+ UserHandle.USER_CURRENT);
}
} catch (RemoteException e) {
}
diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl
index 81469c86810c..83feb88fa55d 100644
--- a/core/java/android/view/IWindowManager.aidl
+++ b/core/java/android/view/IWindowManager.aidl
@@ -73,8 +73,8 @@ interface IWindowManager
void clearForcedDisplaySize(int displayId);
int getInitialDisplayDensity(int displayId);
int getBaseDisplayDensity(int displayId);
- void setForcedDisplayDensity(int displayId, int density);
- void clearForcedDisplayDensity(int displayId);
+ void setForcedDisplayDensityForUser(int displayId, int density, int userId);
+ void clearForcedDisplayDensityForUser(int displayId, int userId);
void setForcedDisplayScalingMode(int displayId, int mode); // 0 = auto, 1 = disable
void setOverscan(int displayId, int left, int top, int right, int bottom);
diff --git a/packages/SettingsLib/src/com/android/settingslib/display/DisplayDensityUtils.java b/packages/SettingsLib/src/com/android/settingslib/display/DisplayDensityUtils.java
index a99e66873958..af8fd4c46a64 100644
--- a/packages/SettingsLib/src/com/android/settingslib/display/DisplayDensityUtils.java
+++ b/packages/SettingsLib/src/com/android/settingslib/display/DisplayDensityUtils.java
@@ -23,6 +23,7 @@ import android.content.res.Resources;
import android.hardware.display.DisplayManager;
import android.os.AsyncTask;
import android.os.RemoteException;
+import android.os.UserHandle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.MathUtils;
@@ -207,39 +208,41 @@ public class DisplayDensityUtils {
/**
* Asynchronously applies display density changes to the specified display.
+ * <p>
+ * The change will be applied to the user specified by the value of
+ * {@link UserHandle#myUserId()} at the time the method is called.
*
* @param displayId the identifier of the display to modify
*/
public static void clearForcedDisplayDensity(final int displayId) {
- AsyncTask.execute(new Runnable() {
- @Override
- public void run() {
- try {
- final IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
- wm.clearForcedDisplayDensity(displayId);
- } catch (RemoteException exc) {
- Log.w(LOG_TAG, "Unable to clear forced display density setting");
- }
+ final int userId = UserHandle.myUserId();
+ AsyncTask.execute(() -> {
+ try {
+ final IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
+ wm.clearForcedDisplayDensityForUser(displayId, userId);
+ } catch (RemoteException exc) {
+ Log.w(LOG_TAG, "Unable to clear forced display density setting");
}
});
}
/**
* Asynchronously applies display density changes to the specified display.
+ * <p>
+ * The change will be applied to the user specified by the value of
+ * {@link UserHandle#myUserId()} at the time the method is called.
*
* @param displayId the identifier of the display to modify
* @param density the density to force for the specified display
*/
public static void setForcedDisplayDensity(final int displayId, final int density) {
- AsyncTask.execute(new Runnable() {
- @Override
- public void run() {
- try {
- final IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
- wm.setForcedDisplayDensity(displayId, density);
- } catch (RemoteException exc) {
- Log.w(LOG_TAG, "Unable to save forced display density setting");
- }
+ final int userId = UserHandle.myUserId();
+ AsyncTask.execute(() -> {
+ try {
+ final IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
+ wm.setForcedDisplayDensityForUser(displayId, density, userId);
+ } catch (RemoteException exc) {
+ Log.w(LOG_TAG, "Unable to save forced display density setting");
}
});
}
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 4372deaf4425..707b13780c46 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -21,6 +21,7 @@ import android.animation.ValueAnimator;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.app.ActivityManager;
import android.app.ActivityManagerInternal;
import android.app.ActivityManagerNative;
import android.app.AppOpsManager;
@@ -9192,7 +9193,7 @@ public class WindowManagerService extends IWindowManager.Stub
}
@Override
- public void setForcedDisplayDensity(int displayId, int density) {
+ public void setForcedDisplayDensityForUser(int displayId, int density, int userId) {
if (mContext.checkCallingOrSelfPermission(
android.Manifest.permission.WRITE_SECURE_SETTINGS) !=
PackageManager.PERMISSION_GRANTED) {
@@ -9202,16 +9203,20 @@ public class WindowManagerService extends IWindowManager.Stub
if (displayId != Display.DEFAULT_DISPLAY) {
throw new IllegalArgumentException("Can only set the default display");
}
+
+ final int targetUserId = ActivityManager.handleIncomingUser(Binder.getCallingPid(),
+ Binder.getCallingUid(), userId, false, true, "setForcedDisplayDensityForUser",
+ null);
final long ident = Binder.clearCallingIdentity();
try {
synchronized(mWindowMap) {
final DisplayContent displayContent = getDisplayContentLocked(displayId);
- if (displayContent != null) {
+ if (displayContent != null && mCurrentUserId == targetUserId) {
setForcedDisplayDensityLocked(displayContent, density);
- Settings.Secure.putStringForUser(mContext.getContentResolver(),
- Settings.Secure.DISPLAY_DENSITY_FORCED,
- Integer.toString(density), mCurrentUserId);
}
+ Settings.Secure.putStringForUser(mContext.getContentResolver(),
+ Settings.Secure.DISPLAY_DENSITY_FORCED,
+ Integer.toString(density), targetUserId);
}
} finally {
Binder.restoreCallingIdentity(ident);
@@ -9219,7 +9224,7 @@ public class WindowManagerService extends IWindowManager.Stub
}
@Override
- public void clearForcedDisplayDensity(int displayId) {
+ public void clearForcedDisplayDensityForUser(int displayId, int userId) {
if (mContext.checkCallingOrSelfPermission(
android.Manifest.permission.WRITE_SECURE_SETTINGS) !=
PackageManager.PERMISSION_GRANTED) {
@@ -9229,16 +9234,20 @@ public class WindowManagerService extends IWindowManager.Stub
if (displayId != Display.DEFAULT_DISPLAY) {
throw new IllegalArgumentException("Can only set the default display");
}
+
+ final int callingUserId = ActivityManager.handleIncomingUser(Binder.getCallingPid(),
+ Binder.getCallingUid(), userId, false, true, "clearForcedDisplayDensityForUser",
+ null);
final long ident = Binder.clearCallingIdentity();
try {
synchronized(mWindowMap) {
final DisplayContent displayContent = getDisplayContentLocked(displayId);
- if (displayContent != null) {
+ if (displayContent != null && mCurrentUserId == callingUserId) {
setForcedDisplayDensityLocked(displayContent,
displayContent.mInitialDisplayDensity);
- Settings.Secure.putStringForUser(mContext.getContentResolver(),
- Settings.Secure.DISPLAY_DENSITY_FORCED, "", mCurrentUserId);
}
+ Settings.Secure.putStringForUser(mContext.getContentResolver(),
+ Settings.Secure.DISPLAY_DENSITY_FORCED, "", callingUserId);
}
} finally {
Binder.restoreCallingIdentity(ident);
diff --git a/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java b/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java
index 58df301b1cfc..76522f95fbd4 100644
--- a/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java
+++ b/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java
@@ -96,7 +96,7 @@ public class IWindowManagerImpl implements IWindowManager {
}
@Override
- public void clearForcedDisplayDensity(int displayId) throws RemoteException {
+ public void clearForcedDisplayDensityForUser(int displayId, int userId) throws RemoteException {
// TODO Auto-generated method stub
}
@@ -397,7 +397,8 @@ public class IWindowManagerImpl implements IWindowManager {
}
@Override
- public void setForcedDisplayDensity(int displayId, int density) throws RemoteException {
+ public void setForcedDisplayDensityForUser(int displayId, int density, int userId)
+ throws RemoteException {
// TODO Auto-generated method stub
}