CMF Buds: Handle In-Ear detection change

When the In-Ear detection state changes on the device (via a 2nd
connected phone) handle the change indicated by the buds and update the
value accordingly.
This commit is contained in:
Dominik Riebeling
2026-05-02 19:50:44 +02:00
committed by José Rebelo
parent c6125e351e
commit f23ec9e51f
@@ -160,6 +160,7 @@ public class Ear1Support extends AbstractHeadphoneBTBRDeviceSupport {
//outgoing
private static final short find_device = (short) 0xf002;
private static final short in_ear_detection = (short) 0xf004;
private static final short in_ear_detection2 = (short) 0xc00e;
private static final short audio_mode = (short) 0xf00f;
private final boolean incrementCounter;
@@ -243,6 +244,10 @@ public class Ear1Support extends AbstractHeadphoneBTBRDeviceSupport {
devEvts.add(handleAudioModeStatus(payload));
break;
case in_ear_detection2:
devEvts.add(handleInEarStatus(payload));
break;
case unk_maybe_ack:
LOG.debug("received ack");
break;
@@ -315,6 +320,15 @@ public class Ear1Support extends AbstractHeadphoneBTBRDeviceSupport {
return preferencesEvent;
}
private GBDeviceEventUpdatePreferences handleInEarStatus(byte[] payload) {
final GBDeviceEventUpdatePreferences preferencesEvent = new GBDeviceEventUpdatePreferences();
if (payload.length >= 3) {
preferencesEvent.withPreference(DeviceSettingsPreferenceConst.PREF_NOTHING_EAR1_INEAR, payload[2] == 0x01 ? true : false);
}
return preferencesEvent;
}
byte[] encodeInEarDetection(byte enabled) {
return encodeMessage((short) 0x120, in_ear_detection, new byte[]{0x01, 0x01, enabled});
}