Simplify IMMS#startVrInputMethodNoCheck a bit

This is a follow up CL to a recent CL [1] that added VR-IME support.

Currently, IMMS#startVrInputMethodNoCheck() internally calls
IMMS#setInputMethodEnabled(), which enforces the caller user ID check
and caller permission check for WRITE_SECURE_SETTINGS.

This appears to make sense for IMMS#startVrInputMethodNoCheck(), but
in reallity IMMS#startVrInputMethodNoCheck() always gets called on
non-binder system server thread hence those checks will never fail.

Note that such a call path is fine and not a security issue.  What this
CL tries to address is just replace IMMS#setInputMethodEnabledLocked()
to make it clear that IMMS allows such an operation for callers that
have RESTRICTED_VR_ACCESS is intentional.

To summarize, this CL just removes redundant operations and there
should be no visible behavior change.

 [1]: I1db7981b5198e7e203d4578cae7e5b6d20037d0d
      89a6c48a8b

Bug: 63037786
Test: compile
Change-Id: Iec43177bd698de6efa453d64ceafec3164538151
This commit is contained in:
Yohei Yukawa
2017-12-10 18:15:19 -08:00
parent 84321d87b9
commit 7a46c28d45

View File

@@ -889,7 +889,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
/**
* Start a VR InputMethod that matches IME with package name of {@param component}.
* Note: This method is called from {@link VrManager}.
* Note: This method is called from {@link android.app.VrManager}.
*/
private void startVrInputMethodNoCheck(@Nullable ComponentName component) {
if (component == null) {
@@ -903,7 +903,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
for (InputMethodInfo info : mMethodList) {
if (TextUtils.equals(info.getPackageName(), packageName) && info.isVrOnly()) {
// set this is as current inputMethod without updating settings.
setInputMethodEnabled(info.getId(), true);
setInputMethodEnabledLocked(info.getId(), true);
setInputMethodLocked(info.getId(), NOT_A_SUBTYPE_ID);
break;
}