switch (msg.what) {
case MSG_REGISTER_CLIENT:
s.mClients.add(msg.replyTo);
+ try {
+ msg.replyTo.send(Message.obtain(null, AltosDroid.MSG_STATE_CHANGE, s.state, -1));
+ } catch (RemoteException e) {
+ s.mClients.remove(msg.replyTo);
+ }
if (D) Log.d(TAG, "Client bound to service");
break;
case MSG_UNREGISTER_CLIENT:
}
}
+ private void sendMessageToClients(Message m) {
+ for (int i=mClients.size()-1; i>=0; i--) {
+ try {
+ mClients.get(i).send(m);
+ } catch (RemoteException e) {
+ mClients.remove(i);
+ }
+ }
+ }
+
private void stopAltosBluetooth() {
+ if (D) Log.i(TAG, "Stopping BT");
setState(STATE_READY);
if (mAltosBluetooth != null) {
+ if (D) Log.i(TAG, "Closing AltosBluetooth");
mAltosBluetooth.close();
mAltosBluetooth = null;
}
}
private void startAltosBluetooth(BluetoothDevice d) {
+ if (D) Log.i(TAG, "Connecting to " + d.getName());
mAltosBluetooth = new AltosBluetooth(d, mHandler);
setState(STATE_CONNECTING);
}