Loading core/java/com/android/internal/view/RotationPolicy.java +41 −6 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.net.Uri; import android.os.AsyncTask; import android.os.Handler; import android.os.RemoteException; import android.os.SystemProperties; import android.os.UserHandle; import android.provider.Settings; import android.util.Log; Loading @@ -41,7 +42,8 @@ import com.android.internal.R; public final class RotationPolicy { private static final String TAG = "RotationPolicy"; private static final int CURRENT_ROTATION = -1; private static final int NATURAL_ROTATION = Surface.ROTATION_0; private static final int NATURAL_ROTATION = SystemProperties.getInt("ro.sf.hwrotation", Surface.ROTATION_0) / 90; private RotationPolicy() { } Loading Loading @@ -72,7 +74,7 @@ public final class RotationPolicy { * otherwise Configuration.ORIENTATION_UNDEFINED if any orientation is lockable. */ public static int getRotationLockOrientation(Context context) { if (!areAllRotationsAllowed(context)) { if (!isCurrentRotationAllowed(context)) { final Point size = new Point(); final IWindowManager wm = WindowManagerGlobal.getWindowManagerService(); try { Loading Loading @@ -112,7 +114,8 @@ public final class RotationPolicy { Settings.System.HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY, 0, UserHandle.USER_CURRENT); final int rotation = areAllRotationsAllowed(context) ? CURRENT_ROTATION : NATURAL_ROTATION; final int rotation = isCurrentRotationAllowed(context) ? CURRENT_ROTATION : NATURAL_ROTATION; setRotationLock(enabled, rotation); } Loading @@ -129,8 +132,40 @@ public final class RotationPolicy { setRotationLock(enabled, NATURAL_ROTATION); } private static boolean areAllRotationsAllowed(Context context) { return context.getResources().getBoolean(R.bool.config_allowAllRotations); public static boolean isRotationAllowed(int rotation, int userRotationAngles, boolean allowAllRotations) { if (userRotationAngles < 0) { // Not set by user so use these defaults userRotationAngles = allowAllRotations ? (1 | 2 | 4 | 8) : // All angles (1 | 2 | 8); // All except 180 } switch (rotation) { case Surface.ROTATION_0: return (userRotationAngles & 1) != 0; case Surface.ROTATION_90: return (userRotationAngles & 2) != 0; case Surface.ROTATION_180: return (userRotationAngles & 4) != 0; case Surface.ROTATION_270: return (userRotationAngles & 8) != 0; } return false; } private static boolean isCurrentRotationAllowed(Context context) { int userRotationAngles = Settings.System.getInt(context.getContentResolver(), "accelerometer_rotation_angles", -1); boolean allowAllRotations = context.getResources().getBoolean( com.android.internal.R.bool.config_allowAllRotations); final IWindowManager wm = WindowManagerGlobal.getWindowManagerService(); try { return isRotationAllowed(wm.getDefaultDisplayRotation(), userRotationAngles, allowAllRotations); } catch (RemoteException exc) { Log.w(TAG, "Unable to getWindowManagerService.getDefaultDisplayRotation()"); } return false; } private static void setRotationLock(final boolean enabled, final int rotation) { Loading core/tests/overlaytests/testrunner.py +1 −1 Original line number Diff line number Diff line Loading @@ -371,7 +371,7 @@ class RootTask: return "" def execute(self): (returncode, stdout, stderr) = _adb_shell('getprop service.adb.root 0') (returncode, stdout, stderr) = _adb_shell('getprop lineage.service.adb.root 0') if returncode != 0: return returncode, stdout, stderr if stdout.strip() == '1': # already root Loading services/core/java/com/android/server/policy/PhoneWindowManager.java +5 −21 Original line number Diff line number Diff line Loading @@ -249,6 +249,7 @@ import com.android.internal.policy.IShortcutService; import com.android.internal.policy.PhoneWindow; import com.android.internal.statusbar.IStatusBarService; import com.android.internal.util.ScreenShapeHelper; import com.android.internal.view.RotationPolicy; import com.android.internal.widget.PointerLocationView; import com.android.server.GestureLauncherService; import com.android.server.LocalServices; Loading Loading @@ -7920,28 +7921,11 @@ public class PhoneWindowManager implements WindowManagerPolicy { mAllowAllRotations = mContext.getResources().getBoolean( com.android.internal.R.bool.config_allowAllRotations) ? 1 : 0; } // Rotation setting bitmask // 1=0 2=90 4=180 8=270 boolean allowed = true; if (mUserRotationAngles < 0) { // Not set by user so use these defaults mUserRotationAngles = mAllowAllRotations == 1 ? (1 | 2 | 4 | 8) : // All angles (1 | 2 | 8); // All except 180 } switch (sensorRotation) { case Surface.ROTATION_0: allowed = (mUserRotationAngles & 1) != 0; break; case Surface.ROTATION_90: allowed = (mUserRotationAngles & 2) != 0; break; case Surface.ROTATION_180: allowed = (mUserRotationAngles & 4) != 0; break; case Surface.ROTATION_270: allowed = (mUserRotationAngles & 8) != 0; break; if (orientation != ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR && orientation != ActivityInfo.SCREEN_ORIENTATION_FULL_USER) { allowed = RotationPolicy.isRotationAllowed(sensorRotation, mUserRotationAngles, mAllowAllRotations != 0); } if (allowed) { preferredRotation = sensorRotation; Loading Loading
core/java/com/android/internal/view/RotationPolicy.java +41 −6 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.net.Uri; import android.os.AsyncTask; import android.os.Handler; import android.os.RemoteException; import android.os.SystemProperties; import android.os.UserHandle; import android.provider.Settings; import android.util.Log; Loading @@ -41,7 +42,8 @@ import com.android.internal.R; public final class RotationPolicy { private static final String TAG = "RotationPolicy"; private static final int CURRENT_ROTATION = -1; private static final int NATURAL_ROTATION = Surface.ROTATION_0; private static final int NATURAL_ROTATION = SystemProperties.getInt("ro.sf.hwrotation", Surface.ROTATION_0) / 90; private RotationPolicy() { } Loading Loading @@ -72,7 +74,7 @@ public final class RotationPolicy { * otherwise Configuration.ORIENTATION_UNDEFINED if any orientation is lockable. */ public static int getRotationLockOrientation(Context context) { if (!areAllRotationsAllowed(context)) { if (!isCurrentRotationAllowed(context)) { final Point size = new Point(); final IWindowManager wm = WindowManagerGlobal.getWindowManagerService(); try { Loading Loading @@ -112,7 +114,8 @@ public final class RotationPolicy { Settings.System.HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY, 0, UserHandle.USER_CURRENT); final int rotation = areAllRotationsAllowed(context) ? CURRENT_ROTATION : NATURAL_ROTATION; final int rotation = isCurrentRotationAllowed(context) ? CURRENT_ROTATION : NATURAL_ROTATION; setRotationLock(enabled, rotation); } Loading @@ -129,8 +132,40 @@ public final class RotationPolicy { setRotationLock(enabled, NATURAL_ROTATION); } private static boolean areAllRotationsAllowed(Context context) { return context.getResources().getBoolean(R.bool.config_allowAllRotations); public static boolean isRotationAllowed(int rotation, int userRotationAngles, boolean allowAllRotations) { if (userRotationAngles < 0) { // Not set by user so use these defaults userRotationAngles = allowAllRotations ? (1 | 2 | 4 | 8) : // All angles (1 | 2 | 8); // All except 180 } switch (rotation) { case Surface.ROTATION_0: return (userRotationAngles & 1) != 0; case Surface.ROTATION_90: return (userRotationAngles & 2) != 0; case Surface.ROTATION_180: return (userRotationAngles & 4) != 0; case Surface.ROTATION_270: return (userRotationAngles & 8) != 0; } return false; } private static boolean isCurrentRotationAllowed(Context context) { int userRotationAngles = Settings.System.getInt(context.getContentResolver(), "accelerometer_rotation_angles", -1); boolean allowAllRotations = context.getResources().getBoolean( com.android.internal.R.bool.config_allowAllRotations); final IWindowManager wm = WindowManagerGlobal.getWindowManagerService(); try { return isRotationAllowed(wm.getDefaultDisplayRotation(), userRotationAngles, allowAllRotations); } catch (RemoteException exc) { Log.w(TAG, "Unable to getWindowManagerService.getDefaultDisplayRotation()"); } return false; } private static void setRotationLock(final boolean enabled, final int rotation) { Loading
core/tests/overlaytests/testrunner.py +1 −1 Original line number Diff line number Diff line Loading @@ -371,7 +371,7 @@ class RootTask: return "" def execute(self): (returncode, stdout, stderr) = _adb_shell('getprop service.adb.root 0') (returncode, stdout, stderr) = _adb_shell('getprop lineage.service.adb.root 0') if returncode != 0: return returncode, stdout, stderr if stdout.strip() == '1': # already root Loading
services/core/java/com/android/server/policy/PhoneWindowManager.java +5 −21 Original line number Diff line number Diff line Loading @@ -249,6 +249,7 @@ import com.android.internal.policy.IShortcutService; import com.android.internal.policy.PhoneWindow; import com.android.internal.statusbar.IStatusBarService; import com.android.internal.util.ScreenShapeHelper; import com.android.internal.view.RotationPolicy; import com.android.internal.widget.PointerLocationView; import com.android.server.GestureLauncherService; import com.android.server.LocalServices; Loading Loading @@ -7920,28 +7921,11 @@ public class PhoneWindowManager implements WindowManagerPolicy { mAllowAllRotations = mContext.getResources().getBoolean( com.android.internal.R.bool.config_allowAllRotations) ? 1 : 0; } // Rotation setting bitmask // 1=0 2=90 4=180 8=270 boolean allowed = true; if (mUserRotationAngles < 0) { // Not set by user so use these defaults mUserRotationAngles = mAllowAllRotations == 1 ? (1 | 2 | 4 | 8) : // All angles (1 | 2 | 8); // All except 180 } switch (sensorRotation) { case Surface.ROTATION_0: allowed = (mUserRotationAngles & 1) != 0; break; case Surface.ROTATION_90: allowed = (mUserRotationAngles & 2) != 0; break; case Surface.ROTATION_180: allowed = (mUserRotationAngles & 4) != 0; break; case Surface.ROTATION_270: allowed = (mUserRotationAngles & 8) != 0; break; if (orientation != ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR && orientation != ActivityInfo.SCREEN_ORIENTATION_FULL_USER) { allowed = RotationPolicy.isRotationAllowed(sensorRotation, mUserRotationAngles, mAllowAllRotations != 0); } if (allowed) { preferredRotation = sensorRotation; Loading