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
diff --git a/services/core/java/com/android/server/appop/AppOpsService.java b/services/core/java/com/android/server/appop/AppOpsService.java
index 314e04c..4eba23b 100644
--- a/services/core/java/com/android/server/appop/AppOpsService.java
+++ b/services/core/java/com/android/server/appop/AppOpsService.java
@@ -3908,8 +3908,9 @@
             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 @@
                     }
                     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(',');
                         }
                     }