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

Commit f038fce3 authored by Michael Bestas's avatar Michael Bestas Committed by Michael Bestas
Browse files

GnssLocationProvider: Implement xtra-daemon toggle

Emergency location is handled through emergencyCallCallback
that calls reloadGpsProperties() which in turn runs toggleXtraDaemon()
before and after the emergency call

Change-Id: I96dd4504f597ed71693c04d9d1806de1c1b73c38
parent 5602538f
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -392,6 +392,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
        if (mGnssVisibilityControl != null) {
            mGnssVisibilityControl.onConfigurationUpdated(mGnssConfiguration);
        }
        toggleXtraDaemon();
    }

    public GnssLocationProvider(Context context, Injector injector, GnssNative gnssNative,
@@ -505,6 +506,16 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
                    }
                }, UserHandle.USER_ALL);

        mContext.getContentResolver().registerContentObserver(
                Settings.Global.getUriFor(Settings.Global.ASSISTED_GPS_ENABLED),
                false,
                new ContentObserver(mHandler) {
                    @Override
                    public void onChange(boolean selfChange) {
                        toggleXtraDaemon();
                    }
                }, UserHandle.USER_ALL);

        mHandler.post(this::handleInitialize);
        mHandler.post(mGnssSatelliteBlocklistHelper::updateSatelliteBlocklist);
    }
@@ -1796,4 +1807,10 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
        return (Settings.Global.getInt(mContext.getContentResolver(),
                        Settings.Global.ASSISTED_GPS_ENABLED, 0) != 0) || isEmergency;
    }

    private void toggleXtraDaemon() {
        Log.i(TAG, "Toggling xtra-daemon via property");
        SystemProperties.set("persist.sys.xtra-daemon.enabled",
                Boolean.toString(isAssistedGpsEnabled()));
    }
}