Pebble: allow sending acks to pebblekit android apps which always use transaction id -1 (this seems to be okay for pebblekit apps which do not want to use real transaction ids)

This commit is contained in:
Andreas Shimokawa 2016-09-26 21:51:11 +02:00
parent 55a1248e8f
commit 9cccb085c4
1 changed files with 14 additions and 16 deletions

View File

@ -47,7 +47,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.GB;
import nodomain.freeyourgadget.gadgetbridge.util.PebbleUtils; import nodomain.freeyourgadget.gadgetbridge.util.PebbleUtils;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs; import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
public class PebbleIoThread extends GBDeviceIoThread { class PebbleIoThread extends GBDeviceIoThread {
private static final Logger LOG = LoggerFactory.getLogger(PebbleIoThread.class); private static final Logger LOG = LoggerFactory.getLogger(PebbleIoThread.class);
public static final String PEBBLEKIT_ACTION_PEBBLE_CONNECTED = "com.getpebble.action.PEBBLE_CONNECTED"; public static final String PEBBLEKIT_ACTION_PEBBLE_CONNECTED = "com.getpebble.action.PEBBLE_CONNECTED";
@ -144,17 +144,7 @@ public class PebbleIoThread extends GBDeviceIoThread {
getContext().sendBroadcast(intent); getContext().sendBroadcast(intent);
} }
private void sendAppMessageAck(int transactionId) { PebbleIoThread(PebbleSupport pebbleSupport, GBDevice gbDevice, GBDeviceProtocol gbDeviceProtocol, BluetoothAdapter btAdapter, Context context) {
if (transactionId > 0 && transactionId <= 255) {
Intent intent = new Intent();
intent.setAction(PEBBLEKIT_ACTION_APP_RECEIVE_ACK);
intent.putExtra("transaction_id", transactionId);
LOG.info("broadcasting ACK (transaction id " + transactionId + ")");
getContext().sendBroadcast(intent);
}
}
public PebbleIoThread(PebbleSupport pebbleSupport, GBDevice gbDevice, GBDeviceProtocol gbDeviceProtocol, BluetoothAdapter btAdapter, Context context) {
super(gbDevice, context); super(gbDevice, context);
mPebbleProtocol = (PebbleProtocol) gbDeviceProtocol; mPebbleProtocol = (PebbleProtocol) gbDeviceProtocol;
mBtAdapter = btAdapter; mBtAdapter = btAdapter;
@ -162,6 +152,14 @@ public class PebbleIoThread extends GBDeviceIoThread {
mEnablePebblekit = prefs.getBoolean("pebble_enable_pebblekit", false); mEnablePebblekit = prefs.getBoolean("pebble_enable_pebblekit", false);
} }
private void sendAppMessageAck(int transactionId) {
Intent intent = new Intent();
intent.setAction(PEBBLEKIT_ACTION_APP_RECEIVE_ACK);
intent.putExtra("transaction_id", transactionId);
LOG.info("broadcasting ACK (transaction id " + transactionId + ")");
getContext().sendBroadcast(intent);
}
@Override @Override
protected boolean connect(String btDeviceAddress) { protected boolean connect(String btDeviceAddress) {
GBDevice.State originalState = gbDevice.getState(); GBDevice.State originalState = gbDevice.getState();
@ -562,11 +560,11 @@ public class PebbleIoThread extends GBDeviceIoThread {
return false; return false;
} }
public void setToken(int token) { private void setToken(int token) {
mAppInstallToken = token; mAppInstallToken = token;
} }
public void setInstallSlot(int slot) { private void setInstallSlot(int slot) {
if (mIsInstalling) { if (mIsInstalling) {
mInstallSlot = slot; mInstallSlot = slot;
} }
@ -580,7 +578,7 @@ public class PebbleIoThread extends GBDeviceIoThread {
write_real(bytes); write_real(bytes);
} }
public void installApp(Uri uri, int appId) { void installApp(Uri uri, int appId) {
if (mIsInstalling) { if (mIsInstalling) {
return; return;
} }
@ -651,7 +649,7 @@ public class PebbleIoThread extends GBDeviceIoThread {
} }
} }
public void finishInstall(boolean hadError) { private void finishInstall(boolean hadError) {
if (!mIsInstalling) { if (!mIsInstalling) {
return; return;
} }