From 60cd96f8dac2fbfb4e4ca17aae3a13272b4c2182 Mon Sep 17 00:00:00 2001 From: Behnam Heydarshahi Date: Tue, 6 Sep 2022 19:55:13 +0000 Subject: [PATCH] Separate notification/ring volume sliders in UI Separate the logic between notification slider and ring slider in setting through new logic in SeekBarVolumizer when ring is not aliased with notification in config.xml. Start the notif/ring separation code but hide it in the new SysUI volume dialog. Bug: b/38477228 Test: manual (1) With ring/notif alias set to false, in the Sound Settings, drag ring volume to zero. Verify notification volume snaps to zero as well. Then drag the notification volume out of zero. Verify that notification volume is stable at the new value and does not wrongly snap back to zero. (2) With the alias set to false, drag media volume to zero, midpoint, and max. Verify the slider control is stable, and that the audio level corresponds relative to the level on UI. (3) Repeat test 2 with the alias set to true. Change-Id: Ifff4c06a952ba13dc6d6830fea5fe47651fa5b2e --- .../java/android/app/INotificationManager.aidl | 1 + .../android/preference/SeekBarVolumizer.java | 18 +++++++++++++++--- .../NotificationManagerService.java | 7 +++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/core/java/android/app/INotificationManager.aidl b/core/java/android/app/INotificationManager.aidl index da6a551175e32..edf96f7b55834 100644 --- a/core/java/android/app/INotificationManager.aidl +++ b/core/java/android/app/INotificationManager.aidl @@ -159,6 +159,7 @@ interface INotificationManager void clearRequestedListenerHints(in INotificationListener token); void requestHintsFromListener(in INotificationListener token, int hints); int getHintsFromListener(in INotificationListener token); + int getHintsFromListenerNoToken(); void requestInterruptionFilterFromListener(in INotificationListener token, int interruptionFilter); int getInterruptionFilterFromListener(in INotificationListener token); void setOnNotificationPostedTrimFromListener(in INotificationListener token, int trim); diff --git a/core/java/android/preference/SeekBarVolumizer.java b/core/java/android/preference/SeekBarVolumizer.java index 0a6a405fbce6f..16f9a12953f81 100644 --- a/core/java/android/preference/SeekBarVolumizer.java +++ b/core/java/android/preference/SeekBarVolumizer.java @@ -115,6 +115,7 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba private final int mMaxStreamVolume; private boolean mAffectedByRingerMode; private boolean mNotificationOrRing; + private final boolean mNotifAliasRing; private final Receiver mReceiver = new Receiver(); private Handler mHandler; @@ -179,6 +180,8 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba if (mNotificationOrRing) { mRingerMode = mAudioManager.getRingerModeInternal(); } + mNotifAliasRing = mContext.getResources().getBoolean( + com.android.internal.R.bool.config_alias_ring_notif_stream_types); mZenMode = mNotificationManager.getZenMode(); if (hasAudioProductStrategies()) { @@ -280,7 +283,15 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba if (zenMuted) { mSeekBar.setProgress(mLastAudibleStreamVolume, true); } else if (mNotificationOrRing && mRingerMode == AudioManager.RINGER_MODE_VIBRATE) { - mSeekBar.setProgress(0, true); + /** + * the first variable above is preserved and the conditions below are made explicit + * so that when user attempts to slide the notification seekbar out of vibrate the + * seekbar doesn't wrongly snap back to 0 when the streams aren't aliased + */ + if (mNotifAliasRing || mStreamType == AudioManager.STREAM_RING + || (mStreamType == AudioManager.STREAM_NOTIFICATION && mMuted)) { + mSeekBar.setProgress(0, true); + } } else if (mMuted) { mSeekBar.setProgress(0, true); } else { @@ -354,6 +365,7 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba // set the time of stop volume if ((mStreamType == AudioManager.STREAM_VOICE_CALL || mStreamType == AudioManager.STREAM_RING + || (!mNotifAliasRing && mStreamType == AudioManager.STREAM_NOTIFICATION) || mStreamType == AudioManager.STREAM_ALARM)) { sStopVolumeTime = java.lang.System.currentTimeMillis(); } @@ -631,8 +643,8 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba } private void updateVolumeSlider(int streamType, int streamValue) { - final boolean streamMatch = mNotificationOrRing ? isNotificationOrRing(streamType) - : (streamType == mStreamType); + final boolean streamMatch = mNotifAliasRing && mNotificationOrRing + ? isNotificationOrRing(streamType) : streamType == mStreamType; if (mSeekBar != null && streamMatch && streamValue != -1) { final boolean muted = mAudioManager.isStreamMute(mStreamType) || streamValue == 0; diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index f11801f61d58a..fd1fdce4cf770 100755 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -4867,6 +4867,13 @@ public class NotificationManagerService extends SystemService { } } + @Override + public int getHintsFromListenerNoToken() { + synchronized (mNotificationLock) { + return mListenerHints; + } + } + @Override public void requestInterruptionFilterFromListener(INotificationListener token, int interruptionFilter) throws RemoteException {