• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 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.android.settings.sound
18 
19 import android.app.settings.SettingsEnums.ACTION_PIN_MEDIA_PLAYER
20 import android.content.Context
21 import android.provider.Settings.Secure.MEDIA_CONTROLS_RESUME
22 import com.android.settings.R
23 import com.android.settings.contract.KEY_PIN_MEDIA_PLAYER
24 import com.android.settings.metrics.PreferenceActionMetricsProvider
25 import com.android.settingslib.datastore.KeyValueStore
26 import com.android.settingslib.datastore.SettingsSecureStore
27 import com.android.settingslib.metadata.ReadWritePermit
28 import com.android.settingslib.metadata.SensitivityLevel
29 import com.android.settingslib.metadata.SwitchPreference
30 
31 // LINT.IfChange
32 class MediaControlsSwitchPreference(
33     private val mediaControlsStore: MediaControlsScreen.MediaControlsStore
34 ) :
35     SwitchPreference(
36         KEY,
37         R.string.media_controls_resume_title,
38         R.string.media_controls_resume_description,
39     ),
40     PreferenceActionMetricsProvider {
41     override val sensitivityLevel
42         get() = SensitivityLevel.NO_SENSITIVITY
43 
44     override val keywords: Int
45         get() = R.string.keywords_media_controls
46 
47     override val preferenceActionMetrics: Int
48         get() = ACTION_PIN_MEDIA_PLAYER
49 
tagsnull50     override fun tags(context: Context) = arrayOf(KEY_PIN_MEDIA_PLAYER)
51 
52     override fun getReadPermissions(context: Context) = SettingsSecureStore.getReadPermissions()
53 
54     override fun getWritePermissions(context: Context) = SettingsSecureStore.getWritePermissions()
55 
56     override fun getReadPermit(context: Context, callingPid: Int, callingUid: Int) =
57         ReadWritePermit.ALLOW
58 
59     override fun getWritePermit(context: Context, callingPid: Int, callingUid: Int) =
60         ReadWritePermit.ALLOW
61 
62     override fun storage(context: Context): KeyValueStore = mediaControlsStore
63 
64     companion object {
65         const val KEY = MEDIA_CONTROLS_RESUME
66     }
67 }
68 // LINT.ThenChange(MediaControlsPreferenceController.java)
69