mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Improve media control logging
This commit is contained in:
+1
-7
@@ -22,15 +22,10 @@ import android.content.Intent;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.receivers.GBMusicControlReceiver;
|
||||
|
||||
public class GBDeviceEventMusicControl extends GBDeviceEvent {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(GBDeviceEventMusicControl.class);
|
||||
|
||||
public Event event;
|
||||
|
||||
public GBDeviceEventMusicControl() {
|
||||
@@ -42,8 +37,7 @@ public class GBDeviceEventMusicControl extends GBDeviceEvent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate(final Context context, final GBDevice device) {
|
||||
LOG.info("Got event for MUSIC_CONTROL");
|
||||
public void evaluate(final Context context, @NonNull final GBDevice device) {
|
||||
final Intent musicIntent = new Intent(GBMusicControlReceiver.ACTION_MUSICCONTROL);
|
||||
musicIntent.putExtra("event", event.ordinal());
|
||||
musicIntent.setPackage(context.getPackageName());
|
||||
|
||||
+8
@@ -77,10 +77,12 @@ public class GBMusicControlReceiver extends BroadcastReceiver {
|
||||
keyCode = KeyEvent.KEYCODE_MEDIA_FAST_FORWARD;
|
||||
break;
|
||||
case VOLUMEUP:
|
||||
LOG.debug("Adjusting volume up");
|
||||
audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE, 0);
|
||||
sendPhoneVolume(audioManager);
|
||||
return;
|
||||
case VOLUMEDOWN:
|
||||
LOG.debug("Adjusting volume down");
|
||||
audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER, 0);
|
||||
sendPhoneVolume(audioManager);
|
||||
return;
|
||||
@@ -150,6 +152,8 @@ public class GBMusicControlReceiver extends BroadcastReceiver {
|
||||
controller = controllers.get(0);
|
||||
}
|
||||
|
||||
LOG.debug("Will send {} to media controller for {}", musicCmd, controller.getPackageName());
|
||||
|
||||
switch (musicCmd) {
|
||||
case NEXT:
|
||||
controller.getTransportControls().skipToNext();
|
||||
@@ -166,6 +170,7 @@ public class GBMusicControlReceiver extends BroadcastReceiver {
|
||||
case PLAYPAUSE:
|
||||
final PlaybackState playbackState = controller.getPlaybackState();
|
||||
if (playbackState != null) {
|
||||
LOG.debug("Current playback state for media controller: {}", playbackState);
|
||||
switch (playbackState.getState()) {
|
||||
case PlaybackState.STATE_NONE:
|
||||
case PlaybackState.STATE_STOPPED:
|
||||
@@ -178,6 +183,7 @@ public class GBMusicControlReceiver extends BroadcastReceiver {
|
||||
controller.getTransportControls().pause();
|
||||
return;
|
||||
default:
|
||||
LOG.error("Unknown playback state {}", playbackState);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@@ -212,6 +218,8 @@ public class GBMusicControlReceiver extends BroadcastReceiver {
|
||||
final int volumeMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
|
||||
final int volumePercentage = (byte) Math.round(100 * (volumeLevel / (float) volumeMax));
|
||||
|
||||
LOG.debug("Sending volume to phone: {}", volumePercentage);
|
||||
|
||||
GBApplication.deviceService().onSetPhoneVolume(volumePercentage);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user