Loading android/app/src/com/android/bluetooth/gatt/AdvertiseManager.java +4 −2 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.bluetooth.le.AdvertiseData; import android.bluetooth.le.AdvertisingSetParameters; import android.bluetooth.le.IAdvertisingSetCallback; import android.bluetooth.le.PeriodicAdvertisingParameters; import android.content.AttributionSource; import android.os.Binder; import android.os.Handler; import android.os.HandlerThread; Loading Loading @@ -246,7 +247,8 @@ public class AdvertiseManager { int duration, int maxExtAdvEvents, int serverIf, IAdvertisingSetCallback callback) { IAdvertisingSetCallback callback, AttributionSource attrSource) { // If we are using an isolated server, force usage of an NRPA if (serverIf != 0 && parameters.getOwnAddressType() Loading Loading @@ -294,7 +296,7 @@ public class AdvertiseManager { Log.d(TAG, "startAdvertisingSet() - reg_id=" + cbId + ", callback: " + binder); mAdvertiserMap.addAppAdvertiseStats(cbId, mService); mAdvertiserMap.addAppAdvertiseStats(cbId, mService, attrSource); mAdvertiserMap.recordAdvertiseStart( cbId, parameters, Loading android/app/src/com/android/bluetooth/gatt/AdvertiserMap.java +3 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.bluetooth.gatt; import android.bluetooth.le.AdvertiseData; import android.bluetooth.le.AdvertisingSetParameters; import android.bluetooth.le.PeriodicAdvertisingParameters; import android.content.AttributionSource; import android.content.Context; import android.os.Binder; import android.util.Log; Loading Loading @@ -45,7 +46,7 @@ class AdvertiserMap { EvictingQueue.create(ADVERTISE_STATE_MAX_SIZE); /** Add an entry to the stats map if it doesn't already exist. */ void addAppAdvertiseStats(int id, Context context) { void addAppAdvertiseStats(int id, Context context, AttributionSource attrSource) { int appUid = Binder.getCallingUid(); String appName = context.getPackageManager().getNameForUid(appUid); if (appName == null) { Loading @@ -55,7 +56,7 @@ class AdvertiserMap { synchronized (this) { if (!mAppAdvertiseStats.containsKey(id)) { addAppAdvertiseStats(id, new AppAdvertiseStats(appUid, id, appName)); addAppAdvertiseStats(id, new AppAdvertiseStats(appUid, id, appName, attrSource)); } } } Loading android/app/src/com/android/bluetooth/gatt/AppAdvertiseStats.java +14 −4 Original line number Diff line number Diff line Loading @@ -15,12 +15,16 @@ */ package com.android.bluetooth.gatt; import static com.android.bluetooth.util.AttributionSourceUtil.getLastAttributionTag; import android.annotation.Nullable; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothProtoEnums; import android.bluetooth.le.AdvertiseData; import android.bluetooth.le.AdvertisingSetCallback; import android.bluetooth.le.AdvertisingSetParameters; import android.bluetooth.le.PeriodicAdvertisingParameters; import android.content.AttributionSource; import android.os.ParcelUuid; import android.util.SparseArray; Loading Loading @@ -82,6 +86,7 @@ class AppAdvertiseStats { private int mAppUid; @VisibleForTesting String mAppName; @Nullable private String mAttributionTag; private int mId; private boolean mAdvertisingEnabled = false; private boolean mPeriodicAdvertisingEnabled = false; Loading @@ -93,17 +98,18 @@ class AppAdvertiseStats { private boolean mAnonymous = false; private boolean mConnectable = false; private boolean mScannable = false; private AppAdvertiserData mAdvertisingData = null; private AppAdvertiserData mScanResponseData = null; private AppAdvertiserData mPeriodicAdvertisingData = null; @Nullable private AppAdvertiserData mAdvertisingData = null; @Nullable private AppAdvertiserData mScanResponseData = null; @Nullable private AppAdvertiserData mPeriodicAdvertisingData = null; private boolean mPeriodicIncludeTxPower = false; private int mPeriodicInterval = 0; public ArrayList<AppAdvertiserRecord> mAdvertiserRecords = new ArrayList<AppAdvertiserRecord>(); AppAdvertiseStats(int appUid, int id, String name) { AppAdvertiseStats(int appUid, int id, String name, AttributionSource attrSource) { this.mAppUid = appUid; this.mId = id; this.mAppName = name; this.mAttributionTag = getLastAttributionTag(attrSource); } void recordAdvertiseStart( Loading Loading @@ -553,6 +559,10 @@ class AppAdvertiseStats { Instant currentTime = Instant.now(); sb.append("\n ").append(stats.mAppName); if (stats.mAttributionTag != null) { sb.append("\n Tag : ") .append(stats.mAttributionTag); } sb.append("\n Advertising ID : ").append(stats.mId); for (int i = 0; i < stats.mAdvertiserRecords.size(); i++) { AppAdvertiserRecord record = stats.mAdvertiserRecords.get(i); Loading android/app/src/com/android/bluetooth/gatt/ContextMap.java +11 −3 Original line number Diff line number Diff line Loading @@ -15,6 +15,10 @@ */ package com.android.bluetooth.gatt; import static com.android.bluetooth.util.AttributionSourceUtil.getLastAttributionTag; import android.annotation.Nullable; import android.content.AttributionSource; import android.content.Context; import android.os.Binder; import android.os.IBinder; Loading Loading @@ -75,6 +79,9 @@ public class ContextMap<C> { /** The package name of the application */ public final String name; /** The last attribution tag of the caller */ @Nullable public final String attributionTag; /** Application callbacks */ public C callback; Loading @@ -88,11 +95,12 @@ public class ContextMap<C> { private List<CallbackInfo> mCongestionQueue = new ArrayList<>(); /** Creates a new app context. */ App(UUID uuid, C callback, int appUid, String name) { App(UUID uuid, C callback, int appUid, String name, AttributionSource attrSource) { this.uuid = uuid; this.callback = callback; this.appUid = appUid; this.name = name; this.attributionTag = getLastAttributionTag(attrSource); } /** Link death recipient */ Loading Loading @@ -146,7 +154,7 @@ public class ContextMap<C> { private final Object mConnectionsLock = new Object(); /** Add an entry to the application context list. */ public App add(UUID uuid, C callback, Context context) { public App add(UUID uuid, C callback, Context context, AttributionSource attrSource) { int appUid = Binder.getCallingUid(); String appName = context.getPackageManager().getNameForUid(appUid); if (appName == null) { Loading @@ -154,7 +162,7 @@ public class ContextMap<C> { appName = "Unknown App (UID: " + appUid + ")"; } synchronized (mAppsLock) { App app = new App(uuid, callback, appUid, appName); App app = new App(uuid, callback, appUid, appName, attrSource); mApps.add(app); return app; } Loading android/app/src/com/android/bluetooth/gatt/GattService.java +20 −5 Original line number Diff line number Diff line Loading @@ -1943,7 +1943,8 @@ public class GattService extends ProfileService { duration, maxExtAdvEvents, serverIf, callback); callback, attributionSource); } @RequiresPermission(BLUETOOTH_ADVERTISE) Loading Loading @@ -2102,7 +2103,7 @@ public class GattService extends ProfileService { } Log.d(TAG, "registerClient() - UUID=" + uuid); mClientMap.add(uuid, callback, this); mClientMap.add(uuid, callback, this, attributionSource); mNativeInterface.gattClientRegisterApp( uuid.getLeastSignificantBits(), uuid.getMostSignificantBits(), eatt_support); } Loading Loading @@ -3161,7 +3162,7 @@ public class GattService extends ProfileService { } Log.d(TAG, "registerServer() - UUID=" + uuid); mServerMap.add(uuid, callback, this); mServerMap.add(uuid, callback, this, attributionSource); mNativeInterface.gattServerRegisterApp( uuid.getLeastSignificantBits(), uuid.getMostSignificantBits(), eatt_support); } Loading Loading @@ -3551,11 +3552,25 @@ public class GattService extends ProfileService { mTransitionalScanHelper.getScannerMap().dumpApps(sb, ProfileService::println); sb.append(" Client:\n"); for (Integer appId : mClientMap.getAllAppsIds()) { println(sb, " app_if: " + appId + ", appName: " + mClientMap.getById(appId).name); ContextMap.App app = mClientMap.getById(appId); println( sb, " app_if: " + appId + ", appName: " + app.name + (app.attributionTag == null ? "" : ", tag: " + app.attributionTag)); } sb.append(" Server:\n"); for (Integer appId : mServerMap.getAllAppsIds()) { println(sb, " app_if: " + appId + ", appName: " + mServerMap.getById(appId).name); ContextMap.App app = mServerMap.getById(appId); println( sb, " app_if: " + appId + ", appName: " + app.name + (app.attributionTag == null ? "" : ", tag: " + app.attributionTag)); } sb.append("\n\n"); } Loading Loading
android/app/src/com/android/bluetooth/gatt/AdvertiseManager.java +4 −2 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.bluetooth.le.AdvertiseData; import android.bluetooth.le.AdvertisingSetParameters; import android.bluetooth.le.IAdvertisingSetCallback; import android.bluetooth.le.PeriodicAdvertisingParameters; import android.content.AttributionSource; import android.os.Binder; import android.os.Handler; import android.os.HandlerThread; Loading Loading @@ -246,7 +247,8 @@ public class AdvertiseManager { int duration, int maxExtAdvEvents, int serverIf, IAdvertisingSetCallback callback) { IAdvertisingSetCallback callback, AttributionSource attrSource) { // If we are using an isolated server, force usage of an NRPA if (serverIf != 0 && parameters.getOwnAddressType() Loading Loading @@ -294,7 +296,7 @@ public class AdvertiseManager { Log.d(TAG, "startAdvertisingSet() - reg_id=" + cbId + ", callback: " + binder); mAdvertiserMap.addAppAdvertiseStats(cbId, mService); mAdvertiserMap.addAppAdvertiseStats(cbId, mService, attrSource); mAdvertiserMap.recordAdvertiseStart( cbId, parameters, Loading
android/app/src/com/android/bluetooth/gatt/AdvertiserMap.java +3 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.bluetooth.gatt; import android.bluetooth.le.AdvertiseData; import android.bluetooth.le.AdvertisingSetParameters; import android.bluetooth.le.PeriodicAdvertisingParameters; import android.content.AttributionSource; import android.content.Context; import android.os.Binder; import android.util.Log; Loading Loading @@ -45,7 +46,7 @@ class AdvertiserMap { EvictingQueue.create(ADVERTISE_STATE_MAX_SIZE); /** Add an entry to the stats map if it doesn't already exist. */ void addAppAdvertiseStats(int id, Context context) { void addAppAdvertiseStats(int id, Context context, AttributionSource attrSource) { int appUid = Binder.getCallingUid(); String appName = context.getPackageManager().getNameForUid(appUid); if (appName == null) { Loading @@ -55,7 +56,7 @@ class AdvertiserMap { synchronized (this) { if (!mAppAdvertiseStats.containsKey(id)) { addAppAdvertiseStats(id, new AppAdvertiseStats(appUid, id, appName)); addAppAdvertiseStats(id, new AppAdvertiseStats(appUid, id, appName, attrSource)); } } } Loading
android/app/src/com/android/bluetooth/gatt/AppAdvertiseStats.java +14 −4 Original line number Diff line number Diff line Loading @@ -15,12 +15,16 @@ */ package com.android.bluetooth.gatt; import static com.android.bluetooth.util.AttributionSourceUtil.getLastAttributionTag; import android.annotation.Nullable; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothProtoEnums; import android.bluetooth.le.AdvertiseData; import android.bluetooth.le.AdvertisingSetCallback; import android.bluetooth.le.AdvertisingSetParameters; import android.bluetooth.le.PeriodicAdvertisingParameters; import android.content.AttributionSource; import android.os.ParcelUuid; import android.util.SparseArray; Loading Loading @@ -82,6 +86,7 @@ class AppAdvertiseStats { private int mAppUid; @VisibleForTesting String mAppName; @Nullable private String mAttributionTag; private int mId; private boolean mAdvertisingEnabled = false; private boolean mPeriodicAdvertisingEnabled = false; Loading @@ -93,17 +98,18 @@ class AppAdvertiseStats { private boolean mAnonymous = false; private boolean mConnectable = false; private boolean mScannable = false; private AppAdvertiserData mAdvertisingData = null; private AppAdvertiserData mScanResponseData = null; private AppAdvertiserData mPeriodicAdvertisingData = null; @Nullable private AppAdvertiserData mAdvertisingData = null; @Nullable private AppAdvertiserData mScanResponseData = null; @Nullable private AppAdvertiserData mPeriodicAdvertisingData = null; private boolean mPeriodicIncludeTxPower = false; private int mPeriodicInterval = 0; public ArrayList<AppAdvertiserRecord> mAdvertiserRecords = new ArrayList<AppAdvertiserRecord>(); AppAdvertiseStats(int appUid, int id, String name) { AppAdvertiseStats(int appUid, int id, String name, AttributionSource attrSource) { this.mAppUid = appUid; this.mId = id; this.mAppName = name; this.mAttributionTag = getLastAttributionTag(attrSource); } void recordAdvertiseStart( Loading Loading @@ -553,6 +559,10 @@ class AppAdvertiseStats { Instant currentTime = Instant.now(); sb.append("\n ").append(stats.mAppName); if (stats.mAttributionTag != null) { sb.append("\n Tag : ") .append(stats.mAttributionTag); } sb.append("\n Advertising ID : ").append(stats.mId); for (int i = 0; i < stats.mAdvertiserRecords.size(); i++) { AppAdvertiserRecord record = stats.mAdvertiserRecords.get(i); Loading
android/app/src/com/android/bluetooth/gatt/ContextMap.java +11 −3 Original line number Diff line number Diff line Loading @@ -15,6 +15,10 @@ */ package com.android.bluetooth.gatt; import static com.android.bluetooth.util.AttributionSourceUtil.getLastAttributionTag; import android.annotation.Nullable; import android.content.AttributionSource; import android.content.Context; import android.os.Binder; import android.os.IBinder; Loading Loading @@ -75,6 +79,9 @@ public class ContextMap<C> { /** The package name of the application */ public final String name; /** The last attribution tag of the caller */ @Nullable public final String attributionTag; /** Application callbacks */ public C callback; Loading @@ -88,11 +95,12 @@ public class ContextMap<C> { private List<CallbackInfo> mCongestionQueue = new ArrayList<>(); /** Creates a new app context. */ App(UUID uuid, C callback, int appUid, String name) { App(UUID uuid, C callback, int appUid, String name, AttributionSource attrSource) { this.uuid = uuid; this.callback = callback; this.appUid = appUid; this.name = name; this.attributionTag = getLastAttributionTag(attrSource); } /** Link death recipient */ Loading Loading @@ -146,7 +154,7 @@ public class ContextMap<C> { private final Object mConnectionsLock = new Object(); /** Add an entry to the application context list. */ public App add(UUID uuid, C callback, Context context) { public App add(UUID uuid, C callback, Context context, AttributionSource attrSource) { int appUid = Binder.getCallingUid(); String appName = context.getPackageManager().getNameForUid(appUid); if (appName == null) { Loading @@ -154,7 +162,7 @@ public class ContextMap<C> { appName = "Unknown App (UID: " + appUid + ")"; } synchronized (mAppsLock) { App app = new App(uuid, callback, appUid, appName); App app = new App(uuid, callback, appUid, appName, attrSource); mApps.add(app); return app; } Loading
android/app/src/com/android/bluetooth/gatt/GattService.java +20 −5 Original line number Diff line number Diff line Loading @@ -1943,7 +1943,8 @@ public class GattService extends ProfileService { duration, maxExtAdvEvents, serverIf, callback); callback, attributionSource); } @RequiresPermission(BLUETOOTH_ADVERTISE) Loading Loading @@ -2102,7 +2103,7 @@ public class GattService extends ProfileService { } Log.d(TAG, "registerClient() - UUID=" + uuid); mClientMap.add(uuid, callback, this); mClientMap.add(uuid, callback, this, attributionSource); mNativeInterface.gattClientRegisterApp( uuid.getLeastSignificantBits(), uuid.getMostSignificantBits(), eatt_support); } Loading Loading @@ -3161,7 +3162,7 @@ public class GattService extends ProfileService { } Log.d(TAG, "registerServer() - UUID=" + uuid); mServerMap.add(uuid, callback, this); mServerMap.add(uuid, callback, this, attributionSource); mNativeInterface.gattServerRegisterApp( uuid.getLeastSignificantBits(), uuid.getMostSignificantBits(), eatt_support); } Loading Loading @@ -3551,11 +3552,25 @@ public class GattService extends ProfileService { mTransitionalScanHelper.getScannerMap().dumpApps(sb, ProfileService::println); sb.append(" Client:\n"); for (Integer appId : mClientMap.getAllAppsIds()) { println(sb, " app_if: " + appId + ", appName: " + mClientMap.getById(appId).name); ContextMap.App app = mClientMap.getById(appId); println( sb, " app_if: " + appId + ", appName: " + app.name + (app.attributionTag == null ? "" : ", tag: " + app.attributionTag)); } sb.append(" Server:\n"); for (Integer appId : mServerMap.getAllAppsIds()) { println(sb, " app_if: " + appId + ", appName: " + mServerMap.getById(appId).name); ContextMap.App app = mServerMap.getById(appId); println( sb, " app_if: " + appId + ", appName: " + app.name + (app.attributionTag == null ? "" : ", tag: " + app.attributionTag)); } sb.append("\n\n"); } Loading