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

Commit f9f919a6 authored by Rocky Fang's avatar Rocky Fang Committed by Automerger Merge Worker
Browse files

Skip AppOps call from system UID am: cb142de5

parents 419df213 cb142de5
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -463,14 +463,16 @@ bool SensorService::SensorEventConnection::noteOpIfRequired(const sensors_event_
        if ((event.type == SENSOR_TYPE_STEP_COUNTER || event.type == SENSOR_TYPE_STEP_DETECTOR) &&
            mTargetSdk > 0 && mTargetSdk <= __ANDROID_API_P__) {
            success = true;
        } else if (mUid == AID_SYSTEM) {
            // Allow access if it is requested from system.
            success = true;
        } else {
            int32_t sensorHandle = event.sensor;
            String16 noteMsg("Sensor event (");
            noteMsg.append(String16(mService->getSensorStringType(sensorHandle)));
            noteMsg.append(String16(")"));
            int32_t appOpMode = mService->sAppOpsManager.noteOp(iter->second, mUid,
                                                                mOpPackageName, mAttributionTag,
                                                                noteMsg);
            int32_t appOpMode = mService->sAppOpsManager.noteOp(iter->second, mUid, mOpPackageName,
                                                                mAttributionTag, noteMsg);
            success = (appOpMode == AppOpsManager::MODE_ALLOWED);
        }
    }
+8 −3
Original line number Diff line number Diff line
@@ -2302,11 +2302,16 @@ bool SensorService::canAccessSensor(const Sensor& sensor, const char* operation,
        // requirement to hold the AR permission to access Step Counter and Step Detector events
        // was introduced.
        canAccess = true;
    } else if (IPCThreadState::self()->getCallingUid() == AID_SYSTEM) {
        // Allow access if it is requested from system.
        canAccess = true;
    } else if (hasPermissionForSensor(sensor)) {
        // Ensure that the AppOp is allowed, or that there is no necessary app op for the sensor
        // Ensure that the AppOp is allowed, or that there is no necessary app op
        // for the sensor
        if (opCode >= 0) {
            const int32_t appOpMode = sAppOpsManager.checkOp(opCode,
                    IPCThreadState::self()->getCallingUid(), opPackageName);
            const int32_t appOpMode =
                    sAppOpsManager.checkOp(opCode, IPCThreadState::self()->getCallingUid(),
                                           opPackageName);
            canAccess = (appOpMode == AppOpsManager::MODE_ALLOWED);
        } else {
            canAccess = true;