1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.google.android.mobly.snippet.bundled;
18 
19 import android.platform.helpers.HelperAccessor;
20 import android.platform.helpers.IAutoCarSmsMessengerHelper;
21 
22 import com.google.android.mobly.snippet.Snippet;
23 import com.google.android.mobly.snippet.rpc.Rpc;
24 
25 /** Snippet class for exposing Messenger App APIs. */
26 public class CarSmsMessengerSnippet implements Snippet {
27 
28     private final HelperAccessor<IAutoCarSmsMessengerHelper> mCarSmsMessengerHelper;
29 
CarSmsMessengerSnippet()30     public CarSmsMessengerSnippet() {
31 
32         mCarSmsMessengerHelper = new HelperAccessor<>(IAutoCarSmsMessengerHelper.class);
33     }
34 
35     @Rpc(description = "Open SMS Application.")
openSmsApp()36     public void openSmsApp() {
37         mCarSmsMessengerHelper.get().open();
38     }
39 
40     @Rpc(description = "Bluetooth SMS Error")
isSmsBluetoothErrorDisplayed()41     public boolean isSmsBluetoothErrorDisplayed() {
42         return mCarSmsMessengerHelper.get().isSmsBluetoothErrorDisplayed();
43     }
44 
45     @Rpc(description = "Checks Unread Sms Badge")
isUnreadSmsDisplayed()46     public boolean isUnreadSmsDisplayed() {
47         return mCarSmsMessengerHelper.get().isUnreadSmsDisplayed();
48     }
49 
50     /** for checking the sms preview */
51     @Rpc(description = "Checks Sms Preview Text")
isSmsPreviewTextDisplayed(String text)52     public boolean isSmsPreviewTextDisplayed(String text) {
53         return mCarSmsMessengerHelper.get().isSmsPreviewDisplayed(text);
54     }
55 
56     @Rpc(description = "Checks Sms Preview TimeStamp")
isSmsTimeStampDisplayed()57     public boolean isSmsTimeStampDisplayed() {
58         return mCarSmsMessengerHelper.get().isSmsTimeStampDisplayed();
59     }
60 
61     @Rpc(description = "Checks Sms No Messages")
isNoMessagesDisplayed()62     public boolean isNoMessagesDisplayed() {
63         return mCarSmsMessengerHelper.get().isNoMessagesDisplayed();
64     }
65 
66     /** for tapping the sms received in order to read it aloud */
67     @Rpc(description = "Clicks on tap to read aloud text to tead out the message")
tapToReadAloud()68     public void tapToReadAloud() {
69         mCarSmsMessengerHelper.get().tapToReadAloud();
70     }
71 
72     /** checks whether the assistant transctption plate is displayed upon tapping received sms */
73     @Rpc(description = "Checks if assistant sms plate is displayed")
isAssistantSMSTranscriptionPlateDisplayed()74     public boolean isAssistantSMSTranscriptionPlateDisplayed() {
75         return mCarSmsMessengerHelper.get().isAssistantSMSTranscriptionPlateDisplayed();
76     }
77 
78     @Override
shutdown()79     public void shutdown() {}
80 }
81