mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
oppo: add handler for DeviceInfoType.ANC_SELECTOR
This commit is contained in:
+21
-5
@@ -360,6 +360,20 @@ public class OppoHeadphonesProtocol extends GBDeviceProtocol {
|
|||||||
// TODO handle
|
// TODO handle
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case ANC_SELECTOR: {
|
||||||
|
final int valueCode = payload[2] & 0xFF;
|
||||||
|
final AncConfigValue mode = AncConfigValue.fromCode(valueCode);
|
||||||
|
if (mode == null) {
|
||||||
|
LOG.warn("Unknown anc mode code {}", valueCode);
|
||||||
|
}
|
||||||
|
LOG.debug("Got anc config for MODE = {}", mode);
|
||||||
|
eventUpdatePreferences.withPreference(
|
||||||
|
OppoHeadphonesPreferences.ANC_SELECTOR,
|
||||||
|
mode.getPrefId()
|
||||||
|
);
|
||||||
|
events.add(eventUpdatePreferences);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case GAME_MODE: {
|
case GAME_MODE: {
|
||||||
final boolean isEnabled = ((payload[1] & 0xFF) == 0x01);
|
final boolean isEnabled = ((payload[1] & 0xFF) == 0x01);
|
||||||
LOG.debug("Got misc config for GAME_MODE = {}", isEnabled);
|
LOG.debug("Got misc config for GAME_MODE = {}", isEnabled);
|
||||||
@@ -389,7 +403,7 @@ public class OppoHeadphonesProtocol extends GBDeviceProtocol {
|
|||||||
LOG.warn("Unknown misc config type code {}", typeCode);
|
LOG.warn("Unknown misc config type code {}", typeCode);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean isEnabled = (valueCode == 1);
|
final boolean isEnabled = (valueCode == 1);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case LDAC:
|
case LDAC:
|
||||||
@@ -470,12 +484,13 @@ public class OppoHeadphonesProtocol extends GBDeviceProtocol {
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case MODE: {
|
case MODE: {
|
||||||
final AncConfigValue mode = AncConfigValue.fromCode(valueCode);
|
final AncConfigValue mode = AncConfigValue.fromCode(valueCode);
|
||||||
if (mode != null) {
|
if (mode == null) {
|
||||||
LOG.debug("Got anc config for {} = {}", type, mode);
|
|
||||||
event.withPreference(OppoHeadphonesPreferences.ANC_SELECTOR, mode.getPrefId());
|
|
||||||
} else {
|
|
||||||
LOG.warn("Unknown anc mode code {}", valueCode);
|
LOG.warn("Unknown anc mode code {}", valueCode);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG.debug("Got anc config for {} = {}", type, mode);
|
||||||
|
event.withPreference(OppoHeadphonesPreferences.ANC_SELECTOR, mode.getPrefId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TOUCH_CYCLE_MODES: {
|
case TOUCH_CYCLE_MODES: {
|
||||||
@@ -660,6 +675,7 @@ public class OppoHeadphonesProtocol extends GBDeviceProtocol {
|
|||||||
final byte[] payload = new byte[] {
|
final byte[] payload = new byte[] {
|
||||||
(byte) 0x09,
|
(byte) 0x09,
|
||||||
(byte) DeviceInfoType.BATTERY.getCode(),
|
(byte) DeviceInfoType.BATTERY.getCode(),
|
||||||
|
(byte) DeviceInfoType.ANC_SELECTOR.getCode(),
|
||||||
(byte) DeviceInfoType.GAME_MODE.getCode(),
|
(byte) DeviceInfoType.GAME_MODE.getCode(),
|
||||||
};
|
};
|
||||||
return encodeMessage(OppoCommand.DEVICE_INFO_SET, payload);
|
return encodeMessage(OppoCommand.DEVICE_INFO_SET, payload);
|
||||||
|
|||||||
+1
@@ -21,6 +21,7 @@ import androidx.annotation.Nullable;
|
|||||||
public enum DeviceInfoType {
|
public enum DeviceInfoType {
|
||||||
BATTERY(0x01),
|
BATTERY(0x01),
|
||||||
STATUS(0x02),
|
STATUS(0x02),
|
||||||
|
ANC_SELECTOR(0x03),
|
||||||
GAME_MODE(0x05),
|
GAME_MODE(0x05),
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user