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

Commit 08cb5412 authored by Soonil Nagarkar's avatar Soonil Nagarkar
Browse files

Minor eventlog and LocationProviderBase cleanups

Change eventlog behavior solely based on logging properties, not the
debug build. This allows for reduced logging even on debug builds. Minor
updates to LocationProviderBase.

Bug: 190609486
Test: manual
Change-Id: I1efb28663de7ddd4224b01afe195baf3ff78ddb0
parent cdbc555a
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -62,6 +62,10 @@ import java.util.Objects;
 * <p>The service should have an intent filter in place for the location provider it wishes to
 * implements. Defaults for some providers are specified as constants in this class.
 *
 * <p>Location providers are identified by their UID / package name / attribution tag. Based on this
 * identity, location providers may be given some special privileges (such as making special
 * requests to other location providers).
 *
 * @hide
 */
@SystemApi
@@ -95,14 +99,14 @@ public abstract class LocationProviderBase {
    public static final String ACTION_FUSED_PROVIDER =
            "com.android.location.service.FusedLocationProvider";

    private final String mTag;
    private final @Nullable String mAttributionTag;
    private final IBinder mBinder;
    final String mTag;
    final @Nullable String mAttributionTag;
    final IBinder mBinder;

    // write locked on mBinder, read lock is optional depending on atomicity requirements
    private @Nullable volatile ILocationProviderManager mManager;
    private volatile ProviderProperties mProperties;
    private volatile boolean mAllowed;
    volatile @Nullable ILocationProviderManager mManager;
    volatile ProviderProperties mProperties;
    volatile boolean mAllowed;

    public LocationProviderBase(@NonNull Context context, @NonNull String tag,
            @NonNull ProviderProperties properties) {
+8 −9
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ import android.annotation.Nullable;
import android.location.LocationRequest;
import android.location.provider.ProviderRequest;
import android.location.util.identity.CallerIdentity;
import android.os.Build;
import android.os.PowerManager.LocationPowerSaveMode;
import android.os.SystemClock;
import android.util.ArrayMap;
@@ -47,8 +46,8 @@ public class LocationEventLog extends LocalEventLog {
    public static final LocationEventLog EVENT_LOG = new LocationEventLog();

    private static int getLogSize() {
        if (Build.IS_DEBUGGABLE || D) {
            return 500;
        if (D) {
            return 600;
        } else {
            return 200;
        }
@@ -152,7 +151,7 @@ public class LocationEventLog extends LocalEventLog {

    /** Logs a client for a location provider entering the foreground state. */
    public void logProviderClientForeground(String provider, CallerIdentity identity) {
        if (Build.IS_DEBUGGABLE || D) {
        if (D) {
            addLogEvent(EVENT_PROVIDER_CLIENT_FOREGROUND, provider, identity);
        }
        getAggregateStats(provider, identity).markRequestForeground();
@@ -160,7 +159,7 @@ public class LocationEventLog extends LocalEventLog {

    /** Logs a client for a location provider leaving the foreground state. */
    public void logProviderClientBackground(String provider, CallerIdentity identity) {
        if (Build.IS_DEBUGGABLE || D) {
        if (D) {
            addLogEvent(EVENT_PROVIDER_CLIENT_BACKGROUND, provider, identity);
        }
        getAggregateStats(provider, identity).markRequestBackground();
@@ -168,14 +167,14 @@ public class LocationEventLog extends LocalEventLog {

    /** Logs a client for a location provider entering the permitted state. */
    public void logProviderClientPermitted(String provider, CallerIdentity identity) {
        if (Build.IS_DEBUGGABLE || D) {
        if (D) {
            addLogEvent(EVENT_PROVIDER_CLIENT_PERMITTED, provider, identity);
        }
    }

    /** Logs a client for a location provider leaving the permitted state. */
    public void logProviderClientUnpermitted(String provider, CallerIdentity identity) {
        if (Build.IS_DEBUGGABLE || D) {
        if (D) {
            addLogEvent(EVENT_PROVIDER_CLIENT_UNPERMITTED, provider, identity);
        }
    }
@@ -187,7 +186,7 @@ public class LocationEventLog extends LocalEventLog {

    /** Logs a new incoming location for a location provider. */
    public void logProviderReceivedLocations(String provider, int numLocations) {
        if (Build.IS_DEBUGGABLE || D) {
        if (D) {
            addLogEvent(EVENT_PROVIDER_RECEIVE_LOCATION, provider, numLocations);
        }
    }
@@ -195,7 +194,7 @@ public class LocationEventLog extends LocalEventLog {
    /** Logs a location deliver for a client of a location provider. */
    public void logProviderDeliveredLocations(String provider, int numLocations,
            CallerIdentity identity) {
        if (Build.IS_DEBUGGABLE || D) {
        if (D) {
            addLogEvent(EVENT_PROVIDER_DELIVER_LOCATION, provider, numLocations, identity);
        }
        getAggregateStats(provider, identity).markLocationDelivered();