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

Commit 5f837195 authored by Vaibhav Devmurari's avatar Vaibhav Devmurari
Browse files

Add TestApi to reset locked modifier state

To make CTS tests more reliable, we need a way to clear locked
modifier state that can creep in from other tests since locked
modifier state is global and saved across devices.

Test: atest CtsInputTestCases
Bug: 377353219
Flag: EXEMPT test_only
Change-Id: I8ae29652067966019d18e5f104925b4fbae91408
parent c319a30b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1805,6 +1805,7 @@ package android.hardware.input {
    method @RequiresPermission(android.Manifest.permission.REMAP_MODIFIER_KEYS) public void remapModifierKey(int, int);
    method @FlaggedApi("com.android.input.flags.device_associations") @RequiresPermission("android.permission.ASSOCIATE_INPUT_DEVICE_TO_DISPLAY") public void removeUniqueIdAssociationByDescriptor(@NonNull String);
    method @RequiresPermission("android.permission.ASSOCIATE_INPUT_DEVICE_TO_DISPLAY") public void removeUniqueIdAssociationByPort(@NonNull String);
    method public void resetLockedModifierState();
    field public static final long BLOCK_UNTRUSTED_TOUCHES = 158002302L; // 0x96aec7eL
  }

+2 −0
Original line number Diff line number Diff line
@@ -281,4 +281,6 @@ interface IInputManager {
    AidlInputGestureData[] getCustomInputGestures(int userId, int tag);

    AidlInputGestureData[] getAppLaunchBookmarks();

    void resetLockedModifierState();
}
+15 −0
Original line number Diff line number Diff line
@@ -1589,6 +1589,21 @@ public final class InputManager {
        }
    }

    /**
     * Resets locked modifier state (i.e.. Caps Lock, Num Lock, Scroll Lock state)
     *
     * @hide
     */
    @TestApi
    @SuppressLint("UnflaggedApi") // @TestApi without associated feature.
    public void resetLockedModifierState() {
        try {
            mIm.resetLockedModifierState();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * A callback used to be notified about battery state changes for an input device. The
     * {@link #onBatteryStateChanged(int, long, BatteryState)} method will be called once after the
+5 −0
Original line number Diff line number Diff line
@@ -3031,6 +3031,11 @@ public class InputManagerService extends IInputManager.Stub
        return mKeyGestureController.getAppLaunchBookmarks();
    }

    @Override
    public void resetLockedModifierState() {
        mNative.resetLockedModifierState();
    }

    private void handleCurrentUserChanged(@UserIdInt int userId) {
        mCurrentUserId = userId;
        mKeyGestureController.setCurrentUserId(userId);
+5 −0
Original line number Diff line number Diff line
@@ -98,6 +98,8 @@ interface NativeInputManagerService {

    void toggleCapsLock(int deviceId);

    void resetLockedModifierState();

    void displayRemoved(int displayId);

    void setInputDispatchMode(boolean enabled, boolean frozen);
@@ -369,6 +371,9 @@ interface NativeInputManagerService {
        @Override
        public native void toggleCapsLock(int deviceId);

        @Override
        public native void resetLockedModifierState();

        @Override
        public native void displayRemoved(int displayId);

Loading