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

Commit af83bfa3 authored by Anil Admal's avatar Anil Admal Committed by android-build-merger
Browse files

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

am: db2b921a

Change-Id: Id049f83a5ac986c5867dde7aa0d02ced9b2a494e
parents 29dd44c0 db2b921a
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];