diff options
author | 2023-06-02 13:31:05 -0700 | |
---|---|---|
committer | 2023-06-05 18:10:15 +0000 | |
commit | 8d669dc15cb499b263aaeb542a1958bf8c944c06 (patch) | |
tree | 0fc506eba8182fe616010f8bb83b3929d6b07dfe | |
parent | c9587bf7bc178381fb1fa26149296958a9353bfa (diff) |
sensor_privacy: use waitForService instead of getService
Test: build & boot
Bug: 284487308
Change-Id: I462fb2f897e0b287c804d2afeac94976446fa66c
-rw-r--r-- | libs/sensorprivacy/SensorPrivacyManager.cpp | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/libs/sensorprivacy/SensorPrivacyManager.cpp b/libs/sensorprivacy/SensorPrivacyManager.cpp index 2be98e7281..57c74ee565 100644 --- a/libs/sensorprivacy/SensorPrivacyManager.cpp +++ b/libs/sensorprivacy/SensorPrivacyManager.cpp @@ -32,27 +32,12 @@ SensorPrivacyManager::SensorPrivacyManager() sp<hardware::ISensorPrivacyManager> SensorPrivacyManager::getService() { std::lock_guard<Mutex> scoped_lock(mLock); - int64_t startTime = 0; sp<hardware::ISensorPrivacyManager> service = mService; - while (service == nullptr || !IInterface::asBinder(service)->isBinderAlive()) { - sp<IBinder> binder = defaultServiceManager()->checkService(String16("sensor_privacy")); - if (binder == nullptr) { - // Wait for the sensor privacy service to come back... - if (startTime == 0) { - startTime = uptimeMillis(); - ALOGI("Waiting for sensor privacy service"); - } else if ((uptimeMillis() - startTime) > 1000000) { - ALOGW("Waiting too long for sensor privacy service, giving up"); - service = nullptr; - break; - } - usleep(25000); - } else { - service = interface_cast<hardware::ISensorPrivacyManager>(binder); - mService = service; - } + if (service == nullptr || !IInterface::asBinder(service)->isBinderAlive()) { + sp<IBinder> binder = defaultServiceManager()->waitForService(String16("sensor_privacy")); + mService = interface_cast<hardware::ISensorPrivacyManager>(binder); } - return service; + return mService; } bool SensorPrivacyManager::supportsSensorToggle(int toggleType, int sensor) { |