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

Commit 42ed7b3d authored by Vaibhav Devmurari's avatar Vaibhav Devmurari
Browse files

Revert "Revert "Allow PWM to pass key gesture event to KeyGestur..."

Revert submission 33530799-revert-33464207-support_gemini_power_key_animation-OWWMRETITV

Reason for revert: Tested locally but the reported tests pass (falsely reverted): Will test on ABTD to confirm

Tests are failing with or without CLs: Some other issue.
Without CL: https://android-build.corp.google.com/builds/abtd/run/L46300030012099882
With CL: https://android-build.corp.google.com/builds/abtd/run/L46300030012098202

Reverted changes: /q/submissionid:33530799-revert-33464207-support_gemini_power_key_animation-OWWMRETITV

Change-Id: Ie739aa9a2479f30542537a21578297c0a05afa70
parent 06a81cac
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -265,14 +265,10 @@ public abstract class InputManagerInternal {
     * NOTE: This is a temporary API added to assist in a long-term refactor, and is not meant for
     * general use by system services.
     *
     * @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
     * @param event the gesture event that needs to be handled.
     *
     */
    public abstract void handleKeyGestureInKeyGestureController(int deviceId, int[] keycodes,
            int modifierState, @KeyGestureEvent.KeyGestureType int event);
    public abstract void handleKeyGestureInKeyGestureController(@NonNull KeyGestureEvent event);

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

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

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

    @VisibleForTesting
    void handleKeyGesture(int deviceId, int[] keycodes, int modifierState,
            @KeyGestureEvent.KeyGestureType int gestureType, int action, int displayId,
            @Nullable IBinder focusedToken, int flags, @Nullable AppLaunchData appLaunchData) {
@@ -1013,14 +1012,6 @@ final class KeyGestureController {
        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) {
        // Handle custom shortcuts
        InputGestureData customGesture;
+15 −16
Original line number Diff line number Diff line
@@ -1648,10 +1648,14 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                }
                break;
            case DOUBLE_PRESS_PRIMARY_LAUNCH_DEFAULT_FITNESS_APP:
                final int stemPrimaryKeyDeviceId = INVALID_INPUT_DEVICE_ID;
                handleKeyGestureInKeyGestureController(
                        KeyGestureEvent.KEY_GESTURE_TYPE_LAUNCH_DEFAULT_FITNESS,
                        stemPrimaryKeyDeviceId, KEYCODE_STEM_PRIMARY, /* metaState= */ 0);
                mInputManagerInternal.handleKeyGestureInKeyGestureController(
                        new KeyGestureEvent.Builder()
                                .setKeyGestureType(
                                        KeyGestureEvent.KEY_GESTURE_TYPE_LAUNCH_DEFAULT_FITNESS)
                                .setDeviceId(INVALID_INPUT_DEVICE_ID)
                                .setKeycodes(new int[]{KEYCODE_STEM_PRIMARY})
                                .setModifierState(/* metaState= */0)
                                .build());
                break;
        }
    }
@@ -2771,8 +2775,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                return;
            }
            // Single press on tail button triggers the open notes gesture.
            handleKeyGestureInKeyGestureController(KeyGestureEvent.KEY_GESTURE_TYPE_OPEN_NOTES,
                    event.getDeviceId(), KEYCODE_STYLUS_BUTTON_TAIL, event.getMetaState());
            mInputManagerInternal.handleKeyGestureInKeyGestureController(
                    new KeyGestureEvent.Builder()
                            .setKeyGestureType(KeyGestureEvent.KEY_GESTURE_TYPE_OPEN_NOTES)
                            .setDeviceId(event.getDeviceId())
                            .setKeycodes(new int[]{KEYCODE_STYLUS_BUTTON_TAIL})
                            .setModifierState(event.getMetaState())
                            .build());
        }
    }

@@ -3264,16 +3273,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                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
    public KeyboardShortcutGroup getApplicationLaunchKeyboardShortcuts(int deviceId) {
        return mModifierShortcutManager.getApplicationLaunchKeyboardShortcuts(deviceId,
+11 −53
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ 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_NO_CONFIRM;

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

    @Mock private StatusBarManagerInternal mStatusBarManagerInternal;

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

    private boolean mIsTalkBackEnabled;
    private boolean mIsTalkBackShortcutGestureEnabled;

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

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

        Supplier<GlobalActions> getGlobalActionsFactory() {
            return () -> mGlobalActions;
        }
@@ -270,7 +262,6 @@ class TestPhoneWindowManager {
     */
    TestPhoneWindowManager(Context context, boolean supportSettingsUpdate) {
        MockitoAnnotations.initMocks(this);
        mHandler = new Handler(mTestLooper.getLooper());
        mContext = mockingDetails(context).isSpy() ? context : spy(context);
        mGestureLauncherService = spy(new GestureLauncherService(mContext, mMetricsLogger,
                mQuickAccessWalletClient, mUiEventLogger));
@@ -333,6 +324,11 @@ class TestPhoneWindowManager {
        doReturn(mInputManager).when(mContext).getSystemService(eq(InputManager.class));
        doNothing().when(mInputManager).registerKeyGestureEventHandler(anyList(), 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(mSensorPrivacyManager).when(mContext).getSystemService(
                eq(SensorPrivacyManager.class));
@@ -394,7 +390,6 @@ class TestPhoneWindowManager {
        mPhoneWindowManager.systemReady();
        mPhoneWindowManager.systemBooted();

        overrideLaunchAccessibility();
        doReturn(false).when(mPhoneWindowManager).keyguardOn();
        doNothing().when(mContext).startActivityAsUser(any(), any());
        doNothing().when(mContext).startActivityAsUser(any(), any(), any());
@@ -430,13 +425,6 @@ class TestPhoneWindowManager {
        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) {
        return mPhoneWindowManager.interceptKeyBeforeQueueing(event, mKeyEventPolicyFlags);
    }
@@ -704,11 +692,6 @@ class TestPhoneWindowManager {
        verify(mAudioManagerInternal, never()).silenceRingerModeInternal(any());
    }

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

    void assertCloseAllDialogs() {
        ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
        verify(mContext).sendBroadcastAsUser(intentCaptor.capture(), any(), any(), any());
@@ -756,34 +739,6 @@ class TestPhoneWindowManager {
        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() {
        mTestLooper.dispatchAll();
        verify(mSearchManager).launchAssist(any());
@@ -990,8 +945,11 @@ class TestPhoneWindowManager {
    }

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

    void assertNoActivityLaunched() {