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.
This commit is contained in:
Jaikumar Ganesh
2009-09-11 09:45:11 -07:00
parent d6375e975e
commit 5f23cb39a1
27 changed files with 126 additions and 83 deletions

View File

@@ -444,7 +444,7 @@
android:label="@string/bluetooth_connect_specific_profiles_title" />
<activity android:name=".bluetooth.BluetoothPairingDialog"
android:label="@string/bluetooth_pin_entry"
android:label="@string/bluetooth_pairing_dialog"
android:excludeFromRecents="true"
android:theme="@*android:style/Theme.Dialog.Alert">
<intent-filter>

View File

@@ -230,7 +230,7 @@
<string name="bluetooth_settings" msgid="2725796451253089609">"Nastavení Bluetooth"</string>
<string name="bluetooth_settings_title" msgid="2824020086246268296">"Nastavení Bluetooth"</string>
<string name="bluetooth_settings_summary" msgid="2091062709530570462">"Umožňuje spravovat připojení, nastavit název zařízení a viditelnost"</string>
<string name="bluetooth_pin_entry" msgid="5627349871303455279">"Požadavek na párování zařízení Bluetooth"</string>
<string name="bluetooth_pairing_dialog" msgid="5627349871303455279">"Požadavek na párování zařízení Bluetooth"</string>
<string name="bluetooth_device_info" msgid="6644515376523965073">"Info o zařízení Bluetooth"</string>
<!-- no translation found for bluetooth_enter_pin_msg (5282139964993593442) -->
<skip />

View File

@@ -230,7 +230,7 @@
<string name="bluetooth_settings" msgid="2725796451253089609">"Bluetooth-indstillinger"</string>
<string name="bluetooth_settings_title" msgid="2824020086246268296">"Bluetooth-indstillinger"</string>
<string name="bluetooth_settings_summary" msgid="2091062709530570462">"Administrer forbindelser, indstil enhedsnavn og søgbarhed"</string>
<string name="bluetooth_pin_entry" msgid="5627349871303455279">"Anmodning om Bluetooth-parring"</string>
<string name="bluetooth_pairing_dialog" msgid="5627349871303455279">"Anmodning om Bluetooth-parring"</string>
<string name="bluetooth_device_info" msgid="6644515376523965073">"Oplysninger om Bluetooth-enhed"</string>
<!-- no translation found for bluetooth_enter_pin_msg (5282139964993593442) -->
<skip />

View File

@@ -230,7 +230,7 @@
<string name="bluetooth_settings" msgid="2725796451253089609">"Bluetooth-Einstellungen"</string>
<string name="bluetooth_settings_title" msgid="2824020086246268296">"Bluetooth-Einstellungen"</string>
<string name="bluetooth_settings_summary" msgid="2091062709530570462">"Verbindungen, Gerätenamen und Erkennbarkeit verwalten"</string>
<string name="bluetooth_pin_entry" msgid="5627349871303455279">"Bluetooth-Pairing-Anfrage"</string>
<string name="bluetooth_pairing_dialog" msgid="5627349871303455279">"Bluetooth-Pairing-Anfrage"</string>
<string name="bluetooth_device_info" msgid="6644515376523965073">"Bluetooth-Geräteinfo"</string>
<!-- no translation found for bluetooth_enter_pin_msg (5282139964993593442) -->
<skip />

View File

@@ -230,7 +230,7 @@
<string name="bluetooth_settings" msgid="2725796451253089609">"Ρυθμίσεις Bluetooth"</string>
<string name="bluetooth_settings_title" msgid="2824020086246268296">"Ρυθμίσεις Bluetooth"</string>
<string name="bluetooth_settings_summary" msgid="2091062709530570462">"Διαχείριση συνδέσεων, ορισμός ονόματος συσκευής &amp; ανιχνευσιμότητα"</string>
<string name="bluetooth_pin_entry" msgid="5627349871303455279">"Αίτημα σύζευξης Bluetooth"</string>
<string name="bluetooth_pairing_dialog" msgid="5627349871303455279">"Αίτημα σύζευξης Bluetooth"</string>
<string name="bluetooth_device_info" msgid="6644515376523965073">"Πληροφορίες συσκευής Bluetooth"</string>
<!-- no translation found for bluetooth_enter_pin_msg (5282139964993593442) -->
<skip />

