Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f7fc27e9 authored by Adnan Begovic's avatar Adnan Begovic Committed by Bruno Martins
Browse files

frameworks: Add unlinked ringtone and notification volumes



Port over linked volumes from 12.1

Implement linked volumes and add upgrade path.

Change-Id: Ibbeff656fcaaa4a2ff79de530b48b216df271b21

frameworks: read VOLUME_LINK_NOTIFICATION from proper table

Change-Id: I15e9caa18f307a51a732c7a59013bbbb234a7477
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
(cherry picked from commit 1b7cfa17)

fix Notification volume slider linking

Change-Id: I0f74485f5c8c2aa7698cf9ba1c60c2c8c967798d
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>

Improve SeekBarVolumizer behavior with unlinked streams

- Fix notification stream enabling at 0 volume
- Fix the notification slider being set when moving ringer stream

Change-Id: If3705cc833c07f726f8ad7b1ec79a42e86e8ff22
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>

base: Fix notification sounds for wifi only devices

The linking of voice & notification doesn't take into account the
fact that a device may not actually have voice capabilities.  Whenever
checking whether or not to link notification and ring volumes, also
verify that the device really is voice capable.

Change-Id: Iae49302d3b5934d36b182e289e4975f5dd85b834

frameworks: fix setting up linked notification stream on boot

updateStreamVolumeAlias() was previously responsible for checking the
linked notification variable and mapping the notification stream, but
the setting to read whether the notifications were linked was read in
after that method had run which was responsible for linking them.
Extract the logic and re-run it again after reading the persisted
settings.

Change-Id: Ia62bf3ca072def54ec6ebf4f9e865d9c913e3bc4
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>

fixup volume stream linking

- Make the SeekBarVolumizer move notification and ringer streams when
 linked and moving ringer.

- Fix initial state causing volume stream seek bar to be set to 0
  initially

- Clean up AudioService initialization code

Change-Id: Ia11a7a392e5eb3ef862147843e365d5f20eaf90a
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>

SystemUI: Fix volume panel inconsistencies

* Use xml drawables everywhere
* Add muted notification icon
* Use AOSP naming scheme for drawables

Change-Id: I14a3af9a7aecf4828f81a8e39855608e452848d6

Misc fixes

Change-Id: Ia94b0a6655e52f5949f031360f525c871cd8df14
Signed-off-by: default avatarMeninblack007 <sanyam.53jain@gmail.com>

Use STREAM_RING on non-voice capable devices

* That's what Google does.

Change-Id: Iac88d161eb1dccbbb5c538d5e04d8d1fc43edef2
(cherry picked from commit 981e89eb)

VolumeDialog: Fix mismerge

Fixes not disappearing cast pickers

* Commit 568585b4 introduced a new LinearLayout for the volume rows
* Remove unused booleans

Change-Id: I0660d10872cc1098fdd67b618a20ea0f8e926e68

Change-Id: Ia11a7a392e5eb3ef862147843e365d5f20eaf90a
parent b3e277de
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
    private final NotificationManager mNotificationManager;
    private final int mStreamType;
    private final int mMaxStreamVolume;
    private final boolean mVoiceCapable;
    private boolean mAffectedByRingerMode;
    private boolean mNotificationOrRing;
    private final Receiver mReceiver = new Receiver();
