From 19d919a9f5ac6ac6b982ff37a4ddb54cda3ac430 Mon Sep 17 00:00:00 2001 From: Dennis Shen Date: Wed, 5 Jul 2023 17:06:01 +0000 Subject: [PATCH] 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 --- .../settings/DeviceConfigService.java | 59 +++++++++++-------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DeviceConfigService.java b/packages/SettingsProvider/src/com/android/providers/settings/DeviceConfigService.java index 657d691defb4e..00f2d0e475ff6 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/DeviceConfigService.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/DeviceConfigService.java @@ -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 listAll(IContentProvider provider) { + final ArrayList 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 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 listAll(IContentProvider provider) { - final ArrayList 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 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: {