diff options
Diffstat (limited to 'src/main/java/com/google/android/mobly/snippet/bundled/AudioSnippet.java')
-rw-r--r-- | src/main/java/com/google/android/mobly/snippet/bundled/AudioSnippet.java | 44 |
1 files changed, 20 insertions, 24 deletions
diff --git a/src/main/java/com/google/android/mobly/snippet/bundled/AudioSnippet.java b/src/main/java/com/google/android/mobly/snippet/bundled/AudioSnippet.java index e435a72..fbdb5d0 100644 --- a/src/main/java/com/google/android/mobly/snippet/bundled/AudioSnippet.java +++ b/src/main/java/com/google/android/mobly/snippet/bundled/AudioSnippet.java @@ -18,7 +18,7 @@ package com.google.android.mobly.snippet.bundled; import android.content.Context; import android.media.AudioManager; -import android.support.test.InstrumentationRegistry; +import androidx.test.platform.app.InstrumentationRegistry; import com.google.android.mobly.snippet.Snippet; import com.google.android.mobly.snippet.rpc.Rpc; import java.lang.reflect.Method; @@ -29,7 +29,7 @@ public class AudioSnippet implements Snippet { private final AudioManager mAudioManager; public AudioSnippet() { - Context context = InstrumentationRegistry.getContext(); + Context context = InstrumentationRegistry.getInstrumentation().getContext(); mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); } @@ -44,7 +44,7 @@ public class AudioSnippet implements Snippet { } @Rpc(description = "Gets the music stream volume.") - public int getMusicVolume() { + public Integer getMusicVolume() { return mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC); } @@ -54,17 +54,16 @@ public class AudioSnippet implements Snippet { } @Rpc( - description = - "Sets the music stream volume. The minimum value is 0. Use 'getMusicMaxVolume'" - + " to determine the maximum." - ) + description = + "Sets the music stream volume. The minimum value is 0. Use 'getMusicMaxVolume'" + + " to determine the maximum.") public void setMusicVolume(Integer value) { mAudioManager.setStreamVolume( AudioManager.STREAM_MUSIC, value, 0 /* flags, 0 = no flags */); } @Rpc(description = "Gets the ringer volume.") - public int getRingVolume() { + public Integer getRingVolume() { return mAudioManager.getStreamVolume(AudioManager.STREAM_RING); } @@ -74,16 +73,15 @@ public class AudioSnippet implements Snippet { } @Rpc( - description = - "Sets the ringer stream volume. The minimum value is 0. Use 'getRingMaxVolume'" - + " to determine the maximum." - ) + description = + "Sets the ringer stream volume. The minimum value is 0. Use 'getRingMaxVolume'" + + " to determine the maximum.") public void setRingVolume(Integer value) { mAudioManager.setStreamVolume(AudioManager.STREAM_RING, value, 0 /* flags, 0 = no flags */); } - + @Rpc(description = "Gets the voice call volume.") - public int getVoiceCallVolume() { + public Integer getVoiceCallVolume() { return mAudioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL); } @@ -93,13 +91,12 @@ public class AudioSnippet implements Snippet { } @Rpc( - description = - "Sets the voice call stream volume. The minimum value is 0. Use" - + " 'getVoiceCallMaxVolume' to determine the maximum." - ) + description = + "Sets the voice call stream volume. The minimum value is 0. Use" + + " 'getVoiceCallMaxVolume' to determine the maximum.") public void setVoiceCallVolume(Integer value) { - mAudioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, - value, 0 /* flags, 0 = no flags */); + mAudioManager.setStreamVolume( + AudioManager.STREAM_VOICE_CALL, value, 0 /* flags, 0 = no flags */); } @Rpc(description = "Silences all audio streams.") @@ -115,10 +112,9 @@ public class AudioSnippet implements Snippet { } @Rpc( - description = - "Puts the ringer volume at the lowest setting, but does not set it to " - + "DO NOT DISTURB; the phone will vibrate when receiving a call." - ) + description = + "Puts the ringer volume at the lowest setting, but does not set it to " + + "DO NOT DISTURB; the phone will vibrate when receiving a call.") public void muteRing() { setRingVolume(0); } |