Loading aconfig/settings_flag_declarations.aconfig +7 −0 Original line number Diff line number Diff line Loading @@ -111,3 +111,10 @@ flag { description: "Enables alert indicator on homepage tiles" bug: "403326850" } flag { name: "device_suggestions_preference" namespace: "android_settings" description: "Add a preference for device suggestions in the media page" bug: "415096359" } res/values/strings.xml +4 −0 Original line number Diff line number Diff line Loading @@ -13488,6 +13488,10 @@ Data usage charges may apply.</string> <string name="media_controls_hide_player">Hide player</string> <!-- Subtext for media settings when the player will be shown [CHAR LIMIT=50] --> <string name="media_controls_show_player">Show player</string> <!-- Title of setting for device suggestions in the media player [CHAR LIMIT=50]--> <string name="media_controls_suggestions_title">Media suggestions</string> <!-- Description of setting for device suggestions in the media player [CHAR LIMIT=NONE]--> <string name="media_controls_suggestions_description">Provide media suggestions from media apps based on your activity and location.</string> <!-- Keywords for the media controls setting [CHAR LIMIT=NONE]--> <string name="keywords_media_controls">media</string> src/com/android/settings/sound/MediaControlsScreen.kt +3 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,9 @@ class MediaControlsScreen(context: Context) : preferenceHierarchy(context, this) { +MediaControlsSwitchPreference(mediaControlsStore) +MediaControlsLockscreenSwitchPreference() if (Flags.deviceSuggestionsPreference()) { +SuggestionsPreference() } } override fun getSummary(context: Context): CharSequence? = Loading src/com/android/settings/sound/SuggestionsPreference.kt 0 → 100644 +45 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.sound import android.content.Context import com.android.settings.R import com.android.settingslib.metadata.PreferenceAvailabilityProvider import com.android.settingslib.metadata.PreferenceMetadata import com.android.settingslib.metadata.PreferenceSummaryProvider /** Preference for media device suggestions. */ class SuggestionsPreference() : PreferenceMetadata, PreferenceSummaryProvider, PreferenceAvailabilityProvider { override val key get() = KEY override val title get() = R.string.media_controls_suggestions_title override fun intent(context: Context) = SuggestionsPreferenceUtils.getSuggestionIntent(context) override fun isAvailable(context: Context) = intent(context) != null override fun getSummary(context: Context) = SuggestionsPreferenceUtils.getSuggestionDescription(context) companion object { const val KEY = "media_suggestions" } } src/com/android/settings/sound/SuggestionsPreferenceUtils.kt 0 → 100644 +55 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.sound import android.content.Context import android.content.Intent import android.content.pm.PackageManager import android.graphics.Typeface import android.provider.Settings import android.text.SpannableString import android.text.SpannableStringBuilder import android.text.Spanned.SPAN_EXCLUSIVE_EXCLUSIVE import android.text.style.ForegroundColorSpan import android.text.style.StyleSpan import com.android.settingslib.Utils /** Utilities for populating the suggestion preference content. */ object SuggestionsPreferenceUtils { private val SUGGESTION_PROVIDER_TARGET = "media_device_suggestions_target" private val SUGGESTION_PROVIDER_DESCRIPTION = "media_device_suggestions_description" fun getSuggestionIntent(context: Context): Intent? { val targetAction = Settings.Secure.getString(context.contentResolver, SUGGESTION_PROVIDER_TARGET) ?: return null val intent = Intent(targetAction) val activityInfo = intent.resolveActivityInfo(context.packageManager, PackageManager.MATCH_ALL) ?: return null if (activityInfo.applicationInfo?.isSystemApp != true) { return null } return intent } fun getSuggestionDescription(context: Context) = Settings.Secure.getString( context.contentResolver, SUGGESTION_PROVIDER_DESCRIPTION ) } Loading
aconfig/settings_flag_declarations.aconfig +7 −0 Original line number Diff line number Diff line Loading @@ -111,3 +111,10 @@ flag { description: "Enables alert indicator on homepage tiles" bug: "403326850" } flag { name: "device_suggestions_preference" namespace: "android_settings" description: "Add a preference for device suggestions in the media page" bug: "415096359" }
res/values/strings.xml +4 −0 Original line number Diff line number Diff line Loading @@ -13488,6 +13488,10 @@ Data usage charges may apply.</string> <string name="media_controls_hide_player">Hide player</string> <!-- Subtext for media settings when the player will be shown [CHAR LIMIT=50] --> <string name="media_controls_show_player">Show player</string> <!-- Title of setting for device suggestions in the media player [CHAR LIMIT=50]--> <string name="media_controls_suggestions_title">Media suggestions</string> <!-- Description of setting for device suggestions in the media player [CHAR LIMIT=NONE]--> <string name="media_controls_suggestions_description">Provide media suggestions from media apps based on your activity and location.</string> <!-- Keywords for the media controls setting [CHAR LIMIT=NONE]--> <string name="keywords_media_controls">media</string>
src/com/android/settings/sound/MediaControlsScreen.kt +3 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,9 @@ class MediaControlsScreen(context: Context) : preferenceHierarchy(context, this) { +MediaControlsSwitchPreference(mediaControlsStore) +MediaControlsLockscreenSwitchPreference() if (Flags.deviceSuggestionsPreference()) { +SuggestionsPreference() } } override fun getSummary(context: Context): CharSequence? = Loading
src/com/android/settings/sound/SuggestionsPreference.kt 0 → 100644 +45 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.sound import android.content.Context import com.android.settings.R import com.android.settingslib.metadata.PreferenceAvailabilityProvider import com.android.settingslib.metadata.PreferenceMetadata import com.android.settingslib.metadata.PreferenceSummaryProvider /** Preference for media device suggestions. */ class SuggestionsPreference() : PreferenceMetadata, PreferenceSummaryProvider, PreferenceAvailabilityProvider { override val key get() = KEY override val title get() = R.string.media_controls_suggestions_title override fun intent(context: Context) = SuggestionsPreferenceUtils.getSuggestionIntent(context) override fun isAvailable(context: Context) = intent(context) != null override fun getSummary(context: Context) = SuggestionsPreferenceUtils.getSuggestionDescription(context) companion object { const val KEY = "media_suggestions" } }
src/com/android/settings/sound/SuggestionsPreferenceUtils.kt 0 → 100644 +55 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.sound import android.content.Context import android.content.Intent import android.content.pm.PackageManager import android.graphics.Typeface import android.provider.Settings import android.text.SpannableString import android.text.SpannableStringBuilder import android.text.Spanned.SPAN_EXCLUSIVE_EXCLUSIVE import android.text.style.ForegroundColorSpan import android.text.style.StyleSpan import com.android.settingslib.Utils /** Utilities for populating the suggestion preference content. */ object SuggestionsPreferenceUtils { private val SUGGESTION_PROVIDER_TARGET = "media_device_suggestions_target" private val SUGGESTION_PROVIDER_DESCRIPTION = "media_device_suggestions_description" fun getSuggestionIntent(context: Context): Intent? { val targetAction = Settings.Secure.getString(context.contentResolver, SUGGESTION_PROVIDER_TARGET) ?: return null val intent = Intent(targetAction) val activityInfo = intent.resolveActivityInfo(context.packageManager, PackageManager.MATCH_ALL) ?: return null if (activityInfo.applicationInfo?.isSystemApp != true) { return null } return intent } fun getSuggestionDescription(context: Context) = Settings.Secure.getString( context.contentResolver, SUGGESTION_PROVIDER_DESCRIPTION ) }