Loading cmds/wm/src/com/android/commands/wm/Wm.java +5 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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) { } Loading core/java/android/view/IWindowManager.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -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); Loading packages/SettingsLib/src/com/android/settingslib/display/DisplayDensityUtils.java +21 −18 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -207,40 +208,42 @@ 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() { final int userId = UserHandle.myUserId(); AsyncTask.execute(() -> { try { final IWindowManager wm = WindowManagerGlobal.getWindowManagerService(); wm.clearForcedDisplayDensity(displayId); 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() { final int userId = UserHandle.myUserId(); AsyncTask.execute(() -> { try { final IWindowManager wm = WindowManagerGlobal.getWindowManagerService(); wm.setForcedDisplayDensity(displayId, density); wm.setForcedDisplayDensityForUser(displayId, density, userId); } catch (RemoteException exc) { Log.w(LOG_TAG, "Unable to save forced display density setting"); } } }); } } services/core/java/com/android/server/wm/WindowManagerService.java +18 −9 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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) { Loading @@ -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); } Integer.toString(density), targetUserId); } } finally { Binder.restoreCallingIdentity(ident); Loading @@ -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) { Loading @@ -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); Loading tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java +3 −2 Original line number Diff line number Diff line Loading @@ -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 } Loading Loading @@ -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 } Loading Loading
cmds/wm/src/com/android/commands/wm/Wm.java +5 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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) { } Loading
core/java/android/view/IWindowManager.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -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); Loading
packages/SettingsLib/src/com/android/settingslib/display/DisplayDensityUtils.java +21 −18 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -207,40 +208,42 @@ 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() { final int userId = UserHandle.myUserId(); AsyncTask.execute(() -> { try { final IWindowManager wm = WindowManagerGlobal.getWindowManagerService(); wm.clearForcedDisplayDensity(displayId); 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() { final int userId = UserHandle.myUserId(); AsyncTask.execute(() -> { try { final IWindowManager wm = WindowManagerGlobal.getWindowManagerService(); wm.setForcedDisplayDensity(displayId, density); wm.setForcedDisplayDensityForUser(displayId, density, userId); } catch (RemoteException exc) { Log.w(LOG_TAG, "Unable to save forced display density setting"); } } }); } }
services/core/java/com/android/server/wm/WindowManagerService.java +18 −9 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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) { Loading @@ -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); } Integer.toString(density), targetUserId); } } finally { Binder.restoreCallingIdentity(ident); Loading @@ -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) { Loading @@ -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); Loading
tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java +3 −2 Original line number Diff line number Diff line Loading @@ -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 } Loading Loading @@ -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 } Loading