Only check high sampling permission when requested (native)
Instead of checking for all packages, only check the permission
when it is required to avoid spammy warnings.
Bug: 199125995
Test: Verify warning logs are reduced
Change-Id: I98ca9ffd513aadbabf484a1522def00d9f7102b2
diff --git a/services/sensorservice/SensorDirectConnection.cpp b/services/sensorservice/SensorDirectConnection.cpp
index af86d09..fae16f6 100644
--- a/services/sensorservice/SensorDirectConnection.cpp
+++ b/services/sensorservice/SensorDirectConnection.cpp
@@ -32,7 +32,6 @@
: mService(service), mUid(uid), mMem(*mem),
mHalChannelHandle(halChannelHandle),
mOpPackageName(opPackageName), mDestroyed(false) {
- mIsRateCappedBasedOnPermission = mService->isRateCappedBasedOnPermission(mOpPackageName);
mUserId = multiuser_get_user_id(mUid);
ALOGD_IF(DEBUG_CONNECTIONS, "Created SensorDirectConnection");
}
@@ -197,8 +196,8 @@
if (mService->isSensorInCappedSet(s.getType())) {
// Back up the rates that the app is allowed to have if the mic toggle is off
// This is used in the uncapRates() function.
- if (!mIsRateCappedBasedOnPermission ||
- requestedRateLevel <= SENSOR_SERVICE_CAPPED_SAMPLING_RATE_LEVEL) {
+ if ((requestedRateLevel <= SENSOR_SERVICE_CAPPED_SAMPLING_RATE_LEVEL) ||
+ !isRateCappedBasedOnPermission()) {
mMicRateBackup[handle] = requestedRateLevel;
} else {
mMicRateBackup[handle] = SENSOR_SERVICE_CAPPED_SAMPLING_RATE_LEVEL;