diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/AbstractBTDeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/AbstractBTDeviceSupport.java index 6d28ce75f..201a43c17 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/AbstractBTDeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/AbstractBTDeviceSupport.java @@ -116,4 +116,9 @@ public abstract class AbstractBTDeviceSupport extends AbstractDeviceSupport { byte[] bytes = gbDeviceProtocol.encodePhoneVersion(os); sendToDevice(bytes); } + + public void onReboot() { + byte[] bytes = gbDeviceProtocol.encodeReboot(); + sendToDevice(bytes); + } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/BluetoothCommunicationService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/BluetoothCommunicationService.java index d18e3040f..fad3f2ec4 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/BluetoothCommunicationService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/BluetoothCommunicationService.java @@ -53,6 +53,7 @@ public class BluetoothCommunicationService extends Service { = "nodomain.freeyourgadget.gadgetbride.bluetoothcommunicationservice.action.deleteapp"; public static final String ACTION_INSTALL_PEBBLEAPP = "nodomain.freeyourgadget.gadgetbride.bluetoothcommunicationservice.action.install_pebbbleapp"; + public static final String ACTION_REBOOT = "nodomain.freeyourgadget.gadgetbride.bluetoothcommunicationservice.action.reboot"; public static final String EXTRA_PERFORM_PAIR = "perform_pair"; private static final Logger LOG = LoggerFactory.getLogger(BluetoothCommunicationService.class); @@ -191,6 +192,10 @@ public class BluetoothCommunicationService extends Service { mDeviceSupport.onEmail(sender, subject, body); break; } + case ACTION_REBOOT: { + mDeviceSupport.onReboot(); + break; + } case ACTION_CALLSTATE: GBCommand command = GBCommand.values()[intent.getIntExtra("call_command", 0)]; // UGLY diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/DebugActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/DebugActivity.java index 398a8df35..d52beb670 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/DebugActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/DebugActivity.java @@ -25,6 +25,7 @@ public class DebugActivity extends Activity { Button testNotificationButton; Button setMusicInfoButton; Button setTimeButton; + Button rebootButton; EditText editContent; private BroadcastReceiver mReceiver = new BroadcastReceiver() { @@ -113,6 +114,16 @@ public class DebugActivity extends Activity { } }); + rebootButton = (Button) findViewById(R.id.rebootButton); + rebootButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent startIntent = new Intent(DebugActivity.this, BluetoothCommunicationService.class); + startIntent.setAction(BluetoothCommunicationService.ACTION_REBOOT); + startService(startIntent); + } + }); + setMusicInfoButton = (Button) findViewById(R.id.setMusicInfoButton); setMusicInfoButton.setOnClickListener(new View.OnClickListener() { @Override diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/EventHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/EventHandler.java index 842ba3e78..ca10b8aed 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/EventHandler.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/EventHandler.java @@ -22,4 +22,6 @@ public interface EventHandler { void onAppDelete(int id, int index); void onPhoneVersion(byte os); + + void onReboot(); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/protocol/GBDeviceProtocol.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/protocol/GBDeviceProtocol.java index 752fb5978..47976fe80 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/protocol/GBDeviceProtocol.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/protocol/GBDeviceProtocol.java @@ -48,7 +48,7 @@ public abstract class GBDeviceProtocol { return null; } - public GBDeviceCommand decodeResponse(byte[] responseData) { - return null; - } + public byte[] encodeReboot() { return null; } + + public GBDeviceCommand decodeResponse(byte[] responseData) { return null; } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_debug.xml b/app/src/main/res/layout/activity_debug.xml index 5b28619d1..49353c518 100644 --- a/app/src/main/res/layout/activity_debug.xml +++ b/app/src/main/res/layout/activity_debug.xml @@ -100,4 +100,13 @@ android:layout_alignParentStart="true" android:layout_alignEnd="@+id/endCallButton" /> +