Loading policy/com/android/internal/policy/impl/PhoneWindowManager.java +77 −60 Original line number Diff line number Diff line Loading @@ -87,12 +87,15 @@ import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_TOAST; import android.view.WindowManagerImpl; import android.view.WindowManagerPolicy; import android.view.WindowManagerPolicy.WindowState; import android.media.IAudioService; import android.media.AudioManager; /** * WindowManagerPolicy implementation for the Android phone UI. * WindowManagerPolicy implementation for the Android phone UI. This * introduces a new method suffix, Lp, for an internal lock of the * PhoneWindowManager. This is used to protect some internal state, and * can be acquired with either thw Lw and Li lock held, so has the restrictions * of both of those when held. */ public class PhoneWindowManager implements WindowManagerPolicy { static final String TAG = "WindowManager"; Loading Loading @@ -141,6 +144,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { // Vibrator pattern for haptic feedback of a long press. private static final long[] LONG_PRESS_VIBE_PATTERN = {0, 1, 20, 21}; final Object mLock = new Object(); Context mContext; IWindowManager mWindowManager; LocalPowerManager mPowerManager; Loading Loading @@ -234,13 +239,14 @@ public class PhoneWindowManager implements WindowManagerPolicy { public void update() { ContentResolver resolver = mContext.getContentResolver(); synchronized (mLock) { mEndcallBehavior = Settings.System.getInt(resolver, Settings.System.END_BUTTON_BEHAVIOR, DEFAULT_ENDCALL_BEHAVIOR); int accelerometerDefault = Settings.System.getInt(resolver, Settings.System.ACCELEROMETER_ROTATION, DEFAULT_ACCELEROMETER_ROTATION); if (mAccelerometerDefault != accelerometerDefault) { mAccelerometerDefault = accelerometerDefault; updateOrientationListener(); updateOrientationListenerLp(); } String imId = Settings.Secure.getString(resolver, Settings.Secure.DEFAULT_INPUT_METHOD); Loading @@ -251,6 +257,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } } } class MyOrientationListener extends WindowOrientationListener { private static final int _LOWER_THRESHOLD = 30; Loading Loading @@ -296,7 +303,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { } MyOrientationListener mOrientationListener; boolean useSensorForOrientation() { boolean useSensorForOrientationLp() { if(mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR) { return true; } Loading @@ -308,7 +315,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { return false; } boolean needSensorRunning() { boolean needSensorRunningLp() { if (mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR) { // If the application has explicitly requested to follow the // orientation, then we need to turn the sensor or. Loading Loading @@ -338,7 +345,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { * screen turning on and current app has sensor based orientation, enable listeners if needed * screen turning on and current app has nosensor based orientation, do nothing */ void updateOrientationListener() { void updateOrientationListenerLp() { if (!mOrientationListener.canDetectOrientation()) { // If sensor is turned off or nonexistent for some reason return; Loading @@ -350,7 +357,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { ", SensorEnabled="+mOrientationSensorEnabled); boolean disable = true; if (mScreenOn) { if(needSensorRunning()) { if (needSensorRunningLp()) { disable = false; //enable listener if not already enabled if (!mOrientationSensorEnabled) { Loading @@ -375,7 +382,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { Runnable mEndCallLongPress = new Runnable() { public void run() { mShouldTurnOffOnKeyUp = false; performHapticFeedback(null, HapticFeedbackConstants.LONG_PRESS, false); performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS); showGlobalActionsDialog(); } Loading Loading @@ -409,7 +416,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { * the user lets go of the home key */ mHomePressed = false; performHapticFeedback(null, HapticFeedbackConstants.LONG_PRESS, false); performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); sendCloseSystemWindows(SYSTEM_DIALOG_REASON_RECENT_APPS); showRecentAppsDialog(); } Loading Loading @@ -1615,18 +1622,22 @@ public class PhoneWindowManager implements WindowManagerPolicy { /** {@inheritDoc} */ public void screenTurnedOff(int why) { synchronized (mLock) { EventLog.writeEvent(70000, 0); mKeyguardMediator.onScreenTurnedOff(why); mScreenOn = false; updateOrientationListener(); updateOrientationListenerLp(); } } /** {@inheritDoc} */ public void screenTurnedOn() { synchronized (mLock) { EventLog.writeEvent(70000, 1); mKeyguardMediator.onScreenTurnedOn(); mScreenOn = true; updateOrientationListener(); updateOrientationListenerLp(); } } /** {@inheritDoc} */ Loading Loading @@ -1674,8 +1685,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } public int rotationForOrientation(int orientation, int lastRotation, public int rotationForOrientationLw(int orientation, int lastRotation, boolean displayEnabled) { synchronized (mLock) { switch (orientation) { case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE: //always return landscape if orientation set to landscape Loading @@ -1690,13 +1702,14 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (mLidOpen) { return Surface.ROTATION_90; } else { if (useSensorForOrientation()) { if (useSensorForOrientationLp()) { // If the user has enabled auto rotation by default, do it. return mSensorRotation >= 0 ? mSensorRotation : lastRotation; } return Surface.ROTATION_0; } } } public boolean detectSafeMode() { try { Loading @@ -1721,8 +1734,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { // tell the keyguard mKeyguardMediator.onSystemReady(); android.os.SystemProperties.set("dev.bootcomplete", "1"); updateOrientationListener(); synchronized (mLock) { updateOrientationListenerLp(); mVibrator = new Vibrator(); } } catch (RemoteException e) { // Ignore } Loading Loading @@ -1778,14 +1793,16 @@ public class PhoneWindowManager implements WindowManagerPolicy { return true; } public void setCurrentOrientation(int newOrientation) { public void setCurrentOrientationLw(int newOrientation) { synchronized (mLock) { if (newOrientation != mCurrentAppOrientation) { mCurrentAppOrientation = newOrientation; updateOrientationListener(); updateOrientationListenerLp(); } } } public boolean performHapticFeedback(WindowState win, int effectId, boolean always) { public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always) { if (!always && Settings.System.getInt(mContext.getContentResolver(), Settings.System.HAPTIC_FEEDBACK_ENABLED, 0) == 0) { return false; Loading @@ -1798,7 +1815,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { return false; } public void screenOnStopped() { public void screenOnStoppedLw() { if (!mKeyguardMediator.isShowing()) { long curTime = SystemClock.uptimeMillis(); mPowerManager.userActivity(curTime, false, LocalPowerManager.OTHER_EVENT); Loading Loading
policy/com/android/internal/policy/impl/PhoneWindowManager.java +77 −60 Original line number Diff line number Diff line Loading @@ -87,12 +87,15 @@ import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_TOAST; import android.view.WindowManagerImpl; import android.view.WindowManagerPolicy; import android.view.WindowManagerPolicy.WindowState; import android.media.IAudioService; import android.media.AudioManager; /** * WindowManagerPolicy implementation for the Android phone UI. * WindowManagerPolicy implementation for the Android phone UI. This * introduces a new method suffix, Lp, for an internal lock of the * PhoneWindowManager. This is used to protect some internal state, and * can be acquired with either thw Lw and Li lock held, so has the restrictions * of both of those when held. */ public class PhoneWindowManager implements WindowManagerPolicy { static final String TAG = "WindowManager"; Loading Loading @@ -141,6 +144,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { // Vibrator pattern for haptic feedback of a long press. private static final long[] LONG_PRESS_VIBE_PATTERN = {0, 1, 20, 21}; final Object mLock = new Object(); Context mContext; IWindowManager mWindowManager; LocalPowerManager mPowerManager; Loading Loading @@ -234,13 +239,14 @@ public class PhoneWindowManager implements WindowManagerPolicy { public void update() { ContentResolver resolver = mContext.getContentResolver(); synchronized (mLock) { mEndcallBehavior = Settings.System.getInt(resolver, Settings.System.END_BUTTON_BEHAVIOR, DEFAULT_ENDCALL_BEHAVIOR); int accelerometerDefault = Settings.System.getInt(resolver, Settings.System.ACCELEROMETER_ROTATION, DEFAULT_ACCELEROMETER_ROTATION); if (mAccelerometerDefault != accelerometerDefault) { mAccelerometerDefault = accelerometerDefault; updateOrientationListener(); updateOrientationListenerLp(); } String imId = Settings.Secure.getString(resolver, Settings.Secure.DEFAULT_INPUT_METHOD); Loading @@ -251,6 +257,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } } } class MyOrientationListener extends WindowOrientationListener { private static final int _LOWER_THRESHOLD = 30; Loading Loading @@ -296,7 +303,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { } MyOrientationListener mOrientationListener; boolean useSensorForOrientation() { boolean useSensorForOrientationLp() { if(mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR) { return true; } Loading @@ -308,7 +315,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { return false; } boolean needSensorRunning() { boolean needSensorRunningLp() { if (mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR) { // If the application has explicitly requested to follow the // orientation, then we need to turn the sensor or. Loading Loading @@ -338,7 +345,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { * screen turning on and current app has sensor based orientation, enable listeners if needed * screen turning on and current app has nosensor based orientation, do nothing */ void updateOrientationListener() { void updateOrientationListenerLp() { if (!mOrientationListener.canDetectOrientation()) { // If sensor is turned off or nonexistent for some reason return; Loading @@ -350,7 +357,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { ", SensorEnabled="+mOrientationSensorEnabled); boolean disable = true; if (mScreenOn) { if(needSensorRunning()) { if (needSensorRunningLp()) { disable = false; //enable listener if not already enabled if (!mOrientationSensorEnabled) { Loading @@ -375,7 +382,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { Runnable mEndCallLongPress = new Runnable() { public void run() { mShouldTurnOffOnKeyUp = false; performHapticFeedback(null, HapticFeedbackConstants.LONG_PRESS, false); performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS); showGlobalActionsDialog(); } Loading Loading @@ -409,7 +416,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { * the user lets go of the home key */ mHomePressed = false; performHapticFeedback(null, HapticFeedbackConstants.LONG_PRESS, false); performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); sendCloseSystemWindows(SYSTEM_DIALOG_REASON_RECENT_APPS); showRecentAppsDialog(); } Loading Loading @@ -1615,18 +1622,22 @@ public class PhoneWindowManager implements WindowManagerPolicy { /** {@inheritDoc} */ public void screenTurnedOff(int why) { synchronized (mLock) { EventLog.writeEvent(70000, 0); mKeyguardMediator.onScreenTurnedOff(why); mScreenOn = false; updateOrientationListener(); updateOrientationListenerLp(); } } /** {@inheritDoc} */ public void screenTurnedOn() { synchronized (mLock) { EventLog.writeEvent(70000, 1); mKeyguardMediator.onScreenTurnedOn(); mScreenOn = true; updateOrientationListener(); updateOrientationListenerLp(); } } /** {@inheritDoc} */ Loading Loading @@ -1674,8 +1685,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } public int rotationForOrientation(int orientation, int lastRotation, public int rotationForOrientationLw(int orientation, int lastRotation, boolean displayEnabled) { synchronized (mLock) { switch (orientation) { case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE: //always return landscape if orientation set to landscape Loading @@ -1690,13 +1702,14 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (mLidOpen) { return Surface.ROTATION_90; } else { if (useSensorForOrientation()) { if (useSensorForOrientationLp()) { // If the user has enabled auto rotation by default, do it. return mSensorRotation >= 0 ? mSensorRotation : lastRotation; } return Surface.ROTATION_0; } } } public boolean detectSafeMode() { try { Loading @@ -1721,8 +1734,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { // tell the keyguard mKeyguardMediator.onSystemReady(); android.os.SystemProperties.set("dev.bootcomplete", "1"); updateOrientationListener(); synchronized (mLock) { updateOrientationListenerLp(); mVibrator = new Vibrator(); } } catch (RemoteException e) { // Ignore } Loading Loading @@ -1778,14 +1793,16 @@ public class PhoneWindowManager implements WindowManagerPolicy { return true; } public void setCurrentOrientation(int newOrientation) { public void setCurrentOrientationLw(int newOrientation) { synchronized (mLock) { if (newOrientation != mCurrentAppOrientation) { mCurrentAppOrientation = newOrientation; updateOrientationListener(); updateOrientationListenerLp(); } } } public boolean performHapticFeedback(WindowState win, int effectId, boolean always) { public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always) { if (!always && Settings.System.getInt(mContext.getContentResolver(), Settings.System.HAPTIC_FEEDBACK_ENABLED, 0) == 0) { return false; Loading @@ -1798,7 +1815,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { return false; } public void screenOnStopped() { public void screenOnStoppedLw() { if (!mKeyguardMediator.isShowing()) { long curTime = SystemClock.uptimeMillis(); mPowerManager.userActivity(curTime, false, LocalPowerManager.OTHER_EVENT); Loading