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.IAutoStatusBarHelper;
21 
22 import com.google.android.mobly.snippet.Snippet;
23 import com.google.android.mobly.snippet.rpc.Rpc;
24 
25 /** Snippet class for exposing Status Bar App APIs. */
26 public class StatusBarSnippet implements Snippet {
27 
28     private final HelperAccessor<IAutoStatusBarHelper> mStatusBarHelper;
29 
StatusBarSnippet()30     public StatusBarSnippet() {
31         mStatusBarHelper = new HelperAccessor<>(IAutoStatusBarHelper.class);
32     }
33 
34     @Rpc(description = "Is Bluetooth Button Enabled")
isBluetoothButtonEnabled()35     public boolean isBluetoothButtonEnabled() {
36         return mStatusBarHelper.get().isBluetoothButtonEnabled();
37     }
38 
39     @Rpc(description = "Is Bluetooth Palette Phone Button Enabled")
isBluetoothPhoneButtonEnabled()40     public boolean isBluetoothPhoneButtonEnabled() {
41         return mStatusBarHelper.get().isBluetoothPhoneButtonEnabled();
42     }
43 
44     @Rpc(description = "Is Bluetooth Palette PMedia Button Enabled")
isBluetoothMediaButtonEnabled()45     public boolean isBluetoothMediaButtonEnabled() {
46         return mStatusBarHelper.get().isBluetoothMediaButtonEnabled();
47     }
48 
49     /** Clicks on Media Button available on the Bluetooth Palette */
50     @Rpc(description = "Click on Bluetooth Palette Media Button")
clickOnBluetoothPaletteMediaButton()51     public void clickOnBluetoothPaletteMediaButton() {
52         mStatusBarHelper.get().clickOnBluetoothPaletteMediaButton();
53     }
54 
55     @Rpc(description = "is Mobile Connected")
isBluetoothConnectedToMobile()56     public boolean isBluetoothConnectedToMobile() {
57         return mStatusBarHelper.get().isBluetoothConnectedToMobile();
58     }
59 
60     @Rpc(description = "is Mobile Disconnected")
isBluetoothDisconnected()61     public boolean isBluetoothDisconnected() {
62         return mStatusBarHelper.get().isBluetoothDisconnected();
63     }
64 
65     @Rpc(description = "Open Bluetooth Palette")
openBluetoothPalette()66     public void openBluetoothPalette() {
67         mStatusBarHelper.get().openBluetoothPalette();
68     }
69 
70     @Rpc(description = "Click Bluetooth Button on the status bar")
clickBluetoothButton()71     public void clickBluetoothButton() {
72         mStatusBarHelper.get().clickBluetoothButton();
73     }
74 
75     @Rpc(description = "is Bluetooth Connected")
isBluetoothConnected()76     public boolean isBluetoothConnected() {
77         return mStatusBarHelper.get().isBluetoothConnected();
78     }
79 
80     @Rpc(description = "Press the Home icon on the status bar")
pressHome()81     public void pressHome() {
82         mStatusBarHelper.get().open();
83     }
84 
85     /** Verify device name in Bluetooth Palette */
86     @Rpc(description = "Verify Device Name")
verifyDeviceName()87     public boolean verifyDeviceName() {
88         return mStatusBarHelper.get().verifyDeviceName();
89     }
90 
91     /** has Bluetooth Button in Bluetooth Palette */
92     @Rpc(description = "Verify Bluetooth Button")
hasBluetoothButton()93     public boolean hasBluetoothButton() {
94         return mStatusBarHelper.get().hasBluetoothButton();
95     }
96 
97     /** has Phone Button in Bluetooth Palette */
98     @Rpc(description = "Has Phone Button ")
hasBluetoothPalettePhoneButton()99     public boolean hasBluetoothPalettePhoneButton() {
100         return mStatusBarHelper.get().hasBluetoothPalettePhoneButton();
101     }
102     /** has Media Button in Bluetooth Palette */
103     @Rpc(description = "Verify Media Button")
hasBluetoothPaletteMediaButton()104     public boolean hasBluetoothPaletteMediaButton() {
105         return mStatusBarHelper.get().hasBluetoothPaletteMediaButton();
106     }
107 
108     @Override
shutdown()109     public void shutdown() {}
110 }
111