def setup_class(self):
        # AVRCP roles
        self.CT = self.android_devices[0]
        self.TG = self.android_devices[1]
        # A2DP roles for the same devices
        self.SNK = self.CT
        self.SRC = self.TG

        # Setup devices
        bt_test_utils.setup_multiple_devices_for_bt_test([self.CT, self.TG])

        self.btAddrCT = self.CT.droid.bluetoothGetLocalAddress()
        self.btAddrTG = self.TG.droid.bluetoothGetLocalAddress()

        # Additional time from the stack reset in setup.
        time.sleep(4)
        # Pair the devices.
        if not bt_test_utils.pair_pri_to_sec(
                self.CT, self.TG, attempts=4, auto_confirm=False):
            self.log.error("Failed to pair")
            return False

        # Disable all
        car_bt_utils.set_car_profile_priorities_off(self.SNK, self.SRC)

        # Enable A2DP
        bt_test_utils.set_profile_priority(
            self.SNK, self.SRC, [BtEnum.BluetoothProfile.A2DP_SINK],
            BtEnum.BluetoothPriorityLevel.PRIORITY_ON)
Ejemplo n.º 2
0
    def setup_class(self):
        if not super(BtCarPbapTest, self).setup_class():
            return False
        self.pce = self.android_devices[0]
        self.pse = self.android_devices[1]
        self.pse2 = self.android_devices[2]
        self.contacts_destination_path = self.log_path + "/"

        permissions_list = [
            "android.permission.READ_CONTACTS",
            "android.permission.WRITE_CONTACTS",
            "android.permission.READ_EXTERNAL_STORAGE"
        ]
        for device in self.android_devices:
            for permission in permissions_list:
                device.adb.shell(
                    "pm grant com.google.android.contacts {}".format(
                        permission))

        # Pair the devices.
        # This call may block until some specified timeout in bt_test_utils.py.
        # Grace time inbetween stack state changes
        if not bt_test_utils.pair_pri_to_sec(self.pce, self.pse):
            self.log.error("Failed to pair.")
            return False
        time.sleep(3)
        if not bt_test_utils.pair_pri_to_sec(self.pce, self.pse2):
            self.log.error("Failed to pair.")
            return False

        # Disable the HFP and A2DP profiles. This will ensure only PBAP
        # gets connected. Also, this will eliminate the auto-connect loop.
        car_bt_utils.set_car_profile_priorities_off(self.pce, self.pse)
        car_bt_utils.set_car_profile_priorities_off(self.pce, self.pse2)

        # Enable PBAP on PSE & PCE.

        self.pse.droid.bluetoothChangeProfileAccessPermission(
            self.pce.droid.bluetoothGetLocalAddress(),
            BtEnum.BluetoothProfile.PBAP_SERVER.value,
            BtEnum.BluetoothAccessLevel.ACCESS_ALLOWED.value)

        self.pse2.droid.bluetoothChangeProfileAccessPermission(
            self.pce.droid.bluetoothGetLocalAddress(),
            BtEnum.BluetoothProfile.PBAP_SERVER.value,
            BtEnum.BluetoothAccessLevel.ACCESS_ALLOWED.value)

        bt_test_utils.set_profile_priority(
            self.pce, self.pse, [BtEnum.BluetoothProfile.PBAP_CLIENT],
            BtEnum.BluetoothPriorityLevel.PRIORITY_ON)
        bt_test_utils.set_profile_priority(
            self.pce, self.pse2, [BtEnum.BluetoothProfile.PBAP_CLIENT],
            BtEnum.BluetoothPriorityLevel.PRIORITY_ON)

        return True
Ejemplo n.º 3
0
    def setup_class(self):
        if not super(BtCarHfpConnectionTest, self).setup_class():
            return False

        # Disable all
        car_bt_utils.set_car_profile_priorities_off(self.hf, self.ag)

        # Enable A2DP
        bt_test_utils.set_profile_priority(
            self.hf, self.ag, [BtEnum.BluetoothProfile.HEADSET_CLIENT],
            BtEnum.BluetoothPriorityLevel.PRIORITY_ON)

        return True
Ejemplo n.º 4
0
    def setup_class(self):
        if not super(BtCarHfpTest, self).setup_class():
            return False
        # Disable the A2DP profile.
        bt_test_utils.set_profile_priority(self.hf, self.ag, [
            BtEnum.BluetoothProfile.PBAP_CLIENT.value,
            BtEnum.BluetoothProfile.A2DP_SINK.value
        ], BtEnum.BluetoothPriorityLevel.PRIORITY_OFF)
        bt_test_utils.set_profile_priority(
            self.hf, self.ag, [BtEnum.BluetoothProfile.HEADSET_CLIENT.value],
            BtEnum.BluetoothPriorityLevel.PRIORITY_ON)

        if not bt_test_utils.connect_pri_to_sec(
                self.hf, self.ag,
                set([BtEnum.BluetoothProfile.HEADSET_CLIENT.value])):
            self.log.error("Failed to connect.")
            return False
        return True
def set_car_profile_priorities_off(car_droid, ph_droid):
    """Sets priority of car related profiles to OFF. This avoids
    autoconnect being triggered randomly. The use of this function
    is encouraged when you're testing individual profiles in isolation

    Args:
        log: log object
        car_droid: Car droid
        ph_droid: Phone droid

    Returns:
        True if success, False if fail.
    """
    # TODO investigate MCE
    car_profiles = [
        BluetoothProfile.A2DP_SINK, BluetoothProfile.HEADSET_CLIENT,
        BluetoothProfile.PBAP_CLIENT, BluetoothProfile.MAP_MCE
    ]
    bt_test_utils.set_profile_priority(car_droid, ph_droid, car_profiles,
                                       BluetoothPriorityLevel.PRIORITY_OFF)