Add "am capabilities" for tools probling
There is no way to know which command/flags are supported in am. This CL adds a "capability" command which allows to probe programatically. Test: NA Bug: 265460189 Change-Id: If50269251a6907968e7c8afe10bf873f25338b91
This commit is contained in:
@@ -3,3 +3,4 @@ per-file wifi.proto = file:/wifi/OWNERS
|
||||
per-file camera.proto = file:/services/core/java/com/android/server/camera/OWNERS
|
||||
per-file system_messages.proto = file:/core/res/OWNERS
|
||||
per-file altitude.proto = file:/location/OWNERS
|
||||
per-file am_capabilities.proto = rpaquay@google.com, sanglardf@google.com
|
||||
|
||||
12
proto/src/am_capabilities.proto
Normal file
12
proto/src/am_capabilities.proto
Normal file
@@ -0,0 +1,12 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package com.android.server.am;
|
||||
option java_multiple_files = true;
|
||||
|
||||
message Capability {
|
||||
string name = 1;
|
||||
}
|
||||
|
||||
message Capabilities {
|
||||
repeated Capability values = 1;
|
||||
}
|
||||
@@ -114,6 +114,8 @@ import android.window.SplashScreen;
|
||||
import com.android.internal.compat.CompatibilityChangeConfig;
|
||||
import com.android.internal.util.MemInfoReader;
|
||||
import com.android.server.am.LowMemDetector.MemFactor;
|
||||
import com.android.server.am.nano.Capabilities;
|
||||
import com.android.server.am.nano.Capability;
|
||||
import com.android.server.compat.PlatformCompat;
|
||||
import com.android.server.utils.Slogf;
|
||||
|
||||
@@ -197,6 +199,9 @@ final class ActivityManagerShellCommand extends ShellCommand {
|
||||
|
||||
final boolean mDumping;
|
||||
|
||||
private static final String[] CAPABILITIES = {"start.suspend"};
|
||||
|
||||
|
||||
ActivityManagerShellCommand(ActivityManagerService service, boolean dumping) {
|
||||
mInterface = service;
|
||||
mTaskInterface = service.mActivityTaskManager;
|
||||
@@ -378,6 +383,8 @@ final class ActivityManagerShellCommand extends ShellCommand {
|
||||
return runListDisplaysForStartingUsers(pw);
|
||||
case "set-foreground-service-delegate":
|
||||
return runSetForegroundServiceDelegate(pw);
|
||||
case "capabilities":
|
||||
return runCapabilities(pw);
|
||||
default:
|
||||
return handleDefaultCommands(cmd);
|
||||
}
|
||||
@@ -387,6 +394,46 @@ final class ActivityManagerShellCommand extends ShellCommand {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int runCapabilities(PrintWriter pw) throws RemoteException {
|
||||
final PrintWriter err = getErrPrintWriter();
|
||||
boolean outputAsProtobuf = false;
|
||||
|
||||
String opt;
|
||||
while ((opt = getNextOption()) != null) {
|
||||
if (opt.equals("--protobuf")) {
|
||||
outputAsProtobuf = true;
|
||||
} else {
|
||||
err.println("Error: Unknown option: " + opt);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (outputAsProtobuf) {
|
||||
Capabilities capabilities = new Capabilities();
|
||||
capabilities.values = new Capability[CAPABILITIES.length];
|
||||
for (int i = 0; i < CAPABILITIES.length; i++) {
|
||||
Capability cap = new Capability();
|
||||
cap.name = CAPABILITIES[i];
|
||||
capabilities.values[i] = cap;
|
||||
}
|
||||
|
||||
try {
|
||||
getRawOutputStream().write(Capabilities.toByteArray(capabilities));
|
||||
} catch (IOException e) {
|
||||
pw.println("Error while serializing capabilities protobuffer");
|
||||
}
|
||||
|
||||
} else {
|
||||
// Unfortunately we don't have protobuf text format capabilities here.
|
||||
// Fallback to line separated list instead for text parser.
|
||||
pw.println("Format: 1");
|
||||
for (String capability : CAPABILITIES) {
|
||||
pw.println(capability);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private Intent makeIntent(int defUser) throws URISyntaxException {
|
||||
mStartFlags = 0;
|
||||
mWaitOption = false;
|
||||
@@ -4135,6 +4182,9 @@ final class ActivityManagerShellCommand extends ShellCommand {
|
||||
pw.println(" Start ignoring delivery group policy set for a broadcast action");
|
||||
pw.println(" clear-ignore-delivery-group-policy <ACTION>");
|
||||
pw.println(" Stop ignoring delivery group policy set for a broadcast action");
|
||||
pw.println(" capabilities [--protobuf]");
|
||||
pw.println(" Output am supported features (text format). Options are:");
|
||||
pw.println(" --protobuf: format output using protobuffer");
|
||||
Intent.printIntentArgsHelp(pw, "");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user