Merge "Tag some "new Binder()" instances to detect leaks." into sc-dev

This commit is contained in:
TreeHugger Robot
2021-07-08 00:33:42 +00:00
committed by Android (Google) Code Review
2 changed files with 7 additions and 4 deletions

View File

@@ -120,6 +120,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
*/ */
public final class BluetoothAdapter { public final class BluetoothAdapter {
private static final String TAG = "BluetoothAdapter"; private static final String TAG = "BluetoothAdapter";
private static final String DESCRIPTOR = "android.bluetooth.BluetoothAdapter";
private static final boolean DBG = true; private static final boolean DBG = true;
private static final boolean VDBG = false; private static final boolean VDBG = false;
@@ -805,7 +806,7 @@ public final class BluetoothAdapter {
mManagerService = Objects.requireNonNull(managerService); mManagerService = Objects.requireNonNull(managerService);
mAttributionSource = Objects.requireNonNull(attributionSource); mAttributionSource = Objects.requireNonNull(attributionSource);
mLeScanClients = new HashMap<LeScanCallback, ScanCallback>(); mLeScanClients = new HashMap<LeScanCallback, ScanCallback>();
mToken = new Binder(); mToken = new Binder(DESCRIPTOR);
} }
/** /**

View File

@@ -86,6 +86,8 @@ import java.util.Set;
*/ */
@Immutable @Immutable
public final class AttributionSource implements Parcelable { public final class AttributionSource implements Parcelable {
private static final String DESCRIPTOR = "android.content.AttributionSource";
private final @NonNull AttributionSourceState mAttributionSourceState; private final @NonNull AttributionSourceState mAttributionSourceState;
private @Nullable AttributionSource mNextCached; private @Nullable AttributionSource mNextCached;
@@ -95,7 +97,7 @@ public final class AttributionSource implements Parcelable {
@TestApi @TestApi
public AttributionSource(int uid, @Nullable String packageName, public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag) { @Nullable String attributionTag) {
this(uid, packageName, attributionTag, new Binder()); this(uid, packageName, attributionTag, new Binder(DESCRIPTOR));
} }
/** @hide */ /** @hide */
@@ -130,7 +132,7 @@ public final class AttributionSource implements Parcelable {
AttributionSource(int uid, @Nullable String packageName, @Nullable String attributionTag, AttributionSource(int uid, @Nullable String packageName, @Nullable String attributionTag,
@Nullable String[] renouncedPermissions, @Nullable AttributionSource next) { @Nullable String[] renouncedPermissions, @Nullable AttributionSource next) {
this(uid, packageName, attributionTag, new Binder(), renouncedPermissions, next); this(uid, packageName, attributionTag, new Binder(DESCRIPTOR), renouncedPermissions, next);
} }
AttributionSource(int uid, @Nullable String packageName, @Nullable String attributionTag, AttributionSource(int uid, @Nullable String packageName, @Nullable String attributionTag,
@@ -541,7 +543,7 @@ public final class AttributionSource implements Parcelable {
if ((mBuilderFieldsSet & 0x10) == 0) { if ((mBuilderFieldsSet & 0x10) == 0) {
mAttributionSourceState.next = null; mAttributionSourceState.next = null;
} }
mAttributionSourceState.token = new Binder(); mAttributionSourceState.token = new Binder(DESCRIPTOR);
if (mAttributionSourceState.next == null) { if (mAttributionSourceState.next == null) {
// The NDK aidl backend doesn't support null parcelable arrays. // The NDK aidl backend doesn't support null parcelable arrays.
mAttributionSourceState.next = new AttributionSourceState[0]; mAttributionSourceState.next = new AttributionSourceState[0];