Initial support for rebooting the device

(via the Debug activity)
Attention: no safety-confirmation dialog yet!
live-sensor-data
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);
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";
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

View File

@ -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

View File

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

View File

@ -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; }
}

View File

@ -100,4 +100,13 @@
android:layout_alignParentStart="true"
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>