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
This commit is contained in:
Antonio Kantek
2022-03-18 16:36:43 -07:00
parent 1da7fdde5e
commit 75cab555c5
2 changed files with 4 additions and 3 deletions

View File

@@ -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)) {

View File

@@ -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);