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

Commit cba800ef authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Require TEST_INPUT_METHOD instead in IMM#addVirtualStylusIdForTestSession()

This is a follow up CL to our previous CL [1], which introduced an @TestApi

  InputMethodManager#addVirtualStylusIdForTestSession(),

which internally requires INJECT_EVENTS permission.

Now that TEST_INPUT_METHOD is also available [2], let's require it
instead of INJECT_EVENTS for better consistency with other test APIs
defined in InputMethodManager.

This CL also add @RequiresPermission(TEST_INPUT_METHOD) to

  InputMethodManager#addVirtualStylusIdForTestSession()

to make it clear that it's guarded with the permission.

 [1]: I7399c0a56c04f024d65c16d459818cc2c5cdbc7f
      d96ef57b
 [2]: Ie79a3e9d41ce22605ae083594d639c37d08b7def
      b869c783

Bug: 256239860
Test: atest CtsInputMethodTestCases:StylusHandwritingTest
Change-Id: Icdbb4ade2bd4b5066984e209efcf0ca93bfa08ca
parent 89d683f2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3157,7 +3157,7 @@ package android.view.inputmethod {
  }

  public final class InputMethodManager {
    method public void addVirtualStylusIdForTestSession();
    method @RequiresPermission(android.Manifest.permission.TEST_INPUT_METHOD) public void addVirtualStylusIdForTestSession();
    method public int getDisplayId();
    method @NonNull @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) public java.util.List<android.view.inputmethod.InputMethodInfo> getInputMethodListAsUser(int);
    method public boolean hasActiveInputConnection(@Nullable android.view.View);
+1 −0
Original line number Diff line number Diff line
@@ -489,6 +489,7 @@ final class IInputMethodManagerGlobalInvoker {
    }

    @AnyThread
    @RequiresPermission(Manifest.permission.TEST_INPUT_METHOD)
    static void addVirtualStylusIdForTestSession(IInputMethodClient client) {
        final IInputMethodManager service = getService();
        if (service == null) {
+1 −0
Original line number Diff line number Diff line
@@ -2590,6 +2590,7 @@ public final class InputMethodManager {
     * @hide
     */
    @TestApi
    @RequiresPermission(Manifest.permission.TEST_INPUT_METHOD)
    public void addVirtualStylusIdForTestSession() {
        synchronized (mH) {
            IInputMethodManagerGlobalInvoker.addVirtualStylusIdForTestSession(mClient);
+2 −2
Original line number Diff line number Diff line
@@ -147,9 +147,9 @@ interface IInputMethodManager {
    boolean isStylusHandwritingAvailableAsUser(int userId);

    /** add virtual stylus id for test Stylus handwriting session **/
    @EnforcePermission("INJECT_EVENTS")
    @EnforcePermission("TEST_INPUT_METHOD")
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
            + "android.Manifest.permission.INJECT_EVENTS)")
            + "android.Manifest.permission.TEST_INPUT_METHOD)")
    void addVirtualStylusIdForTestSession(in IInputMethodClient client);

    /** Set a stylus idle-timeout after which handwriting {@code InkWindow} will be removed. */
+1 −1
Original line number Diff line number Diff line
@@ -4382,7 +4382,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
     * a stylus deviceId is not already registered on device.
     */
    @BinderThread
    @EnforcePermission(Manifest.permission.INJECT_EVENTS)
    @EnforcePermission(Manifest.permission.TEST_INPUT_METHOD)
    @Override
    public void addVirtualStylusIdForTestSession(IInputMethodClient client) {
        int uid = Binder.getCallingUid();