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

Commit d83febca authored by Omair Kamil's avatar Omair Kamil Committed by Automerger Merge Worker
Browse files

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

Merge "Update SdpClientTest to check for the presence of the UUID for HFP." into main am: 56e3ccb9 am: 0db42dec

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/2962623



Change-Id: I1344e7b8ec41e9ee4e35672cd00e0e552c25b49b
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents ee272ea3 0db42dec
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);
    }