From 9f2f1fa5c09839cf2d49642c34ebd9a808830abb Mon Sep 17 00:00:00 2001 From: Gaurav Asati Date: Fri, 10 Oct 2014 12:13:12 +0530 Subject: Bluetooth: Update Call options on Screen Unlock. - Update UI with proper call options when new calls are added in during locked screen. Change-Id: I6e1393b8a8e3308fd569918c0338ae96123a407a CRs-Fixed: 737180 --- .../bluetooth/bttestapp/HfpTestActivity.java | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/bttestapp/src/org/codeaurora/bluetooth/bttestapp/HfpTestActivity.java b/bttestapp/src/org/codeaurora/bluetooth/bttestapp/HfpTestActivity.java index 2831522..aaf1369 100644 --- a/bttestapp/src/org/codeaurora/bluetooth/bttestapp/HfpTestActivity.java +++ b/bttestapp/src/org/codeaurora/bluetooth/bttestapp/HfpTestActivity.java @@ -58,6 +58,7 @@ import org.json.JSONException; import org.json.JSONObject; import java.util.ArrayList; +import java.util.Hashtable; public class HfpTestActivity extends MonkeyActivity implements IBluetoothConnectionObserver, CallHistoryDialogListener { @@ -74,6 +75,8 @@ public class HfpTestActivity extends MonkeyActivity implements IBluetoothConnect private ActionBar mActionBar = null; + private Hashtable mCalls; + // this should be visible for fragments BluetoothHeadsetClient mBluetoothHeadsetClient; ProfileService mProfileService = null; @@ -317,6 +320,7 @@ public class HfpTestActivity extends MonkeyActivity implements IBluetoothConnect ActivityHelper.initialize(this, R.layout.activity_hfp_test); BluetoothConnectionReceiver.registerObserver(this); + mCalls = new Hashtable(); // bind to app service Intent intent = new Intent(this, ProfileService.class); @@ -355,6 +359,25 @@ public class HfpTestActivity extends MonkeyActivity implements IBluetoothConnect filter.addAction(BluetoothHeadsetClient.ACTION_RESULT); filter.addAction(BluetoothHeadsetClient.ACTION_LAST_VTAG); registerReceiver(mHfpClientReceiver, filter); + if (mBluetoothHeadsetClient != null) { + for (BluetoothHeadsetClientCall call : mCalls.values()) { + call.setState(BluetoothHeadsetClientCall.CALL_STATE_TERMINATED); + mCallsListFragment.onCallChanged(call); + new MonkeyEvent("hfp-call-changed", true) + .addExtReply(callToJson(call)) + .send(); + } + for (BluetoothHeadsetClientCall call : + mBluetoothHeadsetClient.getCurrentCalls(mDevice)) { + Logger.v(TAG, "Updating call controls"); + mCallsListFragment.onCallChanged(call); + new MonkeyEvent("hfp-call-changed", true) + .addExtReply(callToJson(call)) + .send(); + } + } else { + Logger.v(TAG,"mBluetoothHeadsetClient is null"); + } super.onResume(); } @@ -363,6 +386,20 @@ public class HfpTestActivity extends MonkeyActivity implements IBluetoothConnect Logger.v(TAG, "onPause"); unregisterReceiver(mHfpClientReceiver); + if (mBluetoothHeadsetClient != null) { + mCalls.clear(); + Integer id = 1; + // save all calls status + if (!mBluetoothHeadsetClient.getCurrentCalls(mDevice).isEmpty()) { + for (BluetoothHeadsetClientCall call : + mBluetoothHeadsetClient.getCurrentCalls(mDevice)) { + mCalls.put(id, call); + id++; + } + } + } else { + Logger.v(TAG,"mBluetoothHeadsetClient is null"); + } super.onPause(); } -- cgit v1.2.3