From 2ef44c5e5def598d07f599675982e1a8b3aefc73 Mon Sep 17 00:00:00 2001 From: Sanket Padawe Date: Fri, 12 Jun 2015 18:09:45 -0700 Subject: [PATCH] Add PBAP checkbox for BT pairing consent dialog. Bug: 20488109 Change-Id: Ib6c98c27e6d2b8e59fa4b640df15214a6b197853 --- res/layout/bluetooth_pin_confirm.xml | 9 ++--- res/layout/bluetooth_pin_entry.xml | 9 ++--- res/values/strings.xml | 2 - .../bluetooth/BluetoothPairingDialog.java | 37 +++++++++++++++++++ 4 files changed, 45 insertions(+), 12 deletions(-) diff --git a/res/layout/bluetooth_pin_confirm.xml b/res/layout/bluetooth_pin_confirm.xml index 08f5d9fc56e..2968b38828a 100644 --- a/res/layout/bluetooth_pin_confirm.xml +++ b/res/layout/bluetooth_pin_confirm.xml @@ -86,16 +86,15 @@ android:textColor="@*android:color/secondary_text_material_light" android:visibility="gone" /> - + android:text="@string/bluetooth_pairing_shares_phonebook" + android:textAppearance="?android:attr/textAppearanceSmall" /> diff --git a/res/layout/bluetooth_pin_entry.xml b/res/layout/bluetooth_pin_entry.xml index 6f50cd42241..aa9f1877437 100644 --- a/res/layout/bluetooth_pin_entry.xml +++ b/res/layout/bluetooth_pin_entry.xml @@ -87,16 +87,15 @@ android:textAppearance="@android:style/TextAppearance.Material.Subhead" android:textColor="@*android:color/secondary_text_material_light"/> - + android:text="@string/bluetooth_pairing_shares_phonebook" + android:textAppearance="?android:attr/textAppearanceSmall" /> diff --git a/res/values/strings.xml b/res/values/strings.xml index 9ca45d05564..d7569b65f09 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1204,8 +1204,6 @@ To pair with:<br><b>%1$s</b><br><br>Type on it:<br><b>%2$s</b>, then press Return or Enter. - - Pairing grants access to your contacts and call history when connected. Grant access to your contacts and call history when connected. diff --git a/src/com/android/settings/bluetooth/BluetoothPairingDialog.java b/src/com/android/settings/bluetooth/BluetoothPairingDialog.java index ffe49450f52..29cac62eadd 100755 --- a/src/com/android/settings/bluetooth/BluetoothPairingDialog.java +++ b/src/com/android/settings/bluetooth/BluetoothPairingDialog.java @@ -16,6 +16,7 @@ package com.android.settings.bluetooth; +import android.bluetooth.BluetoothClass; import android.bluetooth.BluetoothDevice; import android.content.BroadcastReceiver; import android.content.Context; @@ -186,6 +187,24 @@ public final class BluetoothPairingDialog extends AlertActivity implements TextView messageViewContent = (TextView) view.findViewById(R.id.message_subhead); TextView messageView2 = (TextView) view.findViewById(R.id.message_below_pin); CheckBox alphanumericPin = (CheckBox) view.findViewById(R.id.alphanumeric_pin); + CheckBox contactSharing = (CheckBox) view.findViewById( + R.id.phonebook_sharing_message_entry_pin); + contactSharing.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) { + if (isChecked) { + mDevice.setPhonebookAccessPermission(BluetoothDevice.ACCESS_ALLOWED); + } else { + mDevice.setPhonebookAccessPermission(BluetoothDevice.ACCESS_REJECTED); + } + } + }); + if (mDevice.getBluetoothClass().getDeviceClass() + == BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE) { + contactSharing.setVisibility(View.VISIBLE); + } else { + contactSharing.setVisibility(View.GONE); + } mPairingView = (EditText) view.findViewById(R.id.text); mPairingView.addTextChangedListener(this); alphanumericPin.setOnCheckedChangeListener(this); @@ -238,6 +257,24 @@ public final class BluetoothPairingDialog extends AlertActivity implements TextView pairingViewCaption = (TextView) view.findViewById(R.id.pairing_caption); TextView pairingViewContent = (TextView) view.findViewById(R.id.pairing_subhead); TextView messagePairing = (TextView) view.findViewById(R.id.pairing_code_message); + CheckBox contactSharing = (CheckBox) view.findViewById( + R.id.phonebook_sharing_message_confirm_pin); + contactSharing.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) { + if (isChecked) { + mDevice.setPhonebookAccessPermission(BluetoothDevice.ACCESS_ALLOWED); + } else { + mDevice.setPhonebookAccessPermission(BluetoothDevice.ACCESS_REJECTED); + } + } + }); + if (mDevice.getBluetoothClass().getDeviceClass() + == BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE) { + contactSharing.setVisibility(View.VISIBLE); + } else { + contactSharing.setVisibility(View.GONE); + } String messageCaption = null; String pairingContent = null;