Fix NullPointerException at VolumeSliceHelper
Race condition happens on accessing a map while system is destroying it. Test: manual, robotest Fixes: 188114877 Change-Id: I245121b95d1d4db02e3107a47c6d3ae13a5d32e5
This commit is contained in:
@@ -111,6 +111,7 @@ public class VolumeSliceHelper {
|
|||||||
|
|
||||||
private static void handleStreamChanged(Context context, Intent intent) {
|
private static void handleStreamChanged(Context context, Intent intent) {
|
||||||
final int inputType = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, -1);
|
final int inputType = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, -1);
|
||||||
|
synchronized (sRegisteredUri) {
|
||||||
for (Map.Entry<Uri, Integer> entry : sRegisteredUri.entrySet()) {
|
for (Map.Entry<Uri, Integer> entry : sRegisteredUri.entrySet()) {
|
||||||
if (entry.getValue() == inputType) {
|
if (entry.getValue() == inputType) {
|
||||||
context.getContentResolver().notifyChange(entry.getKey(), null /* observer */);
|
context.getContentResolver().notifyChange(entry.getKey(), null /* observer */);
|
||||||
@@ -118,10 +119,13 @@ public class VolumeSliceHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void notifyAllStreamsChanged(Context context) {
|
private static void notifyAllStreamsChanged(Context context) {
|
||||||
|
synchronized (sRegisteredUri) {
|
||||||
sRegisteredUri.forEach((uri, audioStream) -> {
|
sRegisteredUri.forEach((uri, audioStream) -> {
|
||||||
context.getContentResolver().notifyChange(uri, null /* observer */);
|
context.getContentResolver().notifyChange(uri, null /* observer */);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user