Search in sources :

Example 1 with GBDeviceEventUpdateDeviceInfo

use of nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdateDeviceInfo in project Gadgetbridge by Freeyourgadget.

the class SonyProtocolImplV1 method handleAudioCodec.

public List<? extends GBDeviceEvent> handleAudioCodec(final byte[] payload) {
    if (payload.length != 3) {
        LOG.warn("Unexpected payload length {}", payload.length);
        return Collections.emptyList();
    }
    final AudioCodec audioCodec = AudioCodec.fromCode(payload[2]);
    if (audioCodec == null) {
        LOG.warn("Unable to determine audio codec from {}", GB.hexdump(payload));
        return Collections.emptyList();
    }
    final GBDeviceEventUpdateDeviceInfo gbDeviceEventUpdateDeviceInfo = new GBDeviceEventUpdateDeviceInfo("AUDIO_CODEC: ", audioCodec.name());
    final GBDeviceEventUpdatePreferences gbDeviceEventUpdatePreferences = new GBDeviceEventUpdatePreferences().withPreference(DeviceSettingsPreferenceConst.PREF_SONY_AUDIO_CODEC, audioCodec.name().toLowerCase(Locale.getDefault()));
    return Arrays.asList(gbDeviceEventUpdateDeviceInfo, gbDeviceEventUpdatePreferences);
}
Also used : GBDeviceEventUpdatePreferences(nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences) AudioCodec(nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.protocol.impl.v1.params.AudioCodec) GBDeviceEventUpdateDeviceInfo(nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdateDeviceInfo)

Aggregations

GBDeviceEventUpdateDeviceInfo (nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdateDeviceInfo)1 GBDeviceEventUpdatePreferences (nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences)1 AudioCodec (nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.protocol.impl.v1.params.AudioCodec)1