aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSheng-Chieh “Jason” Huang <jh54820303@gmail.com>2024-02-22 18:09:58 +0000
committerSheng-Chieh “Jason” Huang <jh54820303@gmail.com>2024-02-22 18:10:51 +0000
commit93cce807d213775cb72d8eae8ade88f82ffcc4b1 (patch)
treec9b9dd0a3c0bbb969d8ad37b15191624c4560f93
parentc82cffda3dc5f5a57c8b26eb6d0e44b1df22b603 (diff)
downloadsl4a-93cce807d213775cb72d8eae8ade88f82ffcc4b1.tar.gz
Fix potential null pointer exception
- Addressed potential null pointer exception when asynchronously passing Bundle object to EventFacade for client response. - To prevent a null pointer exception during JSON building by SL4A JsonBuilder, clone the Bundle object before posting it to the EventFacade. Test: manually Change-Id: Iedc855e18b05ca30c4783dc26abdbbb4c669b528
-rw-r--r--Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothFacade.java5
1 files changed, 2 insertions, 3 deletions
diff --git a/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothFacade.java b/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothFacade.java
index 722b39a8..68600ebc 100644
--- a/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothFacade.java
@@ -131,18 +131,17 @@ public class BluetoothFacade extends RpcReceiver {
Bundle msg = new Bundle();
if (state == BluetoothAdapter.STATE_ON) {
msg.putString("State", "ON");
- mEventFacade.postEvent("BluetoothStateChangedOn", msg);
+ mEventFacade.postEvent("BluetoothStateChangedOn", msg.clone());
if (!mIsMultiBroadcast) {
mService.unregisterReceiver(mStateReceiver);
}
} else if(state == BluetoothAdapter.STATE_OFF) {
msg.putString("State", "OFF");
- mEventFacade.postEvent("BluetoothStateChangedOff", msg);
+ mEventFacade.postEvent("BluetoothStateChangedOff", msg.clone());
if (!mIsMultiBroadcast) {
mService.unregisterReceiver(mStateReceiver);
}
}
- msg.clear();
}
}
}