summaryrefslogtreecommitdiffstats
path: root/libs/gui/SensorManager.cpp
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2011-10-16 00:38:30 -0700
committerMathias Agopian <mathias@google.com>2011-10-16 00:38:30 -0700
commitbe58de0d627fa0ecb087eeff95da13c783bf2392 (patch)
tree0a66a9bddca9d95fdabd1ad0406657bc641a36aa /libs/gui/SensorManager.cpp
parent00f99e88c88a9e033b391d57304823efb0cefba9 (diff)
downloadframeworks_native-be58de0d627fa0ecb087eeff95da13c783bf2392.tar.gz
frameworks_native-be58de0d627fa0ecb087eeff95da13c783bf2392.tar.bz2
frameworks_native-be58de0d627fa0ecb087eeff95da13c783bf2392.zip
add logging and defensive code when initializing sensors
Bug: 5445240 Change-Id: I9dc7d27d3e8b4f15989488859831526d8c7ded3b
Diffstat (limited to 'libs/gui/SensorManager.cpp')
-rw-r--r--libs/gui/SensorManager.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/libs/gui/SensorManager.cpp b/libs/gui/SensorManager.cpp
index d719efb5f..4774a58b3 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;
}
// ----------------------------------------------------------------------------