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

Commit 2ae74d9f authored by Christopher R. Palmer's avatar Christopher R. Palmer Committed by Roman Birg
Browse files

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
(cherry picked from commit 2870d05e)
parent 1be3a2ae
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
    private final AudioManager mAudioManager;
    private final int mStreamType;
    private final int mMaxStreamVolume;
    private final boolean mVoiceCapable;
    private boolean mAffectedByRingerMode;
    private boolean mNotificationOrRing;
    private final Receiver mReceiver = new Receiver();
@@ -85,6 +86,8 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
            mRingerMode = mAudioManager.getRingerModeInternal();
        }
        mMaxStreamVolume = mAudioManager.getStreamMaxVolume(mStreamType);
        mVoiceCapable = context.getResources().getBoolean(
                            com.android.internal.R.bool.config_voice_capable);
        mCallback = callback;
        mOriginalStreamVolume = mAudioManager.getStreamVolume(mStreamType);
        mMuted = mAudioManager.isStreamMute(mStreamType);
@@ -109,7 +112,7 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
    }

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

+6 −3
Original line number Diff line number Diff line
@@ -379,6 +379,7 @@ public class AudioService extends IAudioService.Stub {
    };

    private boolean mLinkNotificationWithVolume;
    private final boolean mVoiceCapable;

    private final AudioSystem.ErrorCallback mAudioSystemCallback = new AudioSystem.ErrorCallback() {
        public void onError(int error) {
@@ -572,8 +573,10 @@ public class AudioService extends IAudioService.Stub {
        mContentResolver = context.getContentResolver();
        mAppOps = (AppOpsManager)context.getSystemService(Context.APP_OPS_SERVICE);

        if (mContext.getResources().getBoolean(
                com.android.internal.R.bool.config_voice_capable)) {
        mVoiceCapable = context.getResources().getBoolean(
                            com.android.internal.R.bool.config_voice_capable);

        if (mVoiceCapable) {
            mPlatformType = PLATFORM_VOICE;
        } else if (context.getPackageManager().hasSystemFeature(
                                                            PackageManager.FEATURE_LEANBACK)) {
@@ -950,7 +953,7 @@ public class AudioService extends IAudioService.Stub {

        mStreamVolumeAlias[AudioSystem.STREAM_DTMF] = dtmfStreamAlias;

        if (mLinkNotificationWithVolume) {
        if (mLinkNotificationWithVolume && mVoiceCapable) {
            mStreamVolumeAlias[AudioSystem.STREAM_NOTIFICATION] = AudioSystem.STREAM_RING;
        } else {
            mStreamVolumeAlias[AudioSystem.STREAM_NOTIFICATION] = AudioSystem.STREAM_NOTIFICATION;
+5 −2
Original line number Diff line number Diff line
@@ -451,7 +451,8 @@ public class VolumePanel extends Handler implements DemoMode {
        mToneGenerators = new ToneGenerator[AudioSystem.getNumStreamTypes()];
        mVibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
        mHasVibrator = mVibrator != null && mVibrator.hasVibrator();
        mVoiceCapable = context.getResources().getBoolean(R.bool.config_voice_capable);
        mVoiceCapable = context.getResources().getBoolean(
                            com.android.internal.R.bool.config_voice_capable);

        mVolumeLinkNotification = Settings.Secure.getInt(mContext.getContentResolver(),
                Settings.Secure.VOLUME_LINK_NOTIFICATION, 1) == 1;
@@ -805,7 +806,9 @@ public class VolumePanel extends Handler implements DemoMode {
    private boolean isValidExpandedPanelControl(int streamType) {
        switch (streamType) {
            case AudioManager.STREAM_NOTIFICATION:
                if (mVoiceCapable && mVolumeLinkNotification) {
                if (! mVoiceCapable) {
                    return true;
                } else if (mVoiceCapable && mVolumeLinkNotification) {
                    return false;
                }
            case AudioManager.STREAM_RING: