mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-28 12:56:49 +01:00
Xiaomi: fix music volume command only increasing volume
Earlier Xiaomi devices would send either 0 or 100 for the requested volume to indicate whether the app should increase or decrease the phone's volume. Newer devices send the volume to change to, based on the known current volume. We therefore need to check whether the device increased or decreased the volume based on the current volume ourselves in order to determine which event we want to fire.
This commit is contained in:
parent
35217aa405
commit
d39f86f3c8
@ -85,13 +85,18 @@ public class XiaomiMusicService extends AbstractXiaomiService {
|
||||
case BUTTON_NEXT:
|
||||
deviceEventMusicControl.event = GBDeviceEventMusicControl.Event.NEXT;
|
||||
break;
|
||||
case BUTTON_VOLUME:
|
||||
if (music.getMediaKey().getVolume() > 0) {
|
||||
case BUTTON_VOLUME: {
|
||||
final int requestedVolume = music.getMediaKey().getVolume();
|
||||
final int currentVolume = MediaManager.getPhoneVolume(getSupport().getContext());
|
||||
|
||||
if (requestedVolume > currentVolume) {
|
||||
deviceEventMusicControl.event = GBDeviceEventMusicControl.Event.VOLUMEUP;
|
||||
} else {
|
||||
deviceEventMusicControl.event = GBDeviceEventMusicControl.Event.VOLUMEDOWN;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG.warn("Unexpected media button key {}", music.getMediaKey().getKey());
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user