summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorPeng Xu <pengxu@google.com>2017-04-23 15:23:07 -0700
committerPeng Xu <pengxu@google.com>2017-04-23 15:23:07 -0700
commitd9d4e1bc3bcecea31cc0aa055758915b3cbc6bef (patch)
tree27bd937704e1c6a29e90746294bd8aecf9bdc17c /core/java
parentb0806f1006ce4e930e338b61002c1ba5d8cf7fed (diff)
Return correct value at initDataInjection and avoid crash
When data inject channel cannot be initialized return false, instead of causing crash. Bug: 37549731 Test: run GTS SensorHostTest, test succeed with no failures observed. Change-Id: Ia7a078b9e7d4f61927da8d76a0206e588fd6686c
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/hardware/SystemSensorManager.java11
1 files changed, 8 insertions, 3 deletions
diff --git a/core/java/android/hardware/SystemSensorManager.java b/core/java/android/hardware/SystemSensorManager.java
index 10c4cb3df89c..bf82dc6d11e1 100644
--- a/core/java/android/hardware/SystemSensorManager.java
+++ b/core/java/android/hardware/SystemSensorManager.java
@@ -285,17 +285,22 @@ public class SystemSensorManager extends SensorManager {
}
// Initialize a client for data_injection.
if (sInjectEventQueue == null) {
- sInjectEventQueue = new InjectEventQueue(mMainLooper, this,
- mContext.getPackageName());
+ try {
+ sInjectEventQueue = new InjectEventQueue(
+ mMainLooper, this, mContext.getPackageName());
+ } catch (RuntimeException e) {
+ Log.e(TAG, "Cannot create InjectEventQueue: " + e);
+ }
}
+ return sInjectEventQueue != null;
} else {
// If data injection is being disabled clean up the native resources.
if (sInjectEventQueue != null) {
sInjectEventQueue.dispose();
sInjectEventQueue = null;
}
+ return true;
}
- return true;
}
}