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

Commit d5f77513 authored by shafik's avatar shafik
Browse files

Ignore package mode for MANAGE_EXTERNAL_STORAGE

OP_MANAGE_EXTERNAL_STORAGE's app-op mode should be set via setUidMode
instead of setMode. This change ignores the package mode (set via
setMode) for that app-op.

Test: manual update test
    * adb pull /data/system/appops.xml # observe that app-op in the file
    * flash device with the change
    * adb pull /data/system/appops.xml # observe the app-op was removed

Change-Id: I8dd503592ae20388e59b109a4b04f58d00a9597c
parent d4bf524a
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -4068,9 +4068,11 @@ public class AppOpsService extends IAppOpsService.Stub {
    private void readOp(XmlPullParser parser, @NonNull UidState uidState,
        @NonNull String pkgName, boolean isPrivileged) throws NumberFormatException,
        XmlPullParserException, IOException {
        Op op = new Op(uidState, pkgName,
                Integer.parseInt(parser.getAttributeValue(null, "n")),
                uidState.uid);
        int opCode = Integer.parseInt(parser.getAttributeValue(null, "n"));
        if (isIgnoredAppOp(opCode)) {
            return;
        }
        Op op = new Op(uidState, pkgName, opCode, uidState.uid);

        final int mode = XmlUtils.readIntAttribute(parser, "m",
                AppOpsManager.opToDefaultMode(op.op));
@@ -4104,6 +4106,16 @@ public class AppOpsService extends IAppOpsService.Stub {
        ops.put(op.op, op);
    }

    //TODO(b/149995538): Remove once this has reached all affected devices
    private static boolean isIgnoredAppOp(int op) {
        switch (op) {
            case AppOpsManager.OP_MANAGE_EXTERNAL_STORAGE:
                return true;
            default:
                return false;
        }
    }

    void writeState() {
        synchronized (mFile) {
            FileOutputStream stream;