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

Commit d9df33d1 authored by Soonil Nagarkar's avatar Soonil Nagarkar
Browse files

DO NOT MERGE: Always return non null from getGpsStatus

Even though getGpsStatus is marked Nullable, some applications expect it
to always return non-null.

Bug: 161311411
Test: presubmits
Change-Id: I8d58621588253af1dc917711e230cfd176afec37
parent 218b61ac
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -151,6 +151,15 @@ public final class GpsStatus {
        return status;
    }

    /**
     * Builds an empty GpsStatus.
     *
     * @hide
     */
    static GpsStatus createEmpty() {
        return new GpsStatus();
    }

    private GpsStatus() {
    }

+5 −0
Original line number Diff line number Diff line
@@ -1922,12 +1922,17 @@ public class LocationManager {

        GnssStatus gnssStatus = mGnssStatusListenerManager.getGnssStatus();
        int ttff = mGnssStatusListenerManager.getTtff();

        // even though this method is marked nullable, there are legacy applications that expect
        // this to never return null, so avoid breaking those apps
        if (gnssStatus != null) {
            if (status == null) {
                status = GpsStatus.create(gnssStatus, ttff);
            } else {
                status.setStatus(gnssStatus, ttff);
            }
        } else if (status == null) {
            status = GpsStatus.createEmpty();
        }
        return status;
    }