From 95b65265b4dc315654e0ca82af0fd5c28a819ba6 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Mon, 31 Aug 2015 17:25:58 +0200 Subject: [PATCH] remove eventClass field from GBDeviceEvent, use instanceof instead --- .../deviceevents/GBDeviceEvent.java | 14 -- .../deviceevents/GBDeviceEventAppInfo.java | 4 - .../GBDeviceEventAppManagement.java | 4 - .../GBDeviceEventBatteryInfo.java | 6 +- .../GBDeviceEventCallControl.java | 4 - .../GBDeviceEventDismissNotification.java | 4 - .../GBDeviceEventMusicControl.java | 4 - .../deviceevents/GBDeviceEventScreenshot.java | 4 - .../deviceevents/GBDeviceEventSendBytes.java | 4 - .../GBDeviceEventSleepMonitorResult.java | 4 - .../GBDeviceEventVersionInfo.java | 4 - .../service/AbstractDeviceSupport.java | 63 ++++---- .../devices/pebble/PebbleIoThread.java | 145 +++++++++--------- .../serial/AbstractSerialDeviceSupport.java | 11 +- 14 files changed, 102 insertions(+), 173 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEvent.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEvent.java index 5a8246a78..6c4211693 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEvent.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEvent.java @@ -2,20 +2,6 @@ package nodomain.freeyourgadget.gadgetbridge.deviceevents; public abstract class GBDeviceEvent { - public EventClass eventClass = EventClass.UNKNOWN; - public enum EventClass { - UNKNOWN, - MUSIC_CONTROL, - CALL_CONTROL, - APP_INFO, - VERSION_INFO, - APP_MANAGEMENT, - SEND_BYTES, - SLEEP_MONITOR_RES, - SCREENSHOT, - DISMISS_NOTIFICATION, - BATTERY_INFO - } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventAppInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventAppInfo.java index 0340763c9..2772693b5 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventAppInfo.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventAppInfo.java @@ -5,8 +5,4 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceApp; public class GBDeviceEventAppInfo extends GBDeviceEvent { public GBDeviceApp apps[]; public byte freeSlot = -1; - - public GBDeviceEventAppInfo() { - eventClass = EventClass.APP_INFO; - } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventAppManagement.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventAppManagement.java index fe5281f3d..99850c5ff 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventAppManagement.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventAppManagement.java @@ -8,10 +8,6 @@ public class GBDeviceEventAppManagement extends GBDeviceEvent { public int token = -1; public UUID uuid = null; - public GBDeviceEventAppManagement() { - eventClass = EventClass.APP_MANAGEMENT; - } - public enum EventType { UNKNOWN, INSTALL, diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventBatteryInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventBatteryInfo.java index 9371000dc..06eaa4047 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventBatteryInfo.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventBatteryInfo.java @@ -6,15 +6,11 @@ import java.util.GregorianCalendar; import nodomain.freeyourgadget.gadgetbridge.model.BatteryState; public class GBDeviceEventBatteryInfo extends GBDeviceEvent { - public GregorianCalendar lastChargeTime= null; + public GregorianCalendar lastChargeTime = null; public BatteryState state = BatteryState.UNKNOWN; public short level = 50; public int numCharges = -1; - public GBDeviceEventBatteryInfo() { - eventClass = EventClass.BATTERY_INFO; - } - public boolean extendedInfoAvailable() { if (numCharges != -1 && lastChargeTime != null) { return true; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventCallControl.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventCallControl.java index 6699dc1df..7739c4424 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventCallControl.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventCallControl.java @@ -4,10 +4,6 @@ package nodomain.freeyourgadget.gadgetbridge.deviceevents; public class GBDeviceEventCallControl extends GBDeviceEvent { public Event event = Event.UNKNOWN; - public GBDeviceEventCallControl() { - eventClass = EventClass.CALL_CONTROL; - } - public enum Event { UNKNOWN, ACCEPT, diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventDismissNotification.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventDismissNotification.java index 5688ad703..3a4111219 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventDismissNotification.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventDismissNotification.java @@ -2,8 +2,4 @@ package nodomain.freeyourgadget.gadgetbridge.deviceevents; public class GBDeviceEventDismissNotification extends GBDeviceEvent { public int notificationID; - - public GBDeviceEventDismissNotification() { - eventClass = EventClass.DISMISS_NOTIFICATION; - } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventMusicControl.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventMusicControl.java index f0c21b1dc..cdf987a07 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventMusicControl.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventMusicControl.java @@ -4,10 +4,6 @@ package nodomain.freeyourgadget.gadgetbridge.deviceevents; public class GBDeviceEventMusicControl extends GBDeviceEvent { public Event event = Event.UNKNOWN; - public GBDeviceEventMusicControl() { - eventClass = EventClass.MUSIC_CONTROL; - } - public enum Event { UNKNOWN, PLAY, diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventScreenshot.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventScreenshot.java index 4c75060f0..208fdb5a5 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventScreenshot.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventScreenshot.java @@ -6,8 +6,4 @@ public class GBDeviceEventScreenshot extends GBDeviceEvent { public byte bpp; public byte[] clut; public byte[] data; - - public GBDeviceEventScreenshot() { - eventClass = EventClass.SCREENSHOT; - } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventSendBytes.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventSendBytes.java index 689dac466..2ac3741a3 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventSendBytes.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventSendBytes.java @@ -2,8 +2,4 @@ package nodomain.freeyourgadget.gadgetbridge.deviceevents; public class GBDeviceEventSendBytes extends GBDeviceEvent { public byte[] encodedBytes; - - public GBDeviceEventSendBytes() { - eventClass = EventClass.SEND_BYTES; - } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventSleepMonitorResult.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventSleepMonitorResult.java index 41c3bba64..8a99b0336 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventSleepMonitorResult.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventSleepMonitorResult.java @@ -6,8 +6,4 @@ public class GBDeviceEventSleepMonitorResult extends GBDeviceEvent { public int smartalarm_to = -1;// time in minutes relative from 0:00 for smart alarm (latest) public int recording_base_timestamp = -1; // timestamp for the first "point", all folowing are +10 minutes offset each public int alarm_gone_off = -1; // time in minutes relative from 0:00 when alarm gone off - - public GBDeviceEventSleepMonitorResult() { - eventClass = EventClass.SLEEP_MONITOR_RES; - } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventVersionInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventVersionInfo.java index 18b242391..6ebfac165 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventVersionInfo.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventVersionInfo.java @@ -6,8 +6,4 @@ import nodomain.freeyourgadget.gadgetbridge.R; public class GBDeviceEventVersionInfo extends GBDeviceEvent { public String fwVersion = GBApplication.getContext().getString(R.string.n_a); public String hwVersion = GBApplication.getContext().getString(R.string.n_a); - - public GBDeviceEventVersionInfo() { - eventClass = EventClass.VERSION_INFO; - } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/AbstractDeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/AbstractDeviceSupport.java index bc4b40a0e..8242ddff4 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/AbstractDeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/AbstractDeviceSupport.java @@ -19,17 +19,12 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; +import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.activities.AppManagerActivity; import nodomain.freeyourgadget.gadgetbridge.activities.charts.ChartsHost; -import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo; -import nodomain.freeyourgadget.gadgetbridge.model.BatteryState; -import nodomain.freeyourgadget.gadgetbridge.util.GB; -import nodomain.freeyourgadget.gadgetbridge.service.receivers.GBCallControlReceiver; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.service.receivers.GBMusicControlReceiver; -import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventAppInfo; +import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventDismissNotification; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl; @@ -37,6 +32,11 @@ import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventScreenshot import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSleepMonitorResult; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo; import nodomain.freeyourgadget.gadgetbridge.externalevents.NotificationListener; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; +import nodomain.freeyourgadget.gadgetbridge.model.BatteryState; +import nodomain.freeyourgadget.gadgetbridge.service.receivers.GBCallControlReceiver; +import nodomain.freeyourgadget.gadgetbridge.service.receivers.GBMusicControlReceiver; +import nodomain.freeyourgadget.gadgetbridge.util.GB; // TODO: support option for a single reminder notification when notifications could not be delivered? // conditions: app was running and received notifications, but device was not connected. @@ -68,6 +68,7 @@ public abstract class AbstractDeviceSupport implements DeviceSupport { /** * Returns true if the device is not only connected, but also * initialized. + * * @see GBDevice#isInitialized() */ protected boolean isInitialized() { @@ -90,34 +91,22 @@ public abstract class AbstractDeviceSupport implements DeviceSupport { } public void evaluateGBDeviceEvent(GBDeviceEvent deviceEvent) { - - switch (deviceEvent.eventClass) { - case MUSIC_CONTROL: - handleGBDeviceEvent((GBDeviceEventMusicControl) deviceEvent); - break; - case CALL_CONTROL: - handleGBDeviceEvent((GBDeviceEventCallControl) deviceEvent); - break; - case VERSION_INFO: - handleGBDeviceEvent((GBDeviceEventVersionInfo) deviceEvent); - break; - case APP_INFO: - handleGBDeviceEvent((GBDeviceEventAppInfo) deviceEvent); - break; - case SLEEP_MONITOR_RES: - handleGBDeviceEvent((GBDeviceEventSleepMonitorResult) deviceEvent); - break; - case SCREENSHOT: - handleGBDeviceEvent((GBDeviceEventScreenshot) deviceEvent); - break; - case DISMISS_NOTIFICATION: - handleGBDeviceEvent((GBDeviceEventDismissNotification) deviceEvent); - break; - case BATTERY_INFO: - handleGBDeviceEvent((GBDeviceEventBatteryInfo) deviceEvent); - break; - default: - break; + if (deviceEvent instanceof GBDeviceEventMusicControl) { + handleGBDeviceEvent((GBDeviceEventMusicControl) deviceEvent); + } else if (deviceEvent instanceof GBDeviceEventCallControl) { + handleGBDeviceEvent((GBDeviceEventCallControl) deviceEvent); + } else if (deviceEvent instanceof GBDeviceEventVersionInfo) { + handleGBDeviceEvent((GBDeviceEventVersionInfo) deviceEvent); + } else if (deviceEvent instanceof GBDeviceEventAppInfo) { + handleGBDeviceEvent((GBDeviceEventAppInfo) deviceEvent); + } else if (deviceEvent instanceof GBDeviceEventSleepMonitorResult) { + handleGBDeviceEvent((GBDeviceEventSleepMonitorResult) deviceEvent); + } else if (deviceEvent instanceof GBDeviceEventScreenshot) { + handleGBDeviceEvent((GBDeviceEventScreenshot) deviceEvent); + } else if (deviceEvent instanceof GBDeviceEventDismissNotification) { + handleGBDeviceEvent((GBDeviceEventDismissNotification) deviceEvent); + } else if (deviceEvent instanceof GBDeviceEventBatteryInfo) { + handleGBDeviceEvent((GBDeviceEventBatteryInfo) deviceEvent); } } @@ -239,8 +228,8 @@ public abstract class AbstractDeviceSupport implements DeviceSupport { GB.updateBatteryNotification(context.getString(R.string.notif_battery_low_percent, gbDevice.getName(), deviceEvent.level), deviceEvent.extendedInfoAvailable() ? context.getString(R.string.notif_battery_low_percent, gbDevice.getName(), deviceEvent.level) + "\n" + - context.getString(R.string.notif_battery_low_bigtext_last_charge_time, DateFormat.getDateTimeInstance().format(deviceEvent.lastChargeTime.getTime()).toString()) + - context.getString(R.string.notif_battery_low_bigtext_number_of_charges, deviceEvent.numCharges) + context.getString(R.string.notif_battery_low_bigtext_last_charge_time, DateFormat.getDateTimeInstance().format(deviceEvent.lastChargeTime.getTime()).toString()) + + context.getString(R.string.notif_battery_low_bigtext_number_of_charges, deviceEvent.numCharges) : "" , context); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java index 17958601c..76a71483d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java @@ -26,6 +26,7 @@ import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventAppInfo; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventAppManagement; +import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo; import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PBWReader; import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleInstallable; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; @@ -320,85 +321,83 @@ public class PebbleIoThread extends GBDeviceIoThread { // FIXME: parts are supporsed to be generic code private boolean evaluateGBDeviceEventPebble(GBDeviceEvent deviceEvent) { - switch (deviceEvent.eventClass) { - case VERSION_INFO: - SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getContext()); - if (sharedPrefs.getBoolean("datetime_synconconnect", true)) { - LOG.info("syncing time"); - write(mPebbleProtocol.encodeSetTime()); - } - gbDevice.setState(GBDevice.State.INITIALIZED); - return false; - case APP_MANAGEMENT: - GBDeviceEventAppManagement appMgmt = (GBDeviceEventAppManagement) deviceEvent; - switch (appMgmt.type) { - case DELETE: - // right now on the Pebble we also receive this on a failed/successful installation ;/ - switch (appMgmt.event) { - case FAILURE: - if (mIsInstalling) { - if (mInstallState == PebbleAppInstallState.WAIT_SLOT) { - // get the free slot - writeInstallApp(mPebbleProtocol.encodeAppInfoReq()); - } else { - finishInstall(true); - } + if (deviceEvent instanceof GBDeviceEventVersionInfo) { + SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getContext()); + if (sharedPrefs.getBoolean("datetime_synconconnect", true)) { + LOG.info("syncing time"); + write(mPebbleProtocol.encodeSetTime()); + } + gbDevice.setState(GBDevice.State.INITIALIZED); + return false; + } else if (deviceEvent instanceof GBDeviceEventAppManagement) { + GBDeviceEventAppManagement appMgmt = (GBDeviceEventAppManagement) deviceEvent; + switch (appMgmt.type) { + case DELETE: + // right now on the Pebble we also receive this on a failed/successful installation ;/ + switch (appMgmt.event) { + case FAILURE: + if (mIsInstalling) { + if (mInstallState == PebbleAppInstallState.WAIT_SLOT) { + // get the free slot + writeInstallApp(mPebbleProtocol.encodeAppInfoReq()); } else { - LOG.info("failure removing app"); + finishInstall(true); } - break; - case SUCCESS: - if (mIsInstalling) { - if (mInstallState == PebbleAppInstallState.WAIT_SLOT) { - // get the free slot - writeInstallApp(mPebbleProtocol.encodeAppInfoReq()); - } else { - finishInstall(false); - // refresh app list - write(mPebbleProtocol.encodeAppInfoReq()); - } + } else { + LOG.info("failure removing app"); + } + break; + case SUCCESS: + if (mIsInstalling) { + if (mInstallState == PebbleAppInstallState.WAIT_SLOT) { + // get the free slot + writeInstallApp(mPebbleProtocol.encodeAppInfoReq()); } else { - LOG.info("successfully removed app"); + finishInstall(false); + // refresh app list write(mPebbleProtocol.encodeAppInfoReq()); } - break; - default: - break; - } - break; - case INSTALL: - switch (appMgmt.event) { - case FAILURE: - LOG.info("failure installing app"); // TODO: report to Installer - finishInstall(true); - break; - case SUCCESS: - setToken(appMgmt.token); - break; - case REQUEST: - LOG.info("APPFETCH request: " + appMgmt.uuid + " / " + appMgmt.token); - try { - installApp(Uri.fromFile(new File(FileUtils.getExternalFilesDir() + "/pbw-cache/" + appMgmt.uuid.toString() + ".pbw")), appMgmt.token); - } catch (IOException e) { - e.printStackTrace(); - } - break; - default: - break; - } - break; - default: - break; - } - return true; - case APP_INFO: - LOG.info("Got event for APP_INFO"); - GBDeviceEventAppInfo appInfoEvent = (GBDeviceEventAppInfo) deviceEvent; - setInstallSlot(appInfoEvent.freeSlot); - return false; - default: - return false; + } else { + LOG.info("successfully removed app"); + write(mPebbleProtocol.encodeAppInfoReq()); + } + break; + default: + break; + } + break; + case INSTALL: + switch (appMgmt.event) { + case FAILURE: + LOG.info("failure installing app"); // TODO: report to Installer + finishInstall(true); + break; + case SUCCESS: + setToken(appMgmt.token); + break; + case REQUEST: + LOG.info("APPFETCH request: " + appMgmt.uuid + " / " + appMgmt.token); + try { + installApp(Uri.fromFile(new File(FileUtils.getExternalFilesDir() + "/pbw-cache/" + appMgmt.uuid.toString() + ".pbw")), appMgmt.token); + } catch (IOException e) { + e.printStackTrace(); + } + break; + default: + break; + } + break; + default: + break; + } + return true; + } else if (deviceEvent instanceof GBDeviceEventAppInfo) { + LOG.info("Got event for APP_INFO"); + GBDeviceEventAppInfo appInfoEvent = (GBDeviceEventAppInfo) deviceEvent; + setInstallSlot(appInfoEvent.freeSlot); + return false; } + return false; } public void setToken(int token) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/serial/AbstractSerialDeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/serial/AbstractSerialDeviceSupport.java index 387e8111b..1772a34d8 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/serial/AbstractSerialDeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/serial/AbstractSerialDeviceSupport.java @@ -98,15 +98,10 @@ public abstract class AbstractSerialDeviceSupport extends AbstractDeviceSupport @Override public void evaluateGBDeviceEvent(GBDeviceEvent deviceEvent) { - - switch (deviceEvent.eventClass) { - case SEND_BYTES: - handleGBDeviceEvent((GBDeviceEventSendBytes) deviceEvent); - return; - default: - break; + if (deviceEvent instanceof GBDeviceEventSendBytes) { + handleGBDeviceEvent((GBDeviceEventSendBytes) deviceEvent); + return; } - super.evaluateGBDeviceEvent(deviceEvent); }