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

Commit 72c5e35c authored by Arthur Ishiguro's avatar Arthur Ishiguro
Browse files

Catch exception when using noteOp in Context Hub Service

The AppOpManager may throw a security exception, but is not
caught at the service, so a message may be silently dropped.

Bug: 194285834
Test: Load on device
Change-Id: I35c8a9c6d3010865f8cab9b247ba51e74756a9ca
parent 65824102
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -605,10 +605,16 @@ public class ContextHubClientBroker extends IContextHubClient.Stub
        for (String permission : permissions) {
            int opCode = mAppOpsManager.permissionToOpCode(permission);
            if (opCode != AppOpsManager.OP_NONE) {
                try {
                    if (mAppOpsManager.noteOp(opCode, mUid, mPackage, mAttributionTag, noteMessage)
                            != AppOpsManager.MODE_ALLOWED) {
                        return false;
                    }
                } catch (SecurityException e) {
                    Log.e(TAG, "SecurityException: noteOp for pkg " + mPackage + " opcode "
                            + opCode + ": " + e.getMessage());
                    return false;
                }
            }
        }