summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2013-08-01 11:09:27 -0700
committerDianne Hackborn <hackbod@google.com>2013-08-01 11:15:04 -0700
commit483a6bbfc118409b9c46b226cf0aa6afdc4d9159 (patch)
tree96c3da4abc0d1a44cd43b6520af16754c29df2bc
parent38d4cfd4a19de35c2b16c0f64b26d4b9ed362ede (diff)
downloadbase-483a6bbfc118409b9c46b226cf0aa6afdc4d9159.tar.gz
Add version identifier to app ops.
All old versions drop their modes except for the notification op (which is the only one there is currently a user-visible control for). Change-Id: I9e09cebe63e9ea81f2adc01aef7d1a5a59f57a56
-rw-r--r--services/java/com/android/server/AppOpsService.java21
1 files changed, 16 insertions, 5 deletions
diff --git a/services/java/com/android/server/AppOpsService.java b/services/java/com/android/server/AppOpsService.java
index a402642bc0de..983447969b1d 100644
--- a/services/java/com/android/server/AppOpsService.java
+++ b/services/java/com/android/server/AppOpsService.java
@@ -63,6 +63,8 @@ public class AppOpsService extends IAppOpsService.Stub {
// Write at most every 30 minutes.
static final long WRITE_DELAY = DEBUG ? 1000 : 30*60*1000;
+ static final int CURRENT_VERSION = 1;
+
Context mContext;
final AtomicFile mFile;
final Handler mHandler;
@@ -631,6 +633,9 @@ public class AppOpsService extends IAppOpsService.Stub {
throw new IllegalStateException("no start tag found");
}
+ String versStr = parser.getAttributeValue(null, "vers");
+ int vers = versStr != null ? Integer.parseInt(versStr) : 0;
+
int outerDepth = parser.getDepth();
while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
&& (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
@@ -640,7 +645,7 @@ public class AppOpsService extends IAppOpsService.Stub {
String tagName = parser.getName();
if (tagName.equals("pkg")) {
- readPackage(parser);
+ readPackage(parser, vers);
} else {
Slog.w(TAG, "Unknown element under <app-ops>: "
+ parser.getName());
@@ -673,7 +678,7 @@ public class AppOpsService extends IAppOpsService.Stub {
}
}
- void readPackage(XmlPullParser parser) throws NumberFormatException,
+ void readPackage(XmlPullParser parser, int vers) throws NumberFormatException,
XmlPullParserException, IOException {
String pkgName = parser.getAttributeValue(null, "n");
int outerDepth = parser.getDepth();
@@ -686,7 +691,7 @@ public class AppOpsService extends IAppOpsService.Stub {
String tagName = parser.getName();
if (tagName.equals("uid")) {
- readUid(parser, pkgName);
+ readUid(parser, vers, pkgName);
} else {
Slog.w(TAG, "Unknown element under <pkg>: "
+ parser.getName());
@@ -695,7 +700,7 @@ public class AppOpsService extends IAppOpsService.Stub {
}
}
- void readUid(XmlPullParser parser, String pkgName) throws NumberFormatException,
+ void readUid(XmlPullParser parser, int vers, String pkgName) throws NumberFormatException,
XmlPullParserException, IOException {
int uid = Integer.parseInt(parser.getAttributeValue(null, "n"));
int outerDepth = parser.getDepth();
@@ -711,7 +716,12 @@ public class AppOpsService extends IAppOpsService.Stub {
Op op = new Op(Integer.parseInt(parser.getAttributeValue(null, "n")));
String mode = parser.getAttributeValue(null, "m");
if (mode != null) {
- op.mode = Integer.parseInt(mode);
+ if (vers < CURRENT_VERSION && op.op != AppOpsManager.OP_POST_NOTIFICATION) {
+ Slog.w(TAG, "AppOps vers " + vers + ": drop mode from "
+ + pkgName + "/" + uid + " op " + op.op);
+ } else {
+ op.mode = Integer.parseInt(mode);
+ }
}
String time = parser.getAttributeValue(null, "t");
if (time != null) {
@@ -761,6 +771,7 @@ public class AppOpsService extends IAppOpsService.Stub {
out.setOutput(stream, "utf-8");
out.startDocument(null, true);
out.startTag(null, "app-ops");
+ out.attribute(null, "vers", Integer.toString(CURRENT_VERSION));
if (allOps != null) {
String lastPkg = null;