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

Commit 3eda9799 authored by Dan Egnor's avatar Dan Egnor
Browse files

Add Debug.dumpService(), a public method for "dumpsys" functionality

parent e879e4b9
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -114301,6 +114301,23 @@
<exception name="IOException" type="java.io.IOException">
</exception>
</method>
<method name="dumpService"
 return="boolean"
 abstract="false"
 native="false"
 synchronized="false"
 static="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="name" type="java.lang.String">
</parameter>
<parameter name="fd" type="java.io.FileDescriptor">
</parameter>
<parameter name="args" type="java.lang.String[]">
</parameter>
</method>
<method name="enableEmulatorTraceOutput"
 return="void"
 abstract="false"
+30 −1
Original line number Diff line number Diff line
@@ -57,6 +57,8 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo
 */
public final class Debug
{
    private static final String TAG = "Debug";

    /**
     * Flags for startMethodTracing().  These can be ORed together.
     *
@@ -1111,7 +1113,7 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo
                }
            }
        } else {
            Log.w("android.os.Debug",
            Log.wtf(TAG,
                  "setFieldsOn(" + (cl == null ? "null" : cl.getName()) +
                  ") called in non-DEBUG build");
        }
@@ -1127,4 +1129,31 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo
    @Retention(RetentionPolicy.RUNTIME)
    public @interface DebugProperty {
    }

    /**
     * Get a debugging dump of a system service by name.
     *
     * <p>Most services require the caller to hold android.permission.DUMP.
     *
     * @param name of the service to dump
     * @param fd to write dump output to (usually an output log file)
     * @param args to pass to the service's dump method, may be null
     * @return true if the service was dumped successfully, false if
     *     the service could not be found or had an error while dumping
     */
    public static boolean dumpService(String name, FileDescriptor fd, String[] args) {
        IBinder service = ServiceManager.getService(name);
        if (service == null) {
            Log.e(TAG, "Can't find service to dump: " + name);
            return false;
        }

        try {
            service.dump(fd, args);
            return true;
        } catch (RemoteException e) {
            Log.e(TAG, "Can't dump service: " + name, e);
            return false;
        }
    }
}