1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-26 02:25:50 +01:00

Initial support for rebooting the device

(via the Debug activity)
Attention: no safety-confirmation dialog yet!
This commit is contained in:
cpfeiffer 2015-05-17 21:58:08 +02:00
parent 9819819b92
commit 14a05c3383
6 changed files with 35 additions and 3 deletions

View File

@ -116,4 +116,9 @@ public abstract class AbstractBTDeviceSupport extends AbstractDeviceSupport {
byte[] bytes = gbDeviceProtocol.encodePhoneVersion(os); byte[] bytes = gbDeviceProtocol.encodePhoneVersion(os);
sendToDevice(bytes); sendToDevice(bytes);
} }
public void onReboot() {
byte[] bytes = gbDeviceProtocol.encodeReboot();
sendToDevice(bytes);
}
} }

View File

@ -53,6 +53,7 @@ public class BluetoothCommunicationService extends Service {
= "nodomain.freeyourgadget.gadgetbride.bluetoothcommunicationservice.action.deleteapp"; = "nodomain.freeyourgadget.gadgetbride.bluetoothcommunicationservice.action.deleteapp";
public static final String ACTION_INSTALL_PEBBLEAPP public static final String ACTION_INSTALL_PEBBLEAPP
= "nodomain.freeyourgadget.gadgetbride.bluetoothcommunicationservice.action.install_pebbbleapp"; = "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"; public static final String EXTRA_PERFORM_PAIR = "perform_pair";
private static final Logger LOG = LoggerFactory.getLogger(BluetoothCommunicationService.class); private static final Logger LOG = LoggerFactory.getLogger(BluetoothCommunicationService.class);
@ -191,6 +192,10 @@ public class BluetoothCommunicationService extends Service {
mDeviceSupport.onEmail(sender, subject, body); mDeviceSupport.onEmail(sender, subject, body);
break; break;
} }
case ACTION_REBOOT: {
mDeviceSupport.onReboot();
break;
}
case ACTION_CALLSTATE: case ACTION_CALLSTATE:
GBCommand command = GBCommand.values()[intent.getIntExtra("call_command", 0)]; // UGLY GBCommand command = GBCommand.values()[intent.getIntExtra("call_command", 0)]; // UGLY

View File

@ -25,6 +25,7 @@ public class DebugActivity extends Activity {
Button testNotificationButton; Button testNotificationButton;
Button setMusicInfoButton; Button setMusicInfoButton;
Button setTimeButton; Button setTimeButton;
Button rebootButton;
EditText editContent; EditText editContent;
private BroadcastReceiver mReceiver = new BroadcastReceiver() { 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 = (Button) findViewById(R.id.setMusicInfoButton);
setMusicInfoButton.setOnClickListener(new View.OnClickListener() { setMusicInfoButton.setOnClickListener(new View.OnClickListener() {
@Override @Override

View File

@ -22,4 +22,6 @@ public interface EventHandler {
void onAppDelete(int id, int index); void onAppDelete(int id, int index);
void onPhoneVersion(byte os); void onPhoneVersion(byte os);
void onReboot();
} }

View File

@ -48,7 +48,7 @@ public abstract class GBDeviceProtocol {
return null; return null;
} }
public GBDeviceCommand decodeResponse(byte[] responseData) { public byte[] encodeReboot() { return null; }
return null;
} public GBDeviceCommand decodeResponse(byte[] responseData) { return null; }
} }

View File

@ -100,4 +100,13 @@
android:layout_alignParentStart="true" android:layout_alignParentStart="true"
android:layout_alignEnd="@+id/endCallButton" /> android:layout_alignEnd="@+id/endCallButton" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="reboot"
android:id="@+id/rebootButton"
android:layout_above="@+id/setTimeButton"
android:layout_alignParentStart="true"
android:layout_alignEnd="@+id/endCallButton" />
</RelativeLayout> </RelativeLayout>