• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.IAutoBluetoothSettingsHelper;
21 import android.platform.helpers.IAutoSettingHelper;
22 import android.platform.helpers.SettingsConstants;
23 
24 import com.google.android.mobly.snippet.Snippet;
25 import com.google.android.mobly.snippet.rpc.Rpc;
26 
27 public class SettingsSnippet implements Snippet {
28 
29     private HelperAccessor<IAutoSettingHelper> mSettingsHelper;
30     private HelperAccessor<IAutoBluetoothSettingsHelper> mBluetoothSettingsHelper;
31 
SettingsSnippet()32     public SettingsSnippet() {
33         mSettingsHelper = new HelperAccessor<>(IAutoSettingHelper.class);
34         mBluetoothSettingsHelper = new HelperAccessor<>(IAutoBluetoothSettingsHelper.class);
35     }
36 
37     @Rpc(
38             description =
39                     "Get the device summary of a device "
40                             + "whose level two connection screen is currently open.")
getDeviceSummary()41     public String getDeviceSummary() {
42         return mBluetoothSettingsHelper.get().getDeviceSummary();
43     }
44 
45     @Rpc(description = "Open system settings.")
openSystemSettings()46     public void openSystemSettings() {
47         mSettingsHelper.get().openFullSettings();
48     }
49 
50     @Rpc(description = "Open the bluetooth settings (from home screen)")
openBluetoothSettings()51     public void openBluetoothSettings() {
52         mSettingsHelper.get().openSetting(SettingsConstants.BLUETOOTH_SETTINGS);
53     }
54 
55     @Rpc(description = "Press the bluetooth toggle on a entry under 'Paired Devices'")
pressBluetoothToggleOnDevice(String deviceName)56     public void pressBluetoothToggleOnDevice(String deviceName) {
57         mBluetoothSettingsHelper.get().pressBluetoothToggleOnDevice(deviceName);
58     }
59 
60     @Rpc(description = "Press an entry listed under 'Paired Devices'")
pressDeviceName(String deviceName)61     public void pressDeviceName(String deviceName) {
62         mBluetoothSettingsHelper.get().pressDevice(deviceName);
63     }
64 
65     @Rpc(
66             description =
67                     "Get the connection status of a device "
68                             + "whose level two connection screen is currently open.")
deviceIsConnected()69     public void deviceIsConnected() {
70         mBluetoothSettingsHelper.get().isConnected();
71     }
72 
73     @Rpc(description = "Press the Forget button on a currently open Level Two connection screen")
pressForget()74     public void pressForget() {
75         mBluetoothSettingsHelper.get().pressForget();
76     }
77 }
78