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

Commit ba13646d authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

Use separate variables as indices in nested loops

Otherwise the loop might be stuck forever if
- mActiveWatchers.size() > mActiveWatchers.get(0).size()

Test: adb shell dumpsys appops
Fixes: 133230634
Change-Id: I324b1750cf1e45a543e7a498407fbeadc98aba1b
parent 52819a13
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -3814,8 +3814,9 @@ public class AppOpsService extends IAppOpsService.Stub {
            if (mActiveWatchers.size() > 0 && dumpMode < 0) {
                needSep = true;
                boolean printedHeader = false;
                for (int i = 0; i < mActiveWatchers.size(); i++) {
                    final SparseArray<ActiveCallback> activeWatchers = mActiveWatchers.valueAt(i);
                for (int watcherNum = 0; watcherNum < mActiveWatchers.size(); watcherNum++) {
                    final SparseArray<ActiveCallback> activeWatchers =
                            mActiveWatchers.valueAt(watcherNum);
                    if (activeWatchers.size() <= 0) {
                        continue;
                    }
@@ -3833,16 +3834,16 @@ public class AppOpsService extends IAppOpsService.Stub {
                    }
                    pw.print("    ");
                    pw.print(Integer.toHexString(System.identityHashCode(
                            mActiveWatchers.keyAt(i))));
                            mActiveWatchers.keyAt(watcherNum))));
                    pw.println(" ->");
                    pw.print("        [");
                    final int opCount = activeWatchers.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(activeWatchers.keyAt(i)));
                        if (i < opCount - 1) {
                        pw.print(AppOpsManager.opToName(activeWatchers.keyAt(opNum)));
                        if (opNum < opCount - 1) {
                            pw.print(',');
                        }
                    }