Loading services/sensorservice/SensorEventConnection.cpp +6 −2 Original line number Diff line number Diff line Loading @@ -161,7 +161,7 @@ bool SensorService::SensorEventConnection::addSensor(int32_t handle) { Mutex::Autolock _l(mConnectionLock); sp<SensorInterface> si = mService->getSensorInterfaceFromHandle(handle); if (si == nullptr || !canAccessSensor(si->getSensor(), "Tried adding", mOpPackageName) || !canAccessSensor(si->getSensor(), "Add to SensorEventConnection: ", mOpPackageName) || mSensorInfo.count(handle) > 0) { return false; } Loading Loading @@ -460,8 +460,12 @@ bool SensorService::SensorEventConnection::noteOpIfRequired(const sensors_event_ mTargetSdk > 0 && mTargetSdk <= __ANDROID_API_P__) { 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); mOpPackageName, {}, noteMsg); success = (appOpMode == AppOpsManager::MODE_ALLOWED); } } Loading services/sensorservice/SensorList.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,12 @@ String8 SensorList::getName(int handle) const { mNonSensor.getName()); } String8 SensorList::getStringType(int handle) const { return getOne<String8>( handle, [] (const Entry& e) -> String8 {return e.si->getSensor().getStringType();}, mNonSensor.getStringType()); } sp<SensorInterface> SensorList::getInterface(int handle) const { return getOne<sp<SensorInterface>>( handle, [] (const Entry& e) -> sp<SensorInterface> {return e.si;}, nullptr); Loading services/sensorservice/SensorList.h +2 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,8 @@ public: const Vector<Sensor> getVirtualSensors() const; String8 getName(int handle) const; String8 getStringType(int handle) const; sp<SensorInterface> getInterface(int handle) const; bool isNewHandle(int handle) const; Loading services/sensorservice/SensorService.cpp +10 −7 Original line number Diff line number Diff line Loading @@ -1112,6 +1112,10 @@ String8 SensorService::getSensorName(int handle) const { return mSensors.getName(handle); } String8 SensorService::getSensorStringType(int handle) const { return mSensors.getStringType(handle); } bool SensorService::isVirtualSensor(int handle) const { sp<SensorInterface> sensor = getSensorInterfaceFromHandle(handle); return sensor != nullptr && sensor->isVirtual(); Loading Loading @@ -1807,9 +1811,6 @@ bool SensorService::canAccessSensor(const Sensor& sensor, const char* operation, } const int32_t opCode = sensor.getRequiredAppOp(); const int32_t appOpMode = sAppOpsManager.checkOp(opCode, IPCThreadState::self()->getCallingUid(), opPackageName); bool appOpAllowed = appOpMode == AppOpsManager::MODE_ALLOWED; int targetSdkVersion = getTargetSdkVersion(opPackageName); bool canAccess = false; Loading @@ -1822,14 +1823,16 @@ bool SensorService::canAccessSensor(const Sensor& sensor, const char* operation, canAccess = true; } else if (hasPermissionForSensor(sensor)) { // Ensure that the AppOp is allowed, or that there is no necessary app op for the sensor if (opCode < 0 || appOpAllowed) { if (opCode >= 0) { const int32_t appOpMode = sAppOpsManager.checkOp(opCode, IPCThreadState::self()->getCallingUid(), opPackageName); canAccess = (appOpMode == AppOpsManager::MODE_ALLOWED); } else { canAccess = true; } } if (canAccess) { sAppOpsManager.noteOp(opCode, IPCThreadState::self()->getCallingUid(), opPackageName); } else { if (!canAccess) { ALOGE("%s %s a sensor (%s) without holding %s", String8(opPackageName).string(), operation, sensor.getName().string(), sensor.getRequiredPermission().string()); } Loading services/sensorservice/SensorService.h +1 −0 Original line number Diff line number Diff line Loading @@ -295,6 +295,7 @@ private: virtual status_t dump(int fd, const Vector<String16>& args); status_t dumpProtoLocked(int fd, ConnectionSafeAutolock* connLock) const; String8 getSensorName(int handle) const; String8 getSensorStringType(int handle) const; bool isVirtualSensor(int handle) const; sp<SensorInterface> getSensorInterfaceFromHandle(int handle) const; bool isWakeUpSensor(int type) const; Loading Loading
services/sensorservice/SensorEventConnection.cpp +6 −2 Original line number Diff line number Diff line Loading @@ -161,7 +161,7 @@ bool SensorService::SensorEventConnection::addSensor(int32_t handle) { Mutex::Autolock _l(mConnectionLock); sp<SensorInterface> si = mService->getSensorInterfaceFromHandle(handle); if (si == nullptr || !canAccessSensor(si->getSensor(), "Tried adding", mOpPackageName) || !canAccessSensor(si->getSensor(), "Add to SensorEventConnection: ", mOpPackageName) || mSensorInfo.count(handle) > 0) { return false; } Loading Loading @@ -460,8 +460,12 @@ bool SensorService::SensorEventConnection::noteOpIfRequired(const sensors_event_ mTargetSdk > 0 && mTargetSdk <= __ANDROID_API_P__) { 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); mOpPackageName, {}, noteMsg); success = (appOpMode == AppOpsManager::MODE_ALLOWED); } } Loading
services/sensorservice/SensorList.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,12 @@ String8 SensorList::getName(int handle) const { mNonSensor.getName()); } String8 SensorList::getStringType(int handle) const { return getOne<String8>( handle, [] (const Entry& e) -> String8 {return e.si->getSensor().getStringType();}, mNonSensor.getStringType()); } sp<SensorInterface> SensorList::getInterface(int handle) const { return getOne<sp<SensorInterface>>( handle, [] (const Entry& e) -> sp<SensorInterface> {return e.si;}, nullptr); Loading
services/sensorservice/SensorList.h +2 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,8 @@ public: const Vector<Sensor> getVirtualSensors() const; String8 getName(int handle) const; String8 getStringType(int handle) const; sp<SensorInterface> getInterface(int handle) const; bool isNewHandle(int handle) const; Loading
services/sensorservice/SensorService.cpp +10 −7 Original line number Diff line number Diff line Loading @@ -1112,6 +1112,10 @@ String8 SensorService::getSensorName(int handle) const { return mSensors.getName(handle); } String8 SensorService::getSensorStringType(int handle) const { return mSensors.getStringType(handle); } bool SensorService::isVirtualSensor(int handle) const { sp<SensorInterface> sensor = getSensorInterfaceFromHandle(handle); return sensor != nullptr && sensor->isVirtual(); Loading Loading @@ -1807,9 +1811,6 @@ bool SensorService::canAccessSensor(const Sensor& sensor, const char* operation, } const int32_t opCode = sensor.getRequiredAppOp(); const int32_t appOpMode = sAppOpsManager.checkOp(opCode, IPCThreadState::self()->getCallingUid(), opPackageName); bool appOpAllowed = appOpMode == AppOpsManager::MODE_ALLOWED; int targetSdkVersion = getTargetSdkVersion(opPackageName); bool canAccess = false; Loading @@ -1822,14 +1823,16 @@ bool SensorService::canAccessSensor(const Sensor& sensor, const char* operation, canAccess = true; } else if (hasPermissionForSensor(sensor)) { // Ensure that the AppOp is allowed, or that there is no necessary app op for the sensor if (opCode < 0 || appOpAllowed) { if (opCode >= 0) { const int32_t appOpMode = sAppOpsManager.checkOp(opCode, IPCThreadState::self()->getCallingUid(), opPackageName); canAccess = (appOpMode == AppOpsManager::MODE_ALLOWED); } else { canAccess = true; } } if (canAccess) { sAppOpsManager.noteOp(opCode, IPCThreadState::self()->getCallingUid(), opPackageName); } else { if (!canAccess) { ALOGE("%s %s a sensor (%s) without holding %s", String8(opPackageName).string(), operation, sensor.getName().string(), sensor.getRequiredPermission().string()); } Loading
services/sensorservice/SensorService.h +1 −0 Original line number Diff line number Diff line Loading @@ -295,6 +295,7 @@ private: virtual status_t dump(int fd, const Vector<String16>& args); status_t dumpProtoLocked(int fd, ConnectionSafeAutolock* connLock) const; String8 getSensorName(int handle) const; String8 getSensorStringType(int handle) const; bool isVirtualSensor(int handle) const; sp<SensorInterface> getSensorInterfaceFromHandle(int handle) const; bool isWakeUpSensor(int type) const; Loading