summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Dianne Hackborn <hackbod@google.com> 2015-08-08 06:35:03 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2015-08-08 06:35:03 +0000
commitfc81be947fcbb0d738a75eb2c6d560c52f7f9a99 (patch)
tree3fe57681fbe853e4b6e5218ea290e5e6c071f6a0
parent70f998e57df2b3ed79331669a93a0ba314f25e7d (diff)
parent4d34bb8304ae2e85c2b12628c9a6346c6835de5d (diff)
Merge "Fix issue #23037093: "Write system settings" permission value fails..." into mnc-dev
-rw-r--r--services/core/java/com/android/server/AppOpsService.java51
1 files changed, 50 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/AppOpsService.java b/services/core/java/com/android/server/AppOpsService.java
index 45c020c8cfc2..56ebed63bc89 100644
--- a/services/core/java/com/android/server/AppOpsService.java
+++ b/services/core/java/com/android/server/AppOpsService.java
@@ -1245,6 +1245,7 @@ public class AppOpsService extends IAppOpsService.Stub {
return;
}
boolean success = false;
+ mUidStates.clear();
try {
XmlPullParser parser = Xml.newPullParser();
parser.setInput(stream, StandardCharsets.UTF_8.name());
@@ -1448,7 +1449,7 @@ public class AppOpsService extends IAppOpsService.Stub {
XmlSerializer out = new FastXmlSerializer();
out.setOutput(stream, StandardCharsets.UTF_8.name());
out.startDocument(null, true);
- out.startTag(null, "app");
+ out.startTag(null, "app-ops");
final int uidStateCount = mUidStates.size();
for (int i = 0; i < uidStateCount; i++) {
@@ -1541,6 +1542,17 @@ public class AppOpsService extends IAppOpsService.Stub {
}
}
+ private void dumpHelp(PrintWriter pw) {
+ pw.println("AppOps service (appops) dump options:");
+ pw.println(" [-h] [CMD]");
+ pw.println(" -h: print this help text.");
+ pw.println("Commands:");
+ pw.println(" write-settings");
+ pw.println(" Immediately write pending changes to storage.");
+ pw.println(" read-settings");
+ pw.println(" Read the last written settings, replacing current state in RAM.");
+ }
+
@Override
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
@@ -1551,6 +1563,43 @@ public class AppOpsService extends IAppOpsService.Stub {
return;
}
+ if (args != null) {
+ for (int i=0; i<args.length; i++) {
+ String arg = args[i];
+ if ("-h".equals(arg)) {
+ dumpHelp(pw);
+ return;
+ } else if ("write-settings".equals(arg)) {
+ long token = Binder.clearCallingIdentity();
+ try {
+ synchronized (this) {
+ mHandler.removeCallbacks(mWriteRunner);
+ }
+ writeState();
+ pw.println("Current settings written.");
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
+ return;
+ } else if ("read-settings".equals(arg)) {
+ long token = Binder.clearCallingIdentity();
+ try {
+ readState();
+ pw.println("Last settings read.");
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
+ return;
+ } else if (arg.length() > 0 && arg.charAt(0) == '-'){
+ pw.println("Unknown option: " + arg);
+ return;
+ } else {
+ pw.println("Unknown command: " + arg);
+ return;
+ }
+ }
+ }
+
synchronized (this) {
pw.println("Current AppOps Service state:");
final long now = System.currentTimeMillis();