HPlus: Handles missing phone number. Fixes #675

master
João Paulo Barraca 2017-05-05 22:17:52 +01:00
parent 9f309df84d
commit d73d4b3a13
1 changed files with 31 additions and 28 deletions

View File

@ -667,14 +667,6 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
private void showIncomingCall(String name, String rawNumber) {
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");
@ -684,11 +676,10 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
//Show Call Icon
builder.write(ctrlCharacteristic, new byte[]{HPlusConstants.CMD_SET_INCOMING_CALL, HPlusConstants.ARG_INCOMING_CALL});
if(name != null) {
byte[] msg = new byte[13];
//Show call name
for (int i = 0; i < msg.length; i++)
msg[i] = ' ';
@ -701,9 +692,19 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
msg[0] = HPlusConstants.CMD_ACTION_DISPLAY_TEXT_NAME_CN;
builder.write(ctrlCharacteristic, msg);
}
builder.wait(200);
msg = msg.clone();
if(rawNumber != null) {
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);
}
}
byte[] msg = new byte[13];
//Show call number
for (int i = 0; i < msg.length; i++)
@ -714,7 +715,9 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
msg[0] = HPlusConstants.CMD_SET_INCOMING_CALL_NUMBER;
builder.wait(200);
builder.write(ctrlCharacteristic, msg);
}
performConnected(builder.getTransaction());
} catch (IOException e) {