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

Commit 75cab555 authored by Antonio Kantek's avatar Antonio Kantek
Browse files

Silent touch mode permission check

Touch mode permission check is done in too phases:
  1. Checks if caller has MODIFY_TOUCH_MODE_STATE permission granted and/or
  2. Checks if caller owns the focused window.

Unnecessary log is produced when caller owns the focused window (2), but
don't have the permission granted (1). This CL fixes that by silently
checking if caller has the permission granted.

Fixes: 223330265
Test: atest WindowManagerServiceTests
Change-Id: I7f8d5c9cfb2df46e1f91fa4db634f7de12e66078
parent 1da7fdde
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -3776,7 +3776,8 @@ public class WindowManagerService extends IWindowManager.Stub
            final int uid = Binder.getCallingUid();
            final boolean hasPermission =
                    mAtmService.instrumentationSourceHasPermission(pid, MODIFY_TOUCH_MODE_STATE)
                            || checkCallingPermission(MODIFY_TOUCH_MODE_STATE, "setInTouchMode()");
                            || checkCallingPermission(MODIFY_TOUCH_MODE_STATE, "setInTouchMode()",
                                                      /* printlog= */ false);
            final long token = Binder.clearCallingIdentity();
            try {
                if (mInputManager.setInTouchMode(mode, pid, uid, hasPermission)) {
+2 −2
Original line number Diff line number Diff line
@@ -292,7 +292,7 @@ public class WindowManagerServiceTests extends WindowTestsBase {
        boolean currentTouchMode = mWm.getInTouchMode();
        int callingPid = Binder.getCallingPid();
        int callingUid = Binder.getCallingUid();
        doReturn(false).when(mWm).checkCallingPermission(anyString(), anyString());
        doReturn(false).when(mWm).checkCallingPermission(anyString(), anyString(), anyBoolean());
        when(mWm.mAtmService.instrumentationSourceHasPermission(callingPid,
                android.Manifest.permission.MODIFY_TOUCH_MODE_STATE)).thenReturn(true);

@@ -307,7 +307,7 @@ public class WindowManagerServiceTests extends WindowTestsBase {
        boolean currentTouchMode = mWm.getInTouchMode();
        int callingPid = Binder.getCallingPid();
        int callingUid = Binder.getCallingUid();
        doReturn(false).when(mWm).checkCallingPermission(anyString(), anyString());
        doReturn(false).when(mWm).checkCallingPermission(anyString(), anyString(), anyBoolean());
        when(mWm.mAtmService.instrumentationSourceHasPermission(callingPid,
                android.Manifest.permission.MODIFY_TOUCH_MODE_STATE)).thenReturn(false);