mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-23 02:16:48 +01:00
Moyoung: Send volume level with music info
This commit is contained in:
parent
504faf6db0
commit
5c7d8c8fa8
@ -206,6 +206,7 @@ public class MoyoungConstants {
|
||||
public static final byte ARG_OPERATION_VOLUME_DOWN = 5;
|
||||
public static final byte ARG_OPERATION_PLAY = 6;
|
||||
public static final byte ARG_OPERATION_PAUSE = 7;
|
||||
public static final byte ARG_OPERATION_SEND_CURRENT_VOLUME = 12; // {0x00-0x10}
|
||||
|
||||
public static final byte CMD_QUERY_ALARM_CLOCK = 33; // (?) {} -> a list of entries like below
|
||||
public static final byte CMD_SET_ALARM_CLOCK = 17; // (?) {id, enable ? 1 : 0, repeat, hour, minute, i >> 8, i, repeatMode}, repeatMode is 0(SINGLE), 127(EVERYDAY), or bitmask of 1,2,4,8,16,32,64(SUNDAY-SATURDAY) is 0,1,2, i is ((year << 12) + (month << 8) + day) where year is 2015-based, month and day start at 1 for repeatMode=SINGLE and 0 otherwise, repeat is 0(SINGLE),1(EVERYDAY),2(OTHER)
|
||||
|
@ -18,6 +18,7 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.moyoung;
|
||||
|
||||
import android.bluetooth.BluetoothGatt;
|
||||
import android.bluetooth.BluetoothGattCharacteristic;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.media.AudioManager;
|
||||
import android.os.Handler;
|
||||
@ -801,6 +802,7 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
public void onSetMusicInfo(MusicSpec musicSpec) {
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("sendMusicInfo");
|
||||
|
||||
byte[] artistBytes = musicSpec.artist.getBytes();
|
||||
byte[] artistPayload = new byte[artistBytes.length + 1];
|
||||
artistPayload[0] = 1;
|
||||
@ -811,6 +813,16 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
trackPayload[0] = 0;
|
||||
System.arraycopy(trackBytes, 0, trackPayload, 1, trackBytes.length);
|
||||
sendPacket(builder, MoyoungPacketOut.buildPacket(mtu, MoyoungConstants.CMD_SET_MUSIC_INFO, trackPayload));
|
||||
|
||||
AudioManager audioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
|
||||
int volumeLevel = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
|
||||
int volumeMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
|
||||
float volumeFraction = (float) volumeLevel / volumeMax;
|
||||
sendPacket(builder, MoyoungPacketOut.buildPacket(mtu, MoyoungConstants.CMD_NOTIFY_PHONE_OPERATION, new byte[]{
|
||||
MoyoungConstants.ARG_OPERATION_SEND_CURRENT_VOLUME,
|
||||
(byte) (16 * volumeFraction)
|
||||
}));
|
||||
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
LOG.error("Error sending music info: ", e);
|
||||
|
Loading…
Reference in New Issue
Block a user