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

Commit 623cf937 authored by Soonil Nagarkar's avatar Soonil Nagarkar
Browse files

Various GNSS cleanups

-Remove GNSS disable on idle behavior. This breaks the contract of
location providers and seems likely to increase power usage by forcing
more network location usage in some circumstances. Power save modes
are already handled at a higher level, the GNSS location provider
should not need to care about them.
-Remove some unnecessary thread trampolining.
-Reorganize vars to better conform to standard ordering practices
(statics first, etc).
-Prevent double reporting of network locations to GNSS HAL.
-Prevent mock locations from being reported to the HAL.
-Switch to listener alarms instead of pending intent alarms.

Test: presubmits
Change-Id: I8c526f32b1dbcdac419d1d7644fc2e511b0f9b5c
parent bf126a7a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -310,6 +310,7 @@ public abstract class AbstractLocationProvider {
     * Sets a new request and worksource for the provider.
     */
    public final void setRequest(ProviderRequest request) {
        // TODO: do we want to hold a wakelock until onSetRequest is run?
        // all calls into the provider must be moved onto the provider thread to prevent deadlock
        mExecutor.execute(() -> onSetRequest(request));
    }
+2 −0
Original line number Diff line number Diff line
@@ -324,6 +324,8 @@ public class LocationManagerService extends ILocationManager.Stub {
    }

    void onSystemThirdPartyAppsCanStart() {
        // network provider should always be initialized before the gps provider since the gps
        // provider has unfortunate hard dependencies on the network provider
        ProxyLocationProvider networkProvider = ProxyLocationProvider.createAndRegister(
                mContext,
                NETWORK_LOCATION_SERVICE_ACTION,
+147 −284

File changed.

Preview size limit exceeded, changes collapsed.

+9 −4
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@ import static android.os.PowerManager.LOCATION_MODE_GPS_DISABLED_WHEN_SCREEN_OFF
import static android.os.PowerManager.LOCATION_MODE_NO_CHANGE;
import static android.os.PowerManager.LOCATION_MODE_THROTTLE_REQUESTS_WHEN_SCREEN_OFF;

import static com.android.server.location.LocationManagerService.D;

import android.annotation.Nullable;
import android.location.LocationRequest;
import android.location.util.identity.CallerIdentity;
@@ -29,14 +31,13 @@ import android.os.Build;
import android.os.PowerManager.LocationPowerSaveMode;

import com.android.internal.location.ProviderRequest;
import com.android.server.location.LocationManagerService;
import com.android.server.utils.eventlog.LocalEventLog;

/** In memory event log for location events. */
public class LocationEventLog extends LocalEventLog {

    private static int getLogSize() {
        if (Build.IS_DEBUGGABLE || LocationManagerService.D) {
        if (Build.IS_DEBUGGABLE || D) {
            return 500;
        } else {
            return 200;
@@ -91,14 +92,18 @@ public class LocationEventLog extends LocalEventLog {

    /** Logs a new incoming location for a location provider. */
    public synchronized void logProviderReceivedLocations(String provider, int numLocations) {
        if (Build.IS_DEBUGGABLE || D) {
            addLogEvent(EVENT_PROVIDER_RECEIVE_LOCATION, provider, numLocations);
        }
    }

    /** Logs a location deliver for a client of a location provider. */
    public synchronized void logProviderDeliveredLocations(String provider, int numLocations,
            CallerIdentity identity) {
        if (Build.IS_DEBUGGABLE || D) {
            addLogEvent(EVENT_PROVIDER_DELIVER_LOCATION, provider, numLocations, identity);
        }
    }

    /** Logs that the location power save mode has changed. */
    public synchronized void logLocationPowerSaveMode(