summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWyattRiley <wyattriley@google.com>2019-02-28 12:05:56 -0800
committerandroid-build-team Robot <android-build-team-robot@google.com>2019-03-13 18:01:49 +0000
commitd374204d68d4eecf1acecc8ee47945eb3a7ab092 (patch)
treee13cc3b52820695d67bee35398888cac35014595
parenta84433b7b7c6467ed653205e9f52cb735659ba5e (diff)
downloadbase-d374204d68d4eecf1acecc8ee47945eb3a7ab092.tar.gz
DO NOT MERGE - SUPL ES Extension - Safer Init and Not After Boot
Safe order of pointer setting and background thread start Verifying mCallEndElapsedRealtimeMillis is not the initial value Bug: 112159033 Bug: 115361555 Bug: 125124724 Test: Verified not-after-boot with test code b/115361555#comment14 Test: Reproed NPE with test thread sleep and verify fix Change-Id: I25dcd5a5b36c218ea8b7ab88d6909382709fd7ab (cherry picked from commit fbcb41f9fbc4e91e023f3103a391182600312ef7)
-rw-r--r--location/java/com/android/internal/location/GpsNetInitiatedHandler.java9
-rw-r--r--services/core/java/com/android/server/location/GnssLocationProvider.java5
2 files changed, 7 insertions, 7 deletions
diff --git a/location/java/com/android/internal/location/GpsNetInitiatedHandler.java b/location/java/com/android/internal/location/GpsNetInitiatedHandler.java
index b5313256e4dc..4e2f28b24305 100644
--- a/location/java/com/android/internal/location/GpsNetInitiatedHandler.java
+++ b/location/java/com/android/internal/location/GpsNetInitiatedHandler.java
@@ -121,8 +121,8 @@ public class GpsNetInitiatedHandler {
static private boolean mIsHexInput = true;
// End time of emergency call, and extension, if set
- private long mCallEndElapsedRealtimeMillis = 0;
- private long mEmergencyExtensionMillis = 0;
+ private volatile long mCallEndElapsedRealtimeMillis = 0;
+ private volatile long mEmergencyExtensionMillis = 0;
public static class GpsNiNotification
{
@@ -245,8 +245,9 @@ public class GpsNetInitiatedHandler {
*/
public boolean getInEmergency() {
boolean isInEmergencyExtension =
- (SystemClock.elapsedRealtime() - mCallEndElapsedRealtimeMillis) <
- mEmergencyExtensionMillis;
+ (mCallEndElapsedRealtimeMillis > 0)
+ && ((SystemClock.elapsedRealtime() - mCallEndElapsedRealtimeMillis)
+ < mEmergencyExtensionMillis);
boolean isInEmergencyCallback = mTelephonyManager.getEmergencyCallbackMode();
return mIsInEmergencyCall || isInEmergencyCallback || isInEmergencyExtension;
}
diff --git a/services/core/java/com/android/server/location/GnssLocationProvider.java b/services/core/java/com/android/server/location/GnssLocationProvider.java
index 809a48f2b4af..59a7cc8c04cb 100644
--- a/services/core/java/com/android/server/location/GnssLocationProvider.java
+++ b/services/core/java/com/android/server/location/GnssLocationProvider.java
@@ -810,12 +810,11 @@ public class GnssLocationProvider implements LocationProviderInterface, InjectNt
// while IO initialization and registration is delegated to our internal handler
// this approach is just fine because events are posted to our handler anyway
mProperties = new Properties();
- sendMessage(INITIALIZE_HANDLER, 0, null);
-
- // Create a GPS net-initiated handler.
+ // Create a GPS net-initiated handler (also needed by handleInitialize)
mNIHandler = new GpsNetInitiatedHandler(context,
mNetInitiatedListener,
mSuplEsEnabled);
+ sendMessage(INITIALIZE_HANDLER, 0, null);
mListenerHelper = new GnssStatusListenerHelper(mHandler) {
@Override