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