Loading res/xml/sound_settings.xml +0 −8 Original line number Diff line number Diff line Loading @@ -64,14 +64,6 @@ settings:searchable="false" settings:controller="com.android.settings.sound.HandsFreeProfileOutputPreferenceController"/> <!-- Ring volume --> <com.android.settings.notification.VolumeSeekBarPreference android:key="ring_volume" android:icon="@drawable/ic_notifications" android:title="@string/ring_volume_option_title" android:order="-160" settings:controller="com.android.settings.notification.RingVolumePreferenceController"/> <!-- Separate Ring volume --> <com.android.settings.notification.VolumeSeekBarPreference android:key="separate_ring_volume" Loading src/com/android/settings/notification/NotificationVolumePreferenceController.java +2 −39 Original line number Diff line number Diff line Loading @@ -16,29 +16,23 @@ package com.android.settings.notification; import android.app.ActivityThread; import android.app.NotificationManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.media.AudioManager; import android.os.Binder; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.provider.DeviceConfig; import android.service.notification.NotificationListenerService; import androidx.lifecycle.OnLifecycleEvent; import androidx.preference.PreferenceScreen; import com.android.internal.config.sysui.SystemUiDeviceConfigFlags; import com.android.settings.R; import com.android.settingslib.core.lifecycle.Lifecycle; import java.util.Set; /** * Update notification volume icon in Settings in response to user adjusting volume. */ Loading Loading @@ -84,37 +78,11 @@ public class NotificationVolumePreferenceController extends updateEnabledState(); } /** * Only display the notification slider when the corresponding device config flag is set */ private void onDeviceConfigChange(DeviceConfig.Properties properties) { Set<String> changeSet = properties.getKeyset(); if (changeSet.contains(SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION)) { boolean newVal = isSeparateNotificationConfigEnabled(); if (newVal != mSeparateNotification) { mSeparateNotification = newVal; // Update UI if config change happens when Sound Settings page is on the foreground if (mPreference != null) { int status = getAvailabilityStatus(); mPreference.setVisible(status == AVAILABLE || status == DISABLED_DEPENDENT_SETTING); if (status == DISABLED_DEPENDENT_SETTING) { mPreference.setEnabled(false); } } } } } @OnLifecycleEvent(Lifecycle.Event.ON_RESUME) @Override public void onResume() { super.onResume(); mReceiver.register(true); Binder.withCleanCallingIdentity(() -> DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_SYSTEMUI, ActivityThread.currentApplication().getMainExecutor(), this::onDeviceConfigChange)); } @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE) Loading @@ -122,18 +90,13 @@ public class NotificationVolumePreferenceController extends public void onPause() { super.onPause(); mReceiver.register(false); Binder.withCleanCallingIdentity(() -> DeviceConfig.removeOnPropertiesChangedListener(this::onDeviceConfigChange)); } @Override public int getAvailabilityStatus() { boolean separateNotification = isSeparateNotificationConfigEnabled(); return mContext.getResources().getBoolean(R.bool.config_show_notification_volume) && !mHelper.isSingleVolume() && separateNotification ? (mRingerMode == AudioManager.RINGER_MODE_NORMAL ? AVAILABLE : DISABLED_DEPENDENT_SETTING) : UNSUPPORTED_ON_DEVICE; && !mHelper.isSingleVolume() ? (mRingerMode == AudioManager.RINGER_MODE_NORMAL ? AVAILABLE : DISABLED_DEPENDENT_SETTING) : UNSUPPORTED_ON_DEVICE; } @Override Loading src/com/android/settings/notification/RingVolumePreferenceController.java +2 −35 Original line number Diff line number Diff line Loading @@ -16,28 +16,22 @@ package com.android.settings.notification; import android.app.ActivityThread; import android.app.NotificationManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.media.AudioManager; import android.os.Binder; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.provider.DeviceConfig; import android.service.notification.NotificationListenerService; import androidx.lifecycle.OnLifecycleEvent; import com.android.internal.config.sysui.SystemUiDeviceConfigFlags; import com.android.settings.R; import com.android.settingslib.core.lifecycle.Lifecycle; import java.util.Set; /** * This slider represents both ring and notification */ Loading @@ -61,33 +55,14 @@ public class RingVolumePreferenceController extends mVibrateIconId = R.drawable.ic_volume_ringer_vibrate; mSilentIconId = R.drawable.ic_notifications_off_24dp; mSeparateNotification = isSeparateNotificationConfigEnabled(); updateRingerMode(); } /** * As the responsibility of this slider changes, so should its title & icon */ private void onDeviceConfigChange(DeviceConfig.Properties properties) { Set<String> changeSet = properties.getKeyset(); if (changeSet.contains(SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION)) { boolean valueUpdated = readSeparateNotificationVolumeConfig(); if (valueUpdated) { updateEffectsSuppressor(); selectPreferenceIconState(); } } } @OnLifecycleEvent(Lifecycle.Event.ON_RESUME) @Override public void onResume() { super.onResume(); mReceiver.register(true); readSeparateNotificationVolumeConfig(); Binder.withCleanCallingIdentity(() -> DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_SYSTEMUI, ActivityThread.currentApplication().getMainExecutor(), this::onDeviceConfigChange)); updateEffectsSuppressor(); selectPreferenceIconState(); Loading @@ -101,8 +76,6 @@ public class RingVolumePreferenceController extends public void onPause() { super.onPause(); mReceiver.register(false); Binder.withCleanCallingIdentity(() -> DeviceConfig.removeOnPropertiesChangedListener(this::onDeviceConfigChange)); } @Override Loading @@ -112,9 +85,7 @@ public class RingVolumePreferenceController extends @Override public int getAvailabilityStatus() { boolean separateNotification = isSeparateNotificationConfigEnabled(); return !separateNotification && !mHelper.isSingleVolume() ? AVAILABLE : UNSUPPORTED_ON_DEVICE; return UNSUPPORTED_ON_DEVICE; } @Override Loading @@ -124,14 +95,10 @@ public class RingVolumePreferenceController extends @Override protected boolean hintsMatch(int hints) { boolean notificationSeparated = isSeparateNotificationConfigEnabled(); return (hints & NotificationListenerService.HINT_HOST_DISABLE_CALL_EFFECTS) != 0 || (hints & NotificationListenerService.HINT_HOST_DISABLE_EFFECTS) != 0 || ((hints & NotificationListenerService.HINT_HOST_DISABLE_NOTIFICATION_EFFECTS) != 0 && !notificationSeparated); || (hints & NotificationListenerService.HINT_HOST_DISABLE_EFFECTS) != 0; } private final class H extends Handler { private static final int UPDATE_EFFECTS_SUPPRESSOR = 1; private static final int UPDATE_RINGER_MODE = 2; Loading src/com/android/settings/notification/RingerModeAffectedVolumePreferenceController.java +0 −28 Original line number Diff line number Diff line Loading @@ -21,14 +21,11 @@ import android.app.NotificationManager; import android.content.ComponentName; import android.content.Context; import android.media.AudioManager; import android.os.Binder; import android.os.ServiceManager; import android.os.Vibrator; import android.provider.DeviceConfig; import android.util.Log; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.config.sysui.SystemUiDeviceConfigFlags; import java.util.Objects; Loading @@ -48,11 +45,8 @@ public abstract class RingerModeAffectedVolumePreferenceController extends protected Vibrator mVibrator; protected int mRingerMode = AudioManager.RINGER_MODE_NORMAL; protected ComponentName mSuppressor; protected boolean mSeparateNotification; protected INotificationManager mNoMan; private static final boolean CONFIG_SEPARATE_NOTIFICATION_DEFAULT_VAL = false; public RingerModeAffectedVolumePreferenceController(Context context, String key, String tag) { super(context, key); mTag = tag; Loading Loading @@ -118,28 +112,6 @@ public abstract class RingerModeAffectedVolumePreferenceController extends return mMuteIcon; } protected boolean isSeparateNotificationConfigEnabled() { return Binder.withCleanCallingIdentity(() -> DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, CONFIG_SEPARATE_NOTIFICATION_DEFAULT_VAL)); } /** * side effect: updates the cached value of the config * @return has the config changed? */ protected boolean readSeparateNotificationVolumeConfig() { boolean newVal = isSeparateNotificationConfigEnabled(); boolean valueUpdated = newVal != mSeparateNotification; if (valueUpdated) { mSeparateNotification = newVal; } return valueUpdated; } /** * Updates UI Icon in response to ringer mode changes. * @return whether the ringer mode has changed. Loading src/com/android/settings/notification/SeparateRingVolumePreferenceController.java +1 −29 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package com.android.settings.notification; import android.app.ActivityThread; import android.app.NotificationManager; import android.content.BroadcastReceiver; import android.content.Context; Loading @@ -26,17 +25,13 @@ import android.media.AudioManager; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.provider.DeviceConfig; import android.service.notification.NotificationListenerService; import androidx.lifecycle.OnLifecycleEvent; import com.android.internal.config.sysui.SystemUiDeviceConfigFlags; import com.android.settings.R; import com.android.settingslib.core.lifecycle.Lifecycle; import java.util.Set; /** * This slider is used to represent ring volume when ring is separated from notification */ Loading @@ -60,32 +55,14 @@ public class SeparateRingVolumePreferenceController extends mVibrateIconId = R.drawable.ic_volume_ringer_vibrate; mSilentIconId = R.drawable.ic_ring_volume_off; mSeparateNotification = isSeparateNotificationConfigEnabled(); updateRingerMode(); } /** * Show/hide settings */ private void onDeviceConfigChange(DeviceConfig.Properties properties) { Set<String> changeSet = properties.getKeyset(); if (changeSet.contains(SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION)) { boolean valueUpdated = readSeparateNotificationVolumeConfig(); if (valueUpdated) { updateEffectsSuppressor(); selectPreferenceIconState(); } } } @OnLifecycleEvent(Lifecycle.Event.ON_RESUME) @Override public void onResume() { super.onResume(); mReceiver.register(true); readSeparateNotificationVolumeConfig(); DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_SYSTEMUI, ActivityThread.currentApplication().getMainExecutor(), this::onDeviceConfigChange); updateEffectsSuppressor(); selectPreferenceIconState(); Loading @@ -99,7 +76,6 @@ public class SeparateRingVolumePreferenceController extends public void onPause() { super.onPause(); mReceiver.register(false); DeviceConfig.removeOnPropertiesChangedListener(this::onDeviceConfigChange); } @Override Loading @@ -109,9 +85,7 @@ public class SeparateRingVolumePreferenceController extends @Override public int getAvailabilityStatus() { boolean separateNotification = isSeparateNotificationConfigEnabled(); return separateNotification && !mHelper.isSingleVolume() ? AVAILABLE : UNSUPPORTED_ON_DEVICE; return !mHelper.isSingleVolume() ? AVAILABLE : UNSUPPORTED_ON_DEVICE; } @Override Loading @@ -125,8 +99,6 @@ public class SeparateRingVolumePreferenceController extends || (hints & NotificationListenerService.HINT_HOST_DISABLE_EFFECTS) != 0; } private final class H extends Handler { private static final int UPDATE_EFFECTS_SUPPRESSOR = 1; private static final int UPDATE_RINGER_MODE = 2; Loading Loading
res/xml/sound_settings.xml +0 −8 Original line number Diff line number Diff line Loading @@ -64,14 +64,6 @@ settings:searchable="false" settings:controller="com.android.settings.sound.HandsFreeProfileOutputPreferenceController"/> <!-- Ring volume --> <com.android.settings.notification.VolumeSeekBarPreference android:key="ring_volume" android:icon="@drawable/ic_notifications" android:title="@string/ring_volume_option_title" android:order="-160" settings:controller="com.android.settings.notification.RingVolumePreferenceController"/> <!-- Separate Ring volume --> <com.android.settings.notification.VolumeSeekBarPreference android:key="separate_ring_volume" Loading
src/com/android/settings/notification/NotificationVolumePreferenceController.java +2 −39 Original line number Diff line number Diff line Loading @@ -16,29 +16,23 @@ package com.android.settings.notification; import android.app.ActivityThread; import android.app.NotificationManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.media.AudioManager; import android.os.Binder; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.provider.DeviceConfig; import android.service.notification.NotificationListenerService; import androidx.lifecycle.OnLifecycleEvent; import androidx.preference.PreferenceScreen; import com.android.internal.config.sysui.SystemUiDeviceConfigFlags; import com.android.settings.R; import com.android.settingslib.core.lifecycle.Lifecycle; import java.util.Set; /** * Update notification volume icon in Settings in response to user adjusting volume. */ Loading Loading @@ -84,37 +78,11 @@ public class NotificationVolumePreferenceController extends updateEnabledState(); } /** * Only display the notification slider when the corresponding device config flag is set */ private void onDeviceConfigChange(DeviceConfig.Properties properties) { Set<String> changeSet = properties.getKeyset(); if (changeSet.contains(SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION)) { boolean newVal = isSeparateNotificationConfigEnabled(); if (newVal != mSeparateNotification) { mSeparateNotification = newVal; // Update UI if config change happens when Sound Settings page is on the foreground if (mPreference != null) { int status = getAvailabilityStatus(); mPreference.setVisible(status == AVAILABLE || status == DISABLED_DEPENDENT_SETTING); if (status == DISABLED_DEPENDENT_SETTING) { mPreference.setEnabled(false); } } } } } @OnLifecycleEvent(Lifecycle.Event.ON_RESUME) @Override public void onResume() { super.onResume(); mReceiver.register(true); Binder.withCleanCallingIdentity(() -> DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_SYSTEMUI, ActivityThread.currentApplication().getMainExecutor(), this::onDeviceConfigChange)); } @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE) Loading @@ -122,18 +90,13 @@ public class NotificationVolumePreferenceController extends public void onPause() { super.onPause(); mReceiver.register(false); Binder.withCleanCallingIdentity(() -> DeviceConfig.removeOnPropertiesChangedListener(this::onDeviceConfigChange)); } @Override public int getAvailabilityStatus() { boolean separateNotification = isSeparateNotificationConfigEnabled(); return mContext.getResources().getBoolean(R.bool.config_show_notification_volume) && !mHelper.isSingleVolume() && separateNotification ? (mRingerMode == AudioManager.RINGER_MODE_NORMAL ? AVAILABLE : DISABLED_DEPENDENT_SETTING) : UNSUPPORTED_ON_DEVICE; && !mHelper.isSingleVolume() ? (mRingerMode == AudioManager.RINGER_MODE_NORMAL ? AVAILABLE : DISABLED_DEPENDENT_SETTING) : UNSUPPORTED_ON_DEVICE; } @Override Loading
src/com/android/settings/notification/RingVolumePreferenceController.java +2 −35 Original line number Diff line number Diff line Loading @@ -16,28 +16,22 @@ package com.android.settings.notification; import android.app.ActivityThread; import android.app.NotificationManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.media.AudioManager; import android.os.Binder; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.provider.DeviceConfig; import android.service.notification.NotificationListenerService; import androidx.lifecycle.OnLifecycleEvent; import com.android.internal.config.sysui.SystemUiDeviceConfigFlags; import com.android.settings.R; import com.android.settingslib.core.lifecycle.Lifecycle; import java.util.Set; /** * This slider represents both ring and notification */ Loading @@ -61,33 +55,14 @@ public class RingVolumePreferenceController extends mVibrateIconId = R.drawable.ic_volume_ringer_vibrate; mSilentIconId = R.drawable.ic_notifications_off_24dp; mSeparateNotification = isSeparateNotificationConfigEnabled(); updateRingerMode(); } /** * As the responsibility of this slider changes, so should its title & icon */ private void onDeviceConfigChange(DeviceConfig.Properties properties) { Set<String> changeSet = properties.getKeyset(); if (changeSet.contains(SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION)) { boolean valueUpdated = readSeparateNotificationVolumeConfig(); if (valueUpdated) { updateEffectsSuppressor(); selectPreferenceIconState(); } } } @OnLifecycleEvent(Lifecycle.Event.ON_RESUME) @Override public void onResume() { super.onResume(); mReceiver.register(true); readSeparateNotificationVolumeConfig(); Binder.withCleanCallingIdentity(() -> DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_SYSTEMUI, ActivityThread.currentApplication().getMainExecutor(), this::onDeviceConfigChange)); updateEffectsSuppressor(); selectPreferenceIconState(); Loading @@ -101,8 +76,6 @@ public class RingVolumePreferenceController extends public void onPause() { super.onPause(); mReceiver.register(false); Binder.withCleanCallingIdentity(() -> DeviceConfig.removeOnPropertiesChangedListener(this::onDeviceConfigChange)); } @Override Loading @@ -112,9 +85,7 @@ public class RingVolumePreferenceController extends @Override public int getAvailabilityStatus() { boolean separateNotification = isSeparateNotificationConfigEnabled(); return !separateNotification && !mHelper.isSingleVolume() ? AVAILABLE : UNSUPPORTED_ON_DEVICE; return UNSUPPORTED_ON_DEVICE; } @Override Loading @@ -124,14 +95,10 @@ public class RingVolumePreferenceController extends @Override protected boolean hintsMatch(int hints) { boolean notificationSeparated = isSeparateNotificationConfigEnabled(); return (hints & NotificationListenerService.HINT_HOST_DISABLE_CALL_EFFECTS) != 0 || (hints & NotificationListenerService.HINT_HOST_DISABLE_EFFECTS) != 0 || ((hints & NotificationListenerService.HINT_HOST_DISABLE_NOTIFICATION_EFFECTS) != 0 && !notificationSeparated); || (hints & NotificationListenerService.HINT_HOST_DISABLE_EFFECTS) != 0; } private final class H extends Handler { private static final int UPDATE_EFFECTS_SUPPRESSOR = 1; private static final int UPDATE_RINGER_MODE = 2; Loading
src/com/android/settings/notification/RingerModeAffectedVolumePreferenceController.java +0 −28 Original line number Diff line number Diff line Loading @@ -21,14 +21,11 @@ import android.app.NotificationManager; import android.content.ComponentName; import android.content.Context; import android.media.AudioManager; import android.os.Binder; import android.os.ServiceManager; import android.os.Vibrator; import android.provider.DeviceConfig; import android.util.Log; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.config.sysui.SystemUiDeviceConfigFlags; import java.util.Objects; Loading @@ -48,11 +45,8 @@ public abstract class RingerModeAffectedVolumePreferenceController extends protected Vibrator mVibrator; protected int mRingerMode = AudioManager.RINGER_MODE_NORMAL; protected ComponentName mSuppressor; protected boolean mSeparateNotification; protected INotificationManager mNoMan; private static final boolean CONFIG_SEPARATE_NOTIFICATION_DEFAULT_VAL = false; public RingerModeAffectedVolumePreferenceController(Context context, String key, String tag) { super(context, key); mTag = tag; Loading Loading @@ -118,28 +112,6 @@ public abstract class RingerModeAffectedVolumePreferenceController extends return mMuteIcon; } protected boolean isSeparateNotificationConfigEnabled() { return Binder.withCleanCallingIdentity(() -> DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, CONFIG_SEPARATE_NOTIFICATION_DEFAULT_VAL)); } /** * side effect: updates the cached value of the config * @return has the config changed? */ protected boolean readSeparateNotificationVolumeConfig() { boolean newVal = isSeparateNotificationConfigEnabled(); boolean valueUpdated = newVal != mSeparateNotification; if (valueUpdated) { mSeparateNotification = newVal; } return valueUpdated; } /** * Updates UI Icon in response to ringer mode changes. * @return whether the ringer mode has changed. Loading
src/com/android/settings/notification/SeparateRingVolumePreferenceController.java +1 −29 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package com.android.settings.notification; import android.app.ActivityThread; import android.app.NotificationManager; import android.content.BroadcastReceiver; import android.content.Context; Loading @@ -26,17 +25,13 @@ import android.media.AudioManager; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.provider.DeviceConfig; import android.service.notification.NotificationListenerService; import androidx.lifecycle.OnLifecycleEvent; import com.android.internal.config.sysui.SystemUiDeviceConfigFlags; import com.android.settings.R; import com.android.settingslib.core.lifecycle.Lifecycle; import java.util.Set; /** * This slider is used to represent ring volume when ring is separated from notification */ Loading @@ -60,32 +55,14 @@ public class SeparateRingVolumePreferenceController extends mVibrateIconId = R.drawable.ic_volume_ringer_vibrate; mSilentIconId = R.drawable.ic_ring_volume_off; mSeparateNotification = isSeparateNotificationConfigEnabled(); updateRingerMode(); } /** * Show/hide settings */ private void onDeviceConfigChange(DeviceConfig.Properties properties) { Set<String> changeSet = properties.getKeyset(); if (changeSet.contains(SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION)) { boolean valueUpdated = readSeparateNotificationVolumeConfig(); if (valueUpdated) { updateEffectsSuppressor(); selectPreferenceIconState(); } } } @OnLifecycleEvent(Lifecycle.Event.ON_RESUME) @Override public void onResume() { super.onResume(); mReceiver.register(true); readSeparateNotificationVolumeConfig(); DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_SYSTEMUI, ActivityThread.currentApplication().getMainExecutor(), this::onDeviceConfigChange); updateEffectsSuppressor(); selectPreferenceIconState(); Loading @@ -99,7 +76,6 @@ public class SeparateRingVolumePreferenceController extends public void onPause() { super.onPause(); mReceiver.register(false); DeviceConfig.removeOnPropertiesChangedListener(this::onDeviceConfigChange); } @Override Loading @@ -109,9 +85,7 @@ public class SeparateRingVolumePreferenceController extends @Override public int getAvailabilityStatus() { boolean separateNotification = isSeparateNotificationConfigEnabled(); return separateNotification && !mHelper.isSingleVolume() ? AVAILABLE : UNSUPPORTED_ON_DEVICE; return !mHelper.isSingleVolume() ? AVAILABLE : UNSUPPORTED_ON_DEVICE; } @Override Loading @@ -125,8 +99,6 @@ public class SeparateRingVolumePreferenceController extends || (hints & NotificationListenerService.HINT_HOST_DISABLE_EFFECTS) != 0; } private final class H extends Handler { private static final int UPDATE_EFFECTS_SUPPRESSOR = 1; private static final int UPDATE_RINGER_MODE = 2; Loading