Loading core/java/com/android/internal/view/RotationPolicy.java +4 −2 Original line number Original line Diff line number Diff line Loading @@ -21,7 +21,6 @@ import android.content.pm.PackageManager; import android.database.ContentObserver; import android.database.ContentObserver; import android.net.Uri; import android.net.Uri; import android.os.AsyncTask; import android.os.AsyncTask; import android.os.Build; import android.os.Handler; import android.os.Handler; import android.os.RemoteException; import android.os.RemoteException; import android.os.UserHandle; import android.os.UserHandle; Loading Loading @@ -52,7 +51,9 @@ public final class RotationPolicy { PackageManager pm = context.getPackageManager(); PackageManager pm = context.getPackageManager(); return pm.hasSystemFeature(PackageManager.FEATURE_SENSOR_ACCELEROMETER) return pm.hasSystemFeature(PackageManager.FEATURE_SENSOR_ACCELEROMETER) && pm.hasSystemFeature(PackageManager.FEATURE_SCREEN_PORTRAIT) && pm.hasSystemFeature(PackageManager.FEATURE_SCREEN_PORTRAIT) && pm.hasSystemFeature(PackageManager.FEATURE_SCREEN_LANDSCAPE); && pm.hasSystemFeature(PackageManager.FEATURE_SCREEN_LANDSCAPE) && context.getResources().getBoolean( com.android.internal.R.bool.config_supportAutoRotation); } } /** /** Loading Loading @@ -176,6 +177,7 @@ public final class RotationPolicy { */ */ public static abstract class RotationPolicyListener { public static abstract class RotationPolicyListener { final ContentObserver mObserver = new ContentObserver(new Handler()) { final ContentObserver mObserver = new ContentObserver(new Handler()) { @Override public void onChange(boolean selfChange, Uri uri) { public void onChange(boolean selfChange, Uri uri) { RotationPolicyListener.this.onChange(); RotationPolicyListener.this.onChange(); } } Loading core/res/res/values/config.xml +9 −0 Original line number Original line Diff line number Diff line Loading @@ -372,6 +372,15 @@ <!-- Auto-rotation behavior --> <!-- Auto-rotation behavior --> <!-- If true, enables auto-rotation features using the accelerometer. Otherwise, auto-rotation is disabled. Applications may still request to use specific orientations but the sensor is ignored and sensor-based orientations are not available. Furthermore, all auto-rotation related settings are omitted from the system UI. In certain situations we may still use the accelerometer to determine the orientation, such as when docked if the dock is configured to enable the accelerometer. --> <bool name="config_supportAutoRotation">true</bool> <!-- If true, the screen can be rotated via the accelerometer in all 4 <!-- If true, the screen can be rotated via the accelerometer in all 4 rotations as the default behavior. --> rotations as the default behavior. --> <bool name="config_allowAllRotations">false</bool> <bool name="config_allowAllRotations">false</bool> Loading core/res/res/values/symbols.xml +1 −0 Original line number Original line Diff line number Diff line Loading @@ -1306,6 +1306,7 @@ <java-symbol type="bool" name="config_lidControlsSleep" /> <java-symbol type="bool" name="config_lidControlsSleep" /> <java-symbol type="bool" name="config_reverseDefaultRotation" /> <java-symbol type="bool" name="config_reverseDefaultRotation" /> <java-symbol type="bool" name="config_showNavigationBar" /> <java-symbol type="bool" name="config_showNavigationBar" /> <java-symbol type="bool" name="config_supportAutoRotation" /> <java-symbol type="bool" name="target_honeycomb_needs_options_menu" /> <java-symbol type="bool" name="target_honeycomb_needs_options_menu" /> <java-symbol type="dimen" name="navigation_bar_height" /> <java-symbol type="dimen" name="navigation_bar_height" /> <java-symbol type="dimen" name="navigation_bar_height_landscape" /> <java-symbol type="dimen" name="navigation_bar_height_landscape" /> Loading policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +18 −8 Original line number Original line Diff line number Diff line Loading @@ -283,6 +283,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { int mUserRotation = Surface.ROTATION_0; int mUserRotation = Surface.ROTATION_0; boolean mAccelerometerDefault; boolean mAccelerometerDefault; boolean mSupportAutoRotation; int mAllowAllRotations = -1; int mAllowAllRotations = -1; boolean mCarDockEnablesAccelerometer; boolean mCarDockEnablesAccelerometer; boolean mDeskDockEnablesAccelerometer; boolean mDeskDockEnablesAccelerometer; Loading Loading @@ -591,14 +592,16 @@ public class PhoneWindowManager implements WindowManagerPolicy { * screen is switched off. * screen is switched off. */ */ boolean needSensorRunningLp() { boolean needSensorRunningLp() { if (mSupportAutoRotation) { if (mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR if (mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE) { || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE) { // If the application has explicitly requested to follow the // If the application has explicitly requested to follow the // orientation, then we need to turn the sensor or. // orientation, then we need to turn the sensor on. return true; return true; } } } if ((mCarDockEnablesAccelerometer && mDockMode == Intent.EXTRA_DOCK_STATE_CAR) || if ((mCarDockEnablesAccelerometer && mDockMode == Intent.EXTRA_DOCK_STATE_CAR) || (mDeskDockEnablesAccelerometer && (mDockMode == Intent.EXTRA_DOCK_STATE_DESK (mDeskDockEnablesAccelerometer && (mDockMode == Intent.EXTRA_DOCK_STATE_DESK || mDockMode == Intent.EXTRA_DOCK_STATE_LE_DESK || mDockMode == Intent.EXTRA_DOCK_STATE_LE_DESK Loading @@ -618,7 +621,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { // still be turned off when the screen is off.) // still be turned off when the screen is off.) return false; return false; } } return true; return mSupportAutoRotation; } } /* /* Loading Loading @@ -883,6 +886,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { mBroadcastWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, mBroadcastWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "PhoneWindowManager.mBroadcastWakeLock"); "PhoneWindowManager.mBroadcastWakeLock"); mEnableShiftMenuBugReports = "1".equals(SystemProperties.get("ro.debuggable")); mEnableShiftMenuBugReports = "1".equals(SystemProperties.get("ro.debuggable")); mSupportAutoRotation = mContext.getResources().getBoolean( com.android.internal.R.bool.config_supportAutoRotation); mLidOpenRotation = readRotation( mLidOpenRotation = readRotation( com.android.internal.R.integer.config_lidOpenRotation); com.android.internal.R.integer.config_lidOpenRotation); mCarDockRotation = readRotation( mCarDockRotation = readRotation( Loading Loading @@ -4485,6 +4490,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { } else if (orientation == ActivityInfo.SCREEN_ORIENTATION_LOCKED) { } else if (orientation == ActivityInfo.SCREEN_ORIENTATION_LOCKED) { // Application just wants to remain locked in the last rotation. // Application just wants to remain locked in the last rotation. preferredRotation = lastRotation; preferredRotation = lastRotation; } else if (!mSupportAutoRotation) { // If we don't support auto-rotation then bail out here and ignore // the sensor and any rotation lock settings. preferredRotation = -1; } else if ((mUserRotationMode == WindowManagerPolicy.USER_ROTATION_FREE } else if ((mUserRotationMode == WindowManagerPolicy.USER_ROTATION_FREE && (orientation == ActivityInfo.SCREEN_ORIENTATION_USER && (orientation == ActivityInfo.SCREEN_ORIENTATION_USER || orientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED || orientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED Loading Loading @@ -5294,6 +5303,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { pw.print(prefix); pw.print("mLastFocusNeedsMenu="); pw.print(prefix); pw.print("mLastFocusNeedsMenu="); pw.println(mLastFocusNeedsMenu); pw.println(mLastFocusNeedsMenu); } } pw.print(prefix); pw.print("mSupportAutoRotation="); pw.println(mSupportAutoRotation); pw.print(prefix); pw.print("mUiMode="); pw.print(mUiMode); pw.print(prefix); pw.print("mUiMode="); pw.print(mUiMode); pw.print(" mDockMode="); pw.print(mDockMode); pw.print(" mDockMode="); pw.print(mDockMode); pw.print(" mCarDockRotation="); pw.print(mCarDockRotation); pw.print(" mCarDockRotation="); pw.print(mCarDockRotation); Loading Loading
core/java/com/android/internal/view/RotationPolicy.java +4 −2 Original line number Original line Diff line number Diff line Loading @@ -21,7 +21,6 @@ import android.content.pm.PackageManager; import android.database.ContentObserver; import android.database.ContentObserver; import android.net.Uri; import android.net.Uri; import android.os.AsyncTask; import android.os.AsyncTask; import android.os.Build; import android.os.Handler; import android.os.Handler; import android.os.RemoteException; import android.os.RemoteException; import android.os.UserHandle; import android.os.UserHandle; Loading Loading @@ -52,7 +51,9 @@ public final class RotationPolicy { PackageManager pm = context.getPackageManager(); PackageManager pm = context.getPackageManager(); return pm.hasSystemFeature(PackageManager.FEATURE_SENSOR_ACCELEROMETER) return pm.hasSystemFeature(PackageManager.FEATURE_SENSOR_ACCELEROMETER) && pm.hasSystemFeature(PackageManager.FEATURE_SCREEN_PORTRAIT) && pm.hasSystemFeature(PackageManager.FEATURE_SCREEN_PORTRAIT) && pm.hasSystemFeature(PackageManager.FEATURE_SCREEN_LANDSCAPE); && pm.hasSystemFeature(PackageManager.FEATURE_SCREEN_LANDSCAPE) && context.getResources().getBoolean( com.android.internal.R.bool.config_supportAutoRotation); } } /** /** Loading Loading @@ -176,6 +177,7 @@ public final class RotationPolicy { */ */ public static abstract class RotationPolicyListener { public static abstract class RotationPolicyListener { final ContentObserver mObserver = new ContentObserver(new Handler()) { final ContentObserver mObserver = new ContentObserver(new Handler()) { @Override public void onChange(boolean selfChange, Uri uri) { public void onChange(boolean selfChange, Uri uri) { RotationPolicyListener.this.onChange(); RotationPolicyListener.this.onChange(); } } Loading
core/res/res/values/config.xml +9 −0 Original line number Original line Diff line number Diff line Loading @@ -372,6 +372,15 @@ <!-- Auto-rotation behavior --> <!-- Auto-rotation behavior --> <!-- If true, enables auto-rotation features using the accelerometer. Otherwise, auto-rotation is disabled. Applications may still request to use specific orientations but the sensor is ignored and sensor-based orientations are not available. Furthermore, all auto-rotation related settings are omitted from the system UI. In certain situations we may still use the accelerometer to determine the orientation, such as when docked if the dock is configured to enable the accelerometer. --> <bool name="config_supportAutoRotation">true</bool> <!-- If true, the screen can be rotated via the accelerometer in all 4 <!-- If true, the screen can be rotated via the accelerometer in all 4 rotations as the default behavior. --> rotations as the default behavior. --> <bool name="config_allowAllRotations">false</bool> <bool name="config_allowAllRotations">false</bool> Loading
core/res/res/values/symbols.xml +1 −0 Original line number Original line Diff line number Diff line Loading @@ -1306,6 +1306,7 @@ <java-symbol type="bool" name="config_lidControlsSleep" /> <java-symbol type="bool" name="config_lidControlsSleep" /> <java-symbol type="bool" name="config_reverseDefaultRotation" /> <java-symbol type="bool" name="config_reverseDefaultRotation" /> <java-symbol type="bool" name="config_showNavigationBar" /> <java-symbol type="bool" name="config_showNavigationBar" /> <java-symbol type="bool" name="config_supportAutoRotation" /> <java-symbol type="bool" name="target_honeycomb_needs_options_menu" /> <java-symbol type="bool" name="target_honeycomb_needs_options_menu" /> <java-symbol type="dimen" name="navigation_bar_height" /> <java-symbol type="dimen" name="navigation_bar_height" /> <java-symbol type="dimen" name="navigation_bar_height_landscape" /> <java-symbol type="dimen" name="navigation_bar_height_landscape" /> Loading
policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +18 −8 Original line number Original line Diff line number Diff line Loading @@ -283,6 +283,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { int mUserRotation = Surface.ROTATION_0; int mUserRotation = Surface.ROTATION_0; boolean mAccelerometerDefault; boolean mAccelerometerDefault; boolean mSupportAutoRotation; int mAllowAllRotations = -1; int mAllowAllRotations = -1; boolean mCarDockEnablesAccelerometer; boolean mCarDockEnablesAccelerometer; boolean mDeskDockEnablesAccelerometer; boolean mDeskDockEnablesAccelerometer; Loading Loading @@ -591,14 +592,16 @@ public class PhoneWindowManager implements WindowManagerPolicy { * screen is switched off. * screen is switched off. */ */ boolean needSensorRunningLp() { boolean needSensorRunningLp() { if (mSupportAutoRotation) { if (mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR if (mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE) { || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE) { // If the application has explicitly requested to follow the // If the application has explicitly requested to follow the // orientation, then we need to turn the sensor or. // orientation, then we need to turn the sensor on. return true; return true; } } } if ((mCarDockEnablesAccelerometer && mDockMode == Intent.EXTRA_DOCK_STATE_CAR) || if ((mCarDockEnablesAccelerometer && mDockMode == Intent.EXTRA_DOCK_STATE_CAR) || (mDeskDockEnablesAccelerometer && (mDockMode == Intent.EXTRA_DOCK_STATE_DESK (mDeskDockEnablesAccelerometer && (mDockMode == Intent.EXTRA_DOCK_STATE_DESK || mDockMode == Intent.EXTRA_DOCK_STATE_LE_DESK || mDockMode == Intent.EXTRA_DOCK_STATE_LE_DESK Loading @@ -618,7 +621,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { // still be turned off when the screen is off.) // still be turned off when the screen is off.) return false; return false; } } return true; return mSupportAutoRotation; } } /* /* Loading Loading @@ -883,6 +886,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { mBroadcastWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, mBroadcastWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "PhoneWindowManager.mBroadcastWakeLock"); "PhoneWindowManager.mBroadcastWakeLock"); mEnableShiftMenuBugReports = "1".equals(SystemProperties.get("ro.debuggable")); mEnableShiftMenuBugReports = "1".equals(SystemProperties.get("ro.debuggable")); mSupportAutoRotation = mContext.getResources().getBoolean( com.android.internal.R.bool.config_supportAutoRotation); mLidOpenRotation = readRotation( mLidOpenRotation = readRotation( com.android.internal.R.integer.config_lidOpenRotation); com.android.internal.R.integer.config_lidOpenRotation); mCarDockRotation = readRotation( mCarDockRotation = readRotation( Loading Loading @@ -4485,6 +4490,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { } else if (orientation == ActivityInfo.SCREEN_ORIENTATION_LOCKED) { } else if (orientation == ActivityInfo.SCREEN_ORIENTATION_LOCKED) { // Application just wants to remain locked in the last rotation. // Application just wants to remain locked in the last rotation. preferredRotation = lastRotation; preferredRotation = lastRotation; } else if (!mSupportAutoRotation) { // If we don't support auto-rotation then bail out here and ignore // the sensor and any rotation lock settings. preferredRotation = -1; } else if ((mUserRotationMode == WindowManagerPolicy.USER_ROTATION_FREE } else if ((mUserRotationMode == WindowManagerPolicy.USER_ROTATION_FREE && (orientation == ActivityInfo.SCREEN_ORIENTATION_USER && (orientation == ActivityInfo.SCREEN_ORIENTATION_USER || orientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED || orientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED Loading Loading @@ -5294,6 +5303,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { pw.print(prefix); pw.print("mLastFocusNeedsMenu="); pw.print(prefix); pw.print("mLastFocusNeedsMenu="); pw.println(mLastFocusNeedsMenu); pw.println(mLastFocusNeedsMenu); } } pw.print(prefix); pw.print("mSupportAutoRotation="); pw.println(mSupportAutoRotation); pw.print(prefix); pw.print("mUiMode="); pw.print(mUiMode); pw.print(prefix); pw.print("mUiMode="); pw.print(mUiMode); pw.print(" mDockMode="); pw.print(mDockMode); pw.print(" mDockMode="); pw.print(mDockMode); pw.print(" mCarDockRotation="); pw.print(mCarDockRotation); pw.print(" mCarDockRotation="); pw.print(mCarDockRotation); Loading