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

Commit 5d25b18e authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Improve debug printing in activity manager."

parents 658b07f3 7ad34e5f
Loading
Loading
Loading
Loading
+17 −15
Original line number Diff line number Diff line
@@ -1840,10 +1840,10 @@ public class ActiveServices {
    /**
     * Prints a list of ServiceRecords (dumpsys activity services)
     */
    boolean dumpServicesLocked(FileDescriptor fd, PrintWriter pw, String[] args,
    void dumpServicesLocked(FileDescriptor fd, PrintWriter pw, String[] args,
            int opti, boolean dumpAll, boolean dumpClient, String dumpPackage) {
        boolean needSep = false;
        boolean needSepResult = false;
        boolean printedAnything = false;

        ItemMatcher matcher = new ItemMatcher();
        matcher.build(args, opti);
@@ -1866,7 +1866,7 @@ public class ActiveServices {
                        if (dumpPackage != null && !dumpPackage.equals(r.appInfo.packageName)) {
                            continue;
                        }
                        needSepResult = true;
                        printedAnything = true;
                        if (!printed) {
                            if (user != 0) {
                                pw.println();
@@ -1893,7 +1893,7 @@ public class ActiveServices {
                            pw.println(r.connections.size());
                            if (r.connections.size() > 0) {
                                pw.println("    Connections:");
                                for (int conni=0; conni<=r.connections.size(); conni++) {
                                for (int conni=0; conni<r.connections.size(); conni++) {
                                    ArrayList<ConnectionRecord> clist = r.connections.valueAt(conni);
                                    for (int i = 0; i < clist.size(); i++) {
                                        ConnectionRecord conn = clist.get(i);
@@ -1930,11 +1930,11 @@ public class ActiveServices {
                            needSep = true;
                        }
                    }
                    needSep = printed;
                    needSep |= printed;
                }
            }
        } catch (Exception e) {
            Log.w(TAG, "Exception in dumpServicesLocked: " + e);
            Log.w(TAG, "Exception in dumpServicesLocked", e);
        }

        if (mPendingServices.size() > 0) {
@@ -1947,9 +1947,9 @@ public class ActiveServices {
                if (dumpPackage != null && !dumpPackage.equals(r.appInfo.packageName)) {
                    continue;
                }
                needSepResult = true;
                printedAnything = true;
                if (!printed) {
                    if (needSep) pw.println(" ");
                    if (needSep) pw.println();
                    needSep = true;
                    pw.println("  Pending services:");
                    printed = true;
@@ -1970,9 +1970,9 @@ public class ActiveServices {
                if (dumpPackage != null && !dumpPackage.equals(r.appInfo.packageName)) {
                    continue;
                }
                needSepResult = true;
                printedAnything = true;
                if (!printed) {
                    if (needSep) pw.println(" ");
                    if (needSep) pw.println();
                    needSep = true;
                    pw.println("  Restarting services:");
                    printed = true;
@@ -1993,9 +1993,9 @@ public class ActiveServices {
                if (dumpPackage != null && !dumpPackage.equals(r.appInfo.packageName)) {
                    continue;
                }
                needSepResult = true;
                printedAnything = true;
                if (!printed) {
                    if (needSep) pw.println(" ");
                    if (needSep) pw.println();
                    needSep = true;
                    pw.println("  Stopping services:");
                    printed = true;
@@ -2022,9 +2022,9 @@ public class ActiveServices {
                                || !dumpPackage.equals(cr.binding.client.info.packageName))) {
                            continue;
                        }
                        needSepResult = true;
                        printedAnything = true;
                        if (!printed) {
                            if (needSep) pw.println(" ");
                            if (needSep) pw.println();
                            needSep = true;
                            pw.println("  Connection bindings to services:");
                            printed = true;
@@ -2036,7 +2036,9 @@ public class ActiveServices {
            }
        }

        return needSepResult;
        if (!printedAnything) {
            pw.println("  (nothing)");
        }
    }

    /**
+239 −144

File changed.

Preview size limit exceeded, changes collapsed.

+6 −2
Original line number Diff line number Diff line
@@ -3334,13 +3334,17 @@ final class ActivityStack {
    }

    boolean dumpActivitiesLocked(FileDescriptor fd, PrintWriter pw, boolean dumpAll,
            boolean dumpClient, String dumpPackage, boolean needSep) {
            boolean dumpClient, String dumpPackage, boolean needSep, String header) {
        boolean printed = false;
        for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) {
            final TaskRecord task = mTaskHistory.get(taskNdx);
            printed |= ActivityStackSupervisor.dumpHistoryList(fd, pw,
                    mTaskHistory.get(taskNdx).mActivities, "    ", "Hist", true, !dumpAll,
                    dumpClient, dumpPackage, needSep, "    Task " + taskNdx + ": id #" + task.taskId);
                    dumpClient, dumpPackage, needSep, header,
                    "    Task " + taskNdx + ": id #" + task.taskId);
            if (printed) {
                header = null;
            }
        }
        return printed;
    }
+51 −39
Original line number Diff line number Diff line
@@ -2209,6 +2209,8 @@ public class ActivityStackSupervisor {
        pw.print(prefix); pw.print("mDismissKeyguardOnNextActivity:");
                pw.println(mDismissKeyguardOnNextActivity);
        pw.print(prefix); pw.print("mStackState="); pw.println(stackStateToString(mStackState));
        pw.print(prefix); pw.println("mSleepTimeout: " + mSleepTimeout);
        pw.print(prefix); pw.println("mCurTaskId: " + mCurTaskId);
    }

    ArrayList<ActivityRecord> getDumpActivitiesLocked(String name) {
@@ -2221,66 +2223,72 @@ public class ActivityStackSupervisor {
            if (dumpPackage == null || dumpPackage.equals(activity.packageName)) {
                if (needSep) {
                    pw.println();
                    needSep = false;
                }
                pw.print(prefix);
                pw.println(activity);
                return true;
            }
        }
        return needSep;
        return false;
    }

    boolean dumpActivitiesLocked(FileDescriptor fd, PrintWriter pw, boolean dumpAll,
            boolean dumpClient, String dumpPackage) {
        boolean printed = false;
        boolean needSep = false;
        final int numStacks = mStacks.size();
        for (int stackNdx = 0; stackNdx < numStacks; ++stackNdx) {
            final ActivityStack stack = mStacks.get(stackNdx);
            if (stackNdx != 0) {
                pw.println();
            }
            pw.print("  Stack #"); pw.print(mStacks.indexOf(stack)); pw.println(":");
            stack.dumpActivitiesLocked(fd, pw, dumpAll, dumpClient, dumpPackage, false);
            dumpHistoryList(fd, pw, stack.mLRUActivities, "    ", "Run", false, !dumpAll, false,
                    dumpPackage, true, "    Running activities (most recent first):");

            boolean needSep = true;
            needSep = printThisActivity(pw, stack.mPausingActivity, dumpPackage, needSep,
            StringBuilder stackHeader = new StringBuilder(128);
            stackHeader.append("  Stack #");
            stackHeader.append(mStacks.indexOf(stack));
            stackHeader.append(":");
            printed |= stack.dumpActivitiesLocked(fd, pw, dumpAll, dumpClient, dumpPackage, needSep,
                    stackHeader.toString());
            printed |= dumpHistoryList(fd, pw, stack.mLRUActivities, "    ", "Run", false, !dumpAll,
                    false, dumpPackage, true, "    Running activities (most recent first):", null);

            needSep = printed;
            boolean pr = printThisActivity(pw, stack.mPausingActivity, dumpPackage, needSep,
                    "    mPausingActivity: ");
            needSep = printThisActivity(pw, stack.mResumedActivity, dumpPackage, needSep,
            if (pr) {
                printed = true;
                needSep = false;
            }
            pr = printThisActivity(pw, stack.mResumedActivity, dumpPackage, needSep,
                    "    mResumedActivity: ");
            if (pr) {
                printed = true;
                needSep = false;
            }
            if (dumpAll) {
                printThisActivity(pw, stack.mLastPausedActivity, dumpPackage, needSep,
                pr = printThisActivity(pw, stack.mLastPausedActivity, dumpPackage, needSep,
                        "    mLastPausedActivity: ");
                if (pr) {
                    printed = true;
                }
            }
            needSep = printed;
        }

        dumpHistoryList(fd, pw, mFinishingActivities, "  ", "Fin", false, !dumpAll, false,
                dumpPackage, true, "  Activities waiting to finish:");
        dumpHistoryList(fd, pw, mStoppingActivities, "  ", "Stop", false, !dumpAll, false,
                dumpPackage, true, "  Activities waiting to stop:");
        dumpHistoryList(fd, pw, mWaitingVisibleActivities, "  ", "Wait", false, !dumpAll,
                false, dumpPackage, true, "  Activities waiting for another to become visible:");
        dumpHistoryList(fd, pw, mGoingToSleepActivities, "  ", "Sleep", false, !dumpAll, false,
                dumpPackage, true, "  Activities waiting to sleep:");
        dumpHistoryList(fd, pw, mGoingToSleepActivities, "  ", "Sleep", false, !dumpAll, false,
                dumpPackage, true, "  Activities waiting to sleep:");
        printed |= dumpHistoryList(fd, pw, mFinishingActivities, "  ", "Fin", false, !dumpAll,
                false, dumpPackage, true, "  Activities waiting to finish:", null);
        printed |= dumpHistoryList(fd, pw, mStoppingActivities, "  ", "Stop", false, !dumpAll,
                false, dumpPackage, true, "  Activities waiting to stop:", null);
        printed |= dumpHistoryList(fd, pw, mWaitingVisibleActivities, "  ", "Wait", false, !dumpAll,
                false, dumpPackage, true, "  Activities waiting for another to become visible:",
                null);
        printed |= dumpHistoryList(fd, pw, mGoingToSleepActivities, "  ", "Sleep", false, !dumpAll,
                false, dumpPackage, true, "  Activities waiting to sleep:", null);
        printed |= dumpHistoryList(fd, pw, mGoingToSleepActivities, "  ", "Sleep", false, !dumpAll,
                false, dumpPackage, true, "  Activities waiting to sleep:", null);

        if (dumpPackage == null) {
            pw.println();
            pw.print("  mStackState="); pw.println(stackStateToString(mStackState));
            if (dumpAll) {
                pw.println("  mSleepTimeout: " + mSleepTimeout);
            }
            if (dumpAll) {
                pw.println("  mCurTaskId: " + mCurTaskId);
            }
        }
        return true;
        return printed;
    }

    static boolean dumpHistoryList(FileDescriptor fd, PrintWriter pw, List<ActivityRecord> list,
            String prefix, String label, boolean complete, boolean brief, boolean client,
            String dumpPackage, boolean needNL, String header) {
            String dumpPackage, boolean needNL, String header1, String header2) {
        TaskRecord lastTask = null;
        String innerPrefix = null;
        String[] args = null;
@@ -2300,9 +2308,13 @@ public class ActivityStackSupervisor {
                pw.println("");
                needNL = false;
            }
            if (header != null) {
                pw.println(header);
                header = null;
            if (header1 != null) {
                pw.println(header1);
                header1 = null;
            }
            if (header2 != null) {
                pw.println(header2);
                header2 = null;
            }
            if (lastTask != r.task) {
                lastTask = r.task;
+1 −2
Original line number Diff line number Diff line
@@ -287,8 +287,7 @@ public class ProviderMap {
        boolean needSep = false;

        if (mSingletonByClass.size() > 0) {
            pw.println("  Published single-user content providers (by class):");
            needSep = dumpProvidersByClassLocked(pw, dumpAll, dumpPackage,
            needSep |= dumpProvidersByClassLocked(pw, dumpAll, dumpPackage,
                    "  Published single-user content providers (by class):", needSep,
                    mSingletonByClass);
        }