Clarify shell/root users also have DUMP permission

This is a follow up CL to my previous CL [1], which aimed to
streamline and centralize when and how caller verifications are
performed inside InputMethodManagerService#onShellCommand().

The goal of this change is just to make it clear that shell/root users
also have DUMP permission.  There should be no behavior change as long
as those users have DUMP permission because IMMS#onShellCommand() is
already locked down to accept IPCs only from these two UIDs [2].

The point is that ShellCommand#handleDefaultCommands() by default
dispatches 'dump' command to Binder#doDump() method.  Thus it would
make sense to clarify that DUMP permission is also granted to
shell/root users for completeness.

 [1]: I6fd47b5cc1e7da7222774df20247a2c69a70f45b
      db25df71be
 [2]: If87189563ccaacd4f9c666bab4f9ad08a9343084
      b8d240fa3f

Bug: 34886274
Test: 'adb shell cmd input_method dump' still work
Change-Id: If91137e0c144d90ac3046f30607e36bb957a7e0e
This commit is contained in:
Yohei Yukawa
2018-12-28 17:23:29 -08:00
parent 80c7a3f55f
commit 8a2b96bb0a

View File

@@ -4624,17 +4624,20 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
}
@RequiresPermission(allOf = {
Manifest.permission.DUMP,
Manifest.permission.INTERACT_ACROSS_USERS_FULL,
Manifest.permission.WRITE_SECURE_SETTINGS,
Manifest.permission.INTERACT_ACROSS_USERS_FULL})
})
@BinderThread
@ShellCommandResult
@Override
public int onCommand(@Nullable String cmd) {
// For shell command, require all the permissions here in favor of code simplicity.
mService.mContext.enforceCallingPermission(
Manifest.permission.INTERACT_ACROSS_USERS_FULL, null);
mService.mContext.enforceCallingPermission(
Manifest.permission.WRITE_SECURE_SETTINGS, null);
Arrays.asList(
Manifest.permission.DUMP,
Manifest.permission.INTERACT_ACROSS_USERS_FULL,
Manifest.permission.WRITE_SECURE_SETTINGS
).forEach(permission -> mService.mContext.enforceCallingPermission(permission, null));
final long identity = Binder.clearCallingIdentity();
try {