From f1034f94b3776c2a81bd16674de62ff4225bb86c Mon Sep 17 00:00:00 2001 From: Daniel Dakhno Date: Wed, 14 Oct 2020 02:00:43 +0200 Subject: [PATCH] Fossil Hybrid: send response to app events --- .../fossil_hr/FossilHRWatchAdapter.java | 3 ++ .../async/ConfirmAppStatusRequest.java | 32 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/async/ConfirmAppStatusRequest.java diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java index 63c73f73a..4d6e841a9 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java @@ -70,6 +70,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fos import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.file.FileLookupRequest; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.notification.PlayCallNotificationRequest; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.notification.PlayTextNotificationRequest; +import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.async.ConfirmAppStatusRequest; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.authentication.VerifyPrivateKeyRequest; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.buttons.ButtonConfiguration; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.buttons.ButtonConfigurationPutRequest; @@ -1076,6 +1077,8 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter { Intent menuIntent = new Intent(QHybridSupport.QHYBRID_EVENT_COMMUTE_MENU); menuIntent.putExtra("EXTRA_ACTION", action); getContext().sendBroadcast(menuIntent); + } else if (request.has("master._.config.app_status")) { + queueWrite(new ConfirmAppStatusRequest(requestId, this)); } else { logger.warn("Unhandled request from watch: " + requestJson.toString()); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/async/ConfirmAppStatusRequest.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/async/ConfirmAppStatusRequest.java new file mode 100644 index 000000000..2de096345 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/async/ConfirmAppStatusRequest.java @@ -0,0 +1,32 @@ +package nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.async; + +import org.json.JSONException; +import org.json.JSONObject; + +import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.fossil_hr.FossilHRWatchAdapter; +import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.json.JsonPutRequest; + +public class ConfirmAppStatusRequest extends JsonPutRequest { + public ConfirmAppStatusRequest(int requestId, FossilHRWatchAdapter adapter) { + super(createResponseObject(requestId), adapter); + } + + private static JSONObject createResponseObject(int requestId){ + try { + return new JSONObject() + .put("res", + new JSONObject() + .put("id", requestId) + .put("set", new JSONObject() + .put("master._.config.app_status", new JSONObject() + .put("message", "") + .put("type", "success") + ) + ) + ); + } catch (JSONException e) { + e.printStackTrace(); + } + return null; + } +}