Skip AppOps call from system UID
This is not needed since system UID should always have permission.
Bug: 334110086
Test: Presubmit
Change-Id: I327fed5587e40cce96f196561f80bad954dbb3be
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp
index e1c43c6..69e4309 100644
--- a/services/sensorservice/SensorService.cpp
+++ b/services/sensorservice/SensorService.cpp
@@ -2302,11 +2302,16 @@
// 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;