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

Commit ffb90349 authored by Rahul Arya's avatar Rahul Arya
Browse files

[Private GATT] Enforce NRPA for private GATT

As per design at go/private-gatt-in-platform, all advertisements using
an isolated server must use an NRPA. This adds a check for that in the
service.

Test: CTS multi-device
Bug: 274945531
Change-Id: If564983b3b3d5ff2b3f883151f47f8f7026e8689
parent c09521a6
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -211,6 +211,20 @@ public class AdvertiseManager {
            AdvertiseData scanResponse, PeriodicAdvertisingParameters periodicParameters,
            AdvertiseData periodicData, int duration, int maxExtAdvEvents, int serverIf,
            IAdvertisingSetCallback callback) {
        // If we are using an isolated server, force usage of an NRPA
        if (serverIf != 0
                && parameters.getOwnAddressType()
                        != AdvertisingSetParameters.ADDRESS_TYPE_RANDOM_NON_RESOLVABLE) {
            Log.w(TAG, "Cannot advertise an isolated GATT server using a resolvable address");
            try {
                callback.onAdvertisingSetStarted(
                        0x00, 0x00, AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR);
            } catch (RemoteException exception) {
                Log.e(TAG, "Failed to callback:" + Log.getStackTraceString(exception));
            }
            return;
        }

        AdvertisingSetDeathRecipient deathRecipient = new AdvertisingSetDeathRecipient(callback);
        IBinder binder = toBinder(callback);
        try {