Merge "Don't hold lock when dumping activities of app side" into qt-r1-dev

am: 0c149c1ab7

Change-Id: I7e7c9a2e540ee077a883917cf89e39d436ca3472
This commit is contained in:
Riddle Hsu
2019-07-16 10:08:58 -07:00
committed by android-build-merger

View File

@@ -4998,6 +4998,9 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
* - the cmd arg isn't the flattened component name of an existing activity: * - the cmd arg isn't the flattened component name of an existing activity:
* dump all activity whose component contains the cmd as a substring * dump all activity whose component contains the cmd as a substring
* - A hex number of the ActivityRecord object instance. * - A hex number of the ActivityRecord object instance.
* <p>
* The caller should not hold lock when calling this method because it will wait for the
* activities to complete the dump.
* *
* @param dumpVisibleStacksOnly dump activity with {@param name} only if in a visible stack * @param dumpVisibleStacksOnly dump activity with {@param name} only if in a visible stack
* @param dumpFocusedStackOnly dump activity with {@param name} only if in the focused stack * @param dumpFocusedStackOnly dump activity with {@param name} only if in the focused stack
@@ -5050,29 +5053,28 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
private void dumpActivity(String prefix, FileDescriptor fd, PrintWriter pw, private void dumpActivity(String prefix, FileDescriptor fd, PrintWriter pw,
final ActivityRecord r, String[] args, boolean dumpAll) { final ActivityRecord r, String[] args, boolean dumpAll) {
String innerPrefix = prefix + " "; String innerPrefix = prefix + " ";
IApplicationThread appThread = null;
synchronized (mGlobalLock) { synchronized (mGlobalLock) {
pw.print(prefix); pw.print("ACTIVITY "); pw.print(r.shortComponentName); pw.print(prefix); pw.print("ACTIVITY "); pw.print(r.shortComponentName);
pw.print(" "); pw.print(Integer.toHexString(System.identityHashCode(r))); pw.print(" "); pw.print(Integer.toHexString(System.identityHashCode(r)));
pw.print(" pid="); pw.print(" pid=");
if (r.hasProcess()) pw.println(r.app.getPid()); if (r.hasProcess()) {
else pw.println("(not running)"); pw.println(r.app.getPid());
appThread = r.app.getThread();
} else {
pw.println("(not running)");
}
if (dumpAll) { if (dumpAll) {
r.dump(pw, innerPrefix); r.dump(pw, innerPrefix);
} }
} }
if (r.attachedToProcess()) { if (appThread != null) {
// flush anything that is already in the PrintWriter since the thread is going // flush anything that is already in the PrintWriter since the thread is going
// to write to the file descriptor directly // to write to the file descriptor directly
pw.flush(); pw.flush();
try { try (TransferPipe tp = new TransferPipe()) {
TransferPipe tp = new TransferPipe(); appThread.dumpActivity(tp.getWriteFd(), r.appToken, innerPrefix, args);
try {
r.app.getThread().dumpActivity(tp.getWriteFd(),
r.appToken, innerPrefix, args);
tp.go(fd); tp.go(fd);
} finally {
tp.kill();
}
} catch (IOException e) { } catch (IOException e) {
pw.println(innerPrefix + "Failure while dumping the activity: " + e); pw.println(innerPrefix + "Failure while dumping the activity: " + e);
} catch (RemoteException e) { } catch (RemoteException e) {
@@ -7181,10 +7183,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
public boolean dumpActivity(FileDescriptor fd, PrintWriter pw, String name, public boolean dumpActivity(FileDescriptor fd, PrintWriter pw, String name,
String[] args, int opti, boolean dumpAll, boolean dumpVisibleStacksOnly, String[] args, int opti, boolean dumpAll, boolean dumpVisibleStacksOnly,
boolean dumpFocusedStackOnly) { boolean dumpFocusedStackOnly) {
synchronized (mGlobalLock) { return ActivityTaskManagerService.this.dumpActivity(fd, pw, name, args, opti, dumpAll,
return ActivityTaskManagerService.this.dumpActivity(fd, pw, name, args, opti, dumpVisibleStacksOnly, dumpFocusedStackOnly);
dumpAll, dumpVisibleStacksOnly, dumpFocusedStackOnly);
}
} }
@Override @Override