From 5f23cb39a1bd9c319383108c209fca7f0256894b Mon Sep 17 00:00:00 2001 From: Jaikumar Ganesh Date: Fri, 11 Sep 2009 09:45:11 -0700 Subject: [PATCH] Modify settings for 2.1 Add incoming pairing dialog Add DisplayPasskey handling of pairing keyboards with 2.1 devices. Modify code path to show errors when bonding request fails. Misc fixes like string changes. --- AndroidManifest.xml | 2 +- res/values-cs/strings.xml | 2 +- res/values-da/strings.xml | 2 +- res/values-de/strings.xml | 2 +- res/values-el/strings.xml | 2 +- res/values-es-rUS/strings.xml | 2 +- res/values-es/strings.xml | 2 +- res/values-fr/strings.xml | 2 +- res/values-it/strings.xml | 2 +- res/values-ja/strings.xml | 2 +- res/values-ko/strings.xml | 2 +- res/values-nb/strings.xml | 2 +- res/values-nl/strings.xml | 2 +- res/values-pl/strings.xml | 2 +- res/values-pt-rPT/strings.xml | 2 +- res/values-pt/strings.xml | 2 +- res/values-ru/strings.xml | 2 +- res/values-sv/strings.xml | 2 +- res/values-tr/strings.xml | 2 +- res/values-zh-rCN/strings.xml | 2 +- res/values-zh-rTW/strings.xml | 2 +- res/values/strings.xml | 10 +- .../bluetooth/BluetoothEventRedirector.java | 11 +- .../bluetooth/BluetoothPairingDialog.java | 118 +++++++++++------- .../bluetooth/BluetoothPairingRequest.java | 3 +- .../CachedBluetoothDeviceManager.java | 14 ++- .../bluetooth/LocalBluetoothManager.java | 11 +- 27 files changed, 126 insertions(+), 83 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 7d85aa41e16..e61d375cae5 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -444,7 +444,7 @@ android:label="@string/bluetooth_connect_specific_profiles_title" /> diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml index 4451d26b234..72abd07092a 100644 --- a/res/values-cs/strings.xml +++ b/res/values-cs/strings.xml @@ -230,7 +230,7 @@ "Nastavení Bluetooth" "Nastavení Bluetooth" "Umožňuje spravovat připojení, nastavit název zařízení a viditelnost" - "Požadavek na párování zařízení Bluetooth" + "Požadavek na párování zařízení Bluetooth" "Info o zařízení Bluetooth" diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml index 57f629a85b0..d3c93e23cac 100644 --- a/res/values-da/strings.xml +++ b/res/values-da/strings.xml @@ -230,7 +230,7 @@ "Bluetooth-indstillinger" "Bluetooth-indstillinger" "Administrer forbindelser, indstil enhedsnavn og søgbarhed" - "Anmodning om Bluetooth-parring" + "Anmodning om Bluetooth-parring" "Oplysninger om Bluetooth-enhed" diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index 61b13ea6e46..0815ab33aab 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -230,7 +230,7 @@ "Bluetooth-Einstellungen" "Bluetooth-Einstellungen" "Verbindungen, Gerätenamen und Erkennbarkeit verwalten" - "Bluetooth-Pairing-Anfrage" + "Bluetooth-Pairing-Anfrage" "Bluetooth-Geräteinfo" diff --git a/res/values-el/strings.xml b/res/values-el/strings.xml index 770b96db294..7b05080dd5e 100644 --- a/res/values-el/strings.xml +++ b/res/values-el/strings.xml @@ -230,7 +230,7 @@ "Ρυθμίσεις Bluetooth" "Ρυθμίσεις Bluetooth" "Διαχείριση συνδέσεων, ορισμός ονόματος συσκευής & ανιχνευσιμότητα" - "Αίτημα σύζευξης Bluetooth" + "Αίτημα σύζευξης Bluetooth" "Πληροφορίες συσκευής Bluetooth" diff --git a/res/values-es-rUS/strings.xml b/res/values-es-rUS/strings.xml index acf8be91eb9..53aee9f133f 100644 --- a/res/values-es-rUS/strings.xml +++ b/res/values-es-rUS/strings.xml @@ -230,7 +230,7 @@ "Configuración de Bluetooth" "Config. de Bluetooth" "Administrar conexiones, establecer nombre y detección del dispositivo" - "Solicitud de vinculación de Bluetooth" + "Solicitud de vinculación de Bluetooth" "Información del dispositivo Bluetooth" diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index fa73a39b578..71603c8ba6f 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -230,7 +230,7 @@ "Bluetooth" "Ajustes de Bluetooth" "Administrar conexiones, establecer el nombre del dispositivo y la visibilidad" - "Solicitud de sincronización de Bluetooth" + "Solicitud de sincronización de Bluetooth" "Información de dispositivo Bluetooth" diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index a477760ff47..d090cd93d77 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -230,7 +230,7 @@ "Paramètres Bluetooth" "Paramètres Bluetooth" "Gérer les connexions, configurer le nom et l\'identification de l\'appareil" - "Demande d\'association Bluetooth" + "Demande d\'association Bluetooth" "Informations sur l\'appareil Bluetooth" diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index d9794547ac7..e31af90a7ad 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -230,7 +230,7 @@ "Impostazioni Bluetooth" "Impostazioni Bluetooth" "Gestisci le connessioni, imposta il nome e la rilevabilità del dispositivo" - "Richiesta accoppiamento Bluetooth" + "Richiesta accoppiamento Bluetooth" "Info dispositivo Bluetooth" diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml index 5bdb035bce5..41e9810f21d 100644 --- a/res/values-ja/strings.xml +++ b/res/values-ja/strings.xml @@ -230,7 +230,7 @@ "Bluetooth設定" "Bluetooth設定" "端末の名前、接続や検出設定" - "Bluetoothペア設定リクエスト" + "Bluetoothペア設定リクエスト" "Bluetooth端末情報" diff --git a/res/values-ko/strings.xml b/res/values-ko/strings.xml index 9950d8eb6a0..13134cce787 100644 --- a/res/values-ko/strings.xml +++ b/res/values-ko/strings.xml @@ -230,7 +230,7 @@ "Bluetooth 설정" "Bluetooth 설정" "연결 관리, 장치이름 및 검색가능 여부 설정" - "Bluetooth 페어링 요청" + "Bluetooth 페어링 요청" "Bluetooth 장치 정보" diff --git a/res/values-nb/strings.xml b/res/values-nb/strings.xml index b75837a54b1..ed8cf3ec931 100644 --- a/res/values-nb/strings.xml +++ b/res/values-nb/strings.xml @@ -230,7 +230,7 @@ "Bluetooth-innstillinger" "Bluetooth-innstillinger" "Tilkoblinger, enhetsnavn og synlighet" - "Forespørsel om Bluetooth-paring" + "Forespørsel om Bluetooth-paring" "Bluetooth-enhetsinformasjon" diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml index 992f0b05975..adb9b0affae 100644 --- a/res/values-nl/strings.xml +++ b/res/values-nl/strings.xml @@ -230,7 +230,7 @@ "Bluetooth-instellingen" "Bluetooth-instellingen" "Verbindingen beheren, apparaatnaam en vindbaarheid instellen" - "Bluetooth-koppelingsverzoek" + "Bluetooth-koppelingsverzoek" "Bluetooth-apparaatinfo" diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml index 702c35e8f82..8e11cadcda2 100644 --- a/res/values-pl/strings.xml +++ b/res/values-pl/strings.xml @@ -230,7 +230,7 @@ "Ustawienia Bluetooth" "Ustawienia Bluetooth" "Zarządzaj połączeniami, ustaw nazwę urządzenia i możliwość wykrycia" - "Żądanie parowania Bluetooth" + "Żądanie parowania Bluetooth" "Informacje o urządzeniu Bluetooth" diff --git a/res/values-pt-rPT/strings.xml b/res/values-pt-rPT/strings.xml index 281fa5be239..04dc719516b 100644 --- a/res/values-pt-rPT/strings.xml +++ b/res/values-pt-rPT/strings.xml @@ -230,7 +230,7 @@ "Definições de Bluetooth" "Definições de Bluetooth" "Gerir ligações, definir nome e detectabilidade do dispositivo" - "Pedido de emparelhamento de Bluetooth" + "Pedido de emparelhamento de Bluetooth" "Informações sobre dispositivo Bluetooth" diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml index 316b7b523b8..5efca261262 100644 --- a/res/values-pt/strings.xml +++ b/res/values-pt/strings.xml @@ -230,7 +230,7 @@ "Configurações de Bluetooth" "Configurações de Bluetooth" "Gerenciar conexões, definir o nome e detecção do dispositivo" - "Solicitação de pareamento Bluetooth" + "Solicitação de pareamento Bluetooth" "Informações do dispositivo Bluetooth" diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index 549f0120d96..096ea68c7a6 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -230,7 +230,7 @@ "Настройки Bluetooth" "Настройки Bluetooth" "Настройка подключений, видимости и имени устройства" - "Запрос сопряжения Bluetooth" + "Запрос сопряжения Bluetooth" "Сведения об устройстве Bluetooth" diff --git a/res/values-sv/strings.xml b/res/values-sv/strings.xml index fd144b925d1..ee5edff709c 100644 --- a/res/values-sv/strings.xml +++ b/res/values-sv/strings.xml @@ -230,7 +230,7 @@ "Bluetooth-inställningar" "Bluetooth-inställningar" "Hantera anslutningar, ange inställningar för enhetens namn och synlighet" - "Begäran om Bluetooth-parkoppling" + "Begäran om Bluetooth-parkoppling" "Information om Bluetooth-enhet" diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml index ffd47810300..12f9e835d4e 100644 --- a/res/values-tr/strings.xml +++ b/res/values-tr/strings.xml @@ -230,7 +230,7 @@ "Bluetooth ayarları" "Bluetooth ayarları" "Bağlantıları yönet, cihaz adını gir ve keşfedilebilirlik ayarını yap" - "Bluetooth eşleşme isteği" + "Bluetooth eşleşme isteği" "Bluetooth cihaz bilgileri" diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index ba90dd5ca77..324bfed6008 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -230,7 +230,7 @@ "蓝牙设置" "蓝牙设置" "管理连接,设置设备名称和可检测性" - "蓝牙配对请求" + "蓝牙配对请求" "蓝牙设备信息" diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml index daba29b3046..c47b3ff6ed7 100644 --- a/res/values-zh-rTW/strings.xml +++ b/res/values-zh-rTW/strings.xml @@ -230,7 +230,7 @@ "藍牙設定" "藍牙設定" "管理連線、設定裝置名稱與可偵測性" - "藍牙配對要求" + "藍牙配對要求" "藍牙裝置資訊" diff --git a/res/values/strings.xml b/res/values/strings.xml index 4d89630ceeb..4db21040c10 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -509,7 +509,7 @@ Manage connections, set device name & discoverability - Bluetooth pairing request + Bluetooth pairing request Bluetooth device info @@ -518,10 +518,16 @@ \nType passkey to pair with \u0022%1$s\u0022. To pair with \u0022%1$s\u0022, confirm that it is showing the passkey: %2$s. + + %1$s\nwants to pair. + + Enter %2$s on \u0022%1$s\u0022 to pair. Pair Don\u0027t Pair + + bluetooth device Attention @@ -529,7 +535,7 @@ There was a problem pairing with %1$s. - There was a problem pairing with %1$s because the typed PIN or Passkey is incorrect. + There was a problem pairing with %1$s because the PIN or Passkey is incorrect. Cannot establish communication with %1$s. diff --git a/src/com/android/settings/bluetooth/BluetoothEventRedirector.java b/src/com/android/settings/bluetooth/BluetoothEventRedirector.java index 44bc640a116..1a373dde4ed 100644 --- a/src/com/android/settings/bluetooth/BluetoothEventRedirector.java +++ b/src/com/android/settings/bluetooth/BluetoothEventRedirector.java @@ -27,6 +27,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.util.Log; +import com.android.settings.R; import com.android.settings.bluetooth.LocalBluetoothProfileManager.Profile; /** @@ -78,11 +79,7 @@ public class BluetoothEventRedirector { mManager.getCachedDeviceManager().onBondingStateChanged(device, bondState); if (bondState == BluetoothDevice.BOND_NONE) { int reason = intent.getIntExtra(BluetoothDevice.EXTRA_REASON, BluetoothDevice.ERROR); - if (reason == BluetoothDevice.UNBOND_REASON_AUTH_REJECTED || - reason == BluetoothDevice.UNBOND_REASON_AUTH_FAILED || - reason == BluetoothDevice.UNBOND_REASON_REMOTE_DEVICE_DOWN) { - mManager.getCachedDeviceManager().onBondingError(device, reason); - } + mManager.getCachedDeviceManager().onBondingError(device, reason); } } else if (action.equals(BluetoothHeadset.ACTION_STATE_CHANGED)) { @@ -110,6 +107,9 @@ public class BluetoothEventRedirector { } else if (action.equals(BluetoothDevice.ACTION_CLASS_CHANGED)) { mManager.getCachedDeviceManager().onBtClassChanged(device); + } else if (action.equals(BluetoothDevice.ACTION_PAIRING_CANCEL)) { + int errorMsg = R.string.bluetooth_pairing_error_message; + mManager.showError(device, R.string.bluetooth_error_title, errorMsg); } } }; @@ -133,6 +133,7 @@ public class BluetoothEventRedirector { // Pairing broadcasts filter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED); + filter.addAction(BluetoothDevice.ACTION_PAIRING_CANCEL); // Fine-grained state broadcasts filter.addAction(BluetoothA2dp.ACTION_SINK_STATE_CHANGED); diff --git a/src/com/android/settings/bluetooth/BluetoothPairingDialog.java b/src/com/android/settings/bluetooth/BluetoothPairingDialog.java index 04b3b6e7f2c..7004ba0fa93 100644 --- a/src/com/android/settings/bluetooth/BluetoothPairingDialog.java +++ b/src/com/android/settings/bluetooth/BluetoothPairingDialog.java @@ -51,23 +51,25 @@ public class BluetoothPairingDialog extends AlertActivity implements DialogInter private LocalBluetoothManager mLocalManager; private BluetoothDevice mDevice; private int mType; - private String mConfirmationPasskey; + private String mPasskey; private EditText mPairingView; private Button mOkButton; - private static final String INSTANCE_KEY_PAIRING_CANCELED = "received_pairing_canceled"; - private boolean mReceivedPairingCanceled; - private BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { - if (!BluetoothDevice.ACTION_PAIRING_CANCEL.equals(intent.getAction())) { - return; - } - - BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); - if (device == null || device.equals(mDevice)) { - onReceivedPairingCanceled(); + if (BluetoothDevice.ACTION_BOND_STATE_CHANGED.equals(intent.getAction())) { + int bondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, + BluetoothDevice.ERROR); + if (bondState == BluetoothDevice.BOND_BONDED || + bondState == BluetoothDevice.BOND_NONE) { + dismissDialog(); + } + } else if(BluetoothDevice.ACTION_PAIRING_CANCEL.equals(intent.getAction())) { + BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); + if (device == null || device.equals(mDevice)) { + dismissDialog(); + } } } }; @@ -92,15 +94,26 @@ public class BluetoothPairingDialog extends AlertActivity implements DialogInter createUserEntryDialog(); } else if (mType == BluetoothDevice.PAIRING_VARIANT_PASSKEY) { createUserEntryDialog(); - } else if (mType == BluetoothDevice.PAIRING_VARIANT_CONFIRMATION){ + } else if (mType == BluetoothDevice.PAIRING_VARIANT_PASSKEY_CONFIRMATION){ int passkey = intent.getIntExtra(BluetoothDevice.EXTRA_PASSKEY, BluetoothDevice.ERROR); if (passkey == BluetoothDevice.ERROR) { Log.e(TAG, "Invalid ConfirmationPasskey received, not showing any dialog"); return; } - mConfirmationPasskey = String.format("%06d", passkey); + mPasskey = String.format("%06d", passkey); createConfirmationDialog(); + } else if (mType == BluetoothDevice.PAIRING_VARIANT_CONSENT) { + createConsentDialog(); + } else if (mType == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PASSKEY) { + int passkey = + intent.getIntExtra(BluetoothDevice.EXTRA_PASSKEY, BluetoothDevice.ERROR); + if (passkey == BluetoothDevice.ERROR) { + Log.e(TAG, "Invalid ConfirmationPasskey received, not showing any dialog"); + return; + } + mPasskey = String.format("%06d", passkey); + createDisplayPasskeyDialog(); } else { Log.e(TAG, "Incorrect pairing type received, not showing any dialog"); } @@ -110,12 +123,13 @@ public class BluetoothPairingDialog extends AlertActivity implements DialogInter * finish the activity in the background if pairing is canceled. */ registerReceiver(mReceiver, new IntentFilter(BluetoothDevice.ACTION_PAIRING_CANCEL)); + registerReceiver(mReceiver, new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED)); } private void createUserEntryDialog() { final AlertController.AlertParams p = mAlertParams; p.mIconId = android.R.drawable.ic_dialog_info; - p.mTitle = getString(R.string.bluetooth_pin_entry); + p.mTitle = getString(R.string.bluetooth_pairing_request); p.mView = createView(); p.mPositiveButtonText = getString(android.R.string.ok); p.mPositiveButtonListener = this; @@ -143,13 +157,22 @@ public class BluetoothPairingDialog extends AlertActivity implements DialogInter } else if (mType == BluetoothDevice.PAIRING_VARIANT_PASSKEY){ messageView.setText(getString(R.string.bluetooth_enter_passkey_msg, name)); // Maximum of 6 digits for passkey - mPairingView.setInputType(InputType.TYPE_NUMBER_FLAG_SIGNED); + mPairingView.setInputType(InputType.TYPE_CLASS_NUMBER | + InputType.TYPE_NUMBER_FLAG_SIGNED); mPairingView.setFilters(new InputFilter[] { new LengthFilter(BLUETOOTH_PASSKEY_MAX_LENGTH)}); - } else { + } else if (mType == BluetoothDevice.PAIRING_VARIANT_PASSKEY_CONFIRMATION) { mPairingView.setVisibility(View.GONE); messageView.setText(getString(R.string.bluetooth_confirm_passkey_msg, name, - mConfirmationPasskey)); + mPasskey)); + } else if (mType == BluetoothDevice.PAIRING_VARIANT_CONSENT) { + mPairingView.setVisibility(View.GONE); + messageView.setText(getString(R.string.bluetooth_incoming_pairing_msg, name)); + } else if (mType == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PASSKEY) { + mPairingView.setVisibility(View.GONE); + messageView.setText(getString(R.string.bluetooth_display_passkey_msg, name, mPasskey)); + } else { + Log.e(TAG, "Incorrect pairing type received, not creating view"); } return view; } @@ -157,7 +180,7 @@ public class BluetoothPairingDialog extends AlertActivity implements DialogInter private void createConfirmationDialog() { final AlertController.AlertParams p = mAlertParams; p.mIconId = android.R.drawable.ic_dialog_info; - p.mTitle = getString(R.string.bluetooth_pin_entry); + p.mTitle = getString(R.string.bluetooth_pairing_request); p.mView = createView(); p.mPositiveButtonText = getString(R.string.bluetooth_pairing_accept); p.mPositiveButtonListener = this; @@ -166,27 +189,35 @@ public class BluetoothPairingDialog extends AlertActivity implements DialogInter setupAlert(); } - @Override - protected void onRestoreInstanceState(Bundle savedInstanceState) { - super.onRestoreInstanceState(savedInstanceState); - - mReceivedPairingCanceled = savedInstanceState.getBoolean(INSTANCE_KEY_PAIRING_CANCELED); - if (mReceivedPairingCanceled) { - onReceivedPairingCanceled(); - } + private void createConsentDialog() { + final AlertController.AlertParams p = mAlertParams; + p.mIconId = android.R.drawable.ic_dialog_info; + p.mTitle = getString(R.string.bluetooth_pairing_request); + p.mView = createView(); + p.mPositiveButtonText = getString(R.string.bluetooth_pairing_accept); + p.mPositiveButtonListener = this; + p.mNegativeButtonText = getString(R.string.bluetooth_pairing_decline); + p.mNegativeButtonListener = this; + setupAlert(); } - @Override - protected void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); + private void createDisplayPasskeyDialog() { + final AlertController.AlertParams p = mAlertParams; + p.mIconId = android.R.drawable.ic_dialog_info; + p.mTitle = getString(R.string.bluetooth_pairing_request); + p.mView = createView(); + p.mPositiveButtonText = getString(android.R.string.ok); + p.mPositiveButtonListener = this; + setupAlert(); - outState.putBoolean(INSTANCE_KEY_PAIRING_CANCELED, mReceivedPairingCanceled); + // Since its only a notification, send an OK to the framework, + // indicating that the dialog has been displayed. + mDevice.setPairingConfirmation(true); } @Override protected void onDestroy() { super.onDestroy(); - unregisterReceiver(mReceiver); } @@ -196,21 +227,8 @@ public class BluetoothPairingDialog extends AlertActivity implements DialogInter } } - private void onReceivedPairingCanceled() { - mReceivedPairingCanceled = true; - - TextView messageView = (TextView) findViewById(R.id.message); - messageView.setText(getString(R.string.bluetooth_pairing_error_message, - mDevice.getName())); - - mPairingView.setVisibility(View.GONE); - mPairingView.clearFocus(); - mPairingView.removeTextChangedListener(this); - - mOkButton = mAlert.getButton(DialogInterface.BUTTON_POSITIVE); - mOkButton.setEnabled(true); - mOkButton.setText(android.R.string.ok); - mAlert.getButton(DialogInterface.BUTTON_NEGATIVE).setVisibility(View.GONE); + private void dismissDialog() { + this.dismiss(); } private void onPair(String value) { @@ -223,8 +241,14 @@ public class BluetoothPairingDialog extends AlertActivity implements DialogInter } else if (mType == BluetoothDevice.PAIRING_VARIANT_PASSKEY) { int passkey = Integer.parseInt(value); mDevice.setPasskey(passkey); - } else { + } else if (mType == BluetoothDevice.PAIRING_VARIANT_PASSKEY_CONFIRMATION) { mDevice.setPairingConfirmation(true); + } else if (mType == BluetoothDevice.PAIRING_VARIANT_CONSENT) { + mDevice.setPairingConfirmation(true); + } else if (mType == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PASSKEY) { + // Do Nothing. + } else { + Log.e(TAG, "Incorrect pairing type received"); } } diff --git a/src/com/android/settings/bluetooth/BluetoothPairingRequest.java b/src/com/android/settings/bluetooth/BluetoothPairingRequest.java index 87278061a65..2fa17448ea2 100644 --- a/src/com/android/settings/bluetooth/BluetoothPairingRequest.java +++ b/src/com/android/settings/bluetooth/BluetoothPairingRequest.java @@ -54,7 +54,8 @@ public class BluetoothPairingRequest extends BroadcastReceiver { pairingIntent.setClass(context, BluetoothPairingDialog.class); pairingIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, device); pairingIntent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, type); - if (type == BluetoothDevice.PAIRING_VARIANT_CONFIRMATION) { + if (type == BluetoothDevice.PAIRING_VARIANT_PASSKEY_CONFIRMATION || + type == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PASSKEY) { int passkey = intent.getIntExtra(BluetoothDevice.EXTRA_PASSKEY, BluetoothDevice.ERROR); pairingIntent.putExtra(BluetoothDevice.EXTRA_PASSKEY, passkey); } diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java b/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java index e3f048a93d8..7052bfb6ed2 100644 --- a/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java +++ b/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java @@ -85,7 +85,6 @@ public class CachedBluetoothDeviceManager { mCachedDevices.add(cachedDevice); deviceAdded = true; } - cachedDevice.setRssi(rssi); cachedDevice.setBtClass(btClass); cachedDevice.setName(name); @@ -193,17 +192,26 @@ public class CachedBluetoothDeviceManager { switch(reason) { case BluetoothDevice.UNBOND_REASON_AUTH_FAILED: errorMsg = R.string.bluetooth_pairing_pin_error_message; + mLocalManager.showError(device, R.string.bluetooth_error_title, errorMsg); break; case BluetoothDevice.UNBOND_REASON_AUTH_REJECTED: errorMsg = R.string.bluetooth_pairing_rejected_error_message; + mLocalManager.showError(device, R.string.bluetooth_error_title, errorMsg); break; case BluetoothDevice.UNBOND_REASON_REMOTE_DEVICE_DOWN: errorMsg = R.string.bluetooth_pairing_device_down_error_message; + mLocalManager.showError(device, R.string.bluetooth_error_title, errorMsg); + break; + case BluetoothDevice.UNBOND_REASON_DISCOVERY_IN_PROGRESS: + case BluetoothDevice.UNBOND_REASON_AUTH_TIMEOUT: + case BluetoothDevice.UNBOND_REASON_REPEATED_ATTEMPTS: + errorMsg = R.string.bluetooth_pairing_error_message; + mLocalManager.showError(device, R.string.bluetooth_error_title, errorMsg); break; default: - errorMsg = R.string.bluetooth_pairing_error_message; + Log.w(TAG, "onBondingError: Not displaying any error message for reason:" + reason); + break; } - mLocalManager.showError(device, R.string.bluetooth_error_title, errorMsg); } public synchronized void onProfileStateChanged(BluetoothDevice device, Profile profile, diff --git a/src/com/android/settings/bluetooth/LocalBluetoothManager.java b/src/com/android/settings/bluetooth/LocalBluetoothManager.java index 9ec95ab8235..501f767f67e 100644 --- a/src/com/android/settings/bluetooth/LocalBluetoothManager.java +++ b/src/com/android/settings/bluetooth/LocalBluetoothManager.java @@ -254,9 +254,12 @@ public class LocalBluetoothManager { public void showError(BluetoothDevice device, int titleResId, int messageResId) { CachedBluetoothDevice cachedDevice = mCachedDeviceManager.findDevice(device); - if (cachedDevice == null) return; - - String name = cachedDevice.getName(); + String name = null; + if (cachedDevice == null) { + name = mContext.getString(R.string.bluetooth_remote_device); + } else { + name = cachedDevice.getName(); + } String message = mContext.getString(messageResId, name); if (mForegroundActivity != null) { @@ -269,7 +272,7 @@ public class LocalBluetoothManager { .show(); } else { // Fallback on a toast - Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show(); + Toast.makeText(mContext, message, Toast.LENGTH_LONG).show(); } }