Support for forcing accelerometer based orientation management when docked.
Change-Id: I5436a7191263a0a2a5ca8108da2f7c094c49b88a
Signed-off-by: Mike Lockwood <lockwood@android.com>
diff --git a/policy/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/com/android/internal/policy/impl/PhoneWindowManager.java
index d6f083b..52b6796 100644
--- a/policy/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -183,6 +183,8 @@
int mDeskDockRotation;
boolean mCarDockKeepsScreenOn;
boolean mDeskDockKeepsScreenOn;
+ boolean mCarDockEnablesAccelerometer;
+ boolean mDeskDockEnablesAccelerometer;
int mLidKeyboardAccessibility;
int mLidNavigationAccessibility;
boolean mScreenOn = false;
@@ -317,8 +319,10 @@
if (appOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR) {
return true;
}
- if (mAccelerometerDefault != 0 && (
- appOrientation == ActivityInfo.SCREEN_ORIENTATION_USER ||
+ if ((mAccelerometerDefault != 0 ||
+ (mCarDockEnablesAccelerometer && mDockState == Intent.EXTRA_DOCK_STATE_CAR) ||
+ (mDeskDockEnablesAccelerometer && mDockState == Intent.EXTRA_DOCK_STATE_DESK))
+ && (appOrientation == ActivityInfo.SCREEN_ORIENTATION_USER ||
appOrientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)) {
return true;
}
@@ -336,6 +340,12 @@
// orientation, then we need to turn the sensor or.
return true;
}
+ if ((mCarDockEnablesAccelerometer && mDockState == Intent.EXTRA_DOCK_STATE_CAR) ||
+ (mDeskDockEnablesAccelerometer && mDockState == Intent.EXTRA_DOCK_STATE_DESK)) {
+ // enable accelerometer if we are docked in a dock that enables accelerometer
+ // orientation management,
+ return true;
+ }
if (mAccelerometerDefault == 0) {
// If the setting for using the sensor by default is enabled, then
// we will always leave it on. Note that the user could go to
@@ -477,6 +487,10 @@
com.android.internal.R.bool.config_carDockKeepsScreenOn);
mDeskDockKeepsScreenOn = mContext.getResources().getBoolean(
com.android.internal.R.bool.config_deskDockKeepsScreenOn);
+ mCarDockEnablesAccelerometer = mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_carDockEnablesAccelerometer);
+ mDeskDockEnablesAccelerometer = mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_deskDockEnablesAccelerometer);
mLidKeyboardAccessibility = mContext.getResources().getInteger(
com.android.internal.R.integer.config_lidKeyboardAccessibility);
mLidNavigationAccessibility = mContext.getResources().getInteger(
@@ -1728,6 +1742,7 @@
Intent.EXTRA_DOCK_STATE_UNDOCKED);
updateRotation(Surface.FLAGS_ORIENTATION_ANIMATION_DISABLE);
updateKeepScreenOn();
+ updateOrientationListenerLp();
}
};