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

Commit 9bb81c04 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Skip get target SDK for VNDK client on aidl" into udc-qpr-dev

parents ba2bdaa5 2ed0c98b
Loading
Loading
Loading
Loading
+7 −5
Original line number Original line Diff line number Diff line
@@ -89,7 +89,7 @@ bool SensorService::sHmacGlobalKeyIsValid = false;
std::map<String16, int> SensorService::sPackageTargetVersion;
std::map<String16, int> SensorService::sPackageTargetVersion;
Mutex SensorService::sPackageTargetVersionLock;
Mutex SensorService::sPackageTargetVersionLock;
String16 SensorService::sSensorInterfaceDescriptorPrefix =
String16 SensorService::sSensorInterfaceDescriptorPrefix =
        String16("android.frameworks.sensorservice@");
    String16("android.frameworks.sensorservice");
AppOpsManager SensorService::sAppOpsManager;
AppOpsManager SensorService::sAppOpsManager;
std::atomic_uint64_t SensorService::curProxCallbackSeq(0);
std::atomic_uint64_t SensorService::curProxCallbackSeq(0);
std::atomic_uint64_t SensorService::completedCallbackSeq(0);
std::atomic_uint64_t SensorService::completedCallbackSeq(0);
@@ -2242,10 +2242,12 @@ bool SensorService::hasPermissionForSensor(const Sensor& sensor) {
}
}


int SensorService::getTargetSdkVersion(const String16& opPackageName) {
int SensorService::getTargetSdkVersion(const String16& opPackageName) {
    // Don't query the SDK version for the ISensorManager descriptor as it doesn't have one. This
    // Don't query the SDK version for the ISensorManager descriptor as it
    // descriptor tends to be used for VNDK clients, but can technically be set by anyone so don't
    // doesn't have one. This descriptor tends to be used for VNDK clients, but
    // give it elevated privileges.
    // can technically be set by anyone so don't give it elevated privileges.
    if (opPackageName.startsWith(sSensorInterfaceDescriptorPrefix)) {
    bool isVNDK = opPackageName.startsWith(sSensorInterfaceDescriptorPrefix) &&
                  opPackageName.contains(String16("@"));
    if (isVNDK) {
        return -1;
        return -1;
    }
    }


+10 −2
Original line number Original line Diff line number Diff line
@@ -188,8 +188,16 @@ ndk::ScopedAStatus SensorManagerAidl::getSensorList(std::vector<SensorInfo>* _ai
}
}


::android::SensorManager& SensorManagerAidl::getInternalManager() {
::android::SensorManager& SensorManagerAidl::getInternalManager() {
    return ::android::SensorManager::getInstanceForPackage(
    int32_t version;
            String16(ISensorManager::descriptor));
    ndk::ScopedAStatus status = getInterfaceVersion(&version);
    if (!status.isOk()) {
        LOG(ERROR) << "Failed to get interface version with error: "
                   << status.getDescription();
        version = -1;
    }
    String16 packageName = String16(ISensorManager::descriptor);
    packageName += String16("@") + String16(std::to_string(version).c_str());
    return ::android::SensorManager::getInstanceForPackage(packageName);
}
}


/* One global looper for all event queues created from this SensorManager. */
/* One global looper for all event queues created from this SensorManager. */