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

Commit e6518039 authored by Adam Bookatz's avatar Adam Bookatz
Browse files

AppOpsService.dump() over-used iterator fix

The dump() was using the variable i in both the
inner and outer loop, causing the list of watchers
that were dumped() to be incorrect (and, in unlucky cases,
never-ending).

Bug: 152023451
Bug: 151193211
Bug: 156230006
Test: compiles. And adb shell dumpsys appops still works.
Change-Id: If098f70b386fdc420d970013e6fe9bcbb640ca4b
Merged-In: If098f70b386fdc420d970013e6fe9bcbb640ca4b
parent c13f012c
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -3908,8 +3908,9 @@ public class AppOpsService extends IAppOpsService.Stub {
            if (mNotedWatchers.size() > 0 && dumpMode < 0) {
                needSep = true;
                boolean printedHeader = false;
                for (int i = 0; i < mNotedWatchers.size(); i++) {
                    final SparseArray<NotedCallback> notedWatchers = mNotedWatchers.valueAt(i);
                for (int watcherNum = 0; watcherNum < mNotedWatchers.size(); watcherNum++) {
                    final SparseArray<NotedCallback> notedWatchers =
                            mNotedWatchers.valueAt(watcherNum);
                    if (notedWatchers.size() <= 0) {
                        continue;
                    }
@@ -3927,16 +3928,16 @@ public class AppOpsService extends IAppOpsService.Stub {
                    }
                    pw.print("    ");
                    pw.print(Integer.toHexString(System.identityHashCode(
                            mNotedWatchers.keyAt(i))));
                            mNotedWatchers.keyAt(watcherNum))));
                    pw.println(" ->");
                    pw.print("        [");
                    final int opCount = notedWatchers.size();
                    for (i = 0; i < opCount; i++) {
                        if (i > 0) {
                    for (int opNum = 0; opNum < opCount; opNum++) {
                        if (opNum > 0) {
                            pw.print(' ');
                        }
                        pw.print(AppOpsManager.opToName(notedWatchers.keyAt(i)));
                        if (i < opCount - 1) {
                        pw.print(AppOpsManager.opToName(notedWatchers.keyAt(opNum)));
                        if (opNum < opCount - 1) {
                            pw.print(',');
                        }
                    }