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

Commit 97df34c1 authored by Vlad Popa's avatar Vlad Popa
Browse files

Show ui if device volume changes on current device

Test: manual
Bug: 393657380
Flag: EXEMPT bugfix
Change-Id: I5ba536b92c0b2008a74017b33d8e528be150b2f5
parent 34fa917f
Loading
Loading
Loading
Loading
+27 −10
Original line number Diff line number Diff line
@@ -4971,8 +4971,14 @@ public class AudioService extends IAudioService.Stub
                new DeviceVolumeEvent(streamType, vi.getVolumeIndex(), ada, callingPackage,
                        currDevIsAda));
        setDeviceVolumeInt(vi, vss, ada, callingPackage, FLAG_ABSOLUTE_VOLUME, /*changeMute=*/
                currDevIsAda, "notifyAbsoluteVolumeChanged");
        int flags = FLAG_ABSOLUTE_VOLUME;
        int index = rescaleVolumeInfoIndex(vi, vss);
        if (currDevIsAda && index != VolumeInfo.INDEX_NOT_SET && (vss.getIndex(
                ada.getInternalType()) + 5) / 10 != index) {
            flags |= AudioManager.FLAG_SHOW_UI;
        }
        setDeviceVolumeInt(vi, vss, ada, callingPackage, flags, /*changeMute=*/currDevIsAda,
                "notifyAbsoluteVolumeChanged");
    }
    private static boolean isVolumeInfoValid(VolumeInfo vi, boolean forAdjust) {
@@ -5040,6 +5046,20 @@ public class AudioService extends IAudioService.Stub
                        + " not between min/max for stream " + vi.getStreamType());
            }
        } else {
            index = rescaleVolumeInfoIndex(vi, vss);
        }
        setStreamVolumeWithAttributionInt(streamType, index, flags,
                ada, callingPackage, null,
                changeMute);
    }
    private int rescaleVolumeInfoIndex(VolumeInfo vi, VolumeStreamState vss) {
        int index = vi.getVolumeIndex();
        if (vi.getMinVolumeIndex() == VolumeInfo.INDEX_NOT_SET
                || vi.getMaxVolumeIndex() == VolumeInfo.INDEX_NOT_SET) {
            // no rescaling if the min max are not set
            return index;
        }
        // check if index needs to be rescaled
        final int min = (vss.getMinIndex() + 5) / 10;
        final int max = (vss.getMaxIndex() + 5) / 10;
@@ -5048,10 +5068,7 @@ public class AudioService extends IAudioService.Stub
                    /*srcMin*/ vi.getMinVolumeIndex(), /*srcMax*/ vi.getMaxVolumeIndex(),
                    /*dstMin*/ min, /*dstMax*/ max);
        }
        }
        setStreamVolumeWithAttributionInt(streamType, index, flags,
                ada, callingPackage, null,
                changeMute);
        return index;
    }
    /** Retain API for unsupported app usage */