Merge "Add more logging around extra attribution tags" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
f1f0b2e333
@@ -305,6 +305,10 @@ public abstract class AbstractLocationProvider {
|
|||||||
setState(state -> state.withIdentity(identity));
|
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.
|
* Call this method to report a change in the provider's extra attribution tags.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import com.android.internal.util.Preconditions;
|
|||||||
import java.io.FileDescriptor;
|
import java.io.FileDescriptor;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a location provider that may switch between a mock implementation and a real
|
* 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) {
|
if (identity != null) {
|
||||||
pw.println("identity=" + identity);
|
pw.println("identity=" + identity);
|
||||||
}
|
}
|
||||||
|
Set<String> extraAttributionTags = getExtraAttributionTags();
|
||||||
|
if (!extraAttributionTags.isEmpty()) {
|
||||||
|
pw.println("extra attribution tags=" + extraAttributionTags);
|
||||||
|
}
|
||||||
ProviderProperties properties = getProperties();
|
ProviderProperties properties = getProperties();
|
||||||
if (properties != null) {
|
if (properties != null) {
|
||||||
pw.println("properties=" + properties);
|
pw.println("properties=" + properties);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package com.android.server.location.provider.proxy;
|
package com.android.server.location.provider.proxy;
|
||||||
|
|
||||||
import static com.android.internal.util.ConcurrentUtils.DIRECT_EXECUTOR;
|
import static com.android.internal.util.ConcurrentUtils.DIRECT_EXECUTOR;
|
||||||
|
import static com.android.server.location.LocationManagerService.TAG;
|
||||||
|
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -32,6 +33,7 @@ import android.os.IBinder;
|
|||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.ArraySet;
|
import android.util.ArraySet;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.internal.annotations.GuardedBy;
|
import com.android.internal.annotations.GuardedBy;
|
||||||
import com.android.server.FgThread;
|
import com.android.server.FgThread;
|
||||||
@@ -44,6 +46,7 @@ import com.android.server.servicewatcher.ServiceWatcher.ServiceListener;
|
|||||||
import java.io.FileDescriptor;
|
import java.io.FileDescriptor;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -78,6 +81,7 @@ public class ProxyLocationProvider extends AbstractLocationProvider implements
|
|||||||
|
|
||||||
final Context mContext;
|
final Context mContext;
|
||||||
final ServiceWatcher mServiceWatcher;
|
final ServiceWatcher mServiceWatcher;
|
||||||
|
final String mName;
|
||||||
|
|
||||||
@GuardedBy("mLock")
|
@GuardedBy("mLock")
|
||||||
final ArrayList<Runnable> mFlushListeners = new ArrayList<>(0);
|
final ArrayList<Runnable> mFlushListeners = new ArrayList<>(0);
|
||||||
@@ -101,6 +105,7 @@ public class ProxyLocationProvider extends AbstractLocationProvider implements
|
|||||||
mServiceWatcher = ServiceWatcher.create(context, provider,
|
mServiceWatcher = ServiceWatcher.create(context, provider,
|
||||||
new CurrentUserServiceSupplier(context, action, enableOverlayResId,
|
new CurrentUserServiceSupplier(context, action, enableOverlayResId,
|
||||||
nonOverlayPackageResId), this);
|
nonOverlayPackageResId), this);
|
||||||
|
mName = provider;
|
||||||
|
|
||||||
mProxy = null;
|
mProxy = null;
|
||||||
mRequest = ProviderRequest.EMPTY_REQUEST;
|
mRequest = ProviderRequest.EMPTY_REQUEST;
|
||||||
@@ -249,6 +254,8 @@ public class ProxyLocationProvider extends AbstractLocationProvider implements
|
|||||||
String tagsStr = mBoundServiceInfo.getMetadata().getString(EXTRA_LOCATION_TAGS);
|
String tagsStr = mBoundServiceInfo.getMetadata().getString(EXTRA_LOCATION_TAGS);
|
||||||
if (!TextUtils.isEmpty(tagsStr)) {
|
if (!TextUtils.isEmpty(tagsStr)) {
|
||||||
attributionTags = tagsStr.split(LOCATION_TAGS_SEPARATOR);
|
attributionTags = tagsStr.split(LOCATION_TAGS_SEPARATOR);
|
||||||
|
Log.i(TAG, mName + " provider loaded extra attribution tags: "
|
||||||
|
+ Arrays.toString(attributionTags));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ArraySet<String> extraAttributionTags = new ArraySet<>(attributionTags);
|
ArraySet<String> extraAttributionTags = new ArraySet<>(attributionTags);
|
||||||
|
|||||||
@@ -135,6 +135,7 @@ class ServiceWatcherImpl<TBoundServiceInfo extends BoundServiceInfo> implements
|
|||||||
|
|
||||||
if (forceRebind || !Objects.equals(mServiceConnection.getBoundServiceInfo(),
|
if (forceRebind || !Objects.equals(mServiceConnection.getBoundServiceInfo(),
|
||||||
newBoundServiceInfo)) {
|
newBoundServiceInfo)) {
|
||||||
|
Log.i(TAG, "[" + mTag + "] chose new implementation " + newBoundServiceInfo);
|
||||||
MyServiceConnection oldServiceConnection = mServiceConnection;
|
MyServiceConnection oldServiceConnection = mServiceConnection;
|
||||||
MyServiceConnection newServiceConnection = new MyServiceConnection(newBoundServiceInfo);
|
MyServiceConnection newServiceConnection = new MyServiceConnection(newBoundServiceInfo);
|
||||||
mServiceConnection = newServiceConnection;
|
mServiceConnection = newServiceConnection;
|
||||||
@@ -196,7 +197,9 @@ class ServiceWatcherImpl<TBoundServiceInfo extends BoundServiceInfo> implements
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.i(TAG, "[" + mTag + "] binding to " + mBoundServiceInfo);
|
if (D) {
|
||||||
|
Log.d(TAG, "[" + mTag + "] binding to " + mBoundServiceInfo);
|
||||||
|
}
|
||||||
|
|
||||||
Intent bindIntent = new Intent(mBoundServiceInfo.getAction()).setComponent(
|
Intent bindIntent = new Intent(mBoundServiceInfo.getAction()).setComponent(
|
||||||
mBoundServiceInfo.getComponentName());
|
mBoundServiceInfo.getComponentName());
|
||||||
@@ -255,9 +258,7 @@ class ServiceWatcherImpl<TBoundServiceInfo extends BoundServiceInfo> implements
|
|||||||
Preconditions.checkState(Looper.myLooper() == mHandler.getLooper());
|
Preconditions.checkState(Looper.myLooper() == mHandler.getLooper());
|
||||||
Preconditions.checkState(mBinder == null);
|
Preconditions.checkState(mBinder == null);
|
||||||
|
|
||||||
if (D) {
|
Log.i(TAG, "[" + mTag + "] connected to " + component.toShortString());
|
||||||
Log.d(TAG, "[" + mTag + "] connected to " + component.toShortString());
|
|
||||||
}
|
|
||||||
|
|
||||||
mBinder = binder;
|
mBinder = binder;
|
||||||
|
|
||||||
@@ -280,9 +281,7 @@ class ServiceWatcherImpl<TBoundServiceInfo extends BoundServiceInfo> implements
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (D) {
|
Log.i(TAG, "[" + mTag + "] disconnected from " + mBoundServiceInfo);
|
||||||
Log.d(TAG, "[" + mTag + "] disconnected from " + mBoundServiceInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
mBinder = null;
|
mBinder = null;
|
||||||
if (mServiceListener != null) {
|
if (mServiceListener != null) {
|
||||||
@@ -294,9 +293,11 @@ class ServiceWatcherImpl<TBoundServiceInfo extends BoundServiceInfo> implements
|
|||||||
public final void onBindingDied(ComponentName component) {
|
public final void onBindingDied(ComponentName component) {
|
||||||
Preconditions.checkState(Looper.myLooper() == mHandler.getLooper());
|
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
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user