Fix crash on PebbleKit intents where app UUID was sent as String

This commit is contained in:
Arjan Schrijver
2025-12-25 14:45:08 +01:00
committed by Arjan Schrijver
parent ba0e8c3d86
commit 15f404f2f9
@@ -75,7 +75,7 @@ class PebbleKitSupport {
switch (action) { switch (action) {
case PEBBLEKIT_ACTION_APP_START: case PEBBLEKIT_ACTION_APP_START:
case PEBBLEKIT_ACTION_APP_STOP: case PEBBLEKIT_ACTION_APP_STOP:
uuid = (UUID) intent.getSerializableExtra("uuid"); uuid = parseUUIDFromIntent(intent);
if (uuid != null) { if (uuid != null) {
if (action.equals(PEBBLEKIT_ACTION_APP_STOP) && if (action.equals(PEBBLEKIT_ACTION_APP_STOP) &&
intent.getBooleanExtra(PEBBLEKIT_EXTRA_REOPEN_LAST_APP, false)) { intent.getBooleanExtra(PEBBLEKIT_EXTRA_REOPEN_LAST_APP, false)) {
@@ -87,7 +87,7 @@ class PebbleKitSupport {
break; break;
case PEBBLEKIT_ACTION_APP_SEND: case PEBBLEKIT_ACTION_APP_SEND:
int transaction_id = intent.getIntExtra("transaction_id", -1); int transaction_id = intent.getIntExtra("transaction_id", -1);
uuid = (UUID) intent.getSerializableExtra("uuid"); uuid = parseUUIDFromIntent(intent);
String jsonString = intent.getStringExtra("msg_data"); String jsonString = intent.getStringExtra("msg_data");
LOG.info("json string: " + jsonString); LOG.info("json string: " + jsonString);
@@ -136,6 +136,14 @@ class PebbleKitSupport {
ContextCompat.registerReceiver(mContext, mPebbleKitReceiver, intentFilter, ContextCompat.RECEIVER_EXPORTED); ContextCompat.registerReceiver(mContext, mPebbleKitReceiver, intentFilter, ContextCompat.RECEIVER_EXPORTED);
} }
private UUID parseUUIDFromIntent(Intent intent) {
if (intent.getStringExtra("uuid") != null) {
return UUID.fromString(intent.getStringExtra("uuid"));
} else {
return (UUID) intent.getSerializableExtra("uuid");
}
}
void sendAppMessageIntent(GBDeviceEventAppMessage appMessage) { void sendAppMessageIntent(GBDeviceEventAppMessage appMessage) {
Intent intent = new Intent(); Intent intent = new Intent();
intent.setAction(PEBBLEKIT_ACTION_APP_RECEIVE); intent.setAction(PEBBLEKIT_ACTION_APP_RECEIVE);