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.IAutoMediaHelper;
21 
22 import com.google.android.mobly.snippet.Snippet;
23 import com.google.android.mobly.snippet.rpc.Rpc;
24 
25 public class MediaPlayerSnippet implements Snippet {
26 
27     private final HelperAccessor<IAutoMediaHelper> mAutoMediaHelper =
28             new HelperAccessor<>(IAutoMediaHelper.class);
29 
30     @Rpc(description = "Play Media")
playMedia()31     public void playMedia() {
32         mAutoMediaHelper.get().playMedia();
33     }
34 
35     @Rpc(description = "Pause Media")
pauseMedia()36     public void pauseMedia() {
37         mAutoMediaHelper.get().pauseMedia();
38     }
39 
40     @Rpc(description = "Click on next track")
clickNextTrack()41     public void clickNextTrack() {
42         mAutoMediaHelper.get().clickNextTrack();
43     }
44 
45     @Rpc(description = "Click on previous track")
clickPreviousTrack()46     public void clickPreviousTrack() {
47         mAutoMediaHelper.get().clickPreviousTrack();
48     }
49 
50     @Rpc(description = "Get Media song name")
getMediaTrackName()51     public String getMediaTrackName() {
52         return mAutoMediaHelper.get().getMediaTrackName();
53     }
54 
55     @Rpc(description = "Minimize now playing")
minimizeNowPlaying()56     public void minimizeNowPlaying() {
57         mAutoMediaHelper.get().minimizeNowPlaying();
58     }
59 
60     @Rpc(description = "Maximize now playing")
maximizeNowPlaying()61     public void maximizeNowPlaying() {
62         mAutoMediaHelper.get().maximizeNowPlaying();
63     }
64 
65     @Rpc(description = "Is song playing")
isPlaying()66     public boolean isPlaying() {
67         return mAutoMediaHelper.get().isPlaying();
68     }
69 
70     @Rpc(description = "Open Media app menu items")
openMediaAppMenuItems()71     public void openMediaAppMenuItems() {
72         mAutoMediaHelper.get().openMediaAppMenuItems();
73     }
74 
75     @Rpc(description = "Open Media app")
openMediaApp()76     public void openMediaApp() {
77         mAutoMediaHelper.get().open();
78     }
79 
80     @Rpc(description = "Is Bluetooth Audio disconnected label present")
isBluetoothAudioDisconnectedLabelVisible()81     public boolean isBluetoothAudioDisconnectedLabelVisible() {
82         return mAutoMediaHelper.get().isBluetoothAudioDisconnectedLabelVisible();
83     }
84 
85     @Rpc(description = "Is Connect to Bluetooth label present")
isConnectToBluetoothLabelVisible()86     public boolean isConnectToBluetoothLabelVisible() {
87         return mAutoMediaHelper.get().isConnectToBluetoothLabelVisible();
88     }
89 
90     @Rpc(description = "Open Bluetooth Audio app")
openBluetoothMediaApp()91     public void openBluetoothMediaApp() {
92         mAutoMediaHelper.get().openBluetoothMediaApp();
93     }
94 
95     @Rpc(description = "Click on Bluetooth conncetion togle")
clickOnBluetoothToggle()96     public void clickOnBluetoothToggle() {
97         mAutoMediaHelper.get().clickOnBluetoothToggle();
98     }
99 
100     @Rpc(description = "Click on Cancel Bluetooth Audio conncetion button")
cancelBluetoothAudioConncetion()101     public void cancelBluetoothAudioConncetion() {
102         mAutoMediaHelper.get().cancelBluetoothAudioConncetion();
103     }
104 
105     @Rpc(description = "Scroll play list down")
scrollPlayListDown()106     public void scrollPlayListDown() {
107         mAutoMediaHelper.get().scrollPlayListDown();
108     }
109 
110     @Rpc(description = "Select song from playlist")
clickOnSongFromPlaylist()111     public void clickOnSongFromPlaylist() {
112         mAutoMediaHelper.get().clickOnSongFromPlaylist();
113     }
114 
115     @Rpc(description = "Get Artist tile")
getArtistrTitle()116     public String getArtistrTitle() {
117         return mAutoMediaHelper.get().getArtistrTitle();
118     }
119 
120     @Rpc(description = "Get Album tile")
getAlbumTitle()121     public String getAlbumTitle() {
122         return mAutoMediaHelper.get().getAlbumTitle();
123     }
124 
125     @Rpc(description = "Get song current playing time")
getSongCurrentPlayingTime()126     public String getSongCurrentPlayingTime() {
127         return mAutoMediaHelper.get().getSongCurrentPlayingTime();
128     }
129 
130     @Rpc(description = "Get song max playing time")
getCurrentSongMaxPlayingTime()131     public String getCurrentSongMaxPlayingTime() {
132         return mAutoMediaHelper.get().getCurrentSongMaxPlayingTime();
133     }
134 
135     @Rpc(description = "Is Now Playing label present")
isNowPlayingLabelVisible()136     public boolean isNowPlayingLabelVisible() {
137         return mAutoMediaHelper.get().isNowPlayingLabelVisible();
138     }
139 
140     @Rpc(description = "Is Playlist icon visible")
isPlaylistIconVisible()141     public boolean isPlaylistIconVisible() {
142         return mAutoMediaHelper.get().isPlaylistIconVisible();
143     }
144 
145     @Rpc(description = "Click on PLaylist icon")
clickOnPlaylistIcon()146     public void clickOnPlaylistIcon() {
147         mAutoMediaHelper.get().clickOnPlaylistIcon();
148     }
149 
150     @Rpc(description = "Grant restricted parmissions")
grantRestrictedPermissionsForBTMedia(String permission)151     public void grantRestrictedPermissionsForBTMedia(String permission) {
152         mAutoMediaHelper.get().grantRestrictedPermissionsForBTMedia(permission);
153     }
154 }
155