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

Commit f1f0b2e3 authored by Soonil Nagarkar's avatar Soonil Nagarkar Committed by Android (Google) Code Review
Browse files

Merge "Add more logging around extra attribution tags" into sc-dev

parents 1142e5e8 fdcffa46
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -305,6 +305,10 @@ public abstract class AbstractLocationProvider {
        setState(state -> state.withIdentity(identity));
    }

    public final Set<String> getExtraAttributionTags() {
        return mInternalState.get().state.extraAttributionTags;
    }

    /**
     * Call this method to report a change in the provider's extra attribution tags.
     */
+5 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import com.android.internal.util.Preconditions;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.Collections;
import java.util.Set;

/**
 * Represents a location provider that may switch between a mock implementation and a real
@@ -296,6 +297,10 @@ public class MockableLocationProvider extends AbstractLocationProvider {
            if (identity != null) {
                pw.println("identity=" + identity);
            }
            Set<String> extraAttributionTags = getExtraAttributionTags();
            if (!extraAttributionTags.isEmpty()) {
                pw.println("extra attribution tags=" + extraAttributionTags);
            }
            ProviderProperties properties = getProperties();
            if (properties != null) {
                pw.println("properties=" + properties);
+7 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.server.location.provider.proxy;

import static com.android.internal.util.ConcurrentUtils.DIRECT_EXECUTOR;
import static com.android.server.location.LocationManagerService.TAG;

import android.annotation.Nullable;
import android.content.Context;
@@ -32,6 +33,7 @@ import android.os.IBinder;
import android.os.RemoteException;
import android.text.TextUtils;
import android.util.ArraySet;
import android.util.Log;

import com.android.internal.annotations.GuardedBy;
import com.android.server.FgThread;
@@ -44,6 +46,7 @@ import com.android.server.servicewatcher.ServiceWatcher.ServiceListener;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

@@ -78,6 +81,7 @@ public class ProxyLocationProvider extends AbstractLocationProvider implements

    final Context mContext;
    final ServiceWatcher mServiceWatcher;
    final String mName;

    @GuardedBy("mLock")
    final ArrayList<Runnable> mFlushListeners = new ArrayList<>(0);
@@ -101,6 +105,7 @@ public class ProxyLocationProvider extends AbstractLocationProvider implements
        mServiceWatcher = ServiceWatcher.create(context, provider,
                new CurrentUserServiceSupplier(context, action, enableOverlayResId,
                        nonOverlayPackageResId), this);
        mName = provider;

        mProxy = null;
        mRequest = ProviderRequest.EMPTY_REQUEST;
@@ -249,6 +254,8 @@ public class ProxyLocationProvider extends AbstractLocationProvider implements
                    String tagsStr = mBoundServiceInfo.getMetadata().getString(EXTRA_LOCATION_TAGS);
                    if (!TextUtils.isEmpty(tagsStr)) {
                        attributionTags = tagsStr.split(LOCATION_TAGS_SEPARATOR);
                        Log.i(TAG, mName + " provider loaded extra attribution tags: "
                                + Arrays.toString(attributionTags));
                    }
                }
                ArraySet<String> extraAttributionTags = new ArraySet<>(attributionTags);
+10 −9
Original line number Diff line number Diff line
@@ -135,6 +135,7 @@ class ServiceWatcherImpl<TBoundServiceInfo extends BoundServiceInfo> implements

        if (forceRebind || !Objects.equals(mServiceConnection.getBoundServiceInfo(),
                newBoundServiceInfo)) {
            Log.i(TAG, "[" + mTag + "] chose new implementation " + newBoundServiceInfo);
            MyServiceConnection oldServiceConnection = mServiceConnection;
            MyServiceConnection newServiceConnection = new MyServiceConnection(newBoundServiceInfo);
            mServiceConnection = newServiceConnection;
@@ -196,7 +197,9 @@ class ServiceWatcherImpl<TBoundServiceInfo extends BoundServiceInfo> implements
                return;
            }

            Log.i(TAG, "[" + mTag + "] binding to " + mBoundServiceInfo);
            if (D) {
                Log.d(TAG, "[" + mTag + "] binding to " + mBoundServiceInfo);
            }

            Intent bindIntent = new Intent(mBoundServiceInfo.getAction()).setComponent(
                    mBoundServiceInfo.getComponentName());
@@ -255,9 +258,7 @@ class ServiceWatcherImpl<TBoundServiceInfo extends BoundServiceInfo> implements
            Preconditions.checkState(Looper.myLooper() == mHandler.getLooper());
            Preconditions.checkState(mBinder == null);

            if (D) {
                Log.d(TAG, "[" + mTag + "] connected to " + component.toShortString());
            }
            Log.i(TAG, "[" + mTag + "] connected to " + component.toShortString());

            mBinder = binder;

@@ -280,9 +281,7 @@ class ServiceWatcherImpl<TBoundServiceInfo extends BoundServiceInfo> implements
                return;
            }

            if (D) {
                Log.d(TAG, "[" + mTag + "] disconnected from " + mBoundServiceInfo);
            }
            Log.i(TAG, "[" + mTag + "] disconnected from " + mBoundServiceInfo);

            mBinder = null;
            if (mServiceListener != null) {
@@ -294,9 +293,11 @@ class ServiceWatcherImpl<TBoundServiceInfo extends BoundServiceInfo> implements
        public final void onBindingDied(ComponentName component) {
            Preconditions.checkState(Looper.myLooper() == mHandler.getLooper());

            Log.i(TAG, "[" + mTag + "] " + mBoundServiceInfo + " died");
            Log.w(TAG, "[" + mTag + "] " + mBoundServiceInfo + " died");

            onServiceChanged(true);
            // introduce a small delay to prevent spamming binding over and over, since the likely
            // cause of a binding dying is some package event that may take time to recover from
            mHandler.postDelayed(() -> onServiceChanged(true), 500);
        }

        @Override