diff options
Diffstat (limited to 'com/android/server/policy/PhoneWindowManager.java')
-rw-r--r-- | com/android/server/policy/PhoneWindowManager.java | 147 |
1 files changed, 73 insertions, 74 deletions
diff --git a/com/android/server/policy/PhoneWindowManager.java b/com/android/server/policy/PhoneWindowManager.java index ceb0ad07..db7817ec 100644 --- a/com/android/server/policy/PhoneWindowManager.java +++ b/com/android/server/policy/PhoneWindowManager.java @@ -18,14 +18,13 @@ package com.android.server.policy; import static android.Manifest.permission.INTERNAL_SYSTEM_WINDOW; import static android.Manifest.permission.SYSTEM_ALERT_WINDOW; +import static android.app.ActivityManager.StackId.DOCKED_STACK_ID; +import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID; import static android.app.AppOpsManager.OP_SYSTEM_ALERT_WINDOW; import static android.app.AppOpsManager.OP_TOAST_WINDOW; import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; -import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; -import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; -import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY; import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; import static android.content.Context.CONTEXT_RESTRICTED; import static android.content.Context.DISPLAY_SERVICE; @@ -553,6 +552,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { int mUserRotationMode = WindowManagerPolicy.USER_ROTATION_FREE; int mUserRotation = Surface.ROTATION_0; + boolean mAccelerometerDefault; boolean mSupportAutoRotation; int mAllowAllRotations = -1; @@ -707,6 +707,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { Intent mVrHeadsetHomeIntent; boolean mSearchKeyShortcutPending; boolean mConsumeSearchKeyUp; + boolean mAssistKeyLongPressed; boolean mPendingMetaAction; boolean mPendingCapsLockToggle; int mMetaState; @@ -837,8 +838,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { private static final int MSG_DISPATCH_BACK_KEY_TO_AUTOFILL = 24; private static final int MSG_SYSTEM_KEY_PRESS = 25; private static final int MSG_HANDLE_ALL_APPS = 26; - private static final int MSG_LAUNCH_ASSIST = 27; - private static final int MSG_LAUNCH_ASSIST_LONG_PRESS = 28; private static final int MSG_REQUEST_TRANSIENT_BARS_ARG_STATUS = 0; private static final int MSG_REQUEST_TRANSIENT_BARS_ARG_NAVIGATION = 1; @@ -880,16 +879,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { case MSG_HIDE_BOOT_MESSAGE: handleHideBootMessage(); break; - case MSG_LAUNCH_ASSIST: - final int deviceId = msg.arg1; - final String hint = (String) msg.obj; - launchAssistAction(hint, deviceId); - break; - case MSG_LAUNCH_ASSIST_LONG_PRESS: - launchAssistLongPressAction(); - break; case MSG_LAUNCH_VOICE_ASSIST_WITH_WAKE_LOCK: - launchVoiceAssistWithWakeLock(); + launchVoiceAssistWithWakeLock(msg.arg1 != 0); break; case MSG_POWER_DELAYED_PRESS: powerPress((Long)msg.obj, msg.arg1 != 0, msg.arg2); @@ -919,7 +910,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { disposeInputConsumer((InputConsumer) msg.obj); break; case MSG_BACK_DELAYED_PRESS: - backMultiPressAction(msg.arg1); + backMultiPressAction((Long) msg.obj, msg.arg1); finishBackKeyPress(); break; case MSG_ACCESSIBILITY_SHORTCUT: @@ -1423,7 +1414,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } - private void backMultiPressAction(int count) { + private void backMultiPressAction(long eventTime, int count) { if (count >= PANIC_PRESS_BACK_COUNT) { switch (mPanicPressOnBackBehavior) { case PANIC_PRESS_BACK_NOTHING: @@ -1592,7 +1583,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } - private void sleepPress() { + private void sleepPress(long eventTime) { if (mShortPressOnSleepBehavior == SHORT_PRESS_SLEEP_GO_TO_SLEEP_AND_GO_HOME) { launchHomeFromHotKey(false /* awakenDreams */, true /*respectKeyguard*/); } @@ -2279,11 +2270,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { // Only force the default orientation if the screen is xlarge, at least 960dp x 720dp, per // http://developer.android.com/guide/practices/screens_support.html#range - // For car, ignore the dp limitation. It's physically impossible to rotate the car's screen - // so if the orientation is forced, we need to respect that no matter what. - boolean isCar = mContext.getPackageManager().hasSystemFeature( - PackageManager.FEATURE_AUTOMOTIVE); - mForceDefaultOrientation = ((longSizeDp >= 960 && shortSizeDp >= 720) || isCar) && + mForceDefaultOrientation = longSizeDp >= 960 && shortSizeDp >= 720 && res.getBoolean(com.android.internal.R.bool.config_forceDefaultOrientation) && // For debug purposes the next line turns this feature off with: // $ adb shell setprop config.override_forced_orient true @@ -2857,7 +2844,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { boolean keyguardLocked = isKeyguardLocked(); boolean hideDockDivider = attrs.type == TYPE_DOCK_DIVIDER - && !mWindowManagerInternal.isStackVisible(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY); + && !mWindowManagerInternal.isStackVisible(DOCKED_STACK_ID); return (keyguardLocked && !allowWhenLocked && win.getDisplayId() == DEFAULT_DISPLAY) || hideDockDivider; } @@ -3550,11 +3537,44 @@ public class PhoneWindowManager implements WindowManagerPolicy { toggleKeyboardShortcutsMenu(event.getDeviceId()); } } else if (keyCode == KeyEvent.KEYCODE_ASSIST) { - Slog.wtf(TAG, "KEYCODE_ASSIST should be handled in interceptKeyBeforeQueueing"); + if (down) { + if (repeatCount == 0) { + mAssistKeyLongPressed = false; + } else if (repeatCount == 1) { + mAssistKeyLongPressed = true; + if (!keyguardOn) { + launchAssistLongPressAction(); + } + } + } else { + if (mAssistKeyLongPressed) { + mAssistKeyLongPressed = false; + } else { + if (!keyguardOn) { + launchAssistAction(null, event.getDeviceId()); + } + } + } return -1; } else if (keyCode == KeyEvent.KEYCODE_VOICE_ASSIST) { - Slog.wtf(TAG, "KEYCODE_VOICE_ASSIST should be handled in interceptKeyBeforeQueueing"); - return -1; + if (!down) { + Intent voiceIntent; + if (!keyguardOn) { + voiceIntent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH); + } else { + IDeviceIdleController dic = IDeviceIdleController.Stub.asInterface( + ServiceManager.getService(Context.DEVICE_IDLE_CONTROLLER)); + if (dic != null) { + try { + dic.exitIdle("voice-search"); + } catch (RemoteException e) { + } + } + voiceIntent = new Intent(RecognizerIntent.ACTION_VOICE_SEARCH_HANDS_FREE); + voiceIntent.putExtra(RecognizerIntent.EXTRA_SECURE, true); + } + startActivityAsUser(voiceIntent, UserHandle.CURRENT_OR_SELF); + } } else if (keyCode == KeyEvent.KEYCODE_SYSRQ) { if (down && repeatCount == 0) { mScreenshotRunnable.setScreenshotType(TAKE_SCREENSHOT_FULLSCREEN); @@ -5425,10 +5445,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { boolean appWindow = attrs.type >= FIRST_APPLICATION_WINDOW && attrs.type < FIRST_SYSTEM_WINDOW; - final int windowingMode = win.getWindowingMode(); - final boolean inFullScreenOrSplitScreenSecondaryWindowingMode = - windowingMode == WINDOWING_MODE_FULLSCREEN - || windowingMode == WINDOWING_MODE_SPLIT_SCREEN_SECONDARY; + final int stackId = win.getStackId(); if (mTopFullscreenOpaqueWindowState == null && affectsSystemUi) { if ((fl & FLAG_FORCE_NOT_FULLSCREEN) != 0) { mForceStatusBar = true; @@ -5447,7 +5464,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { // represent should be hidden or if we should hide the lockscreen. For attached app // windows we defer the decision to the window it is attached to. if (appWindow && attached == null) { - if (attrs.isFullscreen() && inFullScreenOrSplitScreenSecondaryWindowingMode) { + if (attrs.isFullscreen() && StackId.normallyFullscreenWindows(stackId)) { if (DEBUG_LAYOUT) Slog.v(TAG, "Fullscreen window: " + win); mTopFullscreenOpaqueWindowState = win; if (mTopFullscreenOpaqueOrDimmingWindowState == null) { @@ -5478,7 +5495,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { // Keep track of the window if it's dimming but not necessarily fullscreen. if (mTopFullscreenOpaqueOrDimmingWindowState == null && affectsSystemUi - && win.isDimming() && inFullScreenOrSplitScreenSecondaryWindowingMode) { + && win.isDimming() && StackId.normallyFullscreenWindows(stackId)) { mTopFullscreenOpaqueOrDimmingWindowState = win; } @@ -5486,7 +5503,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { // separately, because both the "real fullscreen" opaque window and the one for the docked // stack can control View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR. if (mTopDockedOpaqueWindowState == null && affectsSystemUi && appWindow && attached == null - && attrs.isFullscreen() && windowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) { + && attrs.isFullscreen() && stackId == DOCKED_STACK_ID) { mTopDockedOpaqueWindowState = win; if (mTopDockedOpaqueOrDimmingWindowState == null) { mTopDockedOpaqueOrDimmingWindowState = win; @@ -5496,7 +5513,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { // Also keep track of any windows that are dimming but not necessarily fullscreen in the // docked stack. if (mTopDockedOpaqueOrDimmingWindowState == null && affectsSystemUi && win.isDimming() - && windowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) { + && stackId == DOCKED_STACK_ID) { mTopDockedOpaqueOrDimmingWindowState = win; } @@ -5591,9 +5608,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { changes |= FINISH_LAYOUT_REDO_LAYOUT; } } else if (topIsFullscreen - && !mWindowManagerInternal.isStackVisible(WINDOWING_MODE_FREEFORM) - && !mWindowManagerInternal.isStackVisible( - WINDOWING_MODE_SPLIT_SCREEN_PRIMARY)) { + && !mWindowManagerInternal.isStackVisible(FREEFORM_WORKSPACE_STACK_ID) + && !mWindowManagerInternal.isStackVisible(DOCKED_STACK_ID)) { if (DEBUG_LAYOUT) Slog.v(TAG, "** HIDING status bar"); if (mStatusBarController.setBarShowingLw(false)) { changes |= FINISH_LAYOUT_REDO_LAYOUT; @@ -6175,7 +6191,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { useHapticFeedback = false; // suppress feedback if already non-interactive } if (down) { - sleepPress(); + sleepPress(event.getEventTime()); } else { sleepRelease(event.getEventTime()); } @@ -6246,30 +6262,18 @@ public class PhoneWindowManager implements WindowManagerPolicy { } break; } - case KeyEvent.KEYCODE_ASSIST: { - final boolean longPressed = event.getRepeatCount() > 0; - if (down && longPressed) { - Message msg = mHandler.obtainMessage(MSG_LAUNCH_ASSIST_LONG_PRESS); - msg.setAsynchronous(true); - msg.sendToTarget(); - } - if (!down && !longPressed) { - Message msg = mHandler.obtainMessage(MSG_LAUNCH_ASSIST, event.getDeviceId(), - 0 /* unused */, null /* hint */); - msg.setAsynchronous(true); - msg.sendToTarget(); - } - result &= ~ACTION_PASS_TO_USER; - break; - } case KeyEvent.KEYCODE_VOICE_ASSIST: { - if (!down) { + // Only do this if we would otherwise not pass it to the user. In that case, + // interceptKeyBeforeDispatching would apply a similar but different policy in + // order to invoke voice assist actions. Note that we need to make a copy of the + // key event here because the original key event will be recycled when we return. + if ((result & ACTION_PASS_TO_USER) == 0 && !down) { mBroadcastWakeLock.acquire(); - Message msg = mHandler.obtainMessage(MSG_LAUNCH_VOICE_ASSIST_WITH_WAKE_LOCK); + Message msg = mHandler.obtainMessage(MSG_LAUNCH_VOICE_ASSIST_WITH_WAKE_LOCK, + keyguardActive ? 1 : 0, 0); msg.setAsynchronous(true); msg.sendToTarget(); } - result &= ~ACTION_PASS_TO_USER; break; } case KeyEvent.KEYCODE_WINDOW: { @@ -6538,22 +6542,18 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } - void launchVoiceAssistWithWakeLock() { - final Intent voiceIntent; - if (!keyguardOn()) { - voiceIntent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH); - } else { - IDeviceIdleController dic = IDeviceIdleController.Stub.asInterface( - ServiceManager.getService(Context.DEVICE_IDLE_CONTROLLER)); - if (dic != null) { - try { - dic.exitIdle("voice-search"); - } catch (RemoteException e) { - } + void launchVoiceAssistWithWakeLock(boolean keyguardActive) { + IDeviceIdleController dic = IDeviceIdleController.Stub.asInterface( + ServiceManager.getService(Context.DEVICE_IDLE_CONTROLLER)); + if (dic != null) { + try { + dic.exitIdle("voice-search"); + } catch (RemoteException e) { } - voiceIntent = new Intent(RecognizerIntent.ACTION_VOICE_SEARCH_HANDS_FREE); - voiceIntent.putExtra(RecognizerIntent.EXTRA_SECURE, true); } + Intent voiceIntent = + new Intent(RecognizerIntent.ACTION_VOICE_SEARCH_HANDS_FREE); + voiceIntent.putExtra(RecognizerIntent.EXTRA_SECURE, keyguardActive); startActivityAsUser(voiceIntent, UserHandle.CURRENT_OR_SELF); mBroadcastWakeLock.release(); } @@ -8009,10 +8009,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { } private int updateSystemBarsLw(WindowState win, int oldVis, int vis) { - final boolean dockedStackVisible = - mWindowManagerInternal.isStackVisible(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY); + final boolean dockedStackVisible = mWindowManagerInternal.isStackVisible(DOCKED_STACK_ID); final boolean freeformStackVisible = - mWindowManagerInternal.isStackVisible(WINDOWING_MODE_FREEFORM); + mWindowManagerInternal.isStackVisible(FREEFORM_WORKSPACE_STACK_ID); final boolean resizing = mWindowManagerInternal.isDockedDividerResizing(); // We need to force system bars when the docked stack is visible, when the freeform stack |