Fix issue where GeofenceHardwareImpl can crash.
-It can't be instantiated before looper thread
is ready.
Bug: 21185178
Change-Id: I9e5434f7821c608a01bfd962c5482f6c2c2a022d
diff --git a/services/core/java/com/android/server/location/FlpHardwareProvider.java b/services/core/java/com/android/server/location/FlpHardwareProvider.java
index 1fb22be..259ff1d 100644
--- a/services/core/java/com/android/server/location/FlpHardwareProvider.java
+++ b/services/core/java/com/android/server/location/FlpHardwareProvider.java
@@ -48,7 +48,7 @@
// Capabilities provided by FlpCallbacks
private boolean mHaveBatchingCapabilities;
private int mBatchingCapabilities;
- private int mVersion;
+ private int mVersion = 1;
private static FlpHardwareProvider sSingletonInstance = null;
@@ -154,7 +154,9 @@
private void setVersion(int version) {
mVersion = version;
- getGeofenceHardwareSink().setVersion(version);
+ if (mGeofenceHardwareSink != null) {
+ mGeofenceHardwareSink.setVersion(version);
+ }
}
private void maybeSendCapabilities() {
@@ -480,6 +482,7 @@
private GeofenceHardwareImpl getGeofenceHardwareSink() {
if (mGeofenceHardwareSink == null) {
mGeofenceHardwareSink = GeofenceHardwareImpl.getInstance(mContext);
+ mGeofenceHardwareSink.setVersion(mVersion);
}
return mGeofenceHardwareSink;