예제 #1
0
 def test_stress_toggle_wifi_state_bluetooth_on(self):
     """Toggle WiFi state ON and OFF for N times when bluetooth ON."""
     enable_bluetooth(self.dut.droid, self.dut.ed)
     for count in range(self.stress_count):
         """Test toggling wifi"""
         try:
             self.log.debug("Going from on to off.")
             wutils.wifi_toggle_state(self.dut, False)
             self.log.debug("Going from off to on.")
             startTime = time.time()
             wutils.wifi_toggle_state(self.dut, True)
             startup_time = time.time() - startTime
             self.log.debug("WiFi was enabled on the device in %s s." %
                            startup_time)
         except:
             signals.TestFailure(details="",
                                 extras={
                                     "Iterations": "%d" % self.stress_count,
                                     "Pass": "******" % count
                                 })
     disable_bluetooth(self.dut.droid)
     raise signals.TestPass(details="",
                            extras={
                                "Iterations": "%d" % self.stress_count,
                                "Pass": "******" % (count + 1)
                            })
    def teardown_class(self):
        """Clean up the test class after tests finish running

        """
        super().teardown_class()
        self.dut.droid.bluetoothFactoryReset()
        self.dut.adb.shell(BLE_LOCATION_SCAN_DISABLE)
        self.bt_device.reset()
        self.bt_device.power_off()
        btutils.disable_bluetooth(self.dut.droid)
    def teardown_class(self):

        super().teardown_class()
        self.dut.droid.bluetoothFactoryReset()

        # Stopping BT on slave
        self.bt_device.reset()
        self.bt_device.power_off()

        #Stopping BT on master
        bt_utils.disable_bluetooth(self.dut.droid)
    def teardown_class(self):

        super().teardown_class()
        if hasattr(self, 'media'):
            self.media.stop()
        if hasattr(self, 'attenuator'):
            self.attenuator.set_atten(INIT_ATTEN)
        self.dut.droid.bluetoothFactoryReset()
        self.bt_device.reset()
        self.bt_device.power_off()
        btutils.disable_bluetooth(self.dut.droid)
    def teardown_test(self):

        super().teardown_test()
        self.dut.droid.bluetoothFactoryReset()
        self.media.stop()
        # Set Attenuator to the initial attenuation
        if hasattr(self, 'attenuator'):
            self.attenuator.set_atten(INIT_ATTEN)
        self.bt_device.reset()
        self.bt_device.power_off()
        btutils.disable_bluetooth(self.dut.droid)
 def teardown_test(self):
     # Deleting the table
     self.dut.adb.shell('rm {}'.format(self.power_file_paths[1]))
     self.attenuator.set_atten(self.atten_min)
     self.log.info('Attenuation set to {} dB'.format(self.atten_min))
     ble_gatt_disconnection(self.bt_device, self.bluetooth_gatt,
                            self.gatt_callback)
     self.bt_device.droid.bluetoothSocketConnStop()
     self.dut.droid.bluetoothSocketConnStop()
     time.sleep(l2cap_max_inactivity_delay_after_disconnect)
     self.dut.droid.bluetoothFactoryReset()
     bt_utils.disable_bluetooth(self.dut.droid)
예제 #7
0
 def setup_class(self):
     super(BleScanPowerTest, self).setup_class()
     # Get power test device serial number
     power_test_device_serial = self.user_params["PowerTestDevice"]
     # If there are multiple devices in the shield box turn off
     # all of them except the one for the power testing
     if len(self.android_devices) > 1:
         for ad in self.android_devices:
             if ad.serial != power_test_device_serial[0]:
                 self.ad.log.info("Disable BT for %s != %s", ad.serial,
                                  power_test_device_serial[0])
                 disable_bluetooth(ad.droid)
    def test_reboot_wifi_and_bluetooth_on(self):
        """Toggle WiFi and bluetooth ON then reboot """
        wutils.wifi_toggle_state(self.dut, True)
        enable_bluetooth(self.dut.droid, self.dut.ed)

        self.dut.reboot()
        time.sleep(DEFAULT_TIMEOUT)

        asserts.assert_true(self.dut.droid.bluetoothCheckState(),
                "bluetooth state changed after reboot")
        asserts.assert_true(self.dut.droid.wifiCheckState(),
                "wifi state changed after reboot")

        disable_bluetooth(self.dut.droid)
    def teardown_test(self):
        #Stopping Music
        if hasattr(self, 'media'):
            self.media.stop()

        # Stopping BT on slave
        self.bt_device.reset()
        self.bt_device.power_off()

        #Stopping BT on master
        bt_utils.disable_bluetooth(self.dut.droid)

        #Resetting the atten to initial levels
        self.attenuator.set_atten(self.atten_min)
        self.log.info('Attenuation set to {} dB'.format(self.atten_min))
예제 #10
0
    def setup_test(self):

        super().setup_test()
        self.attenuator = self.attenuators[0]
        btutils.enable_bqr(self.dut)
        time.sleep(2)
        btutils.disable_bluetooth(self.dut.droid)
        time.sleep(2)
        btutils.enable_bluetooth(self.dut.droid, self.dut.ed)
        btutils.connect_phone_to_headset(self.dut, self.bt_device, 60)
        vol = self.dut.droid.getMaxMediaVolume() * self.volume
        self.dut.droid.setMediaVolume(int(vol))

        self.cal_data_path = os.path.join(self.log_path, 'Calibration')
        self.log_file = os.path.join(self.cal_data_path, 'Cal_data.csv')
        os.makedirs(os.path.dirname(self.log_file), exist_ok=True)
    def test_power_baseline_play_music_but_disable_bluetooth(self):
        """Test power usage baseline of playing music but Bluetooth is off.

        Test power usage baseline of playing music but Bluetooth is off
           speaker volume is set to 0.

        Steps:
        1. Disable Bluetooth
        2. The same steps described in _main_power_test_function_for_codec()
        3. Enable Bluetooth

        Expected Result:
        Power consumption results

        TAGS: Bluetooth, A2DP, Power, Codec
        Priority: 3

        """
        self.ad.log.info("Disable BT")
        if not disable_bluetooth(self.ad.droid):
            self.log.error("Failed to disable Bluetooth on DUT")
            return False

        self._main_power_test_function_for_codec(
            self.CODEC_SBC, self.SAMPLE_RATE_44100, self.BITS_PER_SAMPLE_16,
            self.cd_quality_music_file, self.LDACBT_NONE, False, True)

        self.ad.log.info("Enable BT")
        if not bluetooth_enabled_check(self.ad):
            self.log.error("Failed to turn Bluetooth on DUT")
예제 #12
0
 def teardown_test(self):
     self.parsing_results()
     with open(self.json_file, 'a') as results_file:
         json.dump(self.result, results_file, indent=4, sort_keys=True)
     if not disable_bluetooth(self.pri_ad.droid):
         self.log.info('Failed to disable bluetooth')
         return False
     self.destroy_android_and_relay_object()
    def teardown_test(self):
        """Tear down necessary objects after test case is finished.

        Bring down the AP interface, delete the bridge interface, stop the
        packet sender, and reset the ethernet interface for the packet sender
        """
        super().teardown_test()
        self.dut.droid.bluetoothFactoryReset()
        self.dut.adb.shell(BLE_LOCATION_SCAN_DISABLE)
        if hasattr(self, 'media'):
            self.media.stop()
        # Set Attenuator to the initial attenuation
        if hasattr(self, 'attenuators'):
            self.set_attenuation(INIT_ATTEN)
        self.bt_device.reset()
        self.bt_device.power_off()
        btutils.disable_bluetooth(self.dut.droid)
