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# 15# Licensed under the Apache License, Version 2.0 (the "License"); 16# you may not use this file except in compliance with the License. 17# You may obtain a copy of the License at 18# 19# http://www.apache.org/licenses/LICENSE-2.0 20# 21# Unless required by applicable law or agreed to in writing, software 22# distributed under the License is distributed on an "AS IS" BASIS, 23# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 24# See the License for the specific language governing permissions and 25# limitations under the License. 26 27from utilities import constants 28from utilities.main_utils import common_main 29from utilities.common_utils import CommonUtils 30from bluetooth_sms_test import bluetooth_sms_base_test 31from mobly.controllers import android_device 32 33class SMSReadAutoSync(bluetooth_sms_base_test.BluetoothSMSBaseTest): 34 35 def setup_class(self): 36 super().setup_class() 37 self.common_utils = CommonUtils(self.target, self.discoverer) 38 39 def setup_test(self): 40 41 # pair the devices 42 self.bt_utils.pair_primary_to_secondary() 43 44 # wait for user permissions popup & give contacts and sms permissions 45 self.call_utils.wait_with_log(20) 46 self.common_utils.click_on_ui_element_with_text('Allow') 47 48 # Clearing the sms from the phone 49 self.call_utils.clear_sms_app(self.target) 50 # Reboot Phone 51 self.target.unload_snippet('mbs') 52 self.call_utils.reboot_device(self.target) 53 self.call_utils.wait_with_log(30) 54 self.target.load_snippet('mbs', android_device.MBS_PACKAGE) 55 56 # send a new sms 57 target_phone_number = self.target.mbs.getPhoneNumber() 58 self.phone_notpaired.mbs.sendSms(target_phone_number,constants.SMS_TEXT) 59 self.call_utils.wait_with_log(10) 60 61 def test_read_sms_auto_sync(self): 62 63 # Verify the new UNREAD sms in IVI device 64 self.call_utils.open_sms_app() 65 self.call_utils.verify_sms_app_unread_message(True) 66 67 # READ the message on paired phone 68 self.call_utils.open_notification_on_phone(self.target) 69 self.call_utils.wait_with_log(5) 70 self.target.mbs.clickUIElementWithText(constants.SMS_TEXT) 71 self.call_utils.wait_with_log(5) 72 73 # Verify the SYNC READ sms in IVI device 74 self.call_utils.verify_sms_app_unread_message(False) 75 self.call_utils.verify_sms_preview_timestamp(True) 76 77 def teardown_test(self): 78 # Go to home screen 79 self.call_utils.press_home() 80 super().teardown_test() 81 82if __name__ == '__main__': 83 common_main()