Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a02bd7a3 authored by Liana Kazanova (xWF)'s avatar Liana Kazanova (xWF)
Browse files

Revert "Allow PWM to pass key gesture event to KeyGestureController"

Revert submission 33464207-support_gemini_power_key_animation

Reason for revert: DroidMonitor: Potential culprit for http://b/417498518 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.

Bug: 417498518

Reverted changes: /q/submissionid:33464207-support_gemini_power_key_animation

Change-Id: If82179d1b9d87a59d5486dbe998686e562894f7e
parent d2f0b835
Loading
Loading
Loading
Loading
+6 −2
Original line number Original line Diff line number Diff line
@@ -265,10 +265,14 @@ public abstract class InputManagerInternal {
     * NOTE: This is a temporary API added to assist in a long-term refactor, and is not meant for
     * NOTE: This is a temporary API added to assist in a long-term refactor, and is not meant for
     * general use by system services.
     * general use by system services.
     *
     *
     * @param event the gesture event that needs to be handled.
     * @param deviceId the device ID of the keyboard using which the event was completed
     * @param keycodes the keys pressed for the event
     * @param modifierState the modifier state
     * @param event the gesture event that was completed
     *
     *
     */
     */
    public abstract void handleKeyGestureInKeyGestureController(@NonNull KeyGestureEvent event);
    public abstract void handleKeyGestureInKeyGestureController(int deviceId, int[] keycodes,
            int modifierState, @KeyGestureEvent.KeyGestureType int event);


    /**
    /**
     * Sets the magnification scale factor for pointer icons.
     * Sets the magnification scale factor for pointer icons.
+3 −6
Original line number Original line Diff line number Diff line
@@ -54,7 +54,6 @@ import android.hardware.display.DisplayManagerInternal;
import android.hardware.display.DisplayTopologyGraph;
import android.hardware.display.DisplayTopologyGraph;
import android.hardware.display.DisplayViewport;
import android.hardware.display.DisplayViewport;
import android.hardware.input.AidlInputGestureData;
import android.hardware.input.AidlInputGestureData;
import android.hardware.input.AppLaunchData;
import android.hardware.input.HostUsiVersion;
import android.hardware.input.HostUsiVersion;
import android.hardware.input.IInputDeviceBatteryListener;
import android.hardware.input.IInputDeviceBatteryListener;
import android.hardware.input.IInputDeviceBatteryState;
import android.hardware.input.IInputDeviceBatteryState;
@@ -3811,11 +3810,9 @@ public class InputManagerService extends IInputManager.Stub
        }
        }


        @Override
        @Override
        public void handleKeyGestureInKeyGestureController(@NonNull KeyGestureEvent event) {
        public void handleKeyGestureInKeyGestureController(int deviceId, int[] keycodes,
            mKeyGestureController.handleKeyGesture(event.getDeviceId(), event.getKeycodes(),
                int modifierState, @KeyGestureEvent.KeyGestureType int gestureType) {
                    event.getModifierState(), event.getKeyGestureType(), event.getAction(),
            mKeyGestureController.handleKeyGesture(deviceId, keycodes, modifierState, gestureType);
                    event.getDisplayId(), /* focusedToken = */null, event.getFlags(),
                    event.getAppLaunchData());
        }
        }


        @Override
        @Override
