• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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 android.platform.systemui_tapl.volume.panel.ui
18 
19 import android.media.AudioManager
20 import androidx.annotation.IntDef
21 
22 /** [AudioManager].STREAM_* supported by the [VolumePanelSlider]. */
23 @Retention(AnnotationRetention.SOURCE)
24 @IntDef(
25     value =
26         [
27             AudioManager.STREAM_MUSIC,
28             AudioManager.STREAM_VOICE_CALL,
29             AudioManager.STREAM_RING,
30             AudioManager.STREAM_NOTIFICATION,
31             AudioManager.STREAM_ALARM,
32         ]
33 )
34 annotation class SliderStream {
35 
36     companion object {
37         private val resourceIdsByStream =
38             mapOf(
39                 AudioManager.STREAM_MUSIC to "Media",
40                 AudioManager.STREAM_VOICE_CALL to "Call",
41                 AudioManager.STREAM_RING to "Ring",
42                 AudioManager.STREAM_NOTIFICATION to "Notification",
43                 AudioManager.STREAM_ALARM to "Alarm",
44             )
45 
getResourceIdnull46         fun getResourceId(@SliderStream stream: Int): String =
47             resourceIdsByStream[stream] ?: throw IllegalArgumentException("Unknown stream $stream")
48     }
49 }
50