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

Commit 92a8b22e authored by Siva Velusamy's avatar Siva Velusamy
Browse files

ActivityManager: add option to allow OpenGL trace.

This patch adds an option to enable tracing of OpenGL functions.
OpenGL tracing can be enabled by passing "--opengl-trace" option
to am start.  This option requires either a device in debug mode,
or that the application itself has debug permission set.

Change-Id: I77788bfe97c9108943b1f947ce81afe8293d78a0
parent 64d10a1d
Loading
Loading
Loading
Loading
+12 −4
Original line number Original line Diff line number Diff line
@@ -61,6 +61,8 @@ public class Am {
    private boolean mWaitOption = false;
    private boolean mWaitOption = false;
    private boolean mStopOption = false;
    private boolean mStopOption = false;


    private boolean mOpenglTraceOption = false;

    private int mRepeat = 0;
    private int mRepeat = 0;


    private String mProfileFile;
    private String mProfileFile;
@@ -151,6 +153,7 @@ public class Am {
        mDebugOption = false;
        mDebugOption = false;
        mWaitOption = false;
        mWaitOption = false;
        mStopOption = false;
        mStopOption = false;
        mOpenglTraceOption = false;
        mRepeat = 0;
        mRepeat = 0;
        mProfileFile = null;
        mProfileFile = null;
        Uri data = null;
        Uri data = null;
@@ -307,6 +310,8 @@ public class Am {
                mRepeat = Integer.parseInt(nextArgRequired());
                mRepeat = Integer.parseInt(nextArgRequired());
            } else if (opt.equals("-S")) {
            } else if (opt.equals("-S")) {
                mStopOption = true;
                mStopOption = true;
            } else if (opt.equals("--opengl-trace")) {
                mOpenglTraceOption = true;
            } else {
            } else {
                System.err.println("Error: Unknown option: " + opt);
                System.err.println("Error: Unknown option: " + opt);
                showUsage();
                showUsage();
@@ -445,12 +450,14 @@ public class Am {
            int res;
            int res;
            if (mWaitOption) {
            if (mWaitOption) {
                result = mAm.startActivityAndWait(null, intent, mimeType,
                result = mAm.startActivityAndWait(null, intent, mimeType,
                            null, 0, null, null, 0, false, mDebugOption,
                            null, 0, null, null, 0, false,
                            mDebugOption, mOpenglTraceOption,
                            mProfileFile, fd, mProfileAutoStop);
                            mProfileFile, fd, mProfileAutoStop);
                res = result.result;
                res = result.result;
            } else {
            } else {
                res = mAm.startActivity(null, intent, mimeType,
                res = mAm.startActivity(null, intent, mimeType,
                        null, 0, null, null, 0, false, mDebugOption,
                        null, 0, null, null, 0, false,
                        mDebugOption, mOpenglTraceOption,
                        mProfileFile, fd, mProfileAutoStop);
                        mProfileFile, fd, mProfileAutoStop);
            }
            }
            PrintStream out = mWaitOption ? System.out : System.err;
            PrintStream out = mWaitOption ? System.out : System.err;
@@ -1277,7 +1284,7 @@ public class Am {
        System.err.println(
        System.err.println(
                "usage: am [subcommand] [options]\n" +
                "usage: am [subcommand] [options]\n" +
                "usage: am start [-D] [-W] [-P <FILE>] [--start-profiler <FILE>]\n" +
                "usage: am start [-D] [-W] [-P <FILE>] [--start-profiler <FILE>]\n" +
                "               [--R COUNT] [-S] <INTENT>\n" +
                "               [--R COUNT] [-S] [--opengl-trace] <INTENT>\n" +
                "       am startservice <INTENT>\n" +
                "       am startservice <INTENT>\n" +
                "       am force-stop <PACKAGE>\n" +
                "       am force-stop <PACKAGE>\n" +
                "       am kill <PACKAGE>\n" +
                "       am kill <PACKAGE>\n" +
@@ -1304,6 +1311,7 @@ public class Am {
                "    -R: repeat the activity launch <COUNT> times.  Prior to each repeat,\n" +
                "    -R: repeat the activity launch <COUNT> times.  Prior to each repeat,\n" +
                "        the top activity will be finished.\n" +
                "        the top activity will be finished.\n" +
                "    -S: force stop the target app before starting the activity\n" +
                "    -S: force stop the target app before starting the activity\n" +
                "    --opengl-trace: enable tracing of OpenGL functions\n" +
                "\n" +
                "\n" +
                "am startservice: start a Service.\n" +
                "am startservice: start a Service.\n" +
                "\n" +
                "\n" +
+5 −6
Original line number Original line Diff line number Diff line
@@ -3388,11 +3388,10 @@ public class Activity extends ContextThemeWrapper
                intent.setAllowFds(false);
                intent.setAllowFds(false);
                result = ActivityManagerNative.getDefault()
                result = ActivityManagerNative.getDefault()
                    .startActivity(mMainThread.getApplicationThread(),
                    .startActivity(mMainThread.getApplicationThread(),
                            intent, intent.resolveTypeIfNeeded(
                            intent, intent.resolveTypeIfNeeded(getContentResolver()),
                                    getContentResolver()),
                            null, 0,
                            null, 0,
                            mToken, mEmbeddedID, requestCode, true, false,
                            mToken, mEmbeddedID, requestCode, true /* onlyIfNeeded */,
                            null, null, false);
                            false, false, null, null, false);
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                // Empty
                // Empty
            }
            }
+14 −8
Original line number Original line Diff line number Diff line
@@ -124,13 +124,15 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            int requestCode = data.readInt();
            int requestCode = data.readInt();
            boolean onlyIfNeeded = data.readInt() != 0;
            boolean onlyIfNeeded = data.readInt() != 0;
            boolean debug = data.readInt() != 0;
            boolean debug = data.readInt() != 0;
            boolean openglTrace = data.readInt() != 0;
            String profileFile = data.readString();
            String profileFile = data.readString();
            ParcelFileDescriptor profileFd = data.readInt() != 0
            ParcelFileDescriptor profileFd = data.readInt() != 0
                    ? data.readFileDescriptor() : null;
                    ? data.readFileDescriptor() : null;
            boolean autoStopProfiler = data.readInt() != 0;
            boolean autoStopProfiler = data.readInt() != 0;
            int result = startActivity(app, intent, resolvedType,
            int result = startActivity(app, intent, resolvedType,
                    grantedUriPermissions, grantedMode, resultTo, resultWho,
                    grantedUriPermissions, grantedMode, resultTo, resultWho,
                    requestCode, onlyIfNeeded, debug, profileFile, profileFd, autoStopProfiler);
                    requestCode, onlyIfNeeded, debug, openglTrace,
                    profileFile, profileFd, autoStopProfiler);
            reply.writeNoException();
            reply.writeNoException();
            reply.writeInt(result);
            reply.writeInt(result);
            return true;
            return true;
@@ -150,13 +152,15 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            int requestCode = data.readInt();
            int requestCode = data.readInt();
            boolean onlyIfNeeded = data.readInt() != 0;
            boolean onlyIfNeeded = data.readInt() != 0;
            boolean debug = data.readInt() != 0;
            boolean debug = data.readInt() != 0;
            boolean openglTrace = data.readInt() != 0;
            String profileFile = data.readString();
            String profileFile = data.readString();
            ParcelFileDescriptor profileFd = data.readInt() != 0
            ParcelFileDescriptor profileFd = data.readInt() != 0
                    ? data.readFileDescriptor() : null;
                    ? data.readFileDescriptor() : null;
            boolean autoStopProfiler = data.readInt() != 0;
            boolean autoStopProfiler = data.readInt() != 0;
            WaitResult result = startActivityAndWait(app, intent, resolvedType,
            WaitResult result = startActivityAndWait(app, intent, resolvedType,
                    grantedUriPermissions, grantedMode, resultTo, resultWho,
                    grantedUriPermissions, grantedMode, resultTo, resultWho,
                    requestCode, onlyIfNeeded, debug, profileFile, profileFd, autoStopProfiler);
                    requestCode, onlyIfNeeded, debug, openglTrace,
                    profileFile, profileFd, autoStopProfiler);
            reply.writeNoException();
            reply.writeNoException();
            result.writeToParcel(reply, 0);
            result.writeToParcel(reply, 0);
            return true;
            return true;
@@ -1617,7 +1621,7 @@ class ActivityManagerProxy implements IActivityManager
            String resolvedType, Uri[] grantedUriPermissions, int grantedMode,
            String resolvedType, Uri[] grantedUriPermissions, int grantedMode,
            IBinder resultTo, String resultWho,
            IBinder resultTo, String resultWho,
            int requestCode, boolean onlyIfNeeded,
            int requestCode, boolean onlyIfNeeded,
            boolean debug, String profileFile, ParcelFileDescriptor profileFd,
            boolean debug, boolean openglTrace, String profileFile, ParcelFileDescriptor profileFd,
            boolean autoStopProfiler) throws RemoteException {
            boolean autoStopProfiler) throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        Parcel reply = Parcel.obtain();
@@ -1632,6 +1636,7 @@ class ActivityManagerProxy implements IActivityManager
        data.writeInt(requestCode);
        data.writeInt(requestCode);
        data.writeInt(onlyIfNeeded ? 1 : 0);
        data.writeInt(onlyIfNeeded ? 1 : 0);
        data.writeInt(debug ? 1 : 0);
        data.writeInt(debug ? 1 : 0);
        data.writeInt(openglTrace ? 1 : 0);
        data.writeString(profileFile);
        data.writeString(profileFile);
        if (profileFd != null) {
        if (profileFd != null) {
            data.writeInt(1);
            data.writeInt(1);
@@ -1651,7 +1656,7 @@ class ActivityManagerProxy implements IActivityManager
            String resolvedType, Uri[] grantedUriPermissions, int grantedMode,
            String resolvedType, Uri[] grantedUriPermissions, int grantedMode,
            IBinder resultTo, String resultWho,
            IBinder resultTo, String resultWho,
            int requestCode, boolean onlyIfNeeded,
            int requestCode, boolean onlyIfNeeded,
            boolean debug, String profileFile, ParcelFileDescriptor profileFd,
            boolean debug, boolean openglTrace, String profileFile, ParcelFileDescriptor profileFd,
            boolean autoStopProfiler) throws RemoteException {
            boolean autoStopProfiler) throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        Parcel reply = Parcel.obtain();
@@ -1666,6 +1671,7 @@ class ActivityManagerProxy implements IActivityManager
        data.writeInt(requestCode);
        data.writeInt(requestCode);
        data.writeInt(onlyIfNeeded ? 1 : 0);
        data.writeInt(onlyIfNeeded ? 1 : 0);
        data.writeInt(debug ? 1 : 0);
        data.writeInt(debug ? 1 : 0);
        data.writeInt(openglTrace ? 1 : 0);
        data.writeString(profileFile);
        data.writeString(profileFile);
        if (profileFd != null) {
        if (profileFd != null) {
            data.writeInt(1);
            data.writeInt(1);
+9 −2
Original line number Original line Diff line number Diff line
@@ -376,6 +376,7 @@ public final class ActivityThread {
        Bundle instrumentationArgs;
        Bundle instrumentationArgs;
        IInstrumentationWatcher instrumentationWatcher;
        IInstrumentationWatcher instrumentationWatcher;
        int debugMode;
        int debugMode;
        boolean enableOpenGlTrace;
        boolean restrictedBackupMode;
        boolean restrictedBackupMode;
        boolean persistent;
        boolean persistent;
        Configuration config;
        Configuration config;
@@ -676,8 +677,8 @@ public final class ActivityThread {
                ComponentName instrumentationName, String profileFile,
                ComponentName instrumentationName, String profileFile,
                ParcelFileDescriptor profileFd, boolean autoStopProfiler,
                ParcelFileDescriptor profileFd, boolean autoStopProfiler,
                Bundle instrumentationArgs, IInstrumentationWatcher instrumentationWatcher,
                Bundle instrumentationArgs, IInstrumentationWatcher instrumentationWatcher,
                int debugMode, boolean isRestrictedBackupMode, boolean persistent,
                int debugMode, boolean enableOpenGlTrace, boolean isRestrictedBackupMode,
                Configuration config, CompatibilityInfo compatInfo,
                boolean persistent, Configuration config, CompatibilityInfo compatInfo,
                Map<String, IBinder> services, Bundle coreSettings) {
                Map<String, IBinder> services, Bundle coreSettings) {


            if (services != null) {
            if (services != null) {
@@ -695,6 +696,7 @@ public final class ActivityThread {
            data.instrumentationArgs = instrumentationArgs;
            data.instrumentationArgs = instrumentationArgs;
            data.instrumentationWatcher = instrumentationWatcher;
            data.instrumentationWatcher = instrumentationWatcher;
            data.debugMode = debugMode;
            data.debugMode = debugMode;
            data.enableOpenGlTrace = enableOpenGlTrace;
            data.restrictedBackupMode = isRestrictedBackupMode;
            data.restrictedBackupMode = isRestrictedBackupMode;
            data.persistent = persistent;
            data.persistent = persistent;
            data.config = config;
            data.config = config;
@@ -3912,6 +3914,11 @@ public final class ActivityThread {
            }
            }
        }
        }


        // Enable OpenGL tracing if required
        if (data.enableOpenGlTrace) {
            GLUtils.enableTracing();
        }

        /**
        /**
         * Initialize the default http proxy in this process for the reasons we set the time zone.
         * Initialize the default http proxy in this process for the reasons we set the time zone.
         */
         */
+8 −5
Original line number Original line Diff line number Diff line
@@ -267,6 +267,7 @@ public abstract class ApplicationThreadNative extends Binder
            IBinder binder = data.readStrongBinder();
            IBinder binder = data.readStrongBinder();
            IInstrumentationWatcher testWatcher = IInstrumentationWatcher.Stub.asInterface(binder);
            IInstrumentationWatcher testWatcher = IInstrumentationWatcher.Stub.asInterface(binder);
            int testMode = data.readInt();
            int testMode = data.readInt();
            boolean openGlTrace = data.readInt() != 0;
            boolean restrictedBackupMode = (data.readInt() != 0);
            boolean restrictedBackupMode = (data.readInt() != 0);
            boolean persistent = (data.readInt() != 0);
            boolean persistent = (data.readInt() != 0);
            Configuration config = Configuration.CREATOR.createFromParcel(data);
            Configuration config = Configuration.CREATOR.createFromParcel(data);
@@ -275,8 +276,8 @@ public abstract class ApplicationThreadNative extends Binder
            Bundle coreSettings = data.readBundle();
            Bundle coreSettings = data.readBundle();
            bindApplication(packageName, info,
            bindApplication(packageName, info,
                            providers, testName, profileName, profileFd, autoStopProfiler,
                            providers, testName, profileName, profileFd, autoStopProfiler,
                            testArgs, testWatcher, testMode, restrictedBackupMode, persistent,
                            testArgs, testWatcher, testMode, openGlTrace, restrictedBackupMode,
                            config, compatInfo, services, coreSettings);
                            persistent, config, compatInfo, services, coreSettings);
            return true;
            return true;
        }
        }


@@ -849,8 +850,9 @@ class ApplicationThreadProxy implements IApplicationThread {
    public final void bindApplication(String packageName, ApplicationInfo info,
    public final void bindApplication(String packageName, ApplicationInfo info,
            List<ProviderInfo> providers, ComponentName testName, String profileName,
            List<ProviderInfo> providers, ComponentName testName, String profileName,
            ParcelFileDescriptor profileFd, boolean autoStopProfiler, Bundle testArgs,
            ParcelFileDescriptor profileFd, boolean autoStopProfiler, Bundle testArgs,
            IInstrumentationWatcher testWatcher, int debugMode, boolean restrictedBackupMode,
            IInstrumentationWatcher testWatcher, int debugMode, boolean openGlTrace,
            boolean persistent, Configuration config, CompatibilityInfo compatInfo,
            boolean restrictedBackupMode, boolean persistent,
            Configuration config, CompatibilityInfo compatInfo,
            Map<String, IBinder> services, Bundle coreSettings) throws RemoteException {
            Map<String, IBinder> services, Bundle coreSettings) throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel data = Parcel.obtain();
        data.writeInterfaceToken(IApplicationThread.descriptor);
        data.writeInterfaceToken(IApplicationThread.descriptor);
@@ -874,6 +876,7 @@ class ApplicationThreadProxy implements IApplicationThread {
        data.writeBundle(testArgs);
        data.writeBundle(testArgs);
        data.writeStrongInterface(testWatcher);
        data.writeStrongInterface(testWatcher);
        data.writeInt(debugMode);
        data.writeInt(debugMode);
        data.writeInt(openGlTrace ? 1 : 0);
        data.writeInt(restrictedBackupMode ? 1 : 0);
        data.writeInt(restrictedBackupMode ? 1 : 0);
        data.writeInt(persistent ? 1 : 0);
        data.writeInt(persistent ? 1 : 0);
        config.writeToParcel(data, 0);
        config.writeToParcel(data, 0);
Loading