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
This commit is contained in:
parent
d213f5e7a4
commit
8f35ca9730
@ -110,10 +110,20 @@ void SensorManager::sensorManagerDied()
|
|||||||
}
|
}
|
||||||
|
|
||||||
status_t SensorManager::assertStateLocked() const {
|
status_t SensorManager::assertStateLocked() const {
|
||||||
|
bool initSensorManager = false;
|
||||||
if (mSensorServer == NULL) {
|
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");
|
const String16 name("sensorservice");
|
||||||
for (int i = 0;i < 10; i++) {
|
for (int i = 0; i < 60; i++) {
|
||||||
status_t err = getService(name, &mSensorServer);
|
status_t err = getService(name, &mSensorServer);
|
||||||
if (err == NAME_NOT_FOUND) {
|
if (err == NAME_NOT_FOUND) {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
@ -135,9 +145,7 @@ status_t SensorManager::assertStateLocked() const {
|
|||||||
DeathObserver(SensorManager& mgr) : mSensorManger(mgr) { }
|
DeathObserver(SensorManager& mgr) : mSensorManger(mgr) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mSensorServer == NULL) {
|
LOG_ALWAYS_FATAL_IF(mSensorServer.get() == NULL, "getService(SensorService) NULL");
|
||||||
ALOGE("FATAL getsensorservice returned NULL");
|
|
||||||
}
|
|
||||||
|
|
||||||
mDeathObserver = new DeathObserver(*const_cast<SensorManager *>(this));
|
mDeathObserver = new DeathObserver(*const_cast<SensorManager *>(this));
|
||||||
IInterface::asBinder(mSensorServer)->linkToDeath(mDeathObserver);
|
IInterface::asBinder(mSensorServer)->linkToDeath(mDeathObserver);
|
||||||
@ -146,6 +154,8 @@ status_t SensorManager::assertStateLocked() const {
|
|||||||
size_t count = mSensors.size();
|
size_t count = mSensors.size();
|
||||||
mSensorList =
|
mSensorList =
|
||||||
static_cast<Sensor const**>(malloc(count * sizeof(Sensor*)));
|
static_cast<Sensor const**>(malloc(count * sizeof(Sensor*)));
|
||||||
|
LOG_ALWAYS_FATAL_IF(mSensorList == NULL, "mSensorList NULL");
|
||||||
|
|
||||||
for (size_t i=0 ; i<count ; i++) {
|
for (size_t i=0 ; i<count ; i++) {
|
||||||
mSensorList[i] = mSensors.array() + i;
|
mSensorList[i] = mSensors.array() + i;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user