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

Commit d130931b authored by WyattRiley's avatar WyattRiley Committed by Wyatt Riley
Browse files

SUPL ES Extension - Safer Init and Not After Boot

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: Ic01a5d35d919ccea7934c8384253311261cd0167
parent 7e968348
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -118,8 +118,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
    {
@@ -242,8 +242,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;
    }
+3 −4
Original line number Diff line number Diff line
@@ -600,12 +600,11 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
        // while IO initialization and registration is delegated to our internal handler
        // this approach is just fine because events are posted to our handler anyway
        mGnssConfiguration = new GnssConfiguration(mContext);
        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);

        mGnssStatusListenerHelper = new GnssStatusListenerHelper(mContext, mHandler) {
            @Override