Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 19d919a9 authored by Dennis Shen's avatar Dennis Shen
Browse files

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
parent e24254de
Loading
Loading
Loading
Loading
+34 −25
Original line number Original line Diff line number Diff line
@@ -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,
    private void callUpdableDeviceConfigShellCommandHandler(FileDescriptor in, FileDescriptor out,
            FileDescriptor err, String[] args, ResultReceiver resultReceiver) {
            FileDescriptor err, String[] args, ResultReceiver resultReceiver) {
        int result = -1;
        int result = -1;
@@ -111,6 +120,31 @@ public final class DeviceConfigService extends Binder {
            mProvider = provider;
            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")
        @SuppressLint("AndroidFrameworkRequiresPermission")
        @Override
        @Override
        public int onCommand(String cmd) {
        public int onCommand(String cmd) {
@@ -391,31 +425,6 @@ public final class DeviceConfigService extends Binder {
            return success;
            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() {
        private static String resolveCallingPackage() {
            switch (Binder.getCallingUid()) {
            switch (Binder.getCallingUid()) {
                case Process.ROOT_UID: {
                case Process.ROOT_UID: {