1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2025-01-13 03:07:32 +01:00

HPlus: Handles missing phone number. Fixes #675

This commit is contained in:
João Paulo Barraca 2017-05-05 22:17:52 +01:00
parent 9f309df84d
commit d73d4b3a13

View File

@ -667,14 +667,6 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
private void showIncomingCall(String name, String rawNumber) { private void showIncomingCall(String name, String rawNumber) {
try { try {
StringBuilder number = new StringBuilder();
//Clean up number as the device only accepts digits
for (char c : rawNumber.toCharArray()) {
if (Character.isDigit(c)) {
number.append(c);
}
}
TransactionBuilder builder = performInitialized("incomingCall"); TransactionBuilder builder = performInitialized("incomingCall");
@ -684,37 +676,48 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
//Show Call Icon //Show Call Icon
builder.write(ctrlCharacteristic, new byte[]{HPlusConstants.CMD_SET_INCOMING_CALL, HPlusConstants.ARG_INCOMING_CALL}); builder.write(ctrlCharacteristic, new byte[]{HPlusConstants.CMD_SET_INCOMING_CALL, HPlusConstants.ARG_INCOMING_CALL});
byte[] msg = new byte[13]; if(name != null) {
byte[] msg = new byte[13];
//Show call name
for (int i = 0; i < msg.length; i++)
msg[i] = ' ';
//Show call name byte[] nameBytes = encodeStringToDevice(name);
for (int i = 0; i < nameBytes.length && i < (msg.length - 1); i++)
msg[i + 1] = nameBytes[i];
for (int i = 0; i < msg.length; i++) msg[0] = HPlusConstants.CMD_ACTION_DISPLAY_TEXT_NAME;
msg[i] = ' '; builder.write(ctrlCharacteristic, msg);
byte[] nameBytes = encodeStringToDevice(name); msg[0] = HPlusConstants.CMD_ACTION_DISPLAY_TEXT_NAME_CN;
for (int i = 0; i < nameBytes.length && i < (msg.length - 1); i++) builder.write(ctrlCharacteristic, msg);
msg[i + 1] = nameBytes[i]; }
msg[0] = HPlusConstants.CMD_ACTION_DISPLAY_TEXT_NAME; if(rawNumber != null) {
builder.write(ctrlCharacteristic, msg); StringBuilder number = new StringBuilder();
msg[0] = HPlusConstants.CMD_ACTION_DISPLAY_TEXT_NAME_CN; //Clean up number as the device only accepts digits
builder.write(ctrlCharacteristic, msg); for (char c : rawNumber.toCharArray()) {
if (Character.isDigit(c)) {
number.append(c);
}
}
builder.wait(200); byte[] msg = new byte[13];
msg = msg.clone();
//Show call number //Show call number
for (int i = 0; i < msg.length; i++) for (int i = 0; i < msg.length; i++)
msg[i] = ' '; msg[i] = ' ';
for (int i = 0; i < number.length() && i < (msg.length - 1); i++) for (int i = 0; i < number.length() && i < (msg.length - 1); i++)
msg[i + 1] = (byte) number.charAt(i); msg[i + 1] = (byte) number.charAt(i);
msg[0] = HPlusConstants.CMD_SET_INCOMING_CALL_NUMBER; msg[0] = HPlusConstants.CMD_SET_INCOMING_CALL_NUMBER;
builder.write(ctrlCharacteristic, msg); builder.wait(200);
builder.write(ctrlCharacteristic, msg);
}
performConnected(builder.getTransaction()); performConnected(builder.getTransaction());
} catch (IOException e) { } catch (IOException e) {