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

Commit 5bd43936 authored by Kun Liang's avatar Kun Liang
Browse files

AppOps: fix "contact" delete ops check failed

applyBatch() is another API that can delete "contact". Add ops
check to block delete ops.

Change-Id: I9e253750b96ac534fb205fd23f51658e19eb86ee
parent 22be7a7f
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -248,7 +248,12 @@ public abstract class ContentProvider implements ComponentCallbacks2 {
                    }
                }

                if (operation.isWriteOperation()) {
                if (operation.isDeleteOperation()) {
                    if (enforceDeletePermission(callingPkg, operation.getUri())
                            != AppOpsManager.MODE_ALLOWED) {
                        throw new OperationApplicationException("App op not allowed", 0);
                    }
                } else if (operation.isWriteOperation()) {
                    if (enforceWritePermission(callingPkg, operation.getUri())
                            != AppOpsManager.MODE_ALLOWED) {
                        throw new OperationApplicationException("App op not allowed", 0);
+5 −0
Original line number Diff line number Diff line
@@ -182,6 +182,11 @@ public class ContentProviderOperation implements Parcelable {
        return mType;
    }

    /** @hide */
    public boolean isDeleteOperation() {
        return mType == TYPE_DELETE;
    }

    public boolean isWriteOperation() {
        return mType == TYPE_DELETE || mType == TYPE_INSERT || mType == TYPE_UPDATE;
    }