diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/amazfitbip/AmazfitBipSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/amazfitbip/AmazfitBipSupport.java index 05c3ade70..d6ec8cad5 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/amazfitbip/AmazfitBipSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/amazfitbip/AmazfitBipSupport.java @@ -16,6 +16,7 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.service.devices.amazfitbip; +import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl; import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.NotificationStrategy; import nodomain.freeyourgadget.gadgetbridge.service.devices.miband2.MiBand2Support; @@ -29,4 +30,21 @@ public class AmazfitBipSupport extends MiBand2Support { public void onFindDevice(boolean start) { // Prevent notification spamming from MiBand2Support for now } + + @Override + public void handleButtonPressed(byte[] value) { + if (value == null || value.length != 1) { + return; + } + GBDeviceEventCallControl callCmd = new GBDeviceEventCallControl(); + + if (value[0] == 0x07) { + callCmd.event = GBDeviceEventCallControl.Event.REJECT; + } else if (value[0] == 0x09) { + callCmd.event = GBDeviceEventCallControl.Event.ACCEPT; + } else { + return; + } + evaluateGBDeviceEvent(callCmd); + } } \ No newline at end of file diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband2/MiBand2Support.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband2/MiBand2Support.java index 16b718c64..a7ab33620 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband2/MiBand2Support.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband2/MiBand2Support.java @@ -808,7 +808,7 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport { return false; } - private void handleButtonPressed(byte[] value) { + public void handleButtonPressed(byte[] value) { LOG.info("Button pressed"); logMessageContent(value); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/receivers/GBCallControlReceiver.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/receivers/GBCallControlReceiver.java index d12c9ab93..263ca85d8 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/receivers/GBCallControlReceiver.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/receivers/GBCallControlReceiver.java @@ -39,6 +39,7 @@ public class GBCallControlReceiver extends BroadcastReceiver { GBDeviceEventCallControl.Event callCmd = GBDeviceEventCallControl.Event.values()[intent.getIntExtra("event", 0)]; switch (callCmd) { case END: + case REJECT: case START: try { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); @@ -46,7 +47,7 @@ public class GBCallControlReceiver extends BroadcastReceiver { Method method = clazz.getDeclaredMethod("getITelephony"); method.setAccessible(true); ITelephony telephonyService = (ITelephony) method.invoke(telephonyManager); - if (callCmd == GBDeviceEventCallControl.Event.END) { + if (callCmd == GBDeviceEventCallControl.Event.END || callCmd == GBDeviceEventCallControl.Event.REJECT) { telephonyService.endCall(); } else { telephonyService.answerRingingCall();