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
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index aa15f39..2610d87 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -376,6 +376,7 @@
         Bundle instrumentationArgs;
         IInstrumentationWatcher instrumentationWatcher;
         int debugMode;
+        boolean enableOpenGlTrace;
         boolean restrictedBackupMode;
         boolean persistent;
         Configuration config;
@@ -676,8 +677,8 @@
                 ComponentName instrumentationName, String profileFile,
                 ParcelFileDescriptor profileFd, boolean autoStopProfiler,
                 Bundle instrumentationArgs, IInstrumentationWatcher instrumentationWatcher,
-                int debugMode, boolean isRestrictedBackupMode, boolean persistent,
-                Configuration config, CompatibilityInfo compatInfo,
+                int debugMode, boolean enableOpenGlTrace, boolean isRestrictedBackupMode,
+                boolean persistent, Configuration config, CompatibilityInfo compatInfo,
                 Map<String, IBinder> services, Bundle coreSettings) {
 
             if (services != null) {
@@ -695,6 +696,7 @@
             data.instrumentationArgs = instrumentationArgs;
             data.instrumentationWatcher = instrumentationWatcher;
             data.debugMode = debugMode;
+            data.enableOpenGlTrace = enableOpenGlTrace;
             data.restrictedBackupMode = isRestrictedBackupMode;
             data.persistent = persistent;
             data.config = config;
@@ -3912,6 +3914,11 @@
             }
         }
 
+        // 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.
          */