Skip to content

Commit 4faaed9

Browse files
vsivaAndroid (Google) Code Review
authored andcommitted
Merge "ActivityManager: add option to allow OpenGL trace."
2 parents b48e029 + 92a8b22 commit 4faaed9

File tree

11 files changed

+102
-45
lines changed

11 files changed

+102
-45
lines changed

cmds/am/src/com/android/commands/am/Am.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ public class Am {
6161
private boolean mWaitOption = false;
6262
private boolean mStopOption = false;
6363

64+
private boolean mOpenglTraceOption = false;
65+
6466
private int mRepeat = 0;
6567

6668
private String mProfileFile;
@@ -151,6 +153,7 @@ private Intent makeIntent() throws URISyntaxException {
151153
mDebugOption = false;
152154
mWaitOption = false;
153155
mStopOption = false;
156+
mOpenglTraceOption = false;
154157
mRepeat = 0;
155158
mProfileFile = null;
156159
Uri data = null;
@@ -307,6 +310,8 @@ private Intent makeIntent() throws URISyntaxException {
307310
mRepeat = Integer.parseInt(nextArgRequired());
308311
} else if (opt.equals("-S")) {
309312
mStopOption = true;
313+
} else if (opt.equals("--opengl-trace")) {
314+
mOpenglTraceOption = true;
310315
} else {
311316
System.err.println("Error: Unknown option: " + opt);
312317
showUsage();
@@ -440,17 +445,19 @@ private void runStart() throws Exception {
440445
return;
441446
}
442447
}
443-
448+
444449
IActivityManager.WaitResult result = null;
445450
int res;
446451
if (mWaitOption) {
447452
result = mAm.startActivityAndWait(null, intent, mimeType,
448-
null, 0, null, null, 0, false, mDebugOption,
453+
null, 0, null, null, 0, false,
454+
mDebugOption, mOpenglTraceOption,
449455
mProfileFile, fd, mProfileAutoStop);
450456
res = result.result;
451457
} else {
452458
res = mAm.startActivity(null, intent, mimeType,
453-
null, 0, null, null, 0, false, mDebugOption,
459+
null, 0, null, null, 0, false,
460+
mDebugOption, mOpenglTraceOption,
454461
mProfileFile, fd, mProfileAutoStop);
455462
}
456463
PrintStream out = mWaitOption ? System.out : System.err;
@@ -1277,7 +1284,7 @@ private static void showUsage() {
12771284
System.err.println(
12781285
"usage: am [subcommand] [options]\n" +
12791286
"usage: am start [-D] [-W] [-P <FILE>] [--start-profiler <FILE>]\n" +
1280-
" [--R COUNT] [-S] <INTENT>\n" +
1287+
" [--R COUNT] [-S] [--opengl-trace] <INTENT>\n" +
12811288
" am startservice <INTENT>\n" +
12821289
" am force-stop <PACKAGE>\n" +
12831290
" am kill <PACKAGE>\n" +
@@ -1304,6 +1311,7 @@ private static void showUsage() {
13041311
" -R: repeat the activity launch <COUNT> times. Prior to each repeat,\n" +
13051312
" the top activity will be finished.\n" +
13061313
" -S: force stop the target app before starting the activity\n" +
1314+
" --opengl-trace: enable tracing of OpenGL functions\n" +
13071315
"\n" +
13081316
"am startservice: start a Service.\n" +
13091317
"\n" +

core/java/android/app/Activity.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3388,17 +3388,16 @@ public boolean startActivityIfNeeded(Intent intent, int requestCode) {
33883388
intent.setAllowFds(false);
33893389
result = ActivityManagerNative.getDefault()
33903390
.startActivity(mMainThread.getApplicationThread(),
3391-
intent, intent.resolveTypeIfNeeded(
3392-
getContentResolver()),
3391+
intent, intent.resolveTypeIfNeeded(getContentResolver()),
33933392
null, 0,
3394-
mToken, mEmbeddedID, requestCode, true, false,
3395-
null, null, false);
3393+
mToken, mEmbeddedID, requestCode, true /* onlyIfNeeded */,
3394+
false, false, null, null, false);
33963395
} catch (RemoteException e) {
33973396
// Empty
33983397
}
3399-
3398+
34003399
Instrumentation.checkStartActivityResult(result, intent);
3401-
3400+
34023401
if (requestCode >= 0) {
34033402
// If this start is requesting a result, we can avoid making
34043403
// the activity visible until the result is received. Setting

core/java/android/app/ActivityManagerNative.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,19 @@ public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
120120
Uri[] grantedUriPermissions = data.createTypedArray(Uri.CREATOR);
121121
int grantedMode = data.readInt();
122122
IBinder resultTo = data.readStrongBinder();
123-
String resultWho = data.readString();
123+
String resultWho = data.readString();
124124
int requestCode = data.readInt();
125125
boolean onlyIfNeeded = data.readInt() != 0;
126126
boolean debug = data.readInt() != 0;
127+
boolean openglTrace = data.readInt() != 0;
127128
String profileFile = data.readString();
128129
ParcelFileDescriptor profileFd = data.readInt() != 0
129130
? data.readFileDescriptor() : null;
130131
boolean autoStopProfiler = data.readInt() != 0;
131132
int result = startActivity(app, intent, resolvedType,
132133
grantedUriPermissions, grantedMode, resultTo, resultWho,
133-
requestCode, onlyIfNeeded, debug, profileFile, profileFd, autoStopProfiler);
134+
requestCode, onlyIfNeeded, debug, openglTrace,
135+
profileFile, profileFd, autoStopProfiler);
134136
reply.writeNoException();
135137
reply.writeInt(result);
136138
return true;
@@ -146,17 +148,19 @@ public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
146148
Uri[] grantedUriPermissions = data.createTypedArray(Uri.CREATOR);
147149
int grantedMode = data.readInt();
148150
IBinder resultTo = data.readStrongBinder();
149-
String resultWho = data.readString();
151+
String resultWho = data.readString();
150152
int requestCode = data.readInt();
151153
boolean onlyIfNeeded = data.readInt() != 0;
152154
boolean debug = data.readInt() != 0;
155+
boolean openglTrace = data.readInt() != 0;
153156
String profileFile = data.readString();
154157
ParcelFileDescriptor profileFd = data.readInt() != 0
155158
? data.readFileDescriptor() : null;
156159
boolean autoStopProfiler = data.readInt() != 0;
157160
WaitResult result = startActivityAndWait(app, intent, resolvedType,
158161
grantedUriPermissions, grantedMode, resultTo, resultWho,
159-
requestCode, onlyIfNeeded, debug, profileFile, profileFd, autoStopProfiler);
162+
requestCode, onlyIfNeeded, debug, openglTrace,
163+
profileFile, profileFd, autoStopProfiler);
160164
reply.writeNoException();
161165
result.writeToParcel(reply, 0);
162166
return true;
@@ -1607,17 +1611,17 @@ public ActivityManagerProxy(IBinder remote)
16071611
{
16081612
mRemote = remote;
16091613
}
1610-
1614+
16111615
public IBinder asBinder()
16121616
{
16131617
return mRemote;
16141618
}
1615-
1619+
16161620
public int startActivity(IApplicationThread caller, Intent intent,
16171621
String resolvedType, Uri[] grantedUriPermissions, int grantedMode,
16181622
IBinder resultTo, String resultWho,
16191623
int requestCode, boolean onlyIfNeeded,
1620-
boolean debug, String profileFile, ParcelFileDescriptor profileFd,
1624+
boolean debug, boolean openglTrace, String profileFile, ParcelFileDescriptor profileFd,
16211625
boolean autoStopProfiler) throws RemoteException {
16221626
Parcel data = Parcel.obtain();
16231627
Parcel reply = Parcel.obtain();
@@ -1632,6 +1636,7 @@ public int startActivity(IApplicationThread caller, Intent intent,
16321636
data.writeInt(requestCode);
16331637
data.writeInt(onlyIfNeeded ? 1 : 0);
16341638
data.writeInt(debug ? 1 : 0);
1639+
data.writeInt(openglTrace ? 1 : 0);
16351640
data.writeString(profileFile);
16361641
if (profileFd != null) {
16371642
data.writeInt(1);
@@ -1651,7 +1656,7 @@ public WaitResult startActivityAndWait(IApplicationThread caller, Intent intent,
16511656
String resolvedType, Uri[] grantedUriPermissions, int grantedMode,
16521657
IBinder resultTo, String resultWho,
16531658
int requestCode, boolean onlyIfNeeded,
1654-
boolean debug, String profileFile, ParcelFileDescriptor profileFd,
1659+
boolean debug, boolean openglTrace, String profileFile, ParcelFileDescriptor profileFd,
16551660
boolean autoStopProfiler) throws RemoteException {
16561661
Parcel data = Parcel.obtain();
16571662
Parcel reply = Parcel.obtain();
@@ -1666,6 +1671,7 @@ public WaitResult startActivityAndWait(IApplicationThread caller, Intent intent,
16661671
data.writeInt(requestCode);
16671672
data.writeInt(onlyIfNeeded ? 1 : 0);
16681673
data.writeInt(debug ? 1 : 0);
1674+
data.writeInt(openglTrace ? 1 : 0);
16691675
data.writeString(profileFile);
16701676
if (profileFd != null) {
16711677
data.writeInt(1);

core/java/android/app/ActivityThread.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ static final class AppBindData {
376376
Bundle instrumentationArgs;
377377
IInstrumentationWatcher instrumentationWatcher;
378378
int debugMode;
379+
boolean enableOpenGlTrace;
379380
boolean restrictedBackupMode;
380381
boolean persistent;
381382
Configuration config;
@@ -676,8 +677,8 @@ public final void bindApplication(String processName,
676677
ComponentName instrumentationName, String profileFile,
677678
ParcelFileDescriptor profileFd, boolean autoStopProfiler,
678679
Bundle instrumentationArgs, IInstrumentationWatcher instrumentationWatcher,
679-
int debugMode, boolean isRestrictedBackupMode, boolean persistent,
680-
Configuration config, CompatibilityInfo compatInfo,
680+
int debugMode, boolean enableOpenGlTrace, boolean isRestrictedBackupMode,
681+
boolean persistent, Configuration config, CompatibilityInfo compatInfo,
681682
Map<String, IBinder> services, Bundle coreSettings) {
682683

683684
if (services != null) {
@@ -695,6 +696,7 @@ public final void bindApplication(String processName,
695696
data.instrumentationArgs = instrumentationArgs;
696697
data.instrumentationWatcher = instrumentationWatcher;
697698
data.debugMode = debugMode;
699+
data.enableOpenGlTrace = enableOpenGlTrace;
698700
data.restrictedBackupMode = isRestrictedBackupMode;
699701
data.persistent = persistent;
700702
data.config = config;
@@ -3912,6 +3914,11 @@ private void handleBindApplication(AppBindData data) {
39123914
}
39133915
}
39143916

3917+
// Enable OpenGL tracing if required
3918+
if (data.enableOpenGlTrace) {
3919+
GLUtils.enableTracing();
3920+
}
3921+
39153922
/**
39163923
* Initialize the default http proxy in this process for the reasons we set the time zone.
39173924
*/

core/java/android/app/ApplicationThreadNative.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
267267
IBinder binder = data.readStrongBinder();
268268
IInstrumentationWatcher testWatcher = IInstrumentationWatcher.Stub.asInterface(binder);
269269
int testMode = data.readInt();
270+
boolean openGlTrace = data.readInt() != 0;
270271
boolean restrictedBackupMode = (data.readInt() != 0);
271272
boolean persistent = (data.readInt() != 0);
272273
Configuration config = Configuration.CREATOR.createFromParcel(data);
@@ -275,11 +276,11 @@ public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
275276
Bundle coreSettings = data.readBundle();
276277
bindApplication(packageName, info,
277278
providers, testName, profileName, profileFd, autoStopProfiler,
278-
testArgs, testWatcher, testMode, restrictedBackupMode, persistent,
279-
config, compatInfo, services, coreSettings);
279+
testArgs, testWatcher, testMode, openGlTrace, restrictedBackupMode,
280+
persistent, config, compatInfo, services, coreSettings);
280281
return true;
281282
}
282-
283+
283284
case SCHEDULE_EXIT_TRANSACTION:
284285
{
285286
data.enforceInterface(IApplicationThread.descriptor);
@@ -849,8 +850,9 @@ public final void scheduleStopService(IBinder token)
849850
public final void bindApplication(String packageName, ApplicationInfo info,
850851
List<ProviderInfo> providers, ComponentName testName, String profileName,
851852
ParcelFileDescriptor profileFd, boolean autoStopProfiler, Bundle testArgs,
852-
IInstrumentationWatcher testWatcher, int debugMode, boolean restrictedBackupMode,
853-
boolean persistent, Configuration config, CompatibilityInfo compatInfo,
853+
IInstrumentationWatcher testWatcher, int debugMode, boolean openGlTrace,
854+
boolean restrictedBackupMode, boolean persistent,
855+
Configuration config, CompatibilityInfo compatInfo,
854856
Map<String, IBinder> services, Bundle coreSettings) throws RemoteException {
855857
Parcel data = Parcel.obtain();
856858
data.writeInterfaceToken(IApplicationThread.descriptor);
@@ -874,6 +876,7 @@ public final void bindApplication(String packageName, ApplicationInfo info,
874876
data.writeBundle(testArgs);
875877
data.writeStrongInterface(testWatcher);
876878
data.writeInt(debugMode);
879+
data.writeInt(openGlTrace ? 1 : 0);
877880
data.writeInt(restrictedBackupMode ? 1 : 0);
878881
data.writeInt(persistent ? 1 : 0);
879882
config.writeToParcel(data, 0);

core/java/android/app/IActivityManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ public interface IActivityManager extends IInterface {
8484
public int startActivity(IApplicationThread caller,
8585
Intent intent, String resolvedType, Uri[] grantedUriPermissions,
8686
int grantedMode, IBinder resultTo, String resultWho, int requestCode,
87-
boolean onlyIfNeeded, boolean debug, String profileFile,
87+
boolean onlyIfNeeded, boolean debug, boolean openglTrace, String profileFile,
8888
ParcelFileDescriptor profileFd, boolean autoStopProfiler) throws RemoteException;
8989
public WaitResult startActivityAndWait(IApplicationThread caller,
9090
Intent intent, String resolvedType, Uri[] grantedUriPermissions,
9191
int grantedMode, IBinder resultTo, String resultWho, int requestCode,
92-
boolean onlyIfNeeded, boolean debug, String profileFile,
92+
boolean onlyIfNeeded, boolean debug, boolean openglTrace, String profileFile,
9393
ParcelFileDescriptor profileFd, boolean autoStopProfiler) throws RemoteException;
9494
public int startActivityWithConfig(IApplicationThread caller,
9595
Intent intent, String resolvedType, Uri[] grantedUriPermissions,

core/java/android/app/IApplicationThread.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void scheduleServiceArgs(IBinder token, boolean taskRemoved, int startId,
8989
void bindApplication(String packageName, ApplicationInfo info, List<ProviderInfo> providers,
9090
ComponentName testName, String profileName, ParcelFileDescriptor profileFd,
9191
boolean autoStopProfiler, Bundle testArguments, IInstrumentationWatcher testWatcher,
92-
int debugMode, boolean restrictedBackupMode, boolean persistent,
92+
int debugMode, boolean openGlTrace, boolean restrictedBackupMode, boolean persistent,
9393
Configuration config, CompatibilityInfo compatInfo, Map<String, IBinder> services,
9494
Bundle coreSettings) throws RemoteException;
9595
void scheduleExit() throws RemoteException;

core/java/android/app/Instrumentation.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,7 @@ public ActivityResult execStartActivity(
13841384
.startActivity(whoThread, intent,
13851385
intent.resolveTypeIfNeeded(who.getContentResolver()),
13861386
null, 0, token, target != null ? target.mEmbeddedID : null,
1387-
requestCode, false, false, null, null, false);
1387+
requestCode, false, false, false, null, null, false);
13881388
checkStartActivityResult(result, intent);
13891389
} catch (RemoteException e) {
13901390
}
@@ -1482,7 +1482,8 @@ public ActivityResult execStartActivity(
14821482
.startActivity(whoThread, intent,
14831483
intent.resolveTypeIfNeeded(who.getContentResolver()),
14841484
null, 0, token, target != null ? target.mWho : null,
1485-
requestCode, false, false, null, null, false);
1485+
requestCode, false, false /* debug */, false /* openglTrace */,
1486+
null, null, false);
14861487
checkStartActivityResult(result, intent);
14871488
} catch (RemoteException e) {
14881489
}

policy/src/com/android/internal/policy/impl/PhoneWindowManager.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3832,7 +3832,8 @@ boolean goHome() {
38323832
int result = ActivityManagerNative.getDefault()
38333833
.startActivity(null, dock,
38343834
dock.resolveTypeIfNeeded(mContext.getContentResolver()),
3835-
null, 0, null, null, 0, true /* onlyIfNeeded*/, false,
3835+
null, 0, null, null, 0, true /* onlyIfNeeded*/,
3836+
false /* debug */, false /* openglTrace */,
38363837
null, null, false);
38373838
if (result == IActivityManager.START_RETURN_INTENT_TO_CALLER) {
38383839
return false;
@@ -3842,7 +3843,8 @@ boolean goHome() {
38423843
int result = ActivityManagerNative.getDefault()
38433844
.startActivity(null, mHomeIntent,
38443845
mHomeIntent.resolveTypeIfNeeded(mContext.getContentResolver()),
3845-
null, 0, null, null, 0, true /* onlyIfNeeded*/, false,
3846+
null, 0, null, null, 0, true /* onlyIfNeeded*/,
3847+
false /* debug */, false /* openglTrace */,
38463848
null, null, false);
38473849
if (result == IActivityManager.START_RETURN_INTENT_TO_CALLER) {
38483850
return false;

0 commit comments

Comments
 (0)