mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-27 00:51:44 +01:00
device should not connect with invalid key anymore
This commit is contained in:
parent
df40fee0c3
commit
b41495c2b8
@ -132,6 +132,11 @@ public class FossilWatchAdapter extends WatchAdapter {
|
|||||||
@Override
|
@Override
|
||||||
public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
|
public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
|
||||||
if(status != BluetoothGatt.GATT_SUCCESS){
|
if(status != BluetoothGatt.GATT_SUCCESS){
|
||||||
|
if(characteristic.getUuid().toString().equals("3dda0005-957f-7d4a-34a6-74696673696d")){
|
||||||
|
GB.log("authentication failed", GB.ERROR, null);
|
||||||
|
setDeviceState(GBDevice.State.AUTHENTICATION_REQUIRED);
|
||||||
|
requestQueue.clear();
|
||||||
|
}
|
||||||
log("characteristic write failed: " + status);
|
log("characteristic write failed: " + status);
|
||||||
fossilRequest = null;
|
fossilRequest = null;
|
||||||
|
|
||||||
@ -483,8 +488,9 @@ public class FossilWatchAdapter extends WatchAdapter {
|
|||||||
fossilRequest.handleResponse(characteristic);
|
fossilRequest.handleResponse(characteristic);
|
||||||
requestFinished = fossilRequest.isFinished();
|
requestFinished = fossilRequest.isFinished();
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
if(fossilRequest instanceof VerifyPrivateKeyRequest){
|
if(characteristic.getUuid().toString().equals("3dda0005-957f-7d4a-34a6-74696673696d")){
|
||||||
getDeviceSupport().getDevice().setState(GBDevice.State.AUTHENTICATION_REQUIRED);
|
GB.log("authentication failed", GB.ERROR, null);
|
||||||
|
setDeviceState(GBDevice.State.AUTHENTICATION_REQUIRED);
|
||||||
requestQueue.clear();
|
requestQueue.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -608,11 +614,15 @@ public class FossilWatchAdapter extends WatchAdapter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
log("setting device state: " + request.getDeviceState());
|
log("setting device state: " + request.getDeviceState());
|
||||||
getDeviceSupport().getDevice().setState(request.getDeviceState());
|
setDeviceState(request.getDeviceState());
|
||||||
getDeviceSupport().getDevice().sendDeviceUpdateIntent(getContext());
|
|
||||||
queueNextRequest();
|
queueNextRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setDeviceState(GBDevice.State state){
|
||||||
|
getDeviceSupport().getDevice().setState(state);
|
||||||
|
getDeviceSupport().getDevice().sendDeviceUpdateIntent(getContext());
|
||||||
|
}
|
||||||
|
|
||||||
public void queueWrite(FossilRequest request, boolean priorise) {
|
public void queueWrite(FossilRequest request, boolean priorise) {
|
||||||
log("is connected: " + getDeviceSupport().isConnected());
|
log("is connected: " + getDeviceSupport().isConnected());
|
||||||
if(!getDeviceSupport().isConnected()){
|
if(!getDeviceSupport().isConnected()){
|
||||||
|
Loading…
Reference in New Issue
Block a user