summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGaurav Asati <gasati@codeaurora.org>2015-02-02 10:29:18 +0530
committerGaurav Asati <gasati@codeaurora.org>2015-02-02 17:06:07 +0530
commitf40fecc359bd855e9dd7c4499743fdf69cefadda (patch)
treefe7eb15c0828703c3de8bc762889725f2ee9a85d
parent29cf1efcc23f180201c8b33d0c69538076cc7a7e (diff)
downloadandroid_packages_apps_BluetoothExt-f40fecc359bd855e9dd7c4499743fdf69cefadda.tar.gz
android_packages_apps_BluetoothExt-f40fecc359bd855e9dd7c4499743fdf69cefadda.tar.bz2
android_packages_apps_BluetoothExt-f40fecc359bd855e9dd7c4499743fdf69cefadda.zip
Bluetooth: Check for null value.
- When HFP Client is disabled, getHfpClient returns null. - Check for device connection state before accessing call states. Change-Id: I14e5c342c1464a07b31ac24f896dcae21c255eae
-rw-r--r--bttestapp/src/org/codeaurora/bluetooth/bttestapp/HfpTestActivity.java7
-rw-r--r--bttestapp/src/org/codeaurora/bluetooth/bttestapp/ServicesFragment.java10
2 files changed, 15 insertions, 2 deletions
diff --git a/bttestapp/src/org/codeaurora/bluetooth/bttestapp/HfpTestActivity.java b/bttestapp/src/org/codeaurora/bluetooth/bttestapp/HfpTestActivity.java
index 05e722b..867cafd 100644
--- a/bttestapp/src/org/codeaurora/bluetooth/bttestapp/HfpTestActivity.java
+++ b/bttestapp/src/org/codeaurora/bluetooth/bttestapp/HfpTestActivity.java
@@ -359,6 +359,13 @@ public class HfpTestActivity extends MonkeyActivity implements IBluetoothConnect
filter.addAction(BluetoothHeadsetClient.ACTION_RESULT);
filter.addAction(BluetoothHeadsetClient.ACTION_LAST_VTAG);
registerReceiver(mHfpClientReceiver, filter);
+ if (mBluetoothHeadsetClient != null &&
+ mBluetoothHeadsetClient.getConnectionState(mDevice) !=
+ BluetoothProfile.STATE_CONNECTED) {
+ Logger.v(TAG, "No device is connected");
+ super.onResume();
+ return;
+ }
if (mBluetoothHeadsetClient != null) {
for (BluetoothHeadsetClientCall call : mCalls.values()) {
call.setState(BluetoothHeadsetClientCall.CALL_STATE_TERMINATED);
diff --git a/bttestapp/src/org/codeaurora/bluetooth/bttestapp/ServicesFragment.java b/bttestapp/src/org/codeaurora/bluetooth/bttestapp/ServicesFragment.java
index f73e435..0fb64e0 100644
--- a/bttestapp/src/org/codeaurora/bluetooth/bttestapp/ServicesFragment.java
+++ b/bttestapp/src/org/codeaurora/bluetooth/bttestapp/ServicesFragment.java
@@ -451,10 +451,16 @@ public class ServicesFragment extends ListFragment {
switch (srv.mType) {
case HFP:
if (isChecked) {
- mActivity.mProfileService.getHfpClient().connect(mActivity.mDevice);
+ if (mActivity.mProfileService.getHfpClient() != null) {
+ mActivity.mProfileService.getHfpClient()
+ .connect(mActivity.mDevice);
+ }
buttonView.setEnabled(false);
} else {
- mActivity.mProfileService.getHfpClient().disconnect(mActivity.mDevice);
+ if (mActivity.mProfileService.getHfpClient() != null) {
+ mActivity.mProfileService.getHfpClient()
+ .disconnect(mActivity.mDevice);
+ }
buttonView.setEnabled(false);
}
break;