Fix issue #10226007: Reset apps restores most of the changed settings...

...to original but not all modified ones

Very stupid mistakes in messing up the iteration when pruning op
entries.

Change-Id: Ie536b9095f797fcd2b86c9a386a72746796430d1
This commit is contained in:
Dianne Hackborn
2013-08-07 15:36:08 -07:00
parent 4032217ee9
commit 7f09ec39b6

View File

@@ -380,12 +380,14 @@ public class AppOpsService extends IAppOpsService.Stub {
HashMap<Callback, ArrayList<Pair<String, Integer>>> callbacks = null;
synchronized (this) {
boolean changed = false;
for (int i=0; i<mUidOps.size(); i++) {
for (int i=mUidOps.size()-1; i>=0; i--) {
HashMap<String, Ops> packages = mUidOps.valueAt(i);
for (Map.Entry<String, Ops> ent : packages.entrySet()) {
Iterator<Map.Entry<String, Ops>> it = packages.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, Ops> ent = it.next();
String packageName = ent.getKey();
Ops pkgOps = ent.getValue();
for (int j=0; j<pkgOps.size(); j++) {
for (int j=pkgOps.size()-1; j>=0; j--) {
Op curOp = pkgOps.valueAt(j);
if (curOp.mode != AppOpsManager.MODE_ALLOWED) {
curOp.mode = AppOpsManager.MODE_ALLOWED;
@@ -394,9 +396,17 @@ public class AppOpsService extends IAppOpsService.Stub {
mOpModeWatchers.get(curOp.op));
callbacks = addCallbacks(callbacks, packageName, curOp.op,
mPackageModeWatchers.get(packageName));
pruneOp(curOp, mUidOps.keyAt(i), packageName);
if (curOp.time == 0 && curOp.rejectTime == 0) {
pkgOps.removeAt(j);
}
}
}
if (pkgOps.size() == 0) {
it.remove();
}
}
if (packages.size() == 0) {
mUidOps.removeAt(i);
}
}
if (changed) {