From ad1e51972326c60c68e2c95fef8611d8ae8afb7e Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Mon, 4 May 2020 21:53:51 +0200 Subject: [PATCH] ZeTime: Basic support for rejecting incoming calls --- .../devices/zetime/ZeTimeConstants.java | 1 + .../devices/zetime/ZeTimeDeviceSupport.java | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/zetime/ZeTimeConstants.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/zetime/ZeTimeConstants.java index 52daf2bec..04ee50e35 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/zetime/ZeTimeConstants.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/zetime/ZeTimeConstants.java @@ -80,6 +80,7 @@ public class ZeTimeConstants { public static final byte CMD_REMINDERS = (byte) 0x97; public static final byte CMD_PUSH_CALENDAR_DAY = (byte) 0x99; public static final byte CMD_MUSIC_CONTROL = (byte) 0xD0; + public static final byte CMD_CALL_CONTROL = (byte) 0xDC; public static final byte CMD_TEST_SIGNALING = (byte) 0xFA; // here are the action commands public static final byte CMD_REQUEST = (byte) 0x70; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/zetime/ZeTimeDeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/zetime/ZeTimeDeviceSupport.java index 2137d6c49..980407017 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/zetime/ZeTimeDeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/zetime/ZeTimeDeviceSupport.java @@ -43,6 +43,7 @@ import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSett import nodomain.freeyourgadget.gadgetbridge.database.DBHandler; import nodomain.freeyourgadget.gadgetbridge.database.DBHelper; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo; +import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo; import nodomain.freeyourgadget.gadgetbridge.devices.zetime.ZeTimeConstants; @@ -79,6 +80,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport { private final GBDeviceEventBatteryInfo batteryCmd = new GBDeviceEventBatteryInfo(); private final GBDeviceEventVersionInfo versionCmd = new GBDeviceEventVersionInfo(); private final GBDeviceEventMusicControl musicCmd = new GBDeviceEventMusicControl(); + private final GBDeviceEventCallControl callCmd = new GBDeviceEventCallControl(); private final int eightHourOffset = 28800; private byte[] lastMsg; private byte msgPart; @@ -895,6 +897,9 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport { case ZeTimeConstants.CMD_MUSIC_CONTROL: handleMusicControl(data); break; + case ZeTimeConstants.CMD_CALL_CONTROL: + handleCallControl(data); + break; } return true; } @@ -1376,6 +1381,17 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport { } } + private void handleCallControl(byte[] callControlMsg) { + if (callControlMsg.length == 7 + && callControlMsg[2] == ZeTimeConstants.CMD_SEND + && callControlMsg[3] == 0x01 + && callControlMsg[4] == 0x00 + && callControlMsg[5] == 0x01) { + callCmd.event = GBDeviceEventCallControl.Event.REJECT; + evaluateGBDeviceEvent(callCmd); + } + } + private void replyMsgToWatch(TransactionBuilder builder, byte[] msg) { if (msg.length > maxMsgLength) { int msgpartlength = 0;