1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-11 19:27:50 +01:00

Huawei: Use default value for channels. Parse sample rates.

This commit is contained in:
Me7c7 2024-10-20 11:38:47 +03:00 committed by José Rebelo
parent d23c931f95
commit 3bb44d8050
3 changed files with 10 additions and 6 deletions

View File

@ -24,6 +24,7 @@ import android.text.TextUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.List; import java.util.List;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
@ -91,7 +92,7 @@ public class HuaweiInstallHandler implements InstallHandler {
LOG.info("bitrate {}", restrictions.bitrate); LOG.info("bitrate {}", restrictions.bitrate);
LOG.info("channels {}", restrictions.channels); LOG.info("channels {}", restrictions.channels);
LOG.info("musicEncode {}", restrictions.musicEncode); LOG.info("musicEncode {}", restrictions.musicEncode);
LOG.info("sampleRate {}", restrictions.sampleRate); LOG.info("sampleRate {}", Arrays.toString(restrictions.sampleRates));
LOG.info("unknownBitrate {}", restrictions.unknownBitrate); LOG.info("unknownBitrate {}", restrictions.unknownBitrate);
if(currentMusicInfo.getChannels() > restrictions.channels) { if(currentMusicInfo.getChannels() > restrictions.channels) {

View File

@ -1,6 +1,7 @@
package nodomain.freeyourgadget.gadgetbridge.devices.huawei; package nodomain.freeyourgadget.gadgetbridge.devices.huawei;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
public class HuaweiMusicUtils { public class HuaweiMusicUtils {
@ -32,10 +33,10 @@ public class HuaweiMusicUtils {
public static class FormatRestrictions { public static class FormatRestrictions {
public byte formatIdx = -1; public byte formatIdx = -1;
public int sampleRate = -1; // TODO: not sure public String[] sampleRates = null;
public byte musicEncode = -1; // TODO: not sure public byte musicEncode = -1; // TODO: not sure
public short bitrate = -1; public short bitrate = -1;
public byte channels = -1; public byte channels = 2;
public short unknownBitrate = -1; // TODO: not sure public short unknownBitrate = -1; // TODO: not sure
// TODO: I am not sure about this. Most of formats unknown for me. // TODO: I am not sure about this. Most of formats unknown for me.
@ -49,7 +50,7 @@ public class HuaweiMusicUtils {
public String toString() { public String toString() {
final StringBuffer sb = new StringBuffer("FormatRestrictions{"); final StringBuffer sb = new StringBuffer("FormatRestrictions{");
sb.append("formatIdx=").append(formatIdx); sb.append("formatIdx=").append(formatIdx);
sb.append(", sampleRate=").append(sampleRate); sb.append(", sampleRates=").append(Arrays.toString(sampleRates));
sb.append(", musicEncode=").append(musicEncode); sb.append(", musicEncode=").append(musicEncode);
sb.append(", bitrate=").append(bitrate); sb.append(", bitrate=").append(bitrate);
sb.append(", channels=").append(channels); sb.append(", channels=").append(channels);

View File

@ -343,8 +343,10 @@ public class MusicControl {
HuaweiMusicUtils.FormatRestrictions restriction = new HuaweiMusicUtils.FormatRestrictions(); HuaweiMusicUtils.FormatRestrictions restriction = new HuaweiMusicUtils.FormatRestrictions();
if (subTlv.contains(0x08)) if (subTlv.contains(0x08))
restriction.formatIdx = subTlv.getByte(0x08); restriction.formatIdx = subTlv.getByte(0x08);
if (subTlv.contains(0x09)) if (subTlv.contains(0x09)) {
restriction.sampleRate = subTlv.getInteger(0x09); String sampleRates = subTlv.getString(0x09);
restriction.sampleRates = sampleRates.split(",");
}
if (subTlv.contains(0x0a)) if (subTlv.contains(0x0a))
restriction.musicEncode = subTlv.getByte(0x0a); restriction.musicEncode = subTlv.getByte(0x0a);
if (subTlv.contains(0x0b)) if (subTlv.contains(0x0b))