diff options
| author | 2014-03-07 10:50:44 +0000 | |
|---|---|---|
| committer | 2014-03-07 10:50:44 +0000 | |
| commit | 2b27ef979dba3808cdae6dce32fe27b59197e34c (patch) | |
| tree | 89b2b08b17cbb9ff70c288c0df16cb7a47204dd1 | |
| parent | 0b93d86bf4ab4a0ff2606af881d8bf4aaa8ce9b2 (diff) | |
| parent | c969450acd4924f0f5478274c345207bf2c57768 (diff) | |
am c969450a: am 840c8474: Merge "Add config_supportAutoRotation." into klp-modular-dev
* commit 'c969450acd4924f0f5478274c345207bf2c57768':
Add config_supportAutoRotation.
| -rw-r--r-- | core/java/com/android/internal/view/RotationPolicy.java | 6 | ||||
| -rw-r--r-- | core/res/res/values/config.xml | 9 | ||||
| -rw-r--r-- | core/res/res/values/symbols.xml | 1 | ||||
| -rw-r--r-- | policy/src/com/android/internal/policy/impl/PhoneWindowManager.java | 26 |
4 files changed, 32 insertions, 10 deletions
diff --git a/core/java/com/android/internal/view/RotationPolicy.java b/core/java/com/android/internal/view/RotationPolicy.java index 70e2bfc6fd11..6295314d201c 100644 --- a/core/java/com/android/internal/view/RotationPolicy.java +++ b/core/java/com/android/internal/view/RotationPolicy.java @@ -21,7 +21,6 @@ import android.content.pm.PackageManager; import android.database.ContentObserver; import android.net.Uri; import android.os.AsyncTask; -import android.os.Build; import android.os.Handler; import android.os.RemoteException; import android.os.UserHandle; @@ -52,7 +51,9 @@ public final class RotationPolicy { PackageManager pm = context.getPackageManager(); return pm.hasSystemFeature(PackageManager.FEATURE_SENSOR_ACCELEROMETER) && 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); } /** @@ -176,6 +177,7 @@ public final class RotationPolicy { */ public static abstract class RotationPolicyListener { final ContentObserver mObserver = new ContentObserver(new Handler()) { + @Override public void onChange(boolean selfChange, Uri uri) { RotationPolicyListener.this.onChange(); } diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 38c43fa16ea7..932f00012a29 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -372,6 +372,15 @@ <!-- 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 rotations as the default behavior. --> <bool name="config_allowAllRotations">false</bool> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index f4798062aaf8..bab2b443c91f 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -1306,6 +1306,7 @@ <java-symbol type="bool" name="config_lidControlsSleep" /> <java-symbol type="bool" name="config_reverseDefaultRotation" /> <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="dimen" name="navigation_bar_height" /> <java-symbol type="dimen" name="navigation_bar_height_landscape" /> diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index 08a0dff727ca..5e90c11c0524 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -283,6 +283,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { int mUserRotation = Surface.ROTATION_0; boolean mAccelerometerDefault; + boolean mSupportAutoRotation; int mAllowAllRotations = -1; boolean mCarDockEnablesAccelerometer; boolean mDeskDockEnablesAccelerometer; @@ -591,13 +592,15 @@ public class PhoneWindowManager implements WindowManagerPolicy { * screen is switched off. */ boolean needSensorRunningLp() { - if (mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR - || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR - || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT - || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE) { - // If the application has explicitly requested to follow the - // orientation, then we need to turn the sensor or. - return true; + if (mSupportAutoRotation) { + if (mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR + || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR + || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT + || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE) { + // If the application has explicitly requested to follow the + // orientation, then we need to turn the sensor on. + return true; + } } if ((mCarDockEnablesAccelerometer && mDockMode == Intent.EXTRA_DOCK_STATE_CAR) || (mDeskDockEnablesAccelerometer && (mDockMode == Intent.EXTRA_DOCK_STATE_DESK @@ -618,7 +621,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { // still be turned off when the screen is off.) return false; } - return true; + return mSupportAutoRotation; } /* @@ -883,6 +886,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { mBroadcastWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "PhoneWindowManager.mBroadcastWakeLock"); mEnableShiftMenuBugReports = "1".equals(SystemProperties.get("ro.debuggable")); + mSupportAutoRotation = mContext.getResources().getBoolean( + com.android.internal.R.bool.config_supportAutoRotation); mLidOpenRotation = readRotation( com.android.internal.R.integer.config_lidOpenRotation); mCarDockRotation = readRotation( @@ -4485,6 +4490,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { } else if (orientation == ActivityInfo.SCREEN_ORIENTATION_LOCKED) { // Application just wants to remain locked in the last rotation. 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 && (orientation == ActivityInfo.SCREEN_ORIENTATION_USER || orientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED @@ -5294,6 +5303,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { pw.print(prefix); pw.print("mLastFocusNeedsMenu="); pw.println(mLastFocusNeedsMenu); } + pw.print(prefix); pw.print("mSupportAutoRotation="); pw.println(mSupportAutoRotation); pw.print(prefix); pw.print("mUiMode="); pw.print(mUiMode); pw.print(" mDockMode="); pw.print(mDockMode); pw.print(" mCarDockRotation="); pw.print(mCarDockRotation); |