diff options
author | Agranee <agranee@google.com> | 2017-08-11 12:45:56 -0700 |
---|---|---|
committer | Joseph Pirozzo <pirozzoj@google.com> | 2017-08-11 23:00:38 +0000 |
commit | bcd5655d0afcf64a7439af8e3e5d6a37045d4ec4 (patch) | |
tree | 5c07c9fa0117739cc83425e94daf98283bd819e6 | |
parent | be8e260954baa801a77d64f74a1e23b1b2e8b5b2 (diff) | |
download | Car-bcd5655d0afcf64a7439af8e3e5d6a37045d4ec4.tar.gz |
KitchenSink Bluetooth Hold call button
Add hold call button to bluetooth headset fragment
Bug: 63412812
Test: Start a Call with a phone/telco that supports hold and hold a call
Change-Id: I8132a20bf7ff1f28b077880fc2e90602b3e7abd7
3 files changed, 34 insertions, 3 deletions
diff --git a/tests/EmbeddedKitchenSinkApp/res/layout/bluetooth_headset.xml b/tests/EmbeddedKitchenSinkApp/res/layout/bluetooth_headset.xml index 0547a8f4f1..5dbefc10e3 100644 --- a/tests/EmbeddedKitchenSinkApp/res/layout/bluetooth_headset.xml +++ b/tests/EmbeddedKitchenSinkApp/res/layout/bluetooth_headset.xml @@ -57,4 +57,9 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/bluetooth_quiet_mode_enable"/> + <Button + android:id="@+id/bluetooth_hold_call" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/bluetooth_hold_call"/> </LinearLayout> diff --git a/tests/EmbeddedKitchenSinkApp/res/values/strings.xml b/tests/EmbeddedKitchenSinkApp/res/values/strings.xml index 69c57dc025..fbba2a0d0d 100644 --- a/tests/EmbeddedKitchenSinkApp/res/values/strings.xml +++ b/tests/EmbeddedKitchenSinkApp/res/values/strings.xml @@ -212,6 +212,7 @@ <string name="bluetooth_sco_disconnect">SCO disconnect</string> <string name="bluetooth_pick_device">Pick Device</string> <string name="bluetooth_quiet_mode_enable">Quiet Mode</string> + <string name="bluetooth_hold_call">Hold call</string> <!--Car Service Settings--> <string name="garage_title">Garage Mode</string> diff --git a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/bluetooth/BluetoothHeadsetFragment.java b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/bluetooth/BluetoothHeadsetFragment.java index 30804feb08..cb668c49b6 100644 --- a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/bluetooth/BluetoothHeadsetFragment.java +++ b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/bluetooth/BluetoothHeadsetFragment.java @@ -57,15 +57,17 @@ public class BluetoothHeadsetFragment extends Fragment { Button mScoConnect; Button mScoDisconnect; Button mEnableQuietMode; + Button mHoldCall; BluetoothHeadsetClient mHfpClientProfile; // Intent for picking a Bluetooth device - public static final String DEVICE_PICKER_ACTION = "android.bluetooth.devicepicker.action.LAUNCH"; + public static final String DEVICE_PICKER_ACTION = + "android.bluetooth.devicepicker.action.LAUNCH"; @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, - @Nullable Bundle savedInstanceState) { + @Nullable Bundle savedInstanceState) { View v = inflater.inflate(R.layout.bluetooth_headset, container, false); mPickedDeviceText = (TextView) v.findViewById(R.id.bluetooth_device); @@ -73,8 +75,9 @@ public class BluetoothHeadsetFragment extends Fragment { mConnect = (Button) v.findViewById(R.id.bluetooth_headset_connect); mDisconnect = (Button) v.findViewById(R.id.bluetooth_headset_disconnect); mScoConnect = (Button) v.findViewById(R.id.bluetooth_sco_connect); - mScoDisconnect= (Button) v.findViewById(R.id.bluetooth_sco_disconnect); + mScoDisconnect = (Button) v.findViewById(R.id.bluetooth_sco_disconnect); mEnableQuietMode = (Button) v.findViewById(R.id.bluetooth_quiet_mode_enable); + mHoldCall = (Button) v.findViewById(R.id.bluetooth_hold_call); // Pick a bluetooth device mDevicePicker.setOnClickListener(new View.OnClickListener() { @@ -123,6 +126,14 @@ public class BluetoothHeadsetFragment extends Fragment { mBluetoothAdapter.enableNoAutoConnect(); } }); + + // Place the current call on hold + mHoldCall.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + holdCall(); + } + }); return v; } @@ -192,6 +203,20 @@ public class BluetoothHeadsetFragment extends Fragment { mHfpClientProfile.disconnectAudio(mPickedDevice); } + void holdCall() { + if (mPickedDevice == null) { + Log.w(TAG, "Device null when trying to put the call on hold!"); + return; + } + + if (mHfpClientProfile == null) { + Log.w(TAG, "HFP Profile proxy not available, cannot put the call on hold " + + mPickedDevice); + return; + } + mHfpClientProfile.holdCall(mPickedDevice); + } + private final BroadcastReceiver mPickerReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { |