1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-29 12:05:53 +01:00

changed request handling

This commit is contained in:
Daniel Dakhno 2019-11-03 20:46:51 +01:00
parent fc9016e98e
commit 1318b58ad2
3 changed files with 13 additions and 11 deletions

View File

@ -239,6 +239,7 @@ public class QHybridSupport extends QHybridBaseSupport {
builder.notify(getCharacteristic(UUID.fromString("3dda000" + i + "-957f-7d4a-34a6-74696673696d")), true); builder.notify(getCharacteristic(UUID.fromString("3dda000" + i + "-957f-7d4a-34a6-74696673696d")), true);
builder builder
.read(getCharacteristic(UUID.fromString("00002a19-0000-1000-8000-00805f9b34fb")))
.read(getCharacteristic(UUID.fromString("00002a26-0000-1000-8000-00805f9b34fb"))) .read(getCharacteristic(UUID.fromString("00002a26-0000-1000-8000-00805f9b34fb")))
.read(getCharacteristic(UUID.fromString("00002a24-0000-1000-8000-00805f9b34fb"))) .read(getCharacteristic(UUID.fromString("00002a24-0000-1000-8000-00805f9b34fb")))
; ;
@ -291,7 +292,7 @@ public class QHybridSupport extends QHybridBaseSupport {
showNotificationsByAllActive(true); showNotificationsByAllActive(true);
} }
private void showNotificationsByAllActive(boolean enforceByNotification) { private void showNotificationsByAllActive(boolean enforceByNotification) {
if (!this.useActivityHand) return; if (!this.useActivityHand) return;
double progress = calculateNotificationProgress(); double progress = calculateNotificationProgress();
showNotificationCountOnActivityHand(progress); showNotificationCountOnActivityHand(progress);
@ -448,7 +449,7 @@ public class QHybridSupport extends QHybridBaseSupport {
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Exception Report"); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Exception Report");
emailIntent.putExtra(Intent.EXTRA_TEXT, "Here's a crash from your stupid app: \n\n" + sStackTrace); emailIntent.putExtra(Intent.EXTRA_TEXT, "Here's a crash from your stupid app: \n\n" + sStackTrace);
PendingIntent intent = PendingIntent.getActivity(getContext(), 0, emailIntent, 0); PendingIntent intent = PendingIntent.getActivity(getContext(), 0, emailIntent, PendingIntent.FLAG_UPDATE_CURRENT);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
notificationBuilder.addAction(new Notification.Action(0, "report", intent)); notificationBuilder.addAction(new Notification.Action(0, "report", intent));

View File

@ -38,7 +38,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.GB;
public class FossilWatchAdapter extends WatchAdapter { public class FossilWatchAdapter extends WatchAdapter {
private ArrayList<Request> requestQueue = new ArrayList<>(); private ArrayList<Request> requestQueue = new ArrayList<>();
FossilRequest fossilRequest; private FossilRequest fossilRequest;
public FossilWatchAdapter(QHybridSupport deviceSupport) { public FossilWatchAdapter(QHybridSupport deviceSupport) {
super(deviceSupport); super(deviceSupport);
@ -167,7 +167,6 @@ public class FossilWatchAdapter extends WatchAdapter {
getDeviceSupport().getDevice().setState(GBDevice.State.NOT_CONNECTED); getDeviceSupport().getDevice().setState(GBDevice.State.NOT_CONNECTED);
getDeviceSupport().getDevice().sendDeviceUpdateIntent(getContext()); getDeviceSupport().getDevice().sendDeviceUpdateIntent(getContext());
throw new RuntimeException("Error uploading notification settings");
} }
getDeviceSupport().getDevice().setState(GBDevice.State.INITIALIZED); getDeviceSupport().getDevice().setState(GBDevice.State.INITIALIZED);
@ -263,8 +262,8 @@ public class FossilWatchAdapter extends WatchAdapter {
} }
} }
try { try {
queueWrite(requestQueue.remove(requestQueue.size() - 1)); queueWrite(requestQueue.remove(0));
} catch (ArrayIndexOutOfBoundsException e) { } catch (IndexOutOfBoundsException e) {
log("requestsQueue empty"); log("requestsQueue empty");
} }
} }
@ -283,12 +282,12 @@ public class FossilWatchAdapter extends WatchAdapter {
public void queueWrite(Request request, boolean priorise) { public void queueWrite(Request request, boolean priorise) {
if (request.isBasicRequest()) { if (request.isBasicRequest()) {
try { try {
queueWrite(requestQueue.remove(requestQueue.size() - 1)); queueWrite(requestQueue.remove(0));
} catch (ArrayIndexOutOfBoundsException e) { } catch (IndexOutOfBoundsException e) {
} }
} else { } else {
if (fossilRequest != null) { if (fossilRequest != null) {
Log.d("requestQueue", "queing request: " + request.getName()); log( "queing request: " + request.getName());
if(priorise){ if(priorise){
requestQueue.add(0, request); requestQueue.add(0, request);
}else { }else {
@ -296,7 +295,7 @@ public class FossilWatchAdapter extends WatchAdapter {
} }
return; return;
} }
Log.d("requestQueue", "executing request: " + request.getName()); log("executing request: " + request.getName());
if (request instanceof FossilRequest) this.fossilRequest = (FossilRequest) request; if (request instanceof FossilRequest) this.fossilRequest = (FossilRequest) request;
} }

View File

@ -161,6 +161,8 @@ public class FilePutRequest extends FossilRequest {
break; break;
} }
case 9: { case 9: {
throw new RuntimeException("file put timeout");
/*timeout = true;
ByteBuffer buffer2 = ByteBuffer.allocate(3); ByteBuffer buffer2 = ByteBuffer.allocate(3);
buffer2.order(ByteOrder.LITTLE_ENDIAN); buffer2.order(ByteOrder.LITTLE_ENDIAN);
buffer2.put((byte) 4); buffer2.put((byte) 4);
@ -174,7 +176,7 @@ public class FilePutRequest extends FossilRequest {
.queue(adapter.getDeviceSupport().getQueue()); .queue(adapter.getDeviceSupport().getQueue());
this.state = UploadState.CLOSING; this.state = UploadState.CLOSING;
break; break;*/
} }
} }
} }