+9 −0
Original line number Original line Diff line number Diff line
@@ -957,6 +957,7 @@ final class KeyGestureController {
                DEFAULT_DISPLAY, /* focusedToken = */null, /* flags = */0, appLaunchData);
                DEFAULT_DISPLAY, /* focusedToken = */null, /* flags = */0, appLaunchData);
    }
    }


    @VisibleForTesting
    void handleKeyGesture(int deviceId, int[] keycodes, int modifierState,
    void handleKeyGesture(int deviceId, int[] keycodes, int modifierState,
            @KeyGestureEvent.KeyGestureType int gestureType, int action, int displayId,
            @KeyGestureEvent.KeyGestureType int gestureType, int action, int displayId,
            @Nullable IBinder focusedToken, int flags, @Nullable AppLaunchData appLaunchData) {
            @Nullable IBinder focusedToken, int flags, @Nullable AppLaunchData appLaunchData) {
@@ -1012,6 +1013,14 @@ final class KeyGestureController {
        mHandler.obtainMessage(MSG_NOTIFY_KEY_GESTURE_EVENT, event).sendToTarget();
        mHandler.obtainMessage(MSG_NOTIFY_KEY_GESTURE_EVENT, event).sendToTarget();
    }
    }


    public void handleKeyGesture(int deviceId, int[] keycodes, int modifierState,
            @KeyGestureEvent.KeyGestureType int gestureType) {
        AidlKeyGestureEvent event = createKeyGestureEvent(deviceId, keycodes, modifierState,
                gestureType, KeyGestureEvent.ACTION_GESTURE_COMPLETE, DEFAULT_DISPLAY,
                /* flags = */0, /* appLaunchData = */null);
        handleKeyGesture(event, null /*focusedToken*/);
    }

    public void handleTouchpadGesture(int touchpadGestureType) {
    public void handleTouchpadGesture(int touchpadGestureType) {
        // Handle custom shortcuts
        // Handle custom shortcuts
        InputGestureData customGesture;
        InputGestureData customGesture;
+16 −15
Original line number Original line Diff line number Diff line
@@ -1648,14 +1648,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                }
                }
                break;
                break;
            case DOUBLE_PRESS_PRIMARY_LAUNCH_DEFAULT_FITNESS_APP:
            case DOUBLE_PRESS_PRIMARY_LAUNCH_DEFAULT_FITNESS_APP:
                mInputManagerInternal.handleKeyGestureInKeyGestureController(
                final int stemPrimaryKeyDeviceId = INVALID_INPUT_DEVICE_ID;
                        new KeyGestureEvent.Builder()
                handleKeyGestureInKeyGestureController(
                                .setKeyGestureType(
                        KeyGestureEvent.KEY_GESTURE_TYPE_LAUNCH_DEFAULT_FITNESS,
                                        KeyGestureEvent.KEY_GESTURE_TYPE_LAUNCH_DEFAULT_FITNESS)
                        stemPrimaryKeyDeviceId, KEYCODE_STEM_PRIMARY, /* metaState= */ 0);
                                .setDeviceId(INVALID_INPUT_DEVICE_ID)
                                .setKeycodes(new int[]{KEYCODE_STEM_PRIMARY})
                                .setModifierState(/* metaState= */0)
                                .build());
                break;
                break;
        }
        }
    }
    }
@@ -2775,13 +2771,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                return;
                return;
            }
            }
            // Single press on tail button triggers the open notes gesture.
            // Single press on tail button triggers the open notes gesture.
            mInputManagerInternal.handleKeyGestureInKeyGestureController(
            handleKeyGestureInKeyGestureController(KeyGestureEvent.KEY_GESTURE_TYPE_OPEN_NOTES,
                    new KeyGestureEvent.Builder()
                    event.getDeviceId(), KEYCODE_STYLUS_BUTTON_TAIL, event.getMetaState());
                            .setKeyGestureType(KeyGestureEvent.KEY_GESTURE_TYPE_OPEN_NOTES)
                            .setDeviceId(event.getDeviceId())
                            .setKeycodes(new int[]{KEYCODE_STYLUS_BUTTON_TAIL})
                            .setModifierState(event.getMetaState())
                            .build());
        }
        }
    }
    }


