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

Commit b97b0459 authored by Omair Kamil's avatar Omair Kamil
Browse files

Update SdpClientTest to check for the presence of the UUID for HFP.

Also replace the usage of the deprecated getExtra method.

Test: atest SdpClientTest
Bug: 325352365
Flag: EXEMPT test change
Change-Id: Ia271a50164dfba39c7b39aba3e0569704ca39317
parent ee771ae1
Loading
Loading
Loading
Loading
+7 −17
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.ParcelUuid;
import android.os.Parcelable;

import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
@@ -40,9 +39,6 @@ import org.junit.runner.RunWith;
import pandora.HostProto.ConnectRequest;
import pandora.HostProto.WaitConnectionRequest;

import java.util.ArrayList;
import java.util.UUID;

/** Test cases for {@link ServiceDiscoveryManager}. */
@RunWith(AndroidJUnit4.class)
public class SdpClientTest {
@@ -52,7 +48,7 @@ public class SdpClientTest {
    private final BluetoothManager mManager = mContext.getSystemService(BluetoothManager.class);
    private final BluetoothAdapter mAdapter = mManager.getAdapter();

    private SettableFuture<ArrayList<UUID>> mFutureIntent;
    private SettableFuture<ParcelUuid[]> mFutureIntent;

    @Rule public final AdoptShellPermissionsRule mPermissionRule = new AdoptShellPermissionsRule();

@@ -63,16 +59,10 @@ public class SdpClientTest {
                @Override
                public void onReceive(Context context, Intent intent) {
                    if (BluetoothDevice.ACTION_UUID.equals(intent.getAction())) {
                        Parcelable[] parcelable =
                                (Parcelable[]) intent.getExtra(BluetoothDevice.EXTRA_UUID);
                        if (parcelable != null) {
                            ArrayList<UUID> list = new ArrayList<UUID>();
                            for (Parcelable p : parcelable) {
                                ParcelUuid uuid = (ParcelUuid) p;
                                list.add(uuid.getUuid());
                            }
                            mFutureIntent.set(list);
                        }
                        ParcelUuid[] parcelUuids =
                                intent.getParcelableArrayExtra(
                                        BluetoothDevice.EXTRA_UUID, ParcelUuid.class);
                        mFutureIntent.set(parcelUuids);
                    }
                }
            };
@@ -107,8 +97,8 @@ public class SdpClientTest {
        // Execute service discovery procedure
        assertThat(device.fetchUuidsWithSdp()).isTrue();

        ArrayList<UUID> list = mFutureIntent.get();
        assertThat(list.isEmpty()).isFalse();
        ParcelUuid[] arr = mFutureIntent.get();
        assertThat(arr).asList().contains(BluetoothUuid.HFP);

        mContext.unregisterReceiver(mConnectionStateReceiver);
    }