mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-12 10:55:49 +01:00
Pebble: make disabling of appmessage handlers more generic
Also disable morpheuz handler if morpheuz is not the chosen activity tracker .... and bump reported version to 3.12 to match the latest pebble release
This commit is contained in:
parent
321707af8f
commit
9d3f3c57cd
@ -17,6 +17,10 @@ public class AppMessageHandler {
|
||||
mPebbleProtocol = pebbleProtocol;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public UUID getUUID() {
|
||||
return mUUID;
|
||||
}
|
||||
|
@ -43,7 +43,8 @@ public class AppMessageHandlerMisfit extends AppMessageHandler {
|
||||
|
||||
private final MisfitSampleProvider sampleProvider = new MisfitSampleProvider();
|
||||
|
||||
private boolean isMisfitEnabled() {
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
Prefs prefs = GBApplication.getPrefs();
|
||||
int activityTracker = prefs.getInt("pebble_activitytracker", SampleProvider.PROVIDER_PEBBLE_HEALTH);
|
||||
return (activityTracker == SampleProvider.PROVIDER_PEBBLE_MISFIT);
|
||||
@ -51,11 +52,6 @@ public class AppMessageHandlerMisfit extends AppMessageHandler {
|
||||
|
||||
@Override
|
||||
public GBDeviceEvent[] handleMessage(ArrayList<Pair<Integer, Object>> pairs) {
|
||||
|
||||
if (!isMisfitEnabled()) {
|
||||
return new GBDeviceEvent[] {null};
|
||||
}
|
||||
|
||||
for (Pair<Integer, Object> pair : pairs) {
|
||||
switch (pair.first) {
|
||||
case KEY_INCOMING_DATA_BEGIN:
|
||||
|
@ -18,6 +18,7 @@ import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSendBytes;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSleepMonitorResult;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.pebble.MorpheuzSampleProvider;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
|
||||
public class AppMessageHandlerMorpheuz extends AppMessageHandler {
|
||||
|
||||
@ -56,6 +57,13 @@ public class AppMessageHandlerMorpheuz extends AppMessageHandler {
|
||||
return mPebbleProtocol.encodeApplicationMessagePush(PebbleProtocol.ENDPOINT_APPLICATIONMESSAGE, mUUID, pairs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
Prefs prefs = GBApplication.getPrefs();
|
||||
int activityTracker = prefs.getInt("pebble_activitytracker", SampleProvider.PROVIDER_PEBBLE_HEALTH);
|
||||
return (activityTracker == SampleProvider.PROVIDER_PEBBLE_MORPHEUZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GBDeviceEvent[] handleMessage(ArrayList<Pair<Integer, Object>> pairs) {
|
||||
int ctrl_message = 0;
|
||||
|
@ -1258,10 +1258,10 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||
|
||||
buf.put(PHONEVERSION_APPVERSION_MAGIC);
|
||||
buf.put((byte) 3); // major
|
||||
buf.put((byte) 8); // minor
|
||||
buf.put((byte) 1); // patch
|
||||
buf.put((byte) 12); // minor
|
||||
buf.put((byte) 0); // patch
|
||||
buf.order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putLong(0x00000000000000af); //flags
|
||||
buf.putLong(0x00000000000001af); //flags
|
||||
|
||||
return buf.array();
|
||||
}
|
||||
@ -2116,8 +2116,12 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||
|
||||
AppMessageHandler handler = mAppMessageHandlers.get(uuid);
|
||||
if (handler != null) {
|
||||
ArrayList<Pair<Integer, Object>> dict = decodeDict(buf);
|
||||
devEvts = handler.handleMessage(dict);
|
||||
if (handler.isEnabled()) {
|
||||
ArrayList<Pair<Integer, Object>> dict = decodeDict(buf);
|
||||
devEvts = handler.handleMessage(dict);
|
||||
} else {
|
||||
devEvts = new GBDeviceEvent[]{null};
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
devEvts = decodeDictToJSONAppMessage(uuid, buf);
|
||||
|
Loading…
x
Reference in New Issue
Block a user