summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAravind Akella <aakella@google.com>2015-08-17 15:22:12 -0700
committerAravind Akella <aakella@google.com>2015-08-25 11:24:02 -0700
commit8f35ca973063e1449c5ec40b618393187a47ec58 (patch)
treefdfae931073dcbb4aef02f28a0d9eaf7451e22c0
parentd213f5e7a4bee477c707fc428cb24aa503971ef1 (diff)
downloadframeworks_native-8f35ca973063e1449c5ec40b618393187a47ec58.zip
frameworks_native-8f35ca973063e1449c5ec40b618393187a47ec58.tar.gz
frameworks_native-8f35ca973063e1449c5ec40b618393187a47ec58.tar.bz2
SensorManager fixes.
i) Use pingBinder() to check the status of sensorservice everytime an event_queue is created. Retry to establish the binder connection if SensorService has recovered from a runtime restart. ii) LOG_ALWAYS_FATAL_IF getService(SensorService) returns NULL or malloc returns NULL. Bug: 22634472 Change-Id: I4e3912839b6f4114be1a124510878774dbd576a4
-rw-r--r--libs/gui/SensorManager.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/libs/gui/SensorManager.cpp b/libs/gui/SensorManager.cpp
index 9934151..33608b5 100644
--- a/libs/gui/SensorManager.cpp
+++ b/libs/gui/SensorManager.cpp
@@ -110,10 +110,20 @@ void SensorManager::sensorManagerDied()
}
status_t SensorManager::assertStateLocked() const {
+ bool initSensorManager = false;
if (mSensorServer == NULL) {
- // try for 10 seconds before giving up ...
+ initSensorManager = true;
+ } else {
+ // Ping binder to check if sensorservice is alive.
+ status_t err = IInterface::asBinder(mSensorServer)->pingBinder();
+ if (err != NO_ERROR) {
+ initSensorManager = true;
+ }
+ }
+ if (initSensorManager) {
+ // try for 300 seconds (60*5(getService() tries for 5 seconds)) before giving up ...
const String16 name("sensorservice");
- for (int i = 0;i < 10; i++) {
+ for (int i = 0; i < 60; i++) {
status_t err = getService(name, &mSensorServer);
if (err == NAME_NOT_FOUND) {
sleep(1);
@@ -135,9 +145,7 @@ status_t SensorManager::assertStateLocked() const {
DeathObserver(SensorManager& mgr) : mSensorManger(mgr) { }
};
- if (mSensorServer == NULL) {
- ALOGE("FATAL getsensorservice returned NULL");
- }
+ LOG_ALWAYS_FATAL_IF(mSensorServer.get() == NULL, "getService(SensorService) NULL");
mDeathObserver = new DeathObserver(*const_cast<SensorManager *>(this));
IInterface::asBinder(mSensorServer)->linkToDeath(mDeathObserver);
@@ -146,6 +154,8 @@ status_t SensorManager::assertStateLocked() const {
size_t count = mSensors.size();
mSensorList =
static_cast<Sensor const**>(malloc(count * sizeof(Sensor*)));
+ LOG_ALWAYS_FATAL_IF(mSensorList == NULL, "mSensorList NULL");
+
for (size_t i=0 ; i<count ; i++) {
mSensorList[i] = mSensors.array() + i;
}