diff options
| author | 2021-09-22 20:22:36 +0200 | |
|---|---|---|
| committer | 2021-09-22 20:22:36 +0200 | |
| commit | c05e55ffbfdcd78cfd2ec8a8c2137e22c42bb8ba (patch) | |
| tree | acd9a4171db7335862b5db123ec6aa14fbcb1d46 | |
| parent | c010164844cf02ca720753225d3e2b647b52abb5 (diff) | |
Use AttributionSource Builder
Attribution source constructor are hidden api
Add a Builder option to take a AttributionSource as parameter
Test: atest BluetoothInstrumentationTests
Bug: 195144968
Tag: #refactor
Ignore-AOSP-First: No such thing on aosp
Change-Id: I901c8afff6a40bd8484fd8e10baf290aa483c280
| -rw-r--r-- | core/api/current.txt | 1 | ||||
| -rw-r--r-- | core/java/android/bluetooth/BluetoothManager.java | 5 | ||||
| -rw-r--r-- | core/java/android/content/AttributionSource.java | 12 |
3 files changed, 16 insertions, 2 deletions
diff --git a/core/api/current.txt b/core/api/current.txt index 49a8cb8dbc39..ea781a948653 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -9975,6 +9975,7 @@ package android.content { public static final class AttributionSource.Builder { ctor public AttributionSource.Builder(int); + ctor public AttributionSource.Builder(@NonNull android.content.AttributionSource); method @NonNull public android.content.AttributionSource build(); method @NonNull public android.content.AttributionSource.Builder setAttributionTag(@Nullable String); method @NonNull public android.content.AttributionSource.Builder setNext(@Nullable android.content.AttributionSource); diff --git a/core/java/android/bluetooth/BluetoothManager.java b/core/java/android/bluetooth/BluetoothManager.java index c21362cd89f9..20152f3d2471 100644 --- a/core/java/android/bluetooth/BluetoothManager.java +++ b/core/java/android/bluetooth/BluetoothManager.java @@ -88,8 +88,9 @@ public final class BluetoothManager { uid = android.os.Process.SYSTEM_UID; } try { - res = new AttributionSource(uid, - AppGlobals.getPackageManager().getPackagesForUid(uid)[0], null); + res = new AttributionSource.Builder(uid) + .setPackageName(AppGlobals.getPackageManager().getPackagesForUid(uid)[0]) + .build(); } catch (RemoteException ignored) { } } diff --git a/core/java/android/content/AttributionSource.java b/core/java/android/content/AttributionSource.java index bdb7900b5bb9..6ae2bb5b642a 100644 --- a/core/java/android/content/AttributionSource.java +++ b/core/java/android/content/AttributionSource.java @@ -474,6 +474,18 @@ public final class AttributionSource implements Parcelable { mAttributionSourceState.uid = uid; } + public Builder(@NonNull AttributionSource current) { + if (current == null) { + throw new IllegalArgumentException("current AttributionSource can not be null"); + } + mAttributionSourceState.uid = current.getUid(); + mAttributionSourceState.packageName = current.getPackageName(); + mAttributionSourceState.attributionTag = current.getAttributionTag(); + mAttributionSourceState.token = current.getToken(); + mAttributionSourceState.renouncedPermissions = + current.mAttributionSourceState.renouncedPermissions; + } + /** * The package that is accessing the permission protected data. */ |