1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-18 06:37:47 +01:00

ZeTime: Basic support for rejecting incoming calls

This commit is contained in:
Andreas Shimokawa 2020-05-04 21:53:51 +02:00
parent 94358e79b0
commit ad1e519723
2 changed files with 17 additions and 0 deletions

View File

@ -80,6 +80,7 @@ public class ZeTimeConstants {
public static final byte CMD_REMINDERS = (byte) 0x97; public static final byte CMD_REMINDERS = (byte) 0x97;
public static final byte CMD_PUSH_CALENDAR_DAY = (byte) 0x99; public static final byte CMD_PUSH_CALENDAR_DAY = (byte) 0x99;
public static final byte CMD_MUSIC_CONTROL = (byte) 0xD0; 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; public static final byte CMD_TEST_SIGNALING = (byte) 0xFA;
// here are the action commands // here are the action commands
public static final byte CMD_REQUEST = (byte) 0x70; public static final byte CMD_REQUEST = (byte) 0x70;

View File

@ -43,6 +43,7 @@ import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSett
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler; import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper; import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo;
import nodomain.freeyourgadget.gadgetbridge.devices.zetime.ZeTimeConstants; import nodomain.freeyourgadget.gadgetbridge.devices.zetime.ZeTimeConstants;
@ -79,6 +80,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
private final GBDeviceEventBatteryInfo batteryCmd = new GBDeviceEventBatteryInfo(); private final GBDeviceEventBatteryInfo batteryCmd = new GBDeviceEventBatteryInfo();
private final GBDeviceEventVersionInfo versionCmd = new GBDeviceEventVersionInfo(); private final GBDeviceEventVersionInfo versionCmd = new GBDeviceEventVersionInfo();
private final GBDeviceEventMusicControl musicCmd = new GBDeviceEventMusicControl(); private final GBDeviceEventMusicControl musicCmd = new GBDeviceEventMusicControl();
private final GBDeviceEventCallControl callCmd = new GBDeviceEventCallControl();
private final int eightHourOffset = 28800; private final int eightHourOffset = 28800;
private byte[] lastMsg; private byte[] lastMsg;
private byte msgPart; private byte msgPart;
@ -895,6 +897,9 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
case ZeTimeConstants.CMD_MUSIC_CONTROL: case ZeTimeConstants.CMD_MUSIC_CONTROL:
handleMusicControl(data); handleMusicControl(data);
break; break;
case ZeTimeConstants.CMD_CALL_CONTROL:
handleCallControl(data);
break;
} }
return true; 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) { private void replyMsgToWatch(TransactionBuilder builder, byte[] msg) {
if (msg.length > maxMsgLength) { if (msg.length > maxMsgLength) {
int msgpartlength = 0; int msgpartlength = 0;