Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit db2b921a authored by Anil Admal's avatar Anil Admal Committed by Android (Google) Code Review
Browse files

Merge "Fix GNSS requests not served when GNSS HIDL service is restarted" into qt-dev

parents 065ba216 7e3953be
Loading
Loading
Loading
Loading
+19 −15
Original line number Diff line number Diff line
@@ -1598,7 +1598,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
        if (DEBUG) Log.d(TAG, "reportGnssServiceDied");
        mHandler.post(() -> {
            class_init_native();
            native_init_once();
            setupNativeGnssService();
            if (isEnabled()) {
                synchronized (mLock) {
                    mEnabled = false;
@@ -2052,20 +2052,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
         * this handler.
         */
        private void handleInitialize() {
            native_init_once();

            /*
             * 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();
            }
            setupNativeGnssService();

            if (native_is_gnss_visibility_control_supported()) {
                mGnssVisibilityControl = new GnssVisibilityControl(mContext, mLooper);
@@ -2227,6 +2214,23 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
        pw.append(s);
    }

    private void setupNativeGnssService() {
        native_init_once();

        /*
         * 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.");
        } else {
            native_cleanup();
        }
    }

    // preallocated to avoid memory allocation in reportNmea()
    private byte[] mNmeaBuffer = new byte[120];