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 Original line Diff line number Diff line
@@ -1598,7 +1598,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
        if (DEBUG) Log.d(TAG, "reportGnssServiceDied");
        if (DEBUG) Log.d(TAG, "reportGnssServiceDied");
        mHandler.post(() -> {
        mHandler.post(() -> {
            class_init_native();
            class_init_native();
            native_init_once();
            setupNativeGnssService();
            if (isEnabled()) {
            if (isEnabled()) {
                synchronized (mLock) {
                synchronized (mLock) {
                    mEnabled = false;
                    mEnabled = false;
@@ -2052,20 +2052,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
         * this handler.
         * this handler.
         */
         */
        private void handleInitialize() {
        private void handleInitialize() {
            native_init_once();
            setupNativeGnssService();

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


            if (native_is_gnss_visibility_control_supported()) {
            if (native_is_gnss_visibility_control_supported()) {
                mGnssVisibilityControl = new GnssVisibilityControl(mContext, mLooper);
                mGnssVisibilityControl = new GnssVisibilityControl(mContext, mLooper);
@@ -2227,6 +2214,23 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
        pw.append(s);
        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()
    // preallocated to avoid memory allocation in reportNmea()
    private byte[] mNmeaBuffer = new byte[120];
    private byte[] mNmeaBuffer = new byte[120];