@@ -129,6 +130,8 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
            }
        }
        mDefaultUri = defaultUri;
        mVoiceCapable = context.getResources().getBoolean(
                com.android.internal.R.bool.config_voice_capable);
    }

    private static boolean isNotificationOrRing(int stream) {
@@ -143,6 +146,11 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
        return stream == AudioManager.STREAM_MUSIC;
    }

    private boolean isNotificationStreamLinked() {
        return mVoiceCapable && Settings.Secure.getInt(mContext.getContentResolver(),
                Settings.Secure.VOLUME_LINK_NOTIFICATION, 1) == 1;
    }

    public void setSeekBar(SeekBar seekBar) {
        if (mSeekBar != null) {
            mSeekBar.setOnSeekBarChangeListener(null);
@@ -170,13 +178,19 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
            mSeekBar.setProgress(mLastAudibleStreamVolume, true);
        } else if (mNotificationOrRing && mRingerMode == AudioManager.RINGER_MODE_VIBRATE) {
            mSeekBar.setProgress(0, true);
            mSeekBar.setEnabled(isSeekBarEnabled());
        } else if (mMuted) {
            mSeekBar.setProgress(0, true);
        } else {
            mSeekBar.setEnabled(isSeekBarEnabled());
            mSeekBar.setProgress(mLastProgress > -1 ? mLastProgress : mOriginalStreamVolume, true);
        }
    }

    private boolean isSeekBarEnabled() {
        return !(mStreamType == AudioManager.STREAM_NOTIFICATION && isNotificationStreamLinked());
    }

    @Override
    public boolean handleMessage(Message msg) {
        switch (msg.what) {
@@ -287,7 +301,7 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
    }

    public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch) {
        if (fromTouch) {
        if (fromTouch && isSeekBarEnabled()) {
            postSetVolume(progress);
        }
        if (mCallback != null) {
@@ -463,7 +477,8 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
        }

        private void updateVolumeSlider(int streamType, int streamValue) {
            final boolean streamMatch = mNotificationOrRing ? isNotificationOrRing(streamType)
            final boolean streamMatch = mNotificationOrRing && isNotificationStreamLinked()
                    ? isNotificationOrRing(streamType)
                    : (streamType == mStreamType);
            if (mSeekBar != null && streamMatch && streamValue != -1) {
                final boolean muted = mAudioManager.isStreamMute(mStreamType)
+12 −0
Original line number Diff line number Diff line
@@ -2300,6 +2300,8 @@ public final class Settings {
            // At one time in System, then Global, but now back in Secure
            MOVED_TO_SECURE.add(Secure.INSTALL_NON_MARKET_APPS);
            MOVED_TO_SECURE.add(Secure.VOLUME_LINK_NOTIFICATION);
        }
        private static final HashSet<String> MOVED_TO_GLOBAL;
@@ -7990,6 +7992,14 @@ public final class Settings {
        public static final String PACKAGES_TO_CLEAR_DATA_BEFORE_FULL_RESTORE =
                "packages_to_clear_data_before_full_restore";
        /**
         * Boolean value whether to link ringtone and notification volume
         * @hide
         */
        public static final String VOLUME_LINK_NOTIFICATION = "volume_link_notification";
        private static final Validator VOLUME_LINK_NOTIFICATION_VALIDATOR = BOOLEAN_VALIDATOR;
        /**
         * This are the settings to be backed up.
         *
@@ -8091,6 +8101,7 @@ public final class Settings {
            VOLUME_HUSH_GESTURE,
            MANUAL_RINGER_TOGGLE_COUNT,
            HUSH_GESTURE_USED,
            VOLUME_LINK_NOTIFICATION,
        };
        /**
@@ -8239,6 +8250,7 @@ public final class Settings {
            VALIDATORS.put(MANUAL_RINGER_TOGGLE_COUNT, MANUAL_RINGER_TOGGLE_COUNT_VALIDATOR);
            VALIDATORS.put(LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, BOOLEAN_VALIDATOR);
            VALIDATORS.put(LOCK_SCREEN_SHOW_NOTIFICATIONS, BOOLEAN_VALIDATOR);
            VALIDATORS.put(VOLUME_LINK_NOTIFICATION, VOLUME_LINK_NOTIFICATION_VALIDATOR);
        }
        /**
+3 −0
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@ public interface VolumeDialogController {
        public ComponentName effectsSuppressor;
        public String effectsSuppressorName;
        public int activeStream = NO_ACTIVE_STREAM;
        public boolean linkedNotification;
        public boolean disallowAlarms;
        public boolean disallowMedia;
        public boolean disallowSystem;
@@ -119,6 +120,7 @@ public interface VolumeDialogController {
            }
            rt.effectsSuppressorName = effectsSuppressorName;
            rt.activeStream = activeStream;
            rt.linkedNotification = linkedNotification;
            rt.disallowAlarms = disallowAlarms;
            rt.disallowMedia = disallowMedia;
            rt.disallowSystem = disallowSystem;
@@ -152,6 +154,7 @@ public interface VolumeDialogController {
            sep(sb, indent); sb.append("effectsSuppressor:").append(effectsSuppressor);
            sep(sb, indent); sb.append("effectsSuppressorName:").append(effectsSuppressorName);
            sep(sb, indent); sb.append("activeStream:").append(activeStream);
            sep(sb, indent); sb.append("linkedNotification:").append(linkedNotification);
            sep(sb, indent); sb.append("disallowAlarms:").append(disallowAlarms);
            sep(sb, indent); sb.append("disallowMedia:").append(disallowMedia);
            sep(sb, indent); sb.append("disallowSystem:").append(disallowSystem);
+30 −0
Original line number Diff line number Diff line
<!--
     Copyright (C) 2017 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:height="24dp"
    android:width="24dp"
    android:viewportHeight="24"
    android:viewportWidth="24"
    android:tint="?android:attr/colorControlNormal" >

    <path
        android:fillColor="#FFFFFFFF"
        android:pathData="M18,17v-6c0,-3.07 -1.63,-5.64 -4.5,-6.32V4c0,-0.83 -0.67,-1.5 -1.5,-1.5S10.5,3.17 10.5,4v0.68C7.64,5.36 6,7.92 6,11v6H4v2h10h0.38H20v-2H18zM16,17H8v-6c0,-2.48 1.51,-4.5 4,-4.5s4,2.02 4,4.5V17z"/>
    <path
        android:fillColor="#FFFFFFFF"
        android:pathData="M12,22c1.1,0 2,-0.9 2,-2h-4C10,21.1 10.9,22 12,22z"/>

</vector>
+33 −0
Original line number Diff line number Diff line
<!--
     Copyright (C) 2017 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:height="24dp"
    android:viewportHeight="24"
    android:viewportWidth="24"
    android:width="24dp"
    android:tint="?android:attr/colorControlNormal" >

    <path
        android:fillColor="#FFFFFFFF"
        android:pathData="M12,22c1.1,0 2,-0.9 2,-2h-4C10,21.1 10.9,22 12,22z"/>
    <path
        android:fillColor="#FFFFFFFF"
        android:pathData="M16,16L2.81,2.81L1.39,4.22l4.85,4.85C6.09,9.68 6,10.33 6,11v6H4v2h12.17l3.61,3.61l1.41,-1.41L16,16zM8,17c0,0 0.01,-6.11 0.01,-6.16L14.17,17H8z"/>
    <path
        android:fillColor="#FFFFFFFF"
        android:pathData="M12,6.5c2.49,0 4,2.02 4,4.5v2.17l2,2V11c0,-3.07 -1.63,-5.64 -4.5,-6.32V4c0,-0.83 -0.67,-1.5 -1.5,-1.5S10.5,3.17 10.5,4v0.68C9.72,4.86 9.05,5.2 8.46,5.63L9.93,7.1C10.51,6.73 11.2,6.5 12,6.5z"/>

</vector>
Loading