Fix attaching debugger before activity launch
Since a launching app has to notify the system to finishAttachApplication, we need to ensure that we wait for debuggers only after notifying the system of a successful start. Otherwise, the system will kill the app after the proc_start timeout Test: atest CtsJdwpTunnelHostTestCases:android.jdwptunnel.cts.JdwpTunnelTest#testAttachDebuggerToDebuggableApp Bug: 261017997 Change-Id: I69afef42c691ce387d3a0e1661c028072db63b14
This commit is contained in:
@@ -6683,34 +6683,6 @@ public final class ActivityThread extends ClientTransactionHandler
|
||||
StrictMode.initThreadDefaults(data.appInfo);
|
||||
StrictMode.initVmDefaults(data.appInfo);
|
||||
|
||||
if (data.debugMode != ApplicationThreadConstants.DEBUG_OFF) {
|
||||
// XXX should have option to change the port.
|
||||
Debug.changeDebugPort(8100);
|
||||
if (data.debugMode == ApplicationThreadConstants.DEBUG_WAIT) {
|
||||
Slog.w(TAG, "Application " + data.info.getPackageName()
|
||||
+ " is waiting for the debugger on port 8100...");
|
||||
|
||||
IActivityManager mgr = ActivityManager.getService();
|
||||
try {
|
||||
mgr.showWaitingForDebugger(mAppThread, true);
|
||||
} catch (RemoteException ex) {
|
||||
throw ex.rethrowFromSystemServer();
|
||||
}
|
||||
|
||||
Debug.waitForDebugger();
|
||||
|
||||
try {
|
||||
mgr.showWaitingForDebugger(mAppThread, false);
|
||||
} catch (RemoteException ex) {
|
||||
throw ex.rethrowFromSystemServer();
|
||||
}
|
||||
|
||||
} else {
|
||||
Slog.w(TAG, "Application " + data.info.getPackageName()
|
||||
+ " can be debugged on port 8100...");
|
||||
}
|
||||
}
|
||||
|
||||
// Allow binder tracing, and application-generated systrace messages if we're profileable.
|
||||
boolean isAppDebuggable = (data.appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
|
||||
boolean isAppProfileable = isAppDebuggable || data.appInfo.isProfileable();
|
||||
@@ -6818,6 +6790,34 @@ public final class ActivityThread extends ClientTransactionHandler
|
||||
throw ex.rethrowFromSystemServer();
|
||||
}
|
||||
|
||||
// Wait for debugger after we have notified the system to finish attach application
|
||||
if (data.debugMode != ApplicationThreadConstants.DEBUG_OFF) {
|
||||
// XXX should have option to change the port.
|
||||
Debug.changeDebugPort(8100);
|
||||
if (data.debugMode == ApplicationThreadConstants.DEBUG_WAIT) {
|
||||
Slog.w(TAG, "Application " + data.info.getPackageName()
|
||||
+ " is waiting for the debugger on port 8100...");
|
||||
|
||||
try {
|
||||
mgr.showWaitingForDebugger(mAppThread, true);
|
||||
} catch (RemoteException ex) {
|
||||
throw ex.rethrowFromSystemServer();
|
||||
}
|
||||
|
||||
Debug.waitForDebugger();
|
||||
|
||||
try {
|
||||
mgr.showWaitingForDebugger(mAppThread, false);
|
||||
} catch (RemoteException ex) {
|
||||
throw ex.rethrowFromSystemServer();
|
||||
}
|
||||
|
||||
} else {
|
||||
Slog.w(TAG, "Application " + data.info.getPackageName()
|
||||
+ " can be debugged on port 8100...");
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// If the app is being launched for full backup or restore, bring it up in
|
||||
// a restricted environment with the base application class.
|
||||
|
||||
Reference in New Issue
Block a user