Add event "test new function" for the debug screen

This commit is contained in:
cpfeiffer 2016-10-11 23:06:59 +02:00
parent b1dcb997bb
commit 713989ef38
12 changed files with 51 additions and 2 deletions

View File

@ -66,4 +66,6 @@ public interface EventHandler {
void onAddCalendarEvent(CalendarEventSpec calendarEventSpec);
void onDeleteCalendarEvent(byte type, long id);
void onTestNewFunction();
}

View File

@ -280,4 +280,10 @@ public class GBDeviceService implements DeviceService {
.putExtra(EXTRA_CALENDAREVENT_ID, id);
invokeService(intent);
}
@Override
public void onTestNewFunction() {
Intent intent = createIntent().setAction(ACTION_TEST_NEW_FUNCTION);
invokeService(intent);
}
}

View File

@ -48,6 +48,7 @@ public interface DeviceService extends EventHandler {
String ACTION_HEARTRATE_MEASUREMENT = PREFIX + ".action.hr_measurement";
String ACTION_ADD_CALENDAREVENT = PREFIX + ".action.add_calendarevent";
String ACTION_DELETE_CALENDAREVENT = PREFIX + ".action.delete_calendarevent";
String ACTION_TEST_NEW_FUNCTION = PREFIX + ".action.test_new_function";
String EXTRA_DEVICE_ADDRESS = "device_address";
String EXTRA_NOTIFICATION_BODY = "notification_body";
String EXTRA_NOTIFICATION_FLAGS = "notification_flags";

View File

@ -80,6 +80,7 @@ import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SE
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SET_CONSTANT_VIBRATION;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_START;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_STARTAPP;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_TEST_NEW_FUNCTION;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_ALARMS;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_APP_CONFIG;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_APP_START;
@ -484,6 +485,10 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
mDeviceSupport.onEnableRealtimeHeartRateMeasurement(enable);
break;
}
case ACTION_TEST_NEW_FUNCTION: {
mDeviceSupport.onTestNewFunction();
break;
}
}
return START_STICKY;

View File

@ -319,4 +319,12 @@ public class ServiceDeviceSupport implements DeviceSupport {
}
delegate.onDeleteCalendarEvent(type, id);
}
@Override
public void onTestNewFunction() {
if (checkBusy("test new function event")) {
return;
}
delegate.onTestNewFunction();
}
}

View File

@ -1206,5 +1206,7 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
}
}
@Override
public void onTestNewFunction() {
}
}

View File

@ -1212,5 +1212,7 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
}
}
@Override
public void onTestNewFunction() {
}
}

View File

@ -147,4 +147,11 @@ public class PebbleSupport extends AbstractSerialDeviceSupport {
super.onDeleteCalendarEvent(type, id);
}
}
@Override
public void onTestNewFunction() {
if (reconnect()) {
super.onTestNewFunction();
}
}
}

View File

@ -269,7 +269,10 @@ public class VibratissimoSupport extends AbstractBTLEDeviceSupport {
LOG.info("Unhandled characteristic read: " + characteristicUUID);
return false;
}
@Override
public void onTestNewFunction() {
}
}

View File

@ -214,4 +214,10 @@ public abstract class AbstractSerialDeviceSupport extends AbstractDeviceSupport
byte[] bytes = gbDeviceProtocol.encodeDeleteCalendarEvent(type, id);
sendToDevice(bytes);
}
@Override
public void onTestNewFunction() {
byte[] bytes = gbDeviceProtocol.encodeTestNewFunction();
sendToDevice(bytes);
}
}

View File

@ -94,6 +94,8 @@ public abstract class GBDeviceProtocol {
return null;
}
public byte[] encodeTestNewFunction() { return null; }
public GBDeviceEvent[] decodeResponse(byte[] responseData) {
return null;
}

View File

@ -167,4 +167,9 @@ public class TestDeviceSupport extends AbstractDeviceSupport {
public void onEnableRealtimeHeartRateMeasurement(boolean enable) {
}
@Override
public void onTestNewFunction() {
}
}