mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-25 03:16:51 +01:00
amazfit bip s: Fix incoming call notification
This commit is contained in:
parent
e844f81056
commit
f06c9fb8e7
@ -19,13 +19,23 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.NotificationUtils;
|
||||
|
||||
public class AmazfitBipSSupport extends AmazfitBipSupport {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AmazfitBipSSupport.class);
|
||||
|
||||
@Override
|
||||
public byte getCryptFlags() {
|
||||
return (byte) 0x80;
|
||||
@ -41,6 +51,34 @@ public class AmazfitBipSSupport extends AmazfitBipSupport {
|
||||
return 0x00;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetCallState(CallSpec callSpec) {
|
||||
if (callSpec.command == CallSpec.CALL_INCOMING) {
|
||||
byte[] message = NotificationUtils.getPreferredTextFor(callSpec).getBytes();
|
||||
int length = 10 + message.length;
|
||||
ByteBuffer buf = ByteBuffer.allocate(length);
|
||||
buf.order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.put(new byte[]{3, 0, 0, 0, 0, 0});
|
||||
buf.put(message);
|
||||
buf.put(new byte[]{0, 0, 0, 2});
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("incoming call");
|
||||
writeToChunked(builder, 0, buf.array());
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
LOG.error("Unable to send incoming call");
|
||||
}
|
||||
} else if ((callSpec.command == CallSpec.CALL_START) || (callSpec.command == CallSpec.CALL_END)) {
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("end call");
|
||||
writeToChunked(builder, 0, new byte[]{3, 3, 0, 0, 0, 0});
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
LOG.error("Unable to send end call");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public HuamiFWHelper createFWHelper(Uri uri, Context context) throws IOException {
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user