Use @EnforcePermission for IIMM#showInputMethodPickerFromSystem()

This CL manually migrates

  IInputMethodManager#showInputMethodPickerFromSystem(boolean, int)

from manual permission check with

  Context#checkCallingPermission(WRITE_SECURE_SETTINGS)

to code-generation check with

  @EnforcePermission("WRITE_SECURE_SETTINGS").

There should be no observable semantic behavior change in this CL.

Bug: 34886274
Bug: 232058525
Bug: 237316307
Test: manually verified that SecurityException is thrown
Change-Id: I9d1be1aa65276fcc50c2868fed6b0447d54ff7ee
This commit is contained in:
Yohei Yukawa
2022-07-15 17:24:47 -07:00
parent 843d7085d5
commit f2e9812cfe
2 changed files with 2 additions and 6 deletions

View File

@@ -76,6 +76,7 @@ interface IInputMethodManager {
void showInputMethodPickerFromClient(in IInputMethodClient client,
int auxiliarySubtypeMode);
@EnforcePermission("WRITE_SECURE_SETTINGS")
@JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
+ "android.Manifest.permission.WRITE_SECURE_SETTINGS)")
void showInputMethodPickerFromSystem(in IInputMethodClient client,

View File

@@ -3993,15 +3993,10 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
}
}
@EnforcePermission(Manifest.permission.WRITE_SECURE_SETTINGS)
@Override
public void showInputMethodPickerFromSystem(IInputMethodClient client, int auxiliarySubtypeMode,
int displayId) {
if (mContext.checkCallingPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS)
!= PackageManager.PERMISSION_GRANTED) {
throw new SecurityException(
"showInputMethodPickerFromSystem requires WRITE_SECURE_SETTINGS "
+ "permission");
}
// Always call subtype picker, because subtype picker is a superset of input method
// picker.
mHandler.obtainMessage(MSG_SHOW_IM_SUBTYPE_PICKER, auxiliarySubtypeMode, displayId)