Merge "Add shell command to trigger global action" into rvc-dev am: 18c1d27df9 am: 755ad932da am: 3d5533d7f1
Change-Id: I508359a20008cdd47f20188f289781e11a7d8297
This commit is contained in:
@@ -2732,7 +2732,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
|||||||
public void onShellCommand(FileDescriptor in, FileDescriptor out,
|
public void onShellCommand(FileDescriptor in, FileDescriptor out,
|
||||||
FileDescriptor err, String[] args, ShellCallback callback,
|
FileDescriptor err, String[] args, ShellCallback callback,
|
||||||
ResultReceiver resultReceiver) {
|
ResultReceiver resultReceiver) {
|
||||||
new AccessibilityShellCommand(this).exec(this, in, out, err, args,
|
new AccessibilityShellCommand(this, mSystemActionPerformer).exec(this, in, out, err, args,
|
||||||
callback, resultReceiver);
|
callback, resultReceiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ package com.android.server.accessibility;
|
|||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
|
import android.os.Binder;
|
||||||
|
import android.os.Process;
|
||||||
import android.os.ShellCommand;
|
import android.os.ShellCommand;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
|
|
||||||
@@ -28,9 +30,12 @@ import java.io.PrintWriter;
|
|||||||
*/
|
*/
|
||||||
final class AccessibilityShellCommand extends ShellCommand {
|
final class AccessibilityShellCommand extends ShellCommand {
|
||||||
final @NonNull AccessibilityManagerService mService;
|
final @NonNull AccessibilityManagerService mService;
|
||||||
|
final @NonNull SystemActionPerformer mSystemActionPerformer;
|
||||||
|
|
||||||
AccessibilityShellCommand(@NonNull AccessibilityManagerService service) {
|
AccessibilityShellCommand(@NonNull AccessibilityManagerService service,
|
||||||
|
@NonNull SystemActionPerformer systemActionPerformer) {
|
||||||
mService = service;
|
mService = service;
|
||||||
|
mSystemActionPerformer = systemActionPerformer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -45,6 +50,9 @@ final class AccessibilityShellCommand extends ShellCommand {
|
|||||||
case "set-bind-instant-service-allowed": {
|
case "set-bind-instant-service-allowed": {
|
||||||
return runSetBindInstantServiceAllowed();
|
return runSetBindInstantServiceAllowed();
|
||||||
}
|
}
|
||||||
|
case "call-system-action": {
|
||||||
|
return runCallSystemAction();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -74,6 +82,22 @@ final class AccessibilityShellCommand extends ShellCommand {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int runCallSystemAction() {
|
||||||
|
final int callingUid = Binder.getCallingUid();
|
||||||
|
if (callingUid != Process.ROOT_UID
|
||||||
|
&& callingUid != Process.SYSTEM_UID
|
||||||
|
&& callingUid != Process.SHELL_UID) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
final String option = getNextArg();
|
||||||
|
if (option != null) {
|
||||||
|
int actionId = Integer.parseInt(option);
|
||||||
|
mSystemActionPerformer.performSystemAction(actionId);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
private Integer parseUserId() {
|
private Integer parseUserId() {
|
||||||
final String option = getNextOption();
|
final String option = getNextOption();
|
||||||
if (option != null) {
|
if (option != null) {
|
||||||
@@ -97,5 +121,7 @@ final class AccessibilityShellCommand extends ShellCommand {
|
|||||||
pw.println(" Set whether binding to services provided by instant apps is allowed.");
|
pw.println(" Set whether binding to services provided by instant apps is allowed.");
|
||||||
pw.println(" get-bind-instant-service-allowed [--user <USER_ID>]");
|
pw.println(" get-bind-instant-service-allowed [--user <USER_ID>]");
|
||||||
pw.println(" Get whether binding to services provided by instant apps is allowed.");
|
pw.println(" Get whether binding to services provided by instant apps is allowed.");
|
||||||
|
pw.println(" call-system-action <ACTION_ID>");
|
||||||
|
pw.println(" Calls the system action with the given action id.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -305,6 +305,7 @@ public class SystemActionPerformer {
|
|||||||
sendDownAndUpKeyEvents(KeyEvent.KEYCODE_HEADSETHOOK);
|
sendDownAndUpKeyEvents(KeyEvent.KEYCODE_HEADSETHOOK);
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
|
Slog.e(TAG, "Invalid action id: " + actionId);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user