OSDN Git Service

Move native_init() from ctor to handler
authorWyatt Riley <wyattriley@google.com>
Tue, 31 Oct 2017 21:36:52 +0000 (14:36 -0700)
committerWyatt Riley <wyattriley@google.com>
Wed, 1 Nov 2017 21:41:17 +0000 (14:41 -0700)
Moves potentially slow reponses to native_init() for
GNSS HAL off the main system service startup
thread to the LocationManagerService handler

Bug: 38362097
Bug: 63707763
Test: GNSS still works on device, boot logcat as expected
Change-Id: If3e6735fdcf2b41cb743878154e8c03fa27f725b

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

index 4cf35bc..660659f 100644 (file)
@@ -803,18 +803,6 @@ public class GnssLocationProvider implements LocationProviderInterface {
             }
         };
         mGnssMetrics = new GnssMetrics();
-
-        /*
-        * A cycle of native_init() and native_cleanup() is needed so that callbacks are registered
-        * after bootup even when location is disabled. This will allow Emergency SUPL to work even
-        * when location is disabled before device restart.
-        * */
-        boolean isInitialized = native_init();
-        if(!isInitialized) {
-            Log.d(TAG, "Failed to initialize at bootup");
-        } else {
-            native_cleanup();
-        }
     }
 
     /**
@@ -2272,6 +2260,19 @@ public class GnssLocationProvider implements LocationProviderInterface {
          * this handler.
          */
         private void handleInitialize() {
+            /*
+             * A cycle of native_init() and native_cleanup() is needed so that callbacks are
+             * registered after bootup even when location is disabled.
+             * This will allow Emergency SUPL to work even when location is disabled before device
+             * restart.
+             */
+            boolean isInitialized = native_init();
+            if(!isInitialized) {
+                Log.w(TAG, "Native initialization failed at bootup");
+            } else {
+                native_cleanup();
+            }
+
             // load default GPS configuration
             // (this configuration might change in the future based on SIM changes)
             reloadGpsProperties(mContext, mProperties);