Fix the ANR in panel when changing volume continuously
When users open volume panel and keep on changing the volume slider for a while, the panel starts to defer the slider updating, and finally gets stuck and causes an ANR. Root cause: Volume panel has four volume adjusting slices. Each of them registers a broadcast receiver to listen to the volume changed and muted events. However, when the media volume changes, AudioManager will send four broadcasts (music, assistant, accessibility, tts) to every receiver, and each of them will reload slice four times. Thus, one media volume changed event will lead to 16 (4*4) UI updates. Consequently, keeping on sliding the volume bar will trigger hundreds of broadcasts and UI updates, which makes the system busy and getting stuck. Solution: Introduce a VolumeSliceHelper to integrate the broadcasts of the volume slices specifically. 1. Only register one broadcast receiver to reduce the broadcast loading since the four slices are listening to the same signal. 2. Filter the only one eligible broadcast among the multiple concurrent ones, and then relay it to the registered slice. 3. Listen to one more action STREAM_DEVICES_CHANGED_ACTION to update the volume panel when audio output device changes. Test: robotest, visual Fixes: 144134209 Fixes: 160489394 Change-Id: I780b9eee35802b19a5f0ab0a7d07bd3e081f5556 Merged-In: I780b9eee35802b19a5f0ab0a7d07bd3e081f5556 (cherry picked from commit 2c7b77da)
Loading
Please register or sign in to comment