View File

@@ -230,7 +230,7 @@
<string name="bluetooth_settings" msgid="2725796451253089609">"Configuración de Bluetooth"</string>
<string name="bluetooth_settings_title" msgid="2824020086246268296">"Config. de Bluetooth"</string>
<string name="bluetooth_settings_summary" msgid="2091062709530570462">"Administrar conexiones, establecer nombre y detección del dispositivo"</string>
<string name="bluetooth_pin_entry" msgid="5627349871303455279">"Solicitud de vinculación de Bluetooth"</string>
<string name="bluetooth_pairing_dialog" msgid="5627349871303455279">"Solicitud de vinculación de Bluetooth"</string>
<string name="bluetooth_device_info" msgid="6644515376523965073">"Información del dispositivo Bluetooth"</string>
<!-- no translation found for bluetooth_enter_pin_msg (5282139964993593442) -->
<skip />

View File

@@ -230,7 +230,7 @@
<string name="bluetooth_settings" msgid="2725796451253089609">"Bluetooth"</string>
<string name="bluetooth_settings_title" msgid="2824020086246268296">"Ajustes de Bluetooth"</string>
<string name="bluetooth_settings_summary" msgid="2091062709530570462">"Administrar conexiones, establecer el nombre del dispositivo y la visibilidad"</string>
<string name="bluetooth_pin_entry" msgid="5627349871303455279">"Solicitud de sincronización de Bluetooth"</string>
<string name="bluetooth_pairing_dialog" msgid="5627349871303455279">"Solicitud de sincronización de Bluetooth"</string>
<string name="bluetooth_device_info" msgid="6644515376523965073">"Información de dispositivo Bluetooth"</string>
<!-- no translation found for bluetooth_enter_pin_msg (5282139964993593442) -->
<skip />

View File

@@ -230,7 +230,7 @@
<string name="bluetooth_settings" msgid="2725796451253089609">"Paramètres Bluetooth"</string>
<string name="bluetooth_settings_title" msgid="2824020086246268296">"Paramètres Bluetooth"</string>
<string name="bluetooth_settings_summary" msgid="2091062709530570462">"Gérer les connexions, configurer le nom et l\'identification de l\'appareil"</string>
<string name="bluetooth_pin_entry" msgid="5627349871303455279">"Demande d\'association Bluetooth"</string>
<string name="bluetooth_pairing_dialog" msgid="5627349871303455279">"Demande d\'association Bluetooth"</string>
<string name="bluetooth_device_info" msgid="6644515376523965073">"Informations sur l\'appareil Bluetooth"</string>
<!-- no translation found for bluetooth_enter_pin_msg (5282139964993593442) -->
<skip />

View File

@@ -230,7 +230,7 @@
<string name="bluetooth_settings" msgid="2725796451253089609">"Impostazioni Bluetooth"</string>
<string name="bluetooth_settings_title" msgid="2824020086246268296">"Impostazioni Bluetooth"</string>
<string name="bluetooth_settings_summary" msgid="2091062709530570462">"Gestisci le connessioni, imposta il nome e la rilevabilità del dispositivo"</string>
<string name="bluetooth_pin_entry" msgid="5627349871303455279">"Richiesta accoppiamento Bluetooth"</string>
<string name="bluetooth_pairing_dialog" msgid="5627349871303455279">"Richiesta accoppiamento Bluetooth"</string>
<string name="bluetooth_device_info" msgid="6644515376523965073">"Info dispositivo Bluetooth"</string>
<!-- no translation found for bluetooth_enter_pin_msg (5282139964993593442) -->
<skip />

View File

@@ -230,7 +230,7 @@
<string name="bluetooth_settings" msgid="2725796451253089609">"Bluetooth設定"</string>
<string name="bluetooth_settings_title" msgid="2824020086246268296">"Bluetooth設定"</string>
<string name="bluetooth_settings_summary" msgid="2091062709530570462">"端末の名前、接続や検出設定"</string>
<string name="bluetooth_pin_entry" msgid="5627349871303455279">"Bluetoothペア設定リクエスト"</string>
<string name="bluetooth_pairing_dialog" msgid="5627349871303455279">"Bluetoothペア設定リクエスト"</string>
<string name="bluetooth_device_info" msgid="6644515376523965073">"Bluetooth端末情報"</string>
<!-- no translation found for bluetooth_enter_pin_msg (5282139964993593442) -->
<skip />

View File

@@ -230,7 +230,7 @@
<string name="bluetooth_settings" msgid="2725796451253089609">"Bluetooth 설정"</string>
<string name="bluetooth_settings_title" msgid="2824020086246268296">"Bluetooth 설정"</string>
<string name="bluetooth_settings_summary" msgid="2091062709530570462">"연결 관리, 장치이름 및 검색가능 여부 설정"</string>
<string name="bluetooth_pin_entry" msgid="5627349871303455279">"Bluetooth 페어링 요청"</string>
<string name="bluetooth_pairing_dialog" msgid="5627349871303455279">"Bluetooth 페어링 요청"</string>
<string name="bluetooth_device_info" msgid="6644515376523965073">"Bluetooth 장치 정보"</string>
<!-- no translation found for bluetooth_enter_pin_msg (5282139964993593442) -->
<skip />

View File

@@ -230,7 +230,7 @@
<string name="bluetooth_settings" msgid="2725796451253089609">"Bluetooth-innstillinger"</string>
<string name="bluetooth_settings_title" msgid="2824020086246268296">"Bluetooth-innstillinger"</string>
<string name="bluetooth_settings_summary" msgid="2091062709530570462">"Tilkoblinger, enhetsnavn og synlighet"</string>
<string name="bluetooth_pin_entry" msgid="5627349871303455279">"Forespørsel om Bluetooth-paring"</string>
<string name="bluetooth_pairing_dialog" msgid="5627349871303455279">"Forespørsel om Bluetooth-paring"</string>
<string name="bluetooth_device_info" msgid="6644515376523965073">"Bluetooth-enhetsinformasjon"</string>
<!-- no translation found for bluetooth_enter_pin_msg (5282139964993593442) -->
<skip />

View File

@@ -230,7 +230,7 @@
<string name="bluetooth_settings" msgid="2725796451253089609">"Bluetooth-instellingen"</string>
<string name="bluetooth_settings_title" msgid="2824020086246268296">"Bluetooth-instellingen"</string>
<string name="bluetooth_settings_summary" msgid="2091062709530570462">"Verbindingen beheren, apparaatnaam en vindbaarheid instellen"</string>
<string name="bluetooth_pin_entry" msgid="5627349871303455279">"Bluetooth-koppelingsverzoek"</string>
<string name="bluetooth_pairing_dialog" msgid="5627349871303455279">"Bluetooth-koppelingsverzoek"</string>
<string name="bluetooth_device_info" msgid="6644515376523965073">"Bluetooth-apparaatinfo"</string>
<!-- no translation found for bluetooth_enter_pin_msg (5282139964993593442) -->
<skip />

View File

@@ -230,7 +230,7 @@
<string name="bluetooth_settings" msgid="2725796451253089609">"Ustawienia Bluetooth"</string>
<string name="bluetooth_settings_title" msgid="2824020086246268296">"Ustawienia Bluetooth"</string>
<string name="bluetooth_settings_summary" msgid="2091062709530570462">"Zarządzaj połączeniami, ustaw nazwę urządzenia i możliwość wykrycia"</string>
<string name="bluetooth_pin_entry" msgid="5627349871303455279">"Żądanie parowania Bluetooth"</string>
<string name="bluetooth_pairing_dialog" msgid="5627349871303455279">"Żądanie parowania Bluetooth"</string>
<string name="bluetooth_device_info" msgid="6644515376523965073">"Informacje o urządzeniu Bluetooth"</string>
<!-- no translation found for bluetooth_enter_pin_msg (5282139964993593442) -->
<skip />

View File

@@ -230,7 +230,7 @@
<string name="bluetooth_settings" msgid="2725796451253089609">"Definições de Bluetooth"</string>
<string name="bluetooth_settings_title" msgid="2824020086246268296">"Definições de Bluetooth"</string>
<string name="bluetooth_settings_summary" msgid="2091062709530570462">"Gerir ligações, definir nome e detectabilidade do dispositivo"</string>
<string name="bluetooth_pin_entry" msgid="5627349871303455279">"Pedido de emparelhamento de Bluetooth"</string>
<string name="bluetooth_pairing_dialog" msgid="5627349871303455279">"Pedido de emparelhamento de Bluetooth"</string>
<string name="bluetooth_device_info" msgid="6644515376523965073">"Informações sobre dispositivo Bluetooth"</string>
<!-- no translation found for bluetooth_enter_pin_msg (5282139964993593442) -->
<skip />

View File

@@ -230,7 +230,7 @@
<string name="bluetooth_settings" msgid="2725796451253089609">"Configurações de Bluetooth"</string>
<string name="bluetooth_settings_title" msgid="2824020086246268296">"Configurações de Bluetooth"</string>
<string name="bluetooth_settings_summary" msgid="2091062709530570462">"Gerenciar conexões, definir o nome e detecção do dispositivo"</string>
<string name="bluetooth_pin_entry" msgid="5627349871303455279">"Solicitação de pareamento Bluetooth"</string>
<string name="bluetooth_pairing_dialog" msgid="5627349871303455279">"Solicitação de pareamento Bluetooth"</string>
<string name="bluetooth_device_info" msgid="6644515376523965073">"Informações do dispositivo Bluetooth"</string>
<!-- no translation found for bluetooth_enter_pin_msg (5282139964993593442) -->
<skip />

View File

@@ -230,7 +230,7 @@
<string name="bluetooth_settings" msgid="2725796451253089609">"Настройки Bluetooth"</string>
<string name="bluetooth_settings_title" msgid="2824020086246268296">"Настройки Bluetooth"</string>
<string name="bluetooth_settings_summary" msgid="2091062709530570462">"Настройка подключений, видимости и имени устройства"</string>
<string name="bluetooth_pin_entry" msgid="5627349871303455279">"Запрос сопряжения Bluetooth"</string>
<string name="bluetooth_pairing_dialog" msgid="5627349871303455279">"Запрос сопряжения Bluetooth"</string>
<string name="bluetooth_device_info" msgid="6644515376523965073">"Сведения об устройстве Bluetooth"</string>
<!-- no translation found for bluetooth_enter_pin_msg (5282139964993593442) -->
<skip />

View File

@@ -230,7 +230,7 @@
<string name="bluetooth_settings" msgid="2725796451253089609">"Bluetooth-inställningar"</string>
<string name="bluetooth_settings_title" msgid="2824020086246268296">"Bluetooth-inställningar"</string>
<string name="bluetooth_settings_summary" msgid="2091062709530570462">"Hantera anslutningar, ange inställningar för enhetens namn och synlighet"</string>
<string name="bluetooth_pin_entry" msgid="5627349871303455279">"Begäran om Bluetooth-parkoppling"</string>
<string name="bluetooth_pairing_dialog" msgid="5627349871303455279">"Begäran om Bluetooth-parkoppling"</string>
<string name="bluetooth_device_info" msgid="6644515376523965073">"Information om Bluetooth-enhet"</string>
<!-- no translation found for bluetooth_enter_pin_msg (5282139964993593442) -->
<skip />

View File

@@ -230,7 +230,7 @@
<string name="bluetooth_settings" msgid="2725796451253089609">"Bluetooth ayarları"</string>
<string name="bluetooth_settings_title" msgid="2824020086246268296">"Bluetooth ayarları"</string>
<string name="bluetooth_settings_summary" msgid="2091062709530570462">"Bağlantıları yönet, cihaz adını gir ve keşfedilebilirlik ayarını yap"</string>
<string name="bluetooth_pin_entry" msgid="5627349871303455279">"Bluetooth eşleşme isteği"</string>
<string name="bluetooth_pairing_dialog" msgid="5627349871303455279">"Bluetooth eşleşme isteği"</string>
<string name="bluetooth_device_info" msgid="6644515376523965073">"Bluetooth cihaz bilgileri"</string>
<!-- no translation found for bluetooth_enter_pin_msg (5282139964993593442) -->
<skip />

View File

@@ -230,7 +230,7 @@
<string name="bluetooth_settings" msgid="2725796451253089609">"蓝牙设置"</string>
<string name="bluetooth_settings_title" msgid="2824020086246268296">"蓝牙设置"</string>
<string name="bluetooth_settings_summary" msgid="2091062709530570462">"管理连接,设置设备名称和可检测性"</string>
<string name="bluetooth_pin_entry" msgid="5627349871303455279">"蓝牙配对请求"</string>
<string name="bluetooth_pairing_dialog" msgid="5627349871303455279">"蓝牙配对请求"</string>
<string name="bluetooth_device_info" msgid="6644515376523965073">"蓝牙设备信息"</string>
<!-- no translation found for bluetooth_enter_pin_msg (5282139964993593442) -->
<skip />

View File

@@ -230,7 +230,7 @@
<string name="bluetooth_settings" msgid="2725796451253089609">"藍牙設定"</string>
<string name="bluetooth_settings_title" msgid="2824020086246268296">"藍牙設定"</string>
<string name="bluetooth_settings_summary" msgid="2091062709530570462">"管理連線、設定裝置名稱與可偵測性"</string>
<string name="bluetooth_pin_entry" msgid="5627349871303455279">"藍牙配對要求"</string>
<string name="bluetooth_pairing_dialog" msgid="5627349871303455279">"藍牙配對要求"</string>
<string name="bluetooth_device_info" msgid="6644515376523965073">"藍牙裝置資訊"</string>
<!-- no translation found for bluetooth_enter_pin_msg (5282139964993593442) -->
<skip />

View File

@@ -509,7 +509,7 @@
<string name="bluetooth_settings_summary">Manage connections, set device name &amp; discoverability</string>
<!-- Title for the dialog to enter PIN. -->
<string name="bluetooth_pin_entry">Bluetooth pairing request</string>
<string name="bluetooth_pairing_request">Bluetooth pairing request</string>
<!-- Title for the bluetooth device info screen. -->
<string name="bluetooth_device_info">Bluetooth device info</string>
<!-- Message when bluetooth dialog for pin entry is showing -->
@@ -518,10 +518,16 @@
<string name="bluetooth_enter_passkey_msg">\nType passkey to pair with \u0022<xliff:g id="device_name">%1$s</xliff:g>\u0022.</string>
<!-- Message when bluetooth dialog for confirmation of passkey is showing -->
<string name="bluetooth_confirm_passkey_msg">To pair with \u0022<xliff:g id="device_name">%1$s</xliff:g>\u0022, confirm that it is showing the passkey: <xliff:g id="passkey">%2$s</xliff:g>.</string>
<!-- Message when bluetooth incoming pairing request for (2.1 devices) dialog is showing -->
<string name="bluetooth_incoming_pairing_msg"><xliff:g id="device_name">%1$s</xliff:g>\nwants to pair.</string>
<!-- Message when bluetooth dialog when passkey needs to be displayed. -->
<string name="bluetooth_display_passkey_msg">Enter <xliff:g id="passkey">%2$s</xliff:g> on \u0022<xliff:g id="device_name">%1$s</xliff:g>\u0022 to pair. </string>
<!-- Button text for accepting an incoming pairing request -->
<string name="bluetooth_pairing_accept">Pair</string>
<!-- Button text for declining an incoming pairing request -->
<string name="bluetooth_pairing_decline">Don\u0027t Pair</string>
<!-- Generic string for remote Bluetooth device -->
<string name="bluetooth_remote_device">bluetooth device</string>
<!-- Title for BT error dialogs. -->
<string name="bluetooth_error_title">Attention</string>
@@ -529,7 +535,7 @@
<string name="bluetooth_pairing_error_message">There was a problem pairing with <xliff:g id="device_name">%1$s</xliff:g>.</string>
<!-- Message for the error dialog when BT pairing fails because the PIN /
Passkey entered is incorrect. -->
<string name="bluetooth_pairing_pin_error_message">There was a problem pairing with <xliff:g id="device_name">%1$s</xliff:g> because the typed PIN or Passkey is incorrect.</string>
<string name="bluetooth_pairing_pin_error_message">There was a problem pairing with <xliff:g id="device_name">%1$s</xliff:g> because the PIN or Passkey is incorrect.</string>
<!-- Message for the error dialog when BT pairing fails because the other device is down. -->
<string name="bluetooth_pairing_device_down_error_message">Cannot establish communication with <xliff:g id="device_name">%1$s</xliff:g>.</string>
<!-- Message for the error dialog when BT pairing fails because the other device rejected the pairing. -->

View File

@@ -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);

View File

@@ -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");
}
}

View File

@@ -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);
}

View File

@@ -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,

View File

@@ -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();
}
}