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

Commit 5b2d7287 authored by Eric Laurent's avatar Eric Laurent Committed by android-build-merger
Browse files

Merge "AudioService: fix accessibility volume range" into qt-dev am: be8a41a6

am: 2e2c9c35

Change-Id: Ibe91b5fb5cfd9ff9af46bf74579ae40e7840e68e
parents 0420f1da 2e2c9c35
Loading
Loading
Loading
Loading
+11 −32
Original line number Original line Diff line number Diff line
@@ -1275,8 +1275,6 @@ public class AudioService extends IAudioService.Stub
                            System.VOLUME_SETTINGS_INT[a11yStreamAlias];
                            System.VOLUME_SETTINGS_INT[a11yStreamAlias];
                    mStreamStates[AudioSystem.STREAM_ACCESSIBILITY].setAllIndexes(
                    mStreamStates[AudioSystem.STREAM_ACCESSIBILITY].setAllIndexes(
                            mStreamStates[a11yStreamAlias], caller);
                            mStreamStates[a11yStreamAlias], caller);
                    mStreamStates[AudioSystem.STREAM_ACCESSIBILITY].refreshRange(
                            mStreamVolumeAlias[AudioSystem.STREAM_ACCESSIBILITY]);
                }
                }
            }
            }
            if (sIndependentA11yVolume) {
            if (sIndependentA11yVolume) {
@@ -1577,20 +1575,19 @@ public class AudioService extends IAudioService.Stub
    }
    }


    private int rescaleIndex(int index, int srcStream, int dstStream) {
    private int rescaleIndex(int index, int srcStream, int dstStream) {
        int max = mStreamStates[srcStream].getMaxIndex();
        int srcRange =
        if (max == 0) {
                mStreamStates[srcStream].getMaxIndex() - mStreamStates[srcStream].getMinIndex();
            Log.e(TAG, "rescaleIndex : Max index should not be zero");
        int dstRange =
            return mStreamStates[srcStream].getMinIndex();
                mStreamStates[dstStream].getMaxIndex() - mStreamStates[dstStream].getMinIndex();
        }

        final int rescaled =
        if (srcRange == 0) {
                (index * mStreamStates[dstStream].getMaxIndex()
            Log.e(TAG, "rescaleIndex : index range should not be zero");
                        + mStreamStates[srcStream].getMaxIndex() / 2)
                / mStreamStates[srcStream].getMaxIndex();
        if (rescaled < mStreamStates[dstStream].getMinIndex()) {
            return mStreamStates[dstStream].getMinIndex();
            return mStreamStates[dstStream].getMinIndex();
        } else {
            return rescaled;
        }
        }

        return mStreamStates[dstStream].getMinIndex()
                + ((index - mStreamStates[srcStream].getMinIndex()) * dstRange + srcRange / 2)
                / srcRange;
    }
    }


    ///////////////////////////////////////////////////////////////////////////
    ///////////////////////////////////////////////////////////////////////////
@@ -4729,24 +4726,6 @@ public class AudioService extends IAudioService.Stub
            return mIndexMin;
            return mIndexMin;
        }
        }


        /**
         * Updates the min/max index values from another stream. Use this when changing the alias
         * for the current stream type.
         * @param sourceStreamType
         */
        // must be sync'd on mSettingsLock before VolumeStreamState.class
        @GuardedBy("VolumeStreamState.class")
        public void refreshRange(int sourceStreamType) {
            mIndexMin = MIN_STREAM_VOLUME[sourceStreamType] * 10;
            mIndexMax = MAX_STREAM_VOLUME[sourceStreamType] * 10;
            // verify all current volumes are within bounds
            for (int i = 0 ; i < mIndexMap.size(); i++) {
                final int device = mIndexMap.keyAt(i);
                final int index = mIndexMap.valueAt(i);
                mIndexMap.put(device, getValidIndex(index));
            }
        }

        /**
        /**
         * Copies all device/index pairs from the given VolumeStreamState after initializing
         * Copies all device/index pairs from the given VolumeStreamState after initializing
         * them with the volume for DEVICE_OUT_DEFAULT. No-op if the source VolumeStreamState
         * them with the volume for DEVICE_OUT_DEFAULT. No-op if the source VolumeStreamState