1#!/usr/bin/env python3
2#
3#   Copyright 2016 - Google
4#
5#   Licensed under the Apache License, Version 2.0 (the "License");
6#   you may not use this file except in compliance with the License.
7#   You may obtain a copy of the License at
8#
9#       http://www.apache.org/licenses/LICENSE-2.0
10#
11#   Unless required by applicable law or agreed to in writing, software
12#   distributed under the License is distributed on an "AS IS" BASIS,
13#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14#   See the License for the specific language governing permissions and
15#   limitations under the License.
16
17# Defines utilities that can be used for making calls indenpendent of
18# subscription IDs. This can be useful when making calls over mediums not SIM
19# based.
20
21# Make a phone call to the specified URI. It is assumed that we are making the
22# call to the user selected default account.
23#
24# We usually want to make sure that the call has ended up in a good state.
25#
26# NOTE: This util is applicable to only non-conference type calls. It is best
27# suited to test cases where only one call is in action at any point of time.
28
29from acts import logger
30from acts_contrib.test_utils.bt import bt_test_utils
31from acts_contrib.test_utils.bt.BtEnum import *
32
33
34def set_car_profile_priorities_off(car_droid, ph_droid):
35    """Sets priority of car related profiles to OFF. This avoids
36    autoconnect being triggered randomly. The use of this function
37    is encouraged when you're testing individual profiles in isolation
38
39    Args:
40        log: log object
41        car_droid: Car droid
42        ph_droid: Phone droid
43
44    Returns:
45        True if success, False if fail.
46    """
47    # TODO investigate MCE
48    car_profiles = [
49        BluetoothProfile.A2DP_SINK, BluetoothProfile.HEADSET_CLIENT,
50        BluetoothProfile.PBAP_CLIENT, BluetoothProfile.MAP_MCE
51    ]
52    bt_test_utils.set_profile_priority(car_droid, ph_droid, car_profiles,
53                                       BluetoothPriorityLevel.PRIORITY_OFF)
54