Initial implementation of bug report dump

The first iteration is to mimic adb shell devic_config list command
output. Future designs are being debated and reasoned. The future design
would improve in the following categories:

(1) differentiate legacy flags and aconfig flags, and have two seperate
print out sections
(2) for aconfig flags, it will be sorted by feature name, or aconfig
package name

Bug: b/289197050
Test: adb shell dumpsys device_config
Change-Id: I1b70ef2ec03aaeefa64b05173a2fbbb668979705
This commit is contained in:
Dennis Shen
2023-07-05 17:06:01 +00:00
parent e24254dea0
commit 19d919a9f5

View File

@@ -75,6 +75,15 @@ public final class DeviceConfigService extends Binder {
}
}
@Override
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
final IContentProvider iprovider = mProvider.getIContentProvider();
pw.println("device config properties:");
for (String line : MyShellCommand.listAll(iprovider)) {
pw.println(line);
}
}
private void callUpdableDeviceConfigShellCommandHandler(FileDescriptor in, FileDescriptor out,
FileDescriptor err, String[] args, ResultReceiver resultReceiver) {
int result = -1;
@@ -111,6 +120,31 @@ public final class DeviceConfigService extends Binder {
mProvider = provider;
}
public static List<String> listAll(IContentProvider provider) {
final ArrayList<String> lines = new ArrayList<>();
try {
Bundle args = new Bundle();
args.putInt(Settings.CALL_METHOD_USER_KEY,
ActivityManager.getService().getCurrentUser().id);
Bundle b = provider.call(new AttributionSource(Process.myUid(),
resolveCallingPackage(), null), Settings.AUTHORITY,
Settings.CALL_METHOD_LIST_CONFIG, null, args);
if (b != null) {
Map<String, String> flagsToValues =
(HashMap) b.getSerializable(Settings.NameValueTable.VALUE);
for (String key : flagsToValues.keySet()) {
lines.add(key + "=" + flagsToValues.get(key));
}
}
Collections.sort(lines);
} catch (RemoteException e) {
throw new RuntimeException("Failed in IPC", e);
}
return lines;
}
@SuppressLint("AndroidFrameworkRequiresPermission")
@Override
public int onCommand(String cmd) {
@@ -391,31 +425,6 @@ public final class DeviceConfigService extends Binder {
return success;
}
private List<String> listAll(IContentProvider provider) {
final ArrayList<String> lines = new ArrayList<>();
try {
Bundle args = new Bundle();
args.putInt(Settings.CALL_METHOD_USER_KEY,
ActivityManager.getService().getCurrentUser().id);
Bundle b = provider.call(new AttributionSource(Process.myUid(),
resolveCallingPackage(), null), Settings.AUTHORITY,
Settings.CALL_METHOD_LIST_CONFIG, null, args);
if (b != null) {
Map<String, String> flagsToValues =
(HashMap) b.getSerializable(Settings.NameValueTable.VALUE);
for (String key : flagsToValues.keySet()) {
lines.add(key + "=" + flagsToValues.get(key));
}
}
Collections.sort(lines);
} catch (RemoteException e) {
throw new RuntimeException("Failed in IPC", e);
}
return lines;
}
private static String resolveCallingPackage() {
switch (Binder.getCallingUid()) {
case Process.ROOT_UID: {