@@ -3273,6 +3264,16 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                new int[]{event.getKeyCode()}, event.getMetaState(), gestureType);
                new int[]{event.getKeyCode()}, event.getMetaState(), gestureType);
    }
    }


    private void handleKeyGestureInKeyGestureController(
            @KeyGestureEvent.KeyGestureType int gestureType, int deviceId, int keyCode,
            int metaState) {
        if (gestureType == KeyGestureEvent.KEY_GESTURE_TYPE_UNSPECIFIED) {
            return;
        }
        mInputManagerInternal.handleKeyGestureInKeyGestureController(deviceId, new int[]{keyCode},
                metaState, gestureType);
    }

    @Override
    @Override
    public KeyboardShortcutGroup getApplicationLaunchKeyboardShortcuts(int deviceId) {
    public KeyboardShortcutGroup getApplicationLaunchKeyboardShortcuts(int deviceId) {
        return mModifierShortcutManager.getApplicationLaunchKeyboardShortcuts(deviceId,
        return mModifierShortcutManager.getApplicationLaunchKeyboardShortcuts(deviceId,
+53 −11
Original line number Original line Diff line number Diff line
@@ -44,7 +44,6 @@ import static com.android.server.policy.PhoneWindowManager.LONG_PRESS_POWER_NOTH
import static com.android.server.policy.PhoneWindowManager.LONG_PRESS_POWER_SHUT_OFF;
import static com.android.server.policy.PhoneWindowManager.LONG_PRESS_POWER_SHUT_OFF;
import static com.android.server.policy.PhoneWindowManager.LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM;
import static com.android.server.policy.PhoneWindowManager.LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.ArgumentMatchers.anyList;
@@ -178,6 +177,7 @@ class TestPhoneWindowManager {
    @Mock private MetricsLogger mMetricsLogger;
    @Mock private MetricsLogger mMetricsLogger;
    @Mock private UiEventLogger mUiEventLogger;
    @Mock private UiEventLogger mUiEventLogger;
    @Mock private GlobalActions mGlobalActions;
    @Mock private GlobalActions mGlobalActions;
    @Mock private AccessibilityShortcutController mAccessibilityShortcutController;


    @Mock private StatusBarManagerInternal mStatusBarManagerInternal;
    @Mock private StatusBarManagerInternal mStatusBarManagerInternal;


@@ -193,6 +193,9 @@ class TestPhoneWindowManager {
    private StaticMockitoSession mMockitoSession;
    private StaticMockitoSession mMockitoSession;
    private OffsettableClock mClock = new OffsettableClock();
    private OffsettableClock mClock = new OffsettableClock();
    private TestLooper mTestLooper = new TestLooper(() -> mClock.now());
    private TestLooper mTestLooper = new TestLooper(() -> mClock.now());
    private HandlerThread mHandlerThread;
    private Handler mHandler;

    private boolean mIsTalkBackEnabled;
    private boolean mIsTalkBackEnabled;
    private boolean mIsTalkBackShortcutGestureEnabled;
    private boolean mIsTalkBackShortcutGestureEnabled;


@@ -228,6 +231,11 @@ class TestPhoneWindowManager {
            return mTestLooper.getLooper();
            return mTestLooper.getLooper();
        }
        }


        AccessibilityShortcutController getAccessibilityShortcutController(
                Context context, Handler handler, int initialUserId) {
            return mAccessibilityShortcutController;
        }

        Supplier<GlobalActions> getGlobalActionsFactory() {
        Supplier<GlobalActions> getGlobalActionsFactory() {
            return () -> mGlobalActions;
            return () -> mGlobalActions;
        }
        }
@@ -262,6 +270,7 @@ class TestPhoneWindowManager {
     */
     */
    TestPhoneWindowManager(Context context, boolean supportSettingsUpdate) {
    TestPhoneWindowManager(Context context, boolean supportSettingsUpdate) {
        MockitoAnnotations.initMocks(this);
        MockitoAnnotations.initMocks(this);
        mHandler = new Handler(mTestLooper.getLooper());
        mContext = mockingDetails(context).isSpy() ? context : spy(context);
        mContext = mockingDetails(context).isSpy() ? context : spy(context);
        mGestureLauncherService = spy(new GestureLauncherService(mContext, mMetricsLogger,
        mGestureLauncherService = spy(new GestureLauncherService(mContext, mMetricsLogger,
                mQuickAccessWalletClient, mUiEventLogger));
                mQuickAccessWalletClient, mUiEventLogger));
@@ -324,11 +333,6 @@ class TestPhoneWindowManager {
        doReturn(mInputManager).when(mContext).getSystemService(eq(InputManager.class));
        doReturn(mInputManager).when(mContext).getSystemService(eq(InputManager.class));
        doNothing().when(mInputManager).registerKeyGestureEventHandler(anyList(), any());
        doNothing().when(mInputManager).registerKeyGestureEventHandler(anyList(), any());
        doNothing().when(mInputManager).unregisterKeyGestureEventHandler(any());
        doNothing().when(mInputManager).unregisterKeyGestureEventHandler(any());
        doAnswer(inv -> {
            mPhoneWindowManager.handleKeyGestureEvent(inv.getArgument(0), /* focusedToken= */null);
            return null;
        }).when(mInputManagerInternal).handleKeyGestureInKeyGestureController(
                any(KeyGestureEvent.class));
        doReturn(mPackageManager).when(mContext).getPackageManager();
        doReturn(mPackageManager).when(mContext).getPackageManager();
        doReturn(mSensorPrivacyManager).when(mContext).getSystemService(
        doReturn(mSensorPrivacyManager).when(mContext).getSystemService(
                eq(SensorPrivacyManager.class));
                eq(SensorPrivacyManager.class));
@@ -390,6 +394,7 @@ class TestPhoneWindowManager {
        mPhoneWindowManager.systemReady();
        mPhoneWindowManager.systemReady();
        mPhoneWindowManager.systemBooted();
        mPhoneWindowManager.systemBooted();


        overrideLaunchAccessibility();
        doReturn(false).when(mPhoneWindowManager).keyguardOn();
        doReturn(false).when(mPhoneWindowManager).keyguardOn();
        doNothing().when(mContext).startActivityAsUser(any(), any());
        doNothing().when(mContext).startActivityAsUser(any(), any());
        doNothing().when(mContext).startActivityAsUser(any(), any(), any());
        doNothing().when(mContext).startActivityAsUser(any(), any(), any());
@@ -425,6 +430,13 @@ class TestPhoneWindowManager {
        mTestLooper.dispatchAll();
        mTestLooper.dispatchAll();
    }
    }


    // Override accessibility setting and perform function.
    private void overrideLaunchAccessibility() {
        doReturn(true).when(mAccessibilityShortcutController)
                .isAccessibilityShortcutAvailable(anyBoolean());
        doNothing().when(mAccessibilityShortcutController).performAccessibilityShortcut();
    }

    int interceptKeyBeforeQueueing(KeyEvent event) {
    int interceptKeyBeforeQueueing(KeyEvent event) {
        return mPhoneWindowManager.interceptKeyBeforeQueueing(event, mKeyEventPolicyFlags);
        return mPhoneWindowManager.interceptKeyBeforeQueueing(event, mKeyEventPolicyFlags);
    }
    }
@@ -692,6 +704,11 @@ class TestPhoneWindowManager {
        verify(mAudioManagerInternal, never()).silenceRingerModeInternal(any());
        verify(mAudioManagerInternal, never()).silenceRingerModeInternal(any());
    }
    }


    void assertAccessibilityKeychordCalled() {
        mTestLooper.dispatchAll();
        verify(mAccessibilityShortcutController).performAccessibilityShortcut();
    }

    void assertCloseAllDialogs() {
    void assertCloseAllDialogs() {
        ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
        ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
        verify(mContext).sendBroadcastAsUser(intentCaptor.capture(), any(), any(), any());
        verify(mContext).sendBroadcastAsUser(intentCaptor.capture(), any(), any(), any());
@@ -739,6 +756,34 @@ class TestPhoneWindowManager {
        assertTrue(capturedValues.contains(true));
        assertTrue(capturedValues.contains(true));
    }
    }


    void assertNoDoublePowerLaunch() {
        ArgumentCaptor<MutableBoolean> valueCaptor = ArgumentCaptor.forClass(MutableBoolean.class);

        mTestLooper.dispatchAll();
        verify(mGestureLauncherService, atLeast(0))
                .interceptPowerKeyDown(any(), anyBoolean(), valueCaptor.capture());

        List<Boolean> capturedValues = valueCaptor.getAllValues().stream()
                .map(mutableBoolean -> mutableBoolean.value)
                .toList();

        assertTrue(capturedValues.stream().noneMatch(value -> value));
    }

    void assertEmergencyLaunch() {
        ArgumentCaptor<MutableBoolean> valueCaptor = ArgumentCaptor.forClass(MutableBoolean.class);

        mTestLooper.dispatchAll();
        verify(mGestureLauncherService, atLeast(1))
                .interceptPowerKeyDown(any(), anyBoolean(), valueCaptor.capture());

        List<Boolean> capturedValues = valueCaptor.getAllValues().stream()
                .map(mutableBoolean -> mutableBoolean.value)
                .toList();

        assertTrue(capturedValues.getLast());
    }

    void assertSearchManagerLaunchAssist() {
    void assertSearchManagerLaunchAssist() {
        mTestLooper.dispatchAll();
        mTestLooper.dispatchAll();
        verify(mSearchManager).launchAssist(any());
        verify(mSearchManager).launchAssist(any());
@@ -945,11 +990,8 @@ class TestPhoneWindowManager {
    }
    }


    void assertKeyGestureEventSentToKeyGestureController(int gestureType) {
    void assertKeyGestureEventSentToKeyGestureController(int gestureType) {
        ArgumentCaptor<KeyGestureEvent> gestureCaptor = ArgumentCaptor.forClass(
        verify(mInputManagerInternal)
                KeyGestureEvent.class);
                .handleKeyGestureInKeyGestureController(anyInt(), any(), anyInt(), eq(gestureType));
        verify(mInputManagerInternal).handleKeyGestureInKeyGestureController(
                gestureCaptor.capture());
        assertEquals(gestureType, gestureCaptor.getValue().getKeyGestureType());
    }
    }


    void assertNoActivityLaunched() {
    void assertNoActivityLaunched() {