diff options
author | Mathias Agopian <mathias@google.com> | 2011-10-16 00:38:30 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2011-10-16 00:38:30 -0700 |
commit | a338379873cdbaf44211223b40592d7a8284f58b (patch) | |
tree | ce70c6befcb4c4b128576c6c7692cb22f1765aaf /libs | |
parent | d814d4fa0c76a0384f7e32816e1ca36f237911c6 (diff) | |
download | frameworks_base-a338379873cdbaf44211223b40592d7a8284f58b.zip frameworks_base-a338379873cdbaf44211223b40592d7a8284f58b.tar.gz frameworks_base-a338379873cdbaf44211223b40592d7a8284f58b.tar.bz2 |
add logging and defensive code when initializing sensors
Bug: 5445240
Change-Id: I9dc7d27d3e8b4f15989488859831526d8c7ded3b
Diffstat (limited to 'libs')
-rw-r--r-- | libs/gui/SensorManager.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/libs/gui/SensorManager.cpp b/libs/gui/SensorManager.cpp index d719efb..4774a58 100644 --- a/libs/gui/SensorManager.cpp +++ b/libs/gui/SensorManager.cpp @@ -78,9 +78,23 @@ Sensor const* SensorManager::getDefaultSensor(int type) sp<SensorEventQueue> SensorManager::createEventQueue() { - sp<SensorEventQueue> result = new SensorEventQueue( - mSensorServer->createSensorEventConnection()); - return result; + sp<SensorEventQueue> queue; + + if (mSensorServer == NULL) { + LOGE("createEventQueue: mSensorSever is NULL"); + return queue; + } + + sp<ISensorEventConnection> connection = + mSensorServer->createSensorEventConnection(); + if (connection == NULL) { + LOGE("createEventQueue: connection is NULL"); + return queue; + } + + queue = new SensorEventQueue(connection); + + return queue; } // ---------------------------------------------------------------------------- |