Fossil HR: Implement Find Phone

There is still no acknowledgement, so if the watch gets a timeout it cant stop the phone from ringing anymore.

If you stop ringing from the watch during before the timeout hits, stopping works...
This commit is contained in:
Andreas Shimokawa 2020-01-29 19:44:54 +01:00
parent 23f4752296
commit 0a4d8499fa

View File

@ -26,6 +26,7 @@ import java.util.Iterator;
import java.util.TimeZone; import java.util.TimeZone;
import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventFindPhone;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl;
import nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.HRConfigActivity; import nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.HRConfigActivity;
import nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.NotificationHRConfiguration; import nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.NotificationHRConfiguration;
@ -535,26 +536,43 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
handleMusicRequest(value); handleMusicRequest(value);
} else if (requestType == (byte) 0x01) { } else if (requestType == (byte) 0x01) {
int eventId = value[2]; int eventId = value[2];
logger.info("got event id " + eventId);
try { try {
JSONObject requestJson = new JSONObject(new String(value, 3, value.length - 3)); String jsonString = new String(value, 3, value.length - 3);
logger.info(jsonString);
JSONObject requestJson = new JSONObject(jsonString);
String action = requestJson.getJSONObject("req").getJSONObject("commuteApp._.config.commute_info") if (requestJson.getJSONObject("req").has("ringMyPhone")) {
.getString("dest"); String action = requestJson.getJSONObject("req").getJSONObject("ringMyPhone").getString("action");
logger.info("got ringMyPhone request; " + action);
String startStop = requestJson.getJSONObject("req").getJSONObject("commuteApp._.config.commute_info") GBDeviceEventFindPhone findPhoneEvent = new GBDeviceEventFindPhone();
.getString("action"); if ("on".equals(action)) {
findPhoneEvent.event = GBDeviceEventFindPhone.Event.START;
if (startStop.equals("stop")) { getDeviceSupport().evaluateGBDeviceEvent(findPhoneEvent);
// overwriteButtons(null); }
return; else if ("off".equals(action)) {
findPhoneEvent.event = GBDeviceEventFindPhone.Event.STOP;
getDeviceSupport().evaluateGBDeviceEvent(findPhoneEvent);
}
} }
else {
String action = requestJson.getJSONObject("req").getJSONObject("commuteApp._.config.commute_info")
.getString("dest");
queueWrite(new SetCommuteMenuMessage("Anfrage wird weitergeleitet...", false, this)); String startStop = requestJson.getJSONObject("req").getJSONObject("commuteApp._.config.commute_info")
.getString("action");
Intent menuIntent = new Intent(QHybridSupport.QHYBRID_EVENT_COMMUTE_MENU); if (startStop.equals("stop")) {
menuIntent.putExtra("EXTRA_ACTION", action); // overwriteButtons(null);
getContext().sendBroadcast(menuIntent); return;
}
queueWrite(new SetCommuteMenuMessage("Anfrage wird weitergeleitet...", false, this));
Intent menuIntent = new Intent(QHybridSupport.QHYBRID_EVENT_COMMUTE_MENU);
menuIntent.putExtra("EXTRA_ACTION", action);
getContext().sendBroadcast(menuIntent);
}
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }