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

Commit 79a46802 authored by Vlad Popa's avatar Vlad Popa
Browse files

Retry onReinitVolumes if stream states are not created

Test: manual
Bug: 414287923
Flag: EXEMPT bugfix
Change-Id: Ie39f4e4b9147852cac105163d46246fb121c179f
parent a4fc9ffb
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -538,6 +538,8 @@ public class AudioService extends IAudioService.Stub
     **/
    private SparseArray<VolumeStreamState> mStreamStates;
    private final AtomicBoolean mStreamStatesCreated = new AtomicBoolean(false);
    /**
     * @see InputDeviceVolumeHelper
     */
@@ -564,6 +566,10 @@ public class AudioService extends IAudioService.Stub
     */
    @Nullable
    /*package*/ VolumeStreamState getVssForStream(int stream) {
        if (!mStreamStatesCreated.get()) {
            Slog.e(TAG, "VSS not created!");
            return null;
        }
        return mStreamStates.get(stream);
    }
@@ -2302,6 +2308,14 @@ public class AudioService extends IAudioService.Stub
    }
    private void onReinitVolumes(@NonNull String caller) {
        if (!mSystemReady || !mStreamStatesCreated.get()) {
            Slog.e(TAG, "Stream states not ready, retry onReinitVolumes()");
            sLifecycleLogger.enqueue(new EventLogger.StringEvent("onReinitVolumes() retry"));
            sendMsg(mAudioHandler, MSG_REINIT_VOLUMES, SENDMSG_REPLACE, 0, 0,
                    null, 500);
            return;
        }
        final int numStreamTypes = AudioSystem.getNumStreamTypes();
        // keep track of any error during stream volume initialization
        int status = AudioSystem.AUDIO_STATUS_OK;
@@ -2695,6 +2709,7 @@ public class AudioService extends IAudioService.Stub
                        new VolumeStreamState(System.VOLUME_SETTINGS_INT[streamAlias], i));
            }
        }
        mStreamStatesCreated.set(true);
        checkAllFixedVolumeDevices();
        checkAllAliasStreamVolumes();