Loading core/java/android/app/ActivityView.java +31 −0 Original line number Diff line number Diff line Loading @@ -29,12 +29,17 @@ import android.content.Intent; import android.graphics.Insets; import android.hardware.display.DisplayManager; import android.hardware.display.VirtualDisplay; import android.hardware.input.InputManager; import android.os.RemoteException; import android.os.SystemClock; import android.os.UserHandle; import android.util.AttributeSet; import android.util.DisplayMetrics; import android.util.Log; import android.view.IWindowManager; import android.view.InputDevice; import android.view.KeyCharacterMap; import android.view.KeyEvent; import android.view.SurfaceControl; import android.view.SurfaceHolder; import android.view.SurfaceSession; Loading Loading @@ -346,6 +351,32 @@ public class ActivityView extends ViewGroup { mSurfaceView.setVisibility(visibility); } /** * Injects a pair of down/up key events with keycode {@link KeyEvent#KEYCODE_BACK} to the * virtual display. */ public void performBackPress() { if (mVirtualDisplay == null) { return; } final int displayId = mVirtualDisplay.getDisplay().getDisplayId(); final InputManager im = InputManager.getInstance(); im.injectInputEvent(createKeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK, displayId), InputManager.INJECT_INPUT_EVENT_MODE_ASYNC); im.injectInputEvent(createKeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_BACK, displayId), InputManager.INJECT_INPUT_EVENT_MODE_ASYNC); } private static KeyEvent createKeyEvent(int action, int code, int displayId) { long when = SystemClock.uptimeMillis(); final KeyEvent ev = new KeyEvent(when, when, action, code, 0 /* repeat */, 0 /* metaState */, KeyCharacterMap.VIRTUAL_KEYBOARD, 0 /* scancode */, KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY, InputDevice.SOURCE_KEYBOARD); ev.setDisplayId(displayId); return ev; } private void initVirtualDisplay(SurfaceSession surfaceSession) { if (mVirtualDisplay != null) { throw new IllegalStateException("Trying to initialize for the second time."); Loading packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +10 −0 Original line number Diff line number Diff line Loading @@ -242,6 +242,16 @@ public class BubbleController implements BubbleExpandedView.OnBubbleBlockedListe mNotificationEntryManager.updateNotifications(); } /** * Directs a back gesture at the bubble stack. When opened, the current expanded bubble * is forwarded a back key down/up pair. */ public void performBackPressIfNeeded() { if (mStackView != null) { mStackView.performBackPressIfNeeded(); } } /** * Adds or updates a bubble associated with the provided notification entry. * Loading packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java +8 −0 Original line number Diff line number Diff line Loading @@ -335,6 +335,14 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList updateView(); } boolean performBackPressIfNeeded() { if (mActivityView == null || !usingActivityView()) { return false; } mActivityView.performBackPress(); return true; } @Override public void onClick(View view) { if (mEntry == null) { Loading packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java +11 −0 Original line number Diff line number Diff line Loading @@ -815,4 +815,15 @@ public class BubbleStackView extends FrameLayout { getNormalizedYPosition()); } } /** * Called when a back gesture should be directed to the Bubbles stack. When expanded, * a back key down/up event pair is forwarded to the bubble Activity. */ boolean performBackPressIfNeeded() { if (!isExpanded()) { return false; } return mExpandedBubble.expandedView.performBackPressIfNeeded(); } } packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +5 −1 Original line number Diff line number Diff line Loading @@ -3261,7 +3261,11 @@ public class StatusBar extends SystemUI implements DemoMode, return true; } if (mState != StatusBarState.KEYGUARD && mState != StatusBarState.SHADE_LOCKED) { if (mNotificationPanel.canPanelBeCollapsed()) { animateCollapsePanels(); } else { mBubbleController.performBackPressIfNeeded(); } return true; } if (mKeyguardUserSwitcher != null && mKeyguardUserSwitcher.hideIfNotSimple(true)) { Loading Loading
core/java/android/app/ActivityView.java +31 −0 Original line number Diff line number Diff line Loading @@ -29,12 +29,17 @@ import android.content.Intent; import android.graphics.Insets; import android.hardware.display.DisplayManager; import android.hardware.display.VirtualDisplay; import android.hardware.input.InputManager; import android.os.RemoteException; import android.os.SystemClock; import android.os.UserHandle; import android.util.AttributeSet; import android.util.DisplayMetrics; import android.util.Log; import android.view.IWindowManager; import android.view.InputDevice; import android.view.KeyCharacterMap; import android.view.KeyEvent; import android.view.SurfaceControl; import android.view.SurfaceHolder; import android.view.SurfaceSession; Loading Loading @@ -346,6 +351,32 @@ public class ActivityView extends ViewGroup { mSurfaceView.setVisibility(visibility); } /** * Injects a pair of down/up key events with keycode {@link KeyEvent#KEYCODE_BACK} to the * virtual display. */ public void performBackPress() { if (mVirtualDisplay == null) { return; } final int displayId = mVirtualDisplay.getDisplay().getDisplayId(); final InputManager im = InputManager.getInstance(); im.injectInputEvent(createKeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK, displayId), InputManager.INJECT_INPUT_EVENT_MODE_ASYNC); im.injectInputEvent(createKeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_BACK, displayId), InputManager.INJECT_INPUT_EVENT_MODE_ASYNC); } private static KeyEvent createKeyEvent(int action, int code, int displayId) { long when = SystemClock.uptimeMillis(); final KeyEvent ev = new KeyEvent(when, when, action, code, 0 /* repeat */, 0 /* metaState */, KeyCharacterMap.VIRTUAL_KEYBOARD, 0 /* scancode */, KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY, InputDevice.SOURCE_KEYBOARD); ev.setDisplayId(displayId); return ev; } private void initVirtualDisplay(SurfaceSession surfaceSession) { if (mVirtualDisplay != null) { throw new IllegalStateException("Trying to initialize for the second time."); Loading
packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +10 −0 Original line number Diff line number Diff line Loading @@ -242,6 +242,16 @@ public class BubbleController implements BubbleExpandedView.OnBubbleBlockedListe mNotificationEntryManager.updateNotifications(); } /** * Directs a back gesture at the bubble stack. When opened, the current expanded bubble * is forwarded a back key down/up pair. */ public void performBackPressIfNeeded() { if (mStackView != null) { mStackView.performBackPressIfNeeded(); } } /** * Adds or updates a bubble associated with the provided notification entry. * Loading
packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java +8 −0 Original line number Diff line number Diff line Loading @@ -335,6 +335,14 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList updateView(); } boolean performBackPressIfNeeded() { if (mActivityView == null || !usingActivityView()) { return false; } mActivityView.performBackPress(); return true; } @Override public void onClick(View view) { if (mEntry == null) { Loading
packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java +11 −0 Original line number Diff line number Diff line Loading @@ -815,4 +815,15 @@ public class BubbleStackView extends FrameLayout { getNormalizedYPosition()); } } /** * Called when a back gesture should be directed to the Bubbles stack. When expanded, * a back key down/up event pair is forwarded to the bubble Activity. */ boolean performBackPressIfNeeded() { if (!isExpanded()) { return false; } return mExpandedBubble.expandedView.performBackPressIfNeeded(); } }
packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +5 −1 Original line number Diff line number Diff line Loading @@ -3261,7 +3261,11 @@ public class StatusBar extends SystemUI implements DemoMode, return true; } if (mState != StatusBarState.KEYGUARD && mState != StatusBarState.SHADE_LOCKED) { if (mNotificationPanel.canPanelBeCollapsed()) { animateCollapsePanels(); } else { mBubbleController.performBackPressIfNeeded(); } return true; } if (mKeyguardUserSwitcher != null && mKeyguardUserSwitcher.hideIfNotSimple(true)) { Loading