예제 #14
0
def phone_setup_for_BT(dut, bt_on, ble_on, screen_status):
    """Sets the phone and Bluetooth in the desired state

    Args:
        dut: object of the android device under test
        bt_on: Enable/Disable BT
        ble_on: Enable/Disable BLE
        screen_status: screen ON or OFF
    """
    # Initialize the dut to rock-bottom state
    wputils.dut_rockbottom(dut)
    time.sleep(2)

    # Check if we are enabling a background scan
    # TODO: Turn OFF cellular wihtout having to turn ON airplane mode
    if bt_on == 'OFF' and ble_on == 'ON':
        dut.adb.shell(BLE_LOCATION_SCAN_ENABLE)
        dut.droid.connectivityToggleAirplaneMode(False)
        time.sleep(2)

    # Turn ON/OFF BT
    if bt_on == 'ON':
        enable_bluetooth(dut.droid, dut.ed)
        dut.log.info('BT is ON')
    else:
        disable_bluetooth(dut.droid)
        dut.droid.bluetoothDisableBLE()
        dut.log.info('BT is OFF')
    time.sleep(2)

    # Turn ON/OFF BLE
    if ble_on == 'ON':
        dut.droid.bluetoothEnableBLE()
        dut.log.info('BLE is ON')
    else:
        dut.droid.bluetoothDisableBLE()
        dut.log.info('BLE is OFF')
    time.sleep(2)

    # Set the desired screen status
    if screen_status == 'OFF':
        dut.droid.goToSleepNow()
        dut.log.info('Screen is OFF')
    time.sleep(2)
예제 #15
0
 def teardown_test(self):
     if "a2dp_streaming" in self.current_test_name:
         if not collect_bluetooth_manager_dumpsys_logs(
                 self.pri_ad, self.current_test_name):
             return False
         self.result["a2dp_packet_drop"] = a2dp_dumpsys_parser()
     with open(self.json_file, 'w+') as results_file:
         json.dump(self.result, results_file, indent=4)
     if not disable_bluetooth(self.pri_ad.droid):
         self.log.info("Failed to disable bluetooth")
         return False
     self.teardown_thread()
예제 #16
0
    def phone_setup_for_BT(self, bt_on, ble_on, screen_status):
        """Sets the phone and Bluetooth in the desired state

        Args:
            bt_on: Enable/Disable BT
            ble_on: Enable/Disable BLE
            screen_status: screen ON or OFF
        """

        # Check if we are enabling a background scan
        # TODO: Turn OFF cellular wihtout having to turn ON airplane mode
        if bt_on == 'OFF' and ble_on == 'ON':
            self.dut.adb.shell(BLE_LOCATION_SCAN_ENABLE)
            self.dut.droid.connectivityToggleAirplaneMode(False)
            time.sleep(2)

        # Turn ON/OFF BT
        if bt_on == 'ON':
            enable_bluetooth(self.dut.droid, self.dut.ed)
            self.dut.log.info('BT is ON')
        else:
            disable_bluetooth(self.dut.droid)
            self.dut.droid.bluetoothDisableBLE()
            self.dut.log.info('BT is OFF')
        time.sleep(2)

        # Turn ON/OFF BLE
        if ble_on == 'ON':
            self.dut.droid.bluetoothEnableBLE()
            self.dut.log.info('BLE is ON')
        else:
            self.dut.droid.bluetoothDisableBLE()
            self.dut.log.info('BLE is OFF')
        time.sleep(2)

        # Set the desired screen status
        if screen_status == 'OFF':
            self.dut.droid.goToSleepNow()
            self.dut.log.info('Screen is OFF')
        time.sleep(2)
 def teardown_test(self):
     self.performance_baseline_check()
     for i in range(self.num_atten):
         self.attenuators[i].set_atten(0)
         current_atten = int(self.attenuators[i].get_atten())
         self.log.debug(
             "Setting attenuation to zero : Current atten {} : {}".format(
                 self.attenuators[i], current_atten))
     self.a2dp_streaming = False
     if not disable_bluetooth(self.pri_ad.droid):
         self.log.info("Failed to disable bluetooth")
         return False
     self.destroy_android_and_relay_object()
     self.rvr = {}
예제 #18
0
 def destroy_android_and_relay_object(self):
     """Destroys android device object and relay device object if required
     devices has android device and relay device."""
     if hasattr(self, 'required_devices'):
         if ('discovery' in self.current_test_name or
                 'ble' in self.current_test_name):
             if hasattr(self, 'inquiry_devices'):
                 for device in range(len(self.inquiry_devices)):
                     inquiry_device = self.inquiry_devices[device]
                     if not disable_bluetooth(inquiry_device.droid):
                         self.log.info('Failed to disable bluetooth')
                 android_device.destroy(self.inquiry_devices)
             if hasattr(self, 'relay'):
                 relay_device_controller.destroy(self.relay)
예제 #19
0
def toggle_bluetooth(pri_ad, duration):
    """Toggles bluetooth on/off for N iterations.

    Args:
        pri_ad: An android device object.
        duration: Iperf duration of the test.

    Returns:
        True if successful, False otherwise.
    """
    start_time = time.time()
    while time.time() < start_time + duration:
        if not enable_bluetooth(pri_ad.droid, pri_ad.ed):
            pri_ad.log.error("Failed to enable bluetooth")
            return False
        time.sleep(BLUETOOTH_WAIT_TIME)
        if not disable_bluetooth(pri_ad.droid):
            pri_ad.log.error("Failed to turn off bluetooth")
            return False
        time.sleep(BLUETOOTH_WAIT_TIME)
    return True
 def teardown_test(self):
     self.performance_baseline_check()
     if not disable_bluetooth(self.pri_ad.droid):
         self.log.error("Failed to disable bluetooth")
         return False
     self.teardown_thread()
 def setup_class(self):
     super().setup_class()
     if not disable_bluetooth(self.pri_ad.droid):
         self.log.info('Failed to disable bluetooth')
         return False
 def teardown_class(self):
     bt_utils.disable_bluetooth(self.dut.droid)
 def setup_test(self):
     CoexPerformanceBaseTest.setup_test(self)
     if not disable_bluetooth(self.pri_ad.droid):
         self.log.info("Failed to disable bluetooth")
         return False
예제 #24
0
    def test_call_transfer_off_on(self):
        """
        Tests that after we turn adapter on when an active call is in
        progress, we show the call.

        Precondition:
        1. AG & HF are disconnected but paired.
        2. HF's adapter is OFF

        Steps:
        1. Make a call from AG role (since disconnected)
        2. Accept from RE role and transition the call to Active
        3. Turn HF's adapter ON
        4. HF should transition into Active call state.

        Returns:
          Pass if True
          Fail if False

        Priority: 1
        """
        # Connect HF & AG
        if not bt_test_utils.connect_pri_to_sec(
                self.hf, self.ag,
                set([BtEnum.BluetoothProfile.HEADSET_CLIENT.value])):
            self.log.error("Could not connect HF and AG {} {}".format(
                self.hf.serial, self.ag.serial))
            return False

        # make a call on AG
        if not initiate_call(self.log, self.ag, self.re_phone_number):
            self.ag.log.error("Failed to initiate call from ag.")
            return False

        # Wait for all HF
        if not car_telecom_utils.wait_for_dialing(self.log, self.hf):
            self.hf.log.error("HF not in ringing state.")
            return False

        # Accept the call on RE
        if not wait_and_answer_call(self.log, self.re):
            self.re.log.error("Failed to accept call on re.")
            return False
        # Wait for all HF, AG, RE to go into an Active state.
        if not car_telecom_utils.wait_for_active(self.log, self.hf):
            self.hf.log.error("HF not in Active state.")
            return False
        if not car_telecom_utils.wait_for_active(self.log, self.ag):
            self.ag.log.error("AG not in Active state.")
            return False
        if not car_telecom_utils.wait_for_active(self.log, self.re):
            self.re.log.error("RE not in Active state.")
            return False

        # Turn the adapter OFF on HF
        if not bt_test_utils.disable_bluetooth(self.hf.droid):
            self.hf.log.error("Failed to turn BT off on HF.")
            return False

        # Turn adapter ON on HF
        if not bt_test_utils.enable_bluetooth(self.hf.droid, self.hf.ed):
            self.hf.log.error("Failed to turn BT ON after call on HF.")
            return False

        # Check that HF is in active state
        if not car_telecom_utils.wait_for_active(self.log, self.hf):
            self.hf.log.error("HF not in Active state.")
            return False

        # Hangup the call and check all devices are clean
        self.hf.droid.telecomEndCall()
        ret = True
        ret &= car_telecom_utils.wait_for_not_in_call(self.log, self.hf)
        ret &= car_telecom_utils.wait_for_not_in_call(self.log, self.ag)
        ret &= car_telecom_utils.wait_for_not_in_call(self.log, self.re)

        return ret