1# Copyright (C) 2023 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15import logging 16import re 17import time 18 19from mobly.controllers import android_device 20from utilities import constants 21 22 23class CallUtilsError(Exception): 24 """This exception may be expanded in the future to provide better error discoverability.""" 25 pass 26 27 28class CallUtils: 29 """Calling sequence utility for BT calling test using Spectatio UI APIs. 30 31 This class provides functions that execute generic call sequences. Specific 32 methods (e.g., verify_precall_state) are left to that implementation, and thus the 33 utilities housed here are meant to describe generic sequences of actions. 34 """ 35 36 def __init__(self, device): 37 self.device = device 38 39 def device_displays_connected(self): 40 """Assumes the device bluetooth connection settings page is open""" 41 logging.info('Checking whether device is connected.') 42 self.device.mbs.deviceIsConnected() 43 44 def open_app_grid(self): 45 """Opens app Grid """ 46 logging.info("Opening app grid") 47 self.device.mbs.openAppGrid() 48 49 def dial_a_number(self, callee_number): 50 """Dial phone number""" 51 logging.info("Dial phone number <%s>", callee_number) 52 self.device.mbs.dialANumber(callee_number) 53 54 def end_call(self): 55 """End the call. Throws an error if non call is currently ongoing.""" 56 logging.info("End the call") 57 self.device.mbs.endCall() 58 59 def execute_shell_on_device(self, device_target, shell_command): 60 """Execute any shell command on any device""" 61 logging.info( 62 "Executing shell command: <%s> on device <%s>", 63 shell_command, 64 device_target.serial, 65 ) 66 return device_target.adb.shell(shell_command) 67 68 def get_dialing_number(self): 69 """Get dialing phone number""" 70 return self.device.mbs.getDialingNumber() 71 72 def get_user_phone_number(self): 73 """Get user phone number""" 74 return self.device.mbs.getUserProfilePhoneNumber() 75 76 def get_home_address_from_details(self): 77 """Return the home address of the contact whose details are currently being displayed""" 78 return self.device.mbs.getHomeAddress() 79 80 def get_device_summary(self): 81 """Assumes the device summary page is open.""" 82 return self.device.mbs.getDeviceSummary() 83 84 def is_phone_profile_enabled(self): 85 """Returns if phone profile is enabled on Bluetooth Summary Screen.""" 86 return self.device.mbs.isPhoneProfileEnabled() 87 88 def import_contacts_from_vcf_file(self, device_target): 89 """Importing contacts from VCF file""" 90 logging.info("Importing contacts from VCF file to device Contacts") 91 self.execute_shell_on_device( 92 device_target, 93 constants.IMPOST_CONTACTS_SHELL_COMAND, 94 ) 95 96 def make_call(self): 97 """Make call""" 98 logging.info("Make a call") 99 self.device.mbs.makeCall() 100 101 def open_call_history(self): 102 """Open call history""" 103 logging.info("Open call history") 104 self.device.mbs.openCallHistory() 105 106 def open_contacts(self): 107 """Open contacts""" 108 logging.info("Opening contacts") 109 self.device.mbs.openContacts() 110 111 def open_favorites(self): 112 """Open favorites""" 113 logging.info("Opening favorites") 114 self.device.mbs.openFavorites() 115 116 def open_dialpad(self): 117 """Open the dial pad from the dialer main screen""" 118 logging.info("Opening the dialpad") 119 self.device.mbs.openDialPad() 120 121 def open_dialer_settings(self): 122 logging.info("Opening the dialer settings") 123 self.device.mbs.openDialerSettings() 124 125 def open_phone_app(self): 126 logging.info("Opening phone app") 127 self.device.mbs.openPhoneApp() 128 129 def open_first_contact_details(self): 130 """Open the contact details page for the first contact visible in the contact list. 131 Assumes we are on the contacts page.""" 132 logging.info("Getting details for first contact on the page") 133 self.device.mbs.openFirstContactDetails() 134 135 def open_bluetooth_settings(self): 136 """Assumes we are on the home screen. 137 Navigate to the Bluetooth setting page""" 138 logging.info("Opening bluetooth settings (via the home screen)") 139 self.device.mbs.openBluetoothSettings() 140 141 def open_bluetooth_settings_form_status_bar(self): 142 """Assumes we are on the home screen. 143 Navigate to the Bluetooth setting page""" 144 logging.info("Opening bluetooth settings (via the Status Bar)") 145 self.device.mbs.openBluetoothSettingsFromStatusBar() 146 147 def press_active_call_toggle(self): 148 logging.info("Pressing the Active Call toggle") 149 self.device.mbs.pressActiveCallToggle() 150 151 def open_dialer_settings(self): 152 logging.info('Opening Dialer settings') 153 self.device.mbs.openDialerSettings() 154 155 def press_bluetooth_toggle_on_device(self, device_name): 156 logging.info('Attempting to press the bluetooth toggle on device: \'%s\'' % device_name) 157 self.device.mbs.pressBluetoothToggleOnDevice(device_name) 158 159 def press_media_toggle_on_device(self, device_name): 160 logging.info('Attempting to press the media toggle on device: \'%s\'' % device_name) 161 self.device.mbs.pressMediaToggleOnDevice(device_name) 162 163 def press_contact_search_result(self, expected_first_name): 164 logging.info('Attempting to press the contact result with name \'%s\'' % expected_first_name) 165 self.device.mbs.pressContactResult(expected_first_name) 166 167 def press_device_entry_on_list_of_paired_devices(self, device_name): 168 logging.info('Attempting to press the device entry on device: ' + device_name) 169 self.device.mbs.pressDeviceInBluetoothSettings(device_name) 170 171 def press_home_screen_on_status_bar(self): 172 """Presses the Home screen button on the status bar 173 (to return the device to the home screen.""" 174 logging.info("Pressing home screen button") 175 self.device.mbs.pressHomeScreen() 176 177 def press_phone_toggle_on_device(self, device_name): 178 logging.info('Attempting to press the phone toggle on device: \'%s\'' % device_name) 179 self.device.mbs.pressPhoneToggleOnDevice(device_name) 180 181 def press_dialer_button_on_phone_card(self): 182 logging.info('Attempting to press the dialer button on the phone card') 183 self.device.mbs.pressDialerButtonOnPhoneCard() 184 185 def device_displays_connected(self): 186 """Assumes the device bluetooth connection settings page is open""" 187 logging.info('Checking whether device is connected.') 188 self.device.mbs.deviceIsConnected() 189 190 def press_forget(self): 191 """Assumes the device bluetooth connection settings page is open""" 192 logging.info('Attempting to press \'Forget\'') 193 self.device.mbs.pressForget() 194 195 def press_home(self): 196 """Press the Home button to go back to the home page.""" 197 logging.info("Pressing HOME ") 198 self.device.mbs.pressHome() 199 200 def press_enter_on_device(self, device_target): 201 logging.info("Pressing ENTER on device.") 202 self.execute_shell_on_device(device_target, "input keyevent KEYCODE_ENTER") 203 self.wait_with_log(constants.ONE_SEC) 204 205 def push_vcf_contacts_to_device(self, device_target, path_to_contacts_file): 206 """Pushing contacts file to device using adb command""" 207 logging.info( 208 "Pushing VCF contacts to device %s to destination <%s>", 209 device_target.serial, 210 constants.PHONE_CONTACTS_DESTINATION_PATH, 211 ) 212 device_target.adb.push( 213 [path_to_contacts_file, constants.PHONE_CONTACTS_DESTINATION_PATH], 214 timeout=20, 215 ) 216 217 def validate_three_preference_buttons(self, bluetooth_enabled): 218 """Checks each of the three preference buttons (bluetooth, phone, audio). 219 220 If bluetooth is enabled, all three buttons should be enabled, and the bluetooth 221 button should be checked. 222 223 If bluetooth is disabled, the bluetooth button should not be checked, 224 and the phone and media buttons should be disabled. 225 """ 226 logging.info("Checking the three Preference buttons on the listed device") 227 expected_check_status = "checked" if bluetooth_enabled else "unchecked" 228 if (self.device.mbs.isBluetoothPreferenceChecked() != bluetooth_enabled): 229 logging.info("Bluetooth preference check status does not match expected status: " 230 + str(bluetooth_enabled)) 231 return False 232 233 expected_status = "enabled" if bluetooth_enabled else "disabled" 234 if (self.device.mbs.isPhonePreferenceEnabled() != bluetooth_enabled): 235 logging.info("Phone preference was does not match expected status: %s", 236 str(expected_status)) 237 return False 238 239 if (self.device.mbs.isMediaPreferenceEnabled() != bluetooth_enabled): 240 logging.info("Media preference does not match enabled status: " + str(expected_status)) 241 return False 242 243 return True 244 245 def upload_vcf_contacts_to_device(self, device_target, path_to_contacts_file): 246 """Upload contacts do device""" 247 self.import_contacts_from_vcf_file(device_target) 248 device_target.mbs.pressDevice() 249 250 def verify_contact_name(self, expected_contact): 251 actual_dialed_contact = self.device.mbs.getContactName() 252 logging.info( 253 "Expected contact name being called: <%s>, Actual: <%s>", 254 expected_contact, 255 actual_dialed_contact, 256 ) 257 if actual_dialed_contact != expected_contact: 258 raise CallUtilsError( 259 "Actual and Expected contacts on dial pad don't match." 260 ) 261 262 def wait_with_log(self, wait_time): 263 """Wait for specific time for debugging""" 264 logging.info("Sleep for %s seconds", wait_time) 265 time.sleep(wait_time) 266 267 def open_details_page(self, contact_name): 268 logging.info('open contacts details page') 269 self.device.mbs.openDetailsPage(contact_name) 270 271 def close_details_page(self): 272 logging.info('close contacts details page') 273 self.device.mbs.closeDetailsPage() 274 275 def add_remove_favorite_contact(self): 276 logging.info('add remove favorite contact') 277 self.device.mbs.addRemoveFavoriteContact() 278 279 def add_favorites_from_favorites_tab(self, contact_name): 280 logging.info('add favorites from favorites tab') 281 self.device.mbs.addFavoritesFromFavoritesTab(contact_name) 282 283 def is_contact_in_favorites(self, contact_name, expected_result): 284 logging.info('check if contact is in favorites') 285 actual_result =self.device.mbs.isContactInFavorites(contact_name) 286 logging.info( 287 ' Add/Remove contacts expected : <%s>, Actual : <%s>', 288 expected_result, 289 actual_result, 290 ) 291 if expected_result == 'True' and expected_result != actual_result: 292 raise CallUtilsError('Contact not added to favorites') 293 if expected_result == 'False' and expected_result != actual_result: 294 raise CallUtilsError('Contact not removed from favorites') 295 296 def open_bluetooth_media_app(self): 297 logging.info('Open Bluetooth Audio app') 298 self.device.mbs.openBluetoothMediaApp(); 299 self.wait_with_log(1) 300 301 def open_bluetooth_sms_app(self): 302 logging.info('Open Bluetooth SMS app') 303 self.device.mbs.openSmsApp(); 304 self.wait_with_log(1) 305 306 def click_phone_button(self): 307 logging.info("Click phone button") 308 self.device.mbs.clickPhoneButton() 309 310 def verify_disabled_phone_profile(self): 311 logging.info("Checks if phone profile is disabled") 312 return self.device.mbs.isBluetoothPhoneButtonEnabled() 313 314 def verify_bluetooth_hfp_error_displayed(self): 315 logging.info("Checks if bluetooth hfp error") 316 return self.device.mbs.isBluetoothHfpErrorDisplayed() 317 318 def verify_dialer_recents_tab(self): 319 logging.info("Checks if dialer recents tab is displayed") 320 return self.device.mbs.verifyDialerRecentsTab() 321 322 def verify_dialer_contacts_tab(self): 323 logging.info("Checks if dialer contacts tab is displayed") 324 return self.device.mbs.verifyDialerContactsTab() 325 326 def verify_dialer_favorites_tab(self): 327 logging.info("Checks if favorites tab is displayed") 328 return self.device.mbs.verifyDialerFavoritesTab() 329 330 def verify_dialer_dialpad_tab(self): 331 logging.info("Checks if dialpad is displayed") 332 return self.device.mbs.verifyDialerDialpadTab() 333 334 def verify_dialer_search_lens(self): 335 logging.info("Checks if Search lens is displayed") 336 return self.device.mbs.verifyDialerSearchLens() 337 338 339 def verify_dialer_settings(self): 340 logging.info("Checks if dialer settings is displayed") 341 return self.device.mbs.verifyDialerSettings() 342 343 def open_sms_app(self): 344 """Open sms app""" 345 logging.info('Opening sms app') 346 self.device.mbs.openSmsApp() 347 348 def open_bluetooth_palette(self): 349 logging.info("Open Bluetooth Palette") 350 self.device.mbs.openBluetoothPalette() 351 352 def click_bluetooth_button(self): 353 logging.info("Click Bluetooth Button") 354 self.device.mbs.clickBluetoothButton() 355 356 def is_bluetooth_connected(self): 357 logging.info("Bluetooth Connected Status") 358 is_connected = self.device.mbs.isBluetoothConnected() 359 return is_connected 360 361 def is_bluetooth_audio_disconnected_label_visible(self): 362 """Return is <Bluetooth Audio disconnected> label present """ 363 logging.info('Checking is <Bluetooth Audio disconnected> label present') 364 actual_disconnected_label_status = self.device.mbs.isBluetoothAudioDisconnectedLabelVisible() 365 logging.info('<Bluetooth Audio disconnected> label is present: %s', 366 actual_disconnected_label_status) 367 return actual_disconnected_label_status 368 369 def is_connect_to_bluetooth_label_visible_on_bluetooth_audio_page(self): 370 """Return is <Connect to Bluetooth> label present """ 371 logging.info('Checking is <Connect to Bluetooth> label present') 372 actual_status = self.device.mbs.isBluetoothAudioDisconnectedLabelVisible() 373 logging.info('<Connect to Bluetooth> label is present: %s',actual_status) 374 return actual_status 375 376 def click_cancel_label_visible_on_bluetooth_audio_page(self): 377 """Clicks on <Cancel> label present on bluetooth Audio page""" 378 self.device.mbs.cancelBluetoothAudioConncetion() 379 logging.info('Clicked on <Cancel> label present on bluetooth Audio page') 380 381 def handle_bluetooth_audio_pop_up(self): 382 """Close on BT audio popup if present on bluetooth Audio page""" 383 logging.info('Adding wait to check the Bluetooth Audio popup') 384 time.sleep(constants.DEFAULT_WAIT_TIME_FIVE_SECS) 385 is_bluetooth_media_popup_present = self.is_connect_to_bluetooth_label_visible_on_bluetooth_audio_page() 386 if is_bluetooth_media_popup_present: 387 logging.info('BT Audio popup present, cancelling that.') 388 self.click_cancel_label_visible_on_bluetooth_audio_page() 389 390 def update_device_timezone(self, expected_timezone): 391 logging.info('Update the device timezone to %s', 392 expected_timezone) 393 self.device.mbs.setTimeZone(expected_timezone) 394 actual_timezone = self.device.mbs.getTimeZone() 395 logging.info('<actual timezone> : %s and <expected_timezone> %s', 396 actual_timezone, expected_timezone) 397 if expected_timezone not in actual_timezone: 398 raise CallUtilsError( 399 "Time Zone did not set properly." 400 ) 401 402 def is_bluetooth_hfp_error_displayed(self): 403 logging.info('Verify Bluetooth HFP error is displayed,' 404 'when bluetooth is disconnected') 405 return self.device.mbs.isBluetoothHfpErrorDisplayed() 406 407 def search_contacts(self): 408 logging.info('Searching contacts using SEARCH_CONTACTS_WORKFLOW') 409 self.device.mbs.searchContacts() 410 411 def search_contacts_name(self, contact_name): 412 logging.info('Searching <%s> in contacts', contact_name) 413 self.device.mbs.searchContactsByName(contact_name) 414 415 def sort_contacts_by_first_name(self): 416 logging.info('Sorting contacts by first name') 417 self.device.mbs.sortContactListByFirstName() 418 419 def get_list_of_visible_contacts(self): 420 logging.info('Getting list of visible contacts') 421 actual_visible_contacts_list = self.device.mbs.getListOfAllContacts() 422 logging.info( 423 'Actual list of visible contacts: <%s>', actual_visible_contacts_list 424 ) 425 return actual_visible_contacts_list 426 427 def verify_ascending_sorting_order(self, actual_sorting_order): 428 expected_sorting_order = sorted(actual_sorting_order) 429 logging.info( 430 'Expected sorting order: <%s>, Actual sorting order: <%s>', 431 expected_sorting_order, 432 actual_sorting_order, 433 ) 434 if actual_sorting_order != expected_sorting_order: 435 raise CallUtilsError("Actual and Expected sorting orders don't match.") 436 437 def is_bluetooth_sms_disconnected_label_visible(self): 438 """Return is <Bluetooth SMS disconnected> label present""" 439 logging.info('Checking is <Bluetooth SMS disconnected> label present') 440 actual_disconnected_label_status = self.device.mbs.isSmsBluetoothErrorDisplayed() 441 logging.info('<Bluetooth SMS disconnected> label is present: %s', 442 actual_disconnected_label_status) 443 return actual_disconnected_label_status 444 445 def verify_dialing_number(self, expected_dialing_number): 446 """Replace all non-digits characters to null""" 447 actual_dialing_number = re.sub(r'\D', '', str(self.get_dialing_number())) 448 logging.info('dialing number: %s',self.get_dialing_number()) 449 logging.info( 450 'Expected dialing number: %s, Actual: %s', 451 expected_dialing_number, 452 actual_dialing_number, 453 ) 454 if actual_dialing_number != expected_dialing_number: 455 raise CallUtilsError( 456 "Actual and Expected dialing numbers don't match.") 457 458 def verify_user_phone_number(self, expected_dialing_number): 459 """Replace all non-digits characters to null""" 460 actual_dialing_number = re.sub(r'\D', '', str(self.get_user_phone_number())) 461 logging.info( 462 'Expected dialing number: %s, Actual: %s', 463 expected_dialing_number, 464 actual_dialing_number, 465 ) 466 if actual_dialing_number != expected_dialing_number: 467 raise CallUtilsError( 468 "Actual and Expected dialing numbers don't match.") 469 470 def is_ongoing_call_displayed_on_home(self, expected_result): 471 logging.info('Open Home screen and verify the ongoing call') 472 self.device.mbs.isOngoingCallDisplayedOnHome() 473 actual_result = self.device.mbs.isOngoingCallDisplayedOnHome() 474 logging.info( 475 'Call Displayed on home expected : <%s>, Actual : <%s>', 476 expected_result, 477 actual_result, 478 ) 479 if expected_result != actual_result: 480 raise CallUtilsError('Ongoing call not displayed on home') 481 482 def get_recent_call_history(self): 483 actual_recent_call_from_history = self.device.mbs.getRecentCallHistory() 484 logging.info( 485 'The latest call from history: <%s>', actual_recent_call_from_history 486 ) 487 return actual_recent_call_from_history 488 489 def verify_last_dialed_number(self, expected_last_dialed_number): 490 actual_last_dialed_number = self.get_recent_call_history() 491 actual_last_dialed_number = ''.join( 492 char for char in actual_last_dialed_number if char.isdigit() 493 ) 494 logging.info( 495 'Expected last called number: %s, Actual: %s', 496 expected_last_dialed_number, 497 actual_last_dialed_number, 498 ) 499 if actual_last_dialed_number != expected_last_dialed_number: 500 raise CallUtilsError( 501 "Actual and Expected last dialed numbers don't match." 502 ) 503 504 def open_phone_app_from_home(self): 505 logging.info('Open Phone from Home Screen card.') 506 self.device.mbs.openPhoneAppFromHome() 507 508 def search_contact_by_name(self, search_contact_name): 509 logging.info('Searching <%s> in contacts', search_contact_name) 510 self.device.mbs.searchContactsByName(search_contact_name) 511 512 def get_first_search_result(self): 513 logging.info('Getting first search result') 514 actual_first_search_result = self.device.mbs.getFirstSearchResult() 515 logging.info('Actual first search result: <%s>', actual_first_search_result) 516 return actual_first_search_result 517 518 def verify_search_results_contain_target_search(self, expected_search_result): 519 actual_search_result = self.get_first_search_result() 520 logging.info( 521 'Expected search result: <%s>, Actual search result: <%s>', 522 expected_search_result, 523 actual_search_result, 524 ) 525 if expected_search_result not in actual_search_result: 526 raise CallUtilsError('Actual search result does not contain Expected.') 527 528 def verify_sms_app_unread_message(self): 529 """Verify unread message badge on sms app""" 530 logging.info('Verify Unread Message on SMS app') 531 return self.device.mbs.isUnreadSmsDisplayed() 532 533 def verify_sms_preview_text(self, text): 534 """Verify sms preview text""" 535 logging.info('Verify SMS Preview Text') 536 return self.device.mbs.isSmsPreviewTextDisplayed(text) 537 538 def tap_to_read_aloud(self): 539 """Tap on Received Text message""" 540 logging.info('Click on the text >>> tap to read aloud ') 541 self.device.mbs.tapToReadAloud() 542 543 def is_assistant_sms_transcription_plate_displayed(self,expected): 544 """ Checks if assistant transcription plate has displayed """ 545 visibility_status = self.device.mbs.isAssistantSMSTranscriptionPlateDisplayed() 546 if visibility_status == expected: 547 logging.info("Assistant SMS Transcription plate has opened upon tapping the SMS.") 548 return visibility_status 549 550 def verify_sms_preview_timestamp(self): 551 """Verify sms preview timestamp""" 552 logging.info('Verify SMS Preview TimeStamp') 553 return self.device.mbs.isSmsTimeStampDisplayed() 554 555 def verify_sms_no_messages_displayed(self): 556 """Verify no messages text is displayed""" 557 logging.info('Verify No Messages Text displayed') 558 return self.device.mbs.isNoMessagesDisplayed() 559 560 def clear_sms_app(self, device_target): 561 """Clearing the sms app""" 562 logging.debug('clearing the sms app') 563 # self.execute_shell_on_device(device_target, constants.ROOT) 564 self.execute_shell_on_device(device_target, constants.DELETE_MESSAGING_DB) 565 self.execute_shell_on_device(device_target, constants.CLEAR_MESSAGING_APP) 566 567 def reboot_device(self, device_target): 568 self.execute_shell_on_device(device_target, constants.REBOOT) 569 570 def has_bluetooth_button(self): 571 logging.info('Has Bluetooth Button ') 572 return self.device.mbs.hasBluetoothButton() 573 574 def has_bluetooth_palette_phone_button(self): 575 logging.info('Has Phone Button') 576 return self.device.mbs.hasBluetoothPalettePhoneButton() 577 578 def has_bluetooth_palette_media_button(self): 579 logging.info('Has Media Button') 580 return self.device.mbs.hasBluetoothPaletteMediaButton() 581 582 def verify_device_name(self): 583 logging.info('Verify Device Name') 584 return self.device.mbs.verifyDeviceName() 585 586 def is_bluetooth_button_enabled(self): 587 logging.info('Is Bluetooth Button Enabled') 588 return self.device.mbs.isBluetoothButtonEnabled() 589 590 def has_bluetooth_toggle_on_message_displayed(self): 591 logging.info('Has Bluetooth Toggle On Message Displayed') 592 return self.device.mbs.hasBluetoothPaletteToggleOnMessage() 593 594 def has_bluetooth_toggle_off_message_displayed(self): 595 logging.info('Has Bluetooth Toggle Off Message Displayed') 596 return self.device.mbs.hasBluetoothPaletteToggleOffMessage() 597 598 def turn_on_off_bluetooth_switch_on_palette(self, switchstate): 599 self.device.mbs.turnOnOffBluetoothSwitchOnPalette(switchstate) 600 logging.info('Expected bluetooth toggle switch status: <%s>', 601 switchstate) 602 603 def is_bluetooth_toggle_switch_in_palette_on(self): 604 logging.info('Verify whether bluetooth toggle button is enabled in Bluetooth palette') 605 return self.device.mbs.isBluetoothToggleSwitchInPaletteOn() 606 607 def is_active_call_enabled(self): 608 logging.info("Verifying whether active call is enabled") 609 return self.device.mbs.isActiveCallEnabled() 610 611 def is_active_call_ongoing_full_screen(self): 612 logging.info("Verify whether an ongoing call is currently showing in full-screen mode") 613 return self.device.mbs.isOngoingCallInFullScreen() 614 615 def is_bluetooth_phone_button_enabled(self): 616 logging.info('Is Bluetooth Palette PhoneButton Enabled') 617 return self.device.mbs.isBluetoothPhoneButtonEnabled() 618 619 def is_bluetooth_media_button_enabled(self): 620 logging.info('Is Bluetooth Palette Media Button Enabled') 621 return self.device.mbs.isBluetoothMediaButtonEnabled() 622 623 def get_dial_in_number(self): 624 return self.device.mbs.getNumberInDialPad() 625 626 def verify_dialed_number_on_dial_pad(self, expected_dialed_number): 627 actual_dialed_number = self.get_dial_in_number() 628 logging.info('Expected number on Dial Pad: <%s>, Actual: <%s>', 629 expected_dialed_number, 630 actual_dialed_number,) 631 632 if actual_dialed_number != expected_dialed_number: 633 raise CallUtilsError( 634 "Actual and Expected dialing numbers on dial pad don't match.") 635 636 def delete_dialed_number_on_dial_pad(self): 637 logging.info('Deleting dialed number on Dial Pad') 638 self.device.mbs.deleteDialedNumber() 639 640 def end_call_using_adb_command(self, device_target): 641 self.execute_shell_on_device(device_target, 'input keyevent KEYCODE_ENDCALL') 642 self.execute_shell_on_device(device_target, 'input keyevent KEYCODE_POWER') 643 644 def call_most_recent_call_history(self): 645 logging.info('Calling most recent call in history') 646 self.device.mbs.callMostRecentHistory() 647 648 def change_audio_source_to_phone(self): 649 logging.info('Changing audio source to PHONE') 650 self.device.mbs.changeAudioSourceToPhone() 651 652 def change_audio_source_to_car_speakers(self): 653 logging.info('Changing audio source to CAR SPEAKERS') 654 self.device.mbs.changeAudioSourceToCarSpeakers() 655 656 def enable_driving_mode(self): 657 logging.info('Enabling the drive mode') 658 self.device.mbs.enableDrivingMode() 659 660 def disable_driving_mode(self): 661 logging.info('Disabling the drive mode') 662 self.device.mbs.disableDrivingMode() 663 664 def is_microphone_displayed_on_status_bar(self, expected_result): 665 logging.info('Mute the call, verify microphone on status bar') 666 actual_result = self.device.mbs.isMicChipPresentOnStatusBar() 667 logging.info( 668 'Microphone Chip on status bar expected : <%s>, Actual : <%s>', 669 expected_result, 670 actual_result, 671 ) 672 if expected_result != actual_result: 673 raise CallUtilsError( 674 'MicroPhone Chip not in sync with call status' 675 ) 676 677 def mute_call(self): 678 logging.info('Muting call') 679 self.device.mbs.muteCall() 680 681 def unmute_call(self): 682 logging.info('Unmuting call') 683 self.device.mbs.unmuteCall() 684 685 def click_on_bluetooth_palette_media_button(self): 686 """Performs click operation on Bluetooth Palette media button""" 687 self.device.mbs.clickOnBluetoothPaletteMediaButton() 688 logging.info("Clicked on bluetooth palette media button") 689 690 def open_notification_on_phone(self, device_target): 691 """Open notifications on Phone""" 692 logging.debug('Open notifications on Phone') 693 self.execute_shell_on_device(device_target, constants.OPEN_NOTIFICATION) 694 695 def press_phone_home_icon_using_adb_command(self, device_target): 696 self.execute_shell_on_device(device_target, 'input keyevent KEYCODE_HOME') 697 698 def get_bt_profile_status_using_adb_command(self, device_target, profile): 699 try: 700 bt_profile_status = self.execute_shell_on_device(device_target, profile).decode('utf8') 701 logging.debug(bt_profile_status) 702 return bt_profile_status 703 except adb.AdbError: 704 logging.info("Adb returned null") 705 706 def get_bt_connection_status_using_adb_command(self, device_target): 707 try: 708 bt_connection_status = self.execute_shell_on_device(device_target, constants.BLUETOOTH_CONNECTION_STATE).decode('utf8') 709 logging.debug(bt_connection_status) 710 return bt_connection_status 711 except adb.AdbError: 712 logging.info("Adb returned null") 713