1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-18 22:57:48 +01:00

Amazfit GTR2: Try to fix incoming calls blindly

This commit is contained in:
Andreas Shimokawa 2021-01-06 16:28:20 +01:00
parent 865a197db6
commit c896e476f4
3 changed files with 36 additions and 29 deletions

View File

@ -804,6 +804,33 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
}
}
public void onSetCallStateNew(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");
}
}
}
private void stopCurrentCallNotification() {
try {
TransactionBuilder builder = performInitialized("stop notification");

View File

@ -23,8 +23,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
@ -36,7 +34,6 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip.Ama
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.UpdateFirmwareOperation;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.UpdateFirmwareOperation2020;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.UpdateFirmwareOperationNew;
import nodomain.freeyourgadget.gadgetbridge.util.NotificationUtils;
import nodomain.freeyourgadget.gadgetbridge.util.Version;
public class AmazfitBipSSupport extends AmazfitBipSupport {
@ -66,30 +63,7 @@ public class AmazfitBipSSupport extends AmazfitBipSupport {
@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");
}
}
onSetCallStateNew(callSpec);
}
@Override

View File

@ -23,17 +23,23 @@ import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr2.AmazfitGTR2FWHelper;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts.AmazfitGTSSupport;
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr.AmazfitGTRSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.UpdateFirmwareOperation;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.UpdateFirmwareOperation2020;
public class AmazfitGTR2Support extends AmazfitGTSSupport {
public class AmazfitGTR2Support extends AmazfitGTRSupport {
@Override
public HuamiFWHelper createFWHelper(Uri uri, Context context) throws IOException {
return new AmazfitGTR2FWHelper(uri, context);
}
@Override
public void onSetCallState(CallSpec callSpec) {
onSetCallStateNew(callSpec);
}
@Override
public UpdateFirmwareOperation createUpdateFirmwareOperation(Uri uri) {
return new UpdateFirmwareOperation2020(uri, this);