OSDN Git Service

DO NOT MERGE - SUPL ES Extension - Safer Init and Not After Boot
authorWyattRiley <wyattriley@google.com>
Thu, 28 Feb 2019 19:43:12 +0000 (11:43 -0800)
committerandroid-build-team Robot <android-build-team-robot@google.com>
Wed, 13 Mar 2019 20:14:28 +0000 (20:14 +0000)
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: Icd2ea91d71da71c8fda109ceb70514733d35060b
(cherry picked from commit a7cb82eb85cd361b90c9700ff935ba614c94f490)

location/java/com/android/internal/location/GpsNetInitiatedHandler.java
services/core/java/com/android/server/location/GnssLocationProvider.java

index 3bfe32c..2c8d9ee 100644 (file)
@@ -124,8 +124,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
     {
@@ -248,8 +248,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;
     }
index 98f4abb..88f712a 100644 (file)
@@ -740,12 +740,11 @@ public class GnssLocationProvider implements LocationProviderInterface {
         // 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