Use @EnforcePermission for IIMM#isInputMethodPickerShownForTest()

This is a follow up CL to my previous CL [1], which locked down

  IInputMethodManager#isInputMethodPickerShownForTest()

with

  android.Manifest.permission.TEST_INPUT_METHOD

permission.

After the original CL was committed the severity assessment was
performed again and in the updated assessment it was concluded that
denial logging was not necessary.  With that, this CL simplifies the
logic by using

  @EnforcePermission

annotation in the ADIL method definition.

Note that there must be no developer-observable behavior change in
this CL, and the security test that was added as part of the original
effort [2] still verifies that the method in question is indeed
guarded with "TEST_INPUT_METHOD" permission.

 [1]: Ie79a3e9d41ce22605ae083594d639c37d08b7def
      b869c78380
 [2]: Idf907e3b762307696a3a7ca11470b0c44b9b7aa4
      3e1dd9d2797f818766105247e3634da525fec8e8

Bug: 237317525
Test: atest CtsInputMethodTestCases:InputMethodManagerTest#testIsInputMethodPickerShownProtection
Change-Id: Ib3f56b1ab1538742a2bf64fec435ced5b8f90bc2
This commit is contained in:
Yohei Yukawa
2022-10-03 15:54:37 -07:00
parent 10b858c39f
commit aa29be8dda
2 changed files with 2 additions and 15 deletions

View File

@@ -84,6 +84,7 @@ interface IInputMethodManager {
void showInputMethodPickerFromSystem(in IInputMethodClient client,
int auxiliarySubtypeMode, int displayId);
@EnforcePermission("TEST_INPUT_METHOD")
@JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
+ "android.Manifest.permission.TEST_INPUT_METHOD)")
boolean isInputMethodPickerShownForTest();

View File

@@ -298,8 +298,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
final IWindowManager mIWindowManager;
private final SparseBooleanArray mLoggedDeniedGetInputMethodWindowVisibleHeightForUid =
new SparseBooleanArray(0);
private final SparseBooleanArray mLoggedDeniedIsInputMethodPickerShownForTestForUid =
new SparseBooleanArray(0);
final WindowManagerInternal mWindowManagerInternal;
final PackageManagerInternal mPackageManagerInternal;
final InputManagerInternal mInputManagerInternal;
@@ -1479,7 +1477,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
public void onUidRemoved(int uid) {
synchronized (ImfLock.class) {
mLoggedDeniedGetInputMethodWindowVisibleHeightForUid.delete(uid);
mLoggedDeniedIsInputMethodPickerShownForTestForUid.delete(uid);
}
}
@@ -4002,19 +3999,8 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
/**
* A test API for CTS to make sure that the input method menu is showing.
*/
@EnforcePermission(Manifest.permission.TEST_INPUT_METHOD)
public boolean isInputMethodPickerShownForTest() {
if (mContext.checkCallingPermission(android.Manifest.permission.TEST_INPUT_METHOD)
!= PackageManager.PERMISSION_GRANTED) {
final int callingUid = Binder.getCallingUid();
synchronized (ImfLock.class) {
if (!mLoggedDeniedIsInputMethodPickerShownForTestForUid.get(callingUid)) {
EventLog.writeEvent(0x534e4554, "237317525", callingUid, "");
mLoggedDeniedIsInputMethodPickerShownForTestForUid.put(callingUid, true);
}
}
throw new SecurityException(
"isInputMethodPickerShownForTest requires TEST_INPUT_METHOD permission");
}
synchronized (ImfLock.class) {
return mMenuController.isisInputMethodPickerShownForTestLocked();
}