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

Commit b22f71ea authored by Eugene Susla's avatar Eugene Susla
Browse files

Log a string to logcat when ContentProvider access gets denied due to appop

Make sure testers have a way to quickly determine when an app is trying to access
call logs or SMS without being the default handler, so we don't get inundated with
bugs about correct behavior

Test: proofread
Change-Id: I46b9dc86073101f8ca08ac1bc90c79338afd114f
parent 4df6418f
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import android.os.UserHandle;
import android.os.storage.StorageManager;
import android.text.TextUtils;
import android.util.Log;
import android.util.Slog;

import com.android.internal.annotations.VisibleForTesting;

@@ -586,7 +587,13 @@ public abstract class ContentProvider implements ComponentCallbacks2 {
        private int noteProxyOp(String callingPkg, int op) {
            if (op != AppOpsManager.OP_NONE) {
                int mode = mAppOpsManager.noteProxyOp(op, callingPkg);
                return mode == MODE_DEFAULT ? interpretDefaultAppOpMode(op) : mode;
                int nonDefaultMode = mode == MODE_DEFAULT ? interpretDefaultAppOpMode(op) : mode;
                if (mode == MODE_DEFAULT && nonDefaultMode == MODE_IGNORED) {
                    Slog.w(TAG, "Denying access for " + callingPkg + " to " + getClass().getName()
                            + " (" + AppOpsManager.opToName(op)
                            + " = " + AppOpsManager.opToName(mode) + ")");
                }
                return mode == MODE_DEFAULT ? nonDefaultMode : mode;
            }

            return AppOpsManager.MODE_ALLOWED;