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

Commit 728081f9 authored by Jason Chiu's avatar Jason Chiu
Browse files

Fix NullPointerException at VolumeSliceHelper

Race condition happens on accessing a map while system is destroying it.

Test: manual, robotest
Fixes: 188114877
Change-Id: I245121b95d1d4db02e3107a47c6d3ae13a5d32e5
parent 4335268c
Loading
Loading
Loading
Loading
+11 −7
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@ public class VolumeSliceHelper {

    private static void handleStreamChanged(Context context, Intent intent) {
        final int inputType = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, -1);
        synchronized (sRegisteredUri) {
            for (Map.Entry<Uri, Integer> entry : sRegisteredUri.entrySet()) {
                if (entry.getValue() == inputType) {
                    context.getContentResolver().notifyChange(entry.getKey(), null /* observer */);
@@ -118,10 +119,13 @@ public class VolumeSliceHelper {
                }
            }
        }
    }

    private static void notifyAllStreamsChanged(Context context) {
        synchronized (sRegisteredUri) {
            sRegisteredUri.forEach((uri, audioStream) -> {
                context.getContentResolver().notifyChange(uri, null /* observer */);
            });
        }
    }
}