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

Commit 5180e467 authored by Brian Stack's avatar Brian Stack
Browse files

Fix inverted logic in isOperationRestricted

SensorService::isOperationRestricted incorrectly returned 'true'
whenever the Sensor Service was in normal mode and an application was
not whitelisted. This patch corrects the logic and updates the
function's name to be isOperationPermitted to avoid confusion.

Bug: 128028800
Test: CTS Direct Channel tests pass
Change-Id: Ia1684be54c1c7c0db81d8fcb2780fd2583a35537
parent 3d694145
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -100,7 +100,7 @@ int32_t SensorService::SensorDirectConnection::configureChannel(int handle, int
        return NO_ERROR;
        return NO_ERROR;
    }
    }


    if (mService->isOperationRestricted(mOpPackageName)) {
    if (!mService->isOperationPermitted(mOpPackageName)) {
        return PERMISSION_DENIED;
        return PERMISSION_DENIED;
    }
    }


+4 −4
Original line number Original line Diff line number Diff line
@@ -1691,13 +1691,13 @@ bool SensorService::isWhiteListedPackage(const String8& packageName) {
    return (packageName.contains(mWhiteListedPackage.string()));
    return (packageName.contains(mWhiteListedPackage.string()));
}
}


bool SensorService::isOperationRestricted(const String16& opPackageName) {
bool SensorService::isOperationPermitted(const String16& opPackageName) {
    Mutex::Autolock _l(mLock);
    Mutex::Autolock _l(mLock);
    if (mCurrentOperatingMode != RESTRICTED) {
    if (mCurrentOperatingMode == RESTRICTED) {
        String8 package(opPackageName);
        String8 package(opPackageName);
        return !isWhiteListedPackage(package);
        return isWhiteListedPackage(package);
    }
    }
    return false;
    return true;
}
}


void SensorService::UidPolicy::registerSelf() {
void SensorService::UidPolicy::registerSelf() {
+1 −1
Original line number Original line Diff line number Diff line
@@ -272,7 +272,7 @@ private:
    // allowed to register for or call flush on sensors. Typically only cts test packages are
    // allowed to register for or call flush on sensors. Typically only cts test packages are
    // allowed.
    // allowed.
    bool isWhiteListedPackage(const String8& packageName);
    bool isWhiteListedPackage(const String8& packageName);
    bool isOperationRestricted(const String16& opPackageName);
    bool isOperationPermitted(const String16& opPackageName);


    // Reset the state of SensorService to NORMAL mode.
    // Reset the state of SensorService to NORMAL mode.
    status_t resetToNormalMode();
    status_t resetToNormalMode();