Loading core/java/android/view/IWindowManager.aidl +4 −3 Original line number Original line Diff line number Diff line Loading @@ -192,11 +192,12 @@ interface IWindowManager int getPreferredOptionsPanelGravity(); int getPreferredOptionsPanelGravity(); /** /** * Lock the device orientation to the current rotation. Sensor input will * Lock the device orientation to the specified rotation, or to the * be ignored until thawRotation() is called. * current rotation if -1. Sensor input will be ignored until * thawRotation() is called. * @hide * @hide */ */ void freezeRotation(); void freezeRotation(int rotation); /** /** * Release the orientation lock imposed by freezeRotation(). * Release the orientation lock imposed by freezeRotation(). Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/AutoRotateController.java +3 −2 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.os.AsyncTask; import android.os.RemoteException; import android.os.RemoteException; import android.os.ServiceManager; import android.os.ServiceManager; import android.provider.Settings; import android.provider.Settings; import android.util.Log; import android.util.Slog; import android.util.Slog; import android.view.IWindowManager; import android.view.IWindowManager; import android.widget.CompoundButton; import android.widget.CompoundButton; Loading Loading @@ -63,13 +64,13 @@ public class AutoRotateController implements CompoundButton.OnCheckedChangeListe try { try { IWindowManager wm = IWindowManager.Stub.asInterface( IWindowManager wm = IWindowManager.Stub.asInterface( ServiceManager.getService(Context.WINDOW_SERVICE)); ServiceManager.getService(Context.WINDOW_SERVICE)); ContentResolver cr = mContext.getContentResolver(); if (autorotate) { if (autorotate) { wm.thawRotation(); wm.thawRotation(); } else { } else { wm.freezeRotation(); wm.freezeRotation(-1); } } } catch (RemoteException exc) { } catch (RemoteException exc) { Log.w(TAG, "Unable to save auto-rotate setting"); } } } } }); }); Loading policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +6 −6 Original line number Original line Diff line number Diff line Loading @@ -2947,10 +2947,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { // enable 180 degree rotation while docked. // enable 180 degree rotation while docked. preferredRotation = mDeskDockEnablesAccelerometer preferredRotation = mDeskDockEnablesAccelerometer ? sensorRotation : mDeskDockRotation; ? sensorRotation : mDeskDockRotation; } else if (mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED) { } else if ((mAccelerometerDefault != 0 /* implies not rotation locked */ // Ignore sensor when user locked rotation. preferredRotation = mUserRotation; } else if ((mAccelerometerDefault != 0 && (orientation == ActivityInfo.SCREEN_ORIENTATION_USER && (orientation == ActivityInfo.SCREEN_ORIENTATION_USER || orientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)) || orientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)) || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR Loading @@ -2973,6 +2970,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { } else { } else { preferredRotation = lastRotation; preferredRotation = lastRotation; } } } else if (mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED) { // Apply rotation lock. preferredRotation = mUserRotation; } } // TODO: Sometimes, we might want to override the application-requested // TODO: Sometimes, we might want to override the application-requested Loading Loading @@ -3018,8 +3018,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { return mPortraitRotation; return mPortraitRotation; default: default: // For USER, UNSPECIFIED and NOSENSOR, just return the preferred // For USER, UNSPECIFIED, NOSENSOR, SENSOR and FULL_SENSOR, // orientation we already calculated. // just return the preferred orientation we already calculated. if (preferredRotation >= 0) { if (preferredRotation >= 0) { return preferredRotation; return preferredRotation; } } Loading services/java/com/android/server/wm/WindowManagerService.java +9 −2 Original line number Original line Diff line number Diff line Loading @@ -5050,16 +5050,23 @@ public class WindowManagerService extends IWindowManager.Stub /** /** * Freeze rotation changes. (Enable "rotation lock".) * Freeze rotation changes. (Enable "rotation lock".) * Persists across reboots. * Persists across reboots. * @param rotation The desired rotation to freeze to, or -1 to use the * current rotation. */ */ public void freezeRotation() { public void freezeRotation(int rotation) { if (!checkCallingPermission(android.Manifest.permission.SET_ORIENTATION, if (!checkCallingPermission(android.Manifest.permission.SET_ORIENTATION, "freezeRotation()")) { "freezeRotation()")) { throw new SecurityException("Requires SET_ORIENTATION permission"); throw new SecurityException("Requires SET_ORIENTATION permission"); } } if (rotation < -1 || rotation > Surface.ROTATION_270) { throw new IllegalArgumentException("Rotation argument must be -1 or a valid " + "rotation constant."); } if (DEBUG_ORIENTATION) Slog.v(TAG, "freezeRotation: mRotation=" + mRotation); if (DEBUG_ORIENTATION) Slog.v(TAG, "freezeRotation: mRotation=" + mRotation); mPolicy.setUserRotationMode(WindowManagerPolicy.USER_ROTATION_LOCKED, mRotation); mPolicy.setUserRotationMode(WindowManagerPolicy.USER_ROTATION_LOCKED, rotation == -1 ? mRotation : rotation); updateRotationUnchecked(false); updateRotationUnchecked(false); } } Loading Loading
core/java/android/view/IWindowManager.aidl +4 −3 Original line number Original line Diff line number Diff line Loading @@ -192,11 +192,12 @@ interface IWindowManager int getPreferredOptionsPanelGravity(); int getPreferredOptionsPanelGravity(); /** /** * Lock the device orientation to the current rotation. Sensor input will * Lock the device orientation to the specified rotation, or to the * be ignored until thawRotation() is called. * current rotation if -1. Sensor input will be ignored until * thawRotation() is called. * @hide * @hide */ */ void freezeRotation(); void freezeRotation(int rotation); /** /** * Release the orientation lock imposed by freezeRotation(). * Release the orientation lock imposed by freezeRotation(). Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/AutoRotateController.java +3 −2 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.os.AsyncTask; import android.os.RemoteException; import android.os.RemoteException; import android.os.ServiceManager; import android.os.ServiceManager; import android.provider.Settings; import android.provider.Settings; import android.util.Log; import android.util.Slog; import android.util.Slog; import android.view.IWindowManager; import android.view.IWindowManager; import android.widget.CompoundButton; import android.widget.CompoundButton; Loading Loading @@ -63,13 +64,13 @@ public class AutoRotateController implements CompoundButton.OnCheckedChangeListe try { try { IWindowManager wm = IWindowManager.Stub.asInterface( IWindowManager wm = IWindowManager.Stub.asInterface( ServiceManager.getService(Context.WINDOW_SERVICE)); ServiceManager.getService(Context.WINDOW_SERVICE)); ContentResolver cr = mContext.getContentResolver(); if (autorotate) { if (autorotate) { wm.thawRotation(); wm.thawRotation(); } else { } else { wm.freezeRotation(); wm.freezeRotation(-1); } } } catch (RemoteException exc) { } catch (RemoteException exc) { Log.w(TAG, "Unable to save auto-rotate setting"); } } } } }); }); Loading
policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +6 −6 Original line number Original line Diff line number Diff line Loading @@ -2947,10 +2947,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { // enable 180 degree rotation while docked. // enable 180 degree rotation while docked. preferredRotation = mDeskDockEnablesAccelerometer preferredRotation = mDeskDockEnablesAccelerometer ? sensorRotation : mDeskDockRotation; ? sensorRotation : mDeskDockRotation; } else if (mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED) { } else if ((mAccelerometerDefault != 0 /* implies not rotation locked */ // Ignore sensor when user locked rotation. preferredRotation = mUserRotation; } else if ((mAccelerometerDefault != 0 && (orientation == ActivityInfo.SCREEN_ORIENTATION_USER && (orientation == ActivityInfo.SCREEN_ORIENTATION_USER || orientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)) || orientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)) || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR Loading @@ -2973,6 +2970,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { } else { } else { preferredRotation = lastRotation; preferredRotation = lastRotation; } } } else if (mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED) { // Apply rotation lock. preferredRotation = mUserRotation; } } // TODO: Sometimes, we might want to override the application-requested // TODO: Sometimes, we might want to override the application-requested Loading Loading @@ -3018,8 +3018,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { return mPortraitRotation; return mPortraitRotation; default: default: // For USER, UNSPECIFIED and NOSENSOR, just return the preferred // For USER, UNSPECIFIED, NOSENSOR, SENSOR and FULL_SENSOR, // orientation we already calculated. // just return the preferred orientation we already calculated. if (preferredRotation >= 0) { if (preferredRotation >= 0) { return preferredRotation; return preferredRotation; } } Loading
services/java/com/android/server/wm/WindowManagerService.java +9 −2 Original line number Original line Diff line number Diff line Loading @@ -5050,16 +5050,23 @@ public class WindowManagerService extends IWindowManager.Stub /** /** * Freeze rotation changes. (Enable "rotation lock".) * Freeze rotation changes. (Enable "rotation lock".) * Persists across reboots. * Persists across reboots. * @param rotation The desired rotation to freeze to, or -1 to use the * current rotation. */ */ public void freezeRotation() { public void freezeRotation(int rotation) { if (!checkCallingPermission(android.Manifest.permission.SET_ORIENTATION, if (!checkCallingPermission(android.Manifest.permission.SET_ORIENTATION, "freezeRotation()")) { "freezeRotation()")) { throw new SecurityException("Requires SET_ORIENTATION permission"); throw new SecurityException("Requires SET_ORIENTATION permission"); } } if (rotation < -1 || rotation > Surface.ROTATION_270) { throw new IllegalArgumentException("Rotation argument must be -1 or a valid " + "rotation constant."); } if (DEBUG_ORIENTATION) Slog.v(TAG, "freezeRotation: mRotation=" + mRotation); if (DEBUG_ORIENTATION) Slog.v(TAG, "freezeRotation: mRotation=" + mRotation); mPolicy.setUserRotationMode(WindowManagerPolicy.USER_ROTATION_LOCKED, mRotation); mPolicy.setUserRotationMode(WindowManagerPolicy.USER_ROTATION_LOCKED, rotation == -1 ? mRotation : rotation); updateRotationUnchecked(false); updateRotationUnchecked(false); } } Loading