1afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project/* 2afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project * Copyright (C) 2008 The Android Open Source Project 3afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project * 4afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License"); 5afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project * you may not use this file except in compliance with the License. 6afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project * You may obtain a copy of the License at 7afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project * 8afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project * http://www.apache.org/licenses/LICENSE-2.0 9afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project * 10afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project * Unless required by applicable law or agreed to in writing, software 11afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS, 12afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project * See the License for the specific language governing permissions and 14afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project * limitations under the License. 15afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project */ 16afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project 17afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Projectpackage com.android.settings.bluetooth; 18afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project 19afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Projectimport android.bluetooth.BluetoothDevice; 20afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Projectimport android.content.BroadcastReceiver; 21afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Projectimport android.content.Context; 22afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Projectimport android.content.DialogInterface; 23afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Projectimport android.content.Intent; 24afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Projectimport android.content.IntentFilter; 25afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Projectimport android.os.Bundle; 26afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Projectimport android.text.Editable; 27ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hambyimport android.text.Html; 28afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Projectimport android.text.InputFilter; 293a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganeshimport android.text.InputType; 30ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hambyimport android.text.Spanned; 31afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Projectimport android.text.TextWatcher; 32afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Projectimport android.text.InputFilter.LengthFilter; 33afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Projectimport android.util.Log; 34afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Projectimport android.view.View; 35afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Projectimport android.widget.Button; 36ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hambyimport android.widget.CheckBox; 37ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hambyimport android.widget.CompoundButton; 38afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Projectimport android.widget.EditText; 39afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Projectimport android.widget.TextView; 40afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project 41afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Projectimport com.android.internal.app.AlertActivity; 42afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Projectimport com.android.internal.app.AlertController; 43afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Projectimport com.android.settings.R; 44aaf8ffff79a73c71d3fb77a31950e344f4c7eab5jhtop.kimimport android.view.KeyEvent; 45afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project 46ae8d5bdc5bfabb457135dbe9c30084bffdc16a7cFabrice Di Meglioimport java.util.Locale; 47ae8d5bdc5bfabb457135dbe9c30084bffdc16a7cFabrice Di Meglio 48afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project/** 493a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh * BluetoothPairingDialog asks the user to enter a PIN / Passkey / simple confirmation 503a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh * for pairing with a remote Bluetooth device. It is an activity that appears as a dialog. 51afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project */ 52ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hambypublic final class BluetoothPairingDialog extends AlertActivity implements 53ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby CompoundButton.OnCheckedChangeListener, DialogInterface.OnClickListener, TextWatcher { 543a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh private static final String TAG = "BluetoothPairingDialog"; 55afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project 56e79f990490de49b39097433707c2bae6d8238330Jake Hamby private static final int BLUETOOTH_PIN_MAX_LENGTH = 16; 57e79f990490de49b39097433707c2bae6d8238330Jake Hamby private static final int BLUETOOTH_PASSKEY_MAX_LENGTH = 6; 58a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee 59a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee private LocalBluetoothManager mBluetoothManager; 60a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee private CachedBluetoothDeviceManager mCachedDeviceManager; 61d63c0112251ab4e4e977545368dd703d875012a4Nick Pelly private BluetoothDevice mDevice; 623a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh private int mType; 63da23ae88d110dce585b19581a180feefbb0be4c8Jaikumar Ganesh private String mPairingKey; 643a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh private EditText mPairingView; 65afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project private Button mOkButton; 66afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project 67436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby /** 68436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby * Dismiss the dialog if the bond state changes to bonded or none, 69436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby * or if pairing was canceled for {@link #mDevice}. 70436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby */ 71436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby private final BroadcastReceiver mReceiver = new BroadcastReceiver() { 72afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project @Override 73afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project public void onReceive(Context context, Intent intent) { 74436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby String action = intent.getAction(); 75436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby if (BluetoothDevice.ACTION_BOND_STATE_CHANGED.equals(action)) { 76435ad270b5f4e31e94a2bba204769660bbd4b3caJaikumar Ganesh int bondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, 77435ad270b5f4e31e94a2bba204769660bbd4b3caJaikumar Ganesh BluetoothDevice.ERROR); 78435ad270b5f4e31e94a2bba204769660bbd4b3caJaikumar Ganesh if (bondState == BluetoothDevice.BOND_BONDED || 79435ad270b5f4e31e94a2bba204769660bbd4b3caJaikumar Ganesh bondState == BluetoothDevice.BOND_NONE) { 80436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby dismiss(); 81435ad270b5f4e31e94a2bba204769660bbd4b3caJaikumar Ganesh } 82436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby } else if (BluetoothDevice.ACTION_PAIRING_CANCEL.equals(action)) { 83435ad270b5f4e31e94a2bba204769660bbd4b3caJaikumar Ganesh BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); 84435ad270b5f4e31e94a2bba204769660bbd4b3caJaikumar Ganesh if (device == null || device.equals(mDevice)) { 85436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby dismiss(); 86435ad270b5f4e31e94a2bba204769660bbd4b3caJaikumar Ganesh } 87afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project } 88afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project } 89afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project }; 903a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh 91afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project @Override 92afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project protected void onCreate(Bundle savedInstanceState) { 93afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project super.onCreate(savedInstanceState); 94afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project 95afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project Intent intent = getIntent(); 9616cc86315d7a8e1f6a0f3083d0a810a7cb097832Nick Pelly if (!intent.getAction().equals(BluetoothDevice.ACTION_PAIRING_REQUEST)) 97afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project { 98436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby Log.e(TAG, "Error: this activity may be started only with intent " + 9916cc86315d7a8e1f6a0f3083d0a810a7cb097832Nick Pelly BluetoothDevice.ACTION_PAIRING_REQUEST); 100afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project finish(); 101436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby return; 102afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project } 1033a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh 104a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee mBluetoothManager = LocalBluetoothManager.getInstance(this); 105a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee if (mBluetoothManager == null) { 106436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby Log.e(TAG, "Error: BluetoothAdapter not supported by system"); 107436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby finish(); 108436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby return; 109436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby } 110a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee mCachedDeviceManager = mBluetoothManager.getCachedDeviceManager(); 111436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby 11216cc86315d7a8e1f6a0f3083d0a810a7cb097832Nick Pelly mDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); 11316cc86315d7a8e1f6a0f3083d0a810a7cb097832Nick Pelly mType = intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, BluetoothDevice.ERROR); 114436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby 115436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby switch (mType) { 116436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby case BluetoothDevice.PAIRING_VARIANT_PIN: 117436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby case BluetoothDevice.PAIRING_VARIANT_PASSKEY: 118a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee createUserEntryDialog(); 119436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby break; 120436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby 121436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby case BluetoothDevice.PAIRING_VARIANT_PASSKEY_CONFIRMATION: 122436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby int passkey = 123436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_KEY, BluetoothDevice.ERROR); 124436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby if (passkey == BluetoothDevice.ERROR) { 125436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby Log.e(TAG, "Invalid Confirmation Passkey received, not showing any dialog"); 126436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby return; 127436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby } 128ae8d5bdc5bfabb457135dbe9c30084bffdc16a7cFabrice Di Meglio mPairingKey = String.format(Locale.US, "%06d", passkey); 129a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee createConfirmationDialog(); 130436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby break; 131436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby 132436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby case BluetoothDevice.PAIRING_VARIANT_CONSENT: 133436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby case BluetoothDevice.PAIRING_VARIANT_OOB_CONSENT: 134a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee createConsentDialog(); 135436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby break; 136436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby 137436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby case BluetoothDevice.PAIRING_VARIANT_DISPLAY_PASSKEY: 138436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby case BluetoothDevice.PAIRING_VARIANT_DISPLAY_PIN: 139436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby int pairingKey = 140436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_KEY, BluetoothDevice.ERROR); 141436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby if (pairingKey == BluetoothDevice.ERROR) { 142436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby Log.e(TAG, "Invalid Confirmation Passkey or PIN received, not showing any dialog"); 143436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby return; 144436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby } 145436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby if (mType == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PASSKEY) { 146436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby mPairingKey = String.format("%06d", pairingKey); 147436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby } else { 148436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby mPairingKey = String.format("%04d", pairingKey); 149436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby } 150a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee createDisplayPasskeyOrPinDialog(); 151436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby break; 152436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby 153436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby default: 154436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby Log.e(TAG, "Incorrect pairing type received, not showing any dialog"); 1553a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh } 1563a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh 1573a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh /* 1583a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh * Leave this registered through pause/resume since we still want to 1593a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh * finish the activity in the background if pairing is canceled. 1603a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh */ 16116cc86315d7a8e1f6a0f3083d0a810a7cb097832Nick Pelly registerReceiver(mReceiver, new IntentFilter(BluetoothDevice.ACTION_PAIRING_CANCEL)); 162435ad270b5f4e31e94a2bba204769660bbd4b3caJaikumar Ganesh registerReceiver(mReceiver, new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED)); 1633a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh } 1643a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh 165a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee private void createUserEntryDialog() { 166afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project final AlertController.AlertParams p = mAlertParams; 167435ad270b5f4e31e94a2bba204769660bbd4b3caJaikumar Ganesh p.mTitle = getString(R.string.bluetooth_pairing_request); 168a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee p.mView = createPinEntryView(); 169afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project p.mPositiveButtonText = getString(android.R.string.ok); 170afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project p.mPositiveButtonListener = this; 171afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project p.mNegativeButtonText = getString(android.R.string.cancel); 172afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project p.mNegativeButtonListener = this; 173afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project setupAlert(); 1743a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh 175436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby mOkButton = mAlert.getButton(BUTTON_POSITIVE); 176afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project mOkButton.setEnabled(false); 1773a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh } 178afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project 179a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee private View createPinEntryView() { 1803a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh View view = getLayoutInflater().inflate(R.layout.bluetooth_pin_entry, null); 181e49c30e533be90280b4a6e9cb0065adb1b43b104PauloftheWest TextView messageViewCaption = (TextView) view.findViewById(R.id.message_caption); 182e49c30e533be90280b4a6e9cb0065adb1b43b104PauloftheWest TextView messageViewContent = (TextView) view.findViewById(R.id.message_subhead); 183ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby TextView messageView2 = (TextView) view.findViewById(R.id.message_below_pin); 184ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby CheckBox alphanumericPin = (CheckBox) view.findViewById(R.id.alphanumeric_pin); 1853a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh mPairingView = (EditText) view.findViewById(R.id.text); 1863a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh mPairingView.addTextChangedListener(this); 187ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby alphanumericPin.setOnCheckedChangeListener(this); 1883a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh 189ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby int messageId1; 190ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby int messageId2; 191ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby int maxLength; 192436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby switch (mType) { 193436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby case BluetoothDevice.PAIRING_VARIANT_PIN: 194ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby messageId1 = R.string.bluetooth_enter_pin_msg; 195ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby messageId2 = R.string.bluetooth_enter_pin_other_device; 196ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby // Maximum of 16 characters in a PIN 197ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby maxLength = BLUETOOTH_PIN_MAX_LENGTH; 198436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby break; 199436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby 200436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby case BluetoothDevice.PAIRING_VARIANT_PASSKEY: 201e49c30e533be90280b4a6e9cb0065adb1b43b104PauloftheWest messageId1 = R.string.bluetooth_enter_pin_msg; 202ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby messageId2 = R.string.bluetooth_enter_passkey_other_device; 203436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby // Maximum of 6 digits for passkey 204ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby maxLength = BLUETOOTH_PASSKEY_MAX_LENGTH; 205ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby alphanumericPin.setVisibility(View.GONE); 206436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby break; 207436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby 208ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby default: 209ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby Log.e(TAG, "Incorrect pairing type for createPinEntryView: " + mType); 210ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby return null; 211ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby } 212ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby 213e49c30e533be90280b4a6e9cb0065adb1b43b104PauloftheWest messageViewCaption.setText(messageId1); 214a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee messageViewContent.setText(mCachedDeviceManager.getName(mDevice)); 215ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby messageView2.setText(messageId2); 216ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby mPairingView.setInputType(InputType.TYPE_CLASS_NUMBER); 217ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby mPairingView.setFilters(new InputFilter[] { 218ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby new LengthFilter(maxLength) }); 219ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby 220ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby return view; 221ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby } 222ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby 223a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee private View createView() { 224ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby View view = getLayoutInflater().inflate(R.layout.bluetooth_pin_confirm, null); 225e49c30e533be90280b4a6e9cb0065adb1b43b104PauloftheWest // Escape device name to avoid HTML injection. 226a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee String name = Html.escapeHtml(mCachedDeviceManager.getName(mDevice)); 227e49c30e533be90280b4a6e9cb0065adb1b43b104PauloftheWest TextView messageViewCaption = (TextView) view.findViewById(R.id.message_caption); 228e49c30e533be90280b4a6e9cb0065adb1b43b104PauloftheWest TextView messageViewContent = (TextView) view.findViewById(R.id.message_subhead); 229e49c30e533be90280b4a6e9cb0065adb1b43b104PauloftheWest TextView pairingViewCaption = (TextView) view.findViewById(R.id.pairing_caption); 230e49c30e533be90280b4a6e9cb0065adb1b43b104PauloftheWest TextView pairingViewContent = (TextView) view.findViewById(R.id.pairing_subhead); 231e49c30e533be90280b4a6e9cb0065adb1b43b104PauloftheWest TextView messagePairing = (TextView) view.findViewById(R.id.pairing_code_message); 232e49c30e533be90280b4a6e9cb0065adb1b43b104PauloftheWest 233e49c30e533be90280b4a6e9cb0065adb1b43b104PauloftheWest String messageCaption = null; 234e49c30e533be90280b4a6e9cb0065adb1b43b104PauloftheWest String pairingContent = null; 235ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby switch (mType) { 236e49c30e533be90280b4a6e9cb0065adb1b43b104PauloftheWest case BluetoothDevice.PAIRING_VARIANT_DISPLAY_PASSKEY: 237e49c30e533be90280b4a6e9cb0065adb1b43b104PauloftheWest case BluetoothDevice.PAIRING_VARIANT_DISPLAY_PIN: 23810773b4d4d7d11c1d4197de0277e57f4f6848e3aPauloftheWest messagePairing.setVisibility(View.VISIBLE); 239436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby case BluetoothDevice.PAIRING_VARIANT_PASSKEY_CONFIRMATION: 240e49c30e533be90280b4a6e9cb0065adb1b43b104PauloftheWest messageCaption = getString(R.string.bluetooth_enter_pin_msg); 241e49c30e533be90280b4a6e9cb0065adb1b43b104PauloftheWest pairingContent = mPairingKey; 242436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby break; 243436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby 244436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby case BluetoothDevice.PAIRING_VARIANT_CONSENT: 245ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby case BluetoothDevice.PAIRING_VARIANT_OOB_CONSENT: 24610773b4d4d7d11c1d4197de0277e57f4f6848e3aPauloftheWest messagePairing.setVisibility(View.VISIBLE); 247e49c30e533be90280b4a6e9cb0065adb1b43b104PauloftheWest messageCaption = getString(R.string.bluetooth_enter_pin_msg); 248436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby break; 249436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby 250436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby default: 251436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby Log.e(TAG, "Incorrect pairing type received, not creating view"); 252ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby return null; 2533a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh } 254e49c30e533be90280b4a6e9cb0065adb1b43b104PauloftheWest 255e49c30e533be90280b4a6e9cb0065adb1b43b104PauloftheWest if (messageViewCaption != null) { 256e49c30e533be90280b4a6e9cb0065adb1b43b104PauloftheWest messageViewCaption.setText(messageCaption); 257e49c30e533be90280b4a6e9cb0065adb1b43b104PauloftheWest messageViewContent.setText(name); 258e49c30e533be90280b4a6e9cb0065adb1b43b104PauloftheWest } 259e49c30e533be90280b4a6e9cb0065adb1b43b104PauloftheWest 260e49c30e533be90280b4a6e9cb0065adb1b43b104PauloftheWest if (pairingContent != null) { 261e49c30e533be90280b4a6e9cb0065adb1b43b104PauloftheWest pairingViewCaption.setVisibility(View.VISIBLE); 262e49c30e533be90280b4a6e9cb0065adb1b43b104PauloftheWest pairingViewContent.setVisibility(View.VISIBLE); 263e49c30e533be90280b4a6e9cb0065adb1b43b104PauloftheWest pairingViewContent.setText(pairingContent); 264e49c30e533be90280b4a6e9cb0065adb1b43b104PauloftheWest } 265e49c30e533be90280b4a6e9cb0065adb1b43b104PauloftheWest 2663a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh return view; 2673a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh } 2683a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh 269a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee private void createConfirmationDialog() { 2703a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh final AlertController.AlertParams p = mAlertParams; 271435ad270b5f4e31e94a2bba204769660bbd4b3caJaikumar Ganesh p.mTitle = getString(R.string.bluetooth_pairing_request); 272a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee p.mView = createView(); 273e41a4ca695db12308006fe1a6d061642b7d3f1a1Michael Chan p.mPositiveButtonText = getString(R.string.bluetooth_pairing_accept); 2743a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh p.mPositiveButtonListener = this; 275e41a4ca695db12308006fe1a6d061642b7d3f1a1Michael Chan p.mNegativeButtonText = getString(R.string.bluetooth_pairing_decline); 2763a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh p.mNegativeButtonListener = this; 2773a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh setupAlert(); 278afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project } 279afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project 280a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee private void createConsentDialog() { 281435ad270b5f4e31e94a2bba204769660bbd4b3caJaikumar Ganesh final AlertController.AlertParams p = mAlertParams; 282435ad270b5f4e31e94a2bba204769660bbd4b3caJaikumar Ganesh p.mTitle = getString(R.string.bluetooth_pairing_request); 283a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee p.mView = createView(); 284435ad270b5f4e31e94a2bba204769660bbd4b3caJaikumar Ganesh p.mPositiveButtonText = getString(R.string.bluetooth_pairing_accept); 285435ad270b5f4e31e94a2bba204769660bbd4b3caJaikumar Ganesh p.mPositiveButtonListener = this; 286435ad270b5f4e31e94a2bba204769660bbd4b3caJaikumar Ganesh p.mNegativeButtonText = getString(R.string.bluetooth_pairing_decline); 287435ad270b5f4e31e94a2bba204769660bbd4b3caJaikumar Ganesh p.mNegativeButtonListener = this; 288435ad270b5f4e31e94a2bba204769660bbd4b3caJaikumar Ganesh setupAlert(); 289afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project } 290afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project 291a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee private void createDisplayPasskeyOrPinDialog() { 292435ad270b5f4e31e94a2bba204769660bbd4b3caJaikumar Ganesh final AlertController.AlertParams p = mAlertParams; 293435ad270b5f4e31e94a2bba204769660bbd4b3caJaikumar Ganesh p.mTitle = getString(R.string.bluetooth_pairing_request); 294a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee p.mView = createView(); 295da23ae88d110dce585b19581a180feefbb0be4c8Jaikumar Ganesh p.mNegativeButtonText = getString(android.R.string.cancel); 296da23ae88d110dce585b19581a180feefbb0be4c8Jaikumar Ganesh p.mNegativeButtonListener = this; 297435ad270b5f4e31e94a2bba204769660bbd4b3caJaikumar Ganesh setupAlert(); 2983a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh 299435ad270b5f4e31e94a2bba204769660bbd4b3caJaikumar Ganesh // Since its only a notification, send an OK to the framework, 300435ad270b5f4e31e94a2bba204769660bbd4b3caJaikumar Ganesh // indicating that the dialog has been displayed. 301da23ae88d110dce585b19581a180feefbb0be4c8Jaikumar Ganesh if (mType == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PASSKEY) { 302da23ae88d110dce585b19581a180feefbb0be4c8Jaikumar Ganesh mDevice.setPairingConfirmation(true); 303da23ae88d110dce585b19581a180feefbb0be4c8Jaikumar Ganesh } else if (mType == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PIN) { 304da23ae88d110dce585b19581a180feefbb0be4c8Jaikumar Ganesh byte[] pinBytes = BluetoothDevice.convertPinToBytes(mPairingKey); 305da23ae88d110dce585b19581a180feefbb0be4c8Jaikumar Ganesh mDevice.setPin(pinBytes); 306da23ae88d110dce585b19581a180feefbb0be4c8Jaikumar Ganesh } 307afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project } 308afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project 309afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project @Override 310afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project protected void onDestroy() { 311afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project super.onDestroy(); 312afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project unregisterReceiver(mReceiver); 313afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project } 314afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project 315afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project public void afterTextChanged(Editable s) { 3162affa6b28ddacc87f0f95f2ddd124b256ff61850jhtop.kim if (mOkButton != null) { 3172affa6b28ddacc87f0f95f2ddd124b256ff61850jhtop.kim mOkButton.setEnabled(s.length() > 0); 318afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project } 319afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project } 320afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project 321a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee private void allowPhonebookAccess() { 322a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee CachedBluetoothDevice cachedDevice = mCachedDeviceManager.findDevice(mDevice); 323a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee if (cachedDevice == null) { 324a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee cachedDevice = mCachedDeviceManager.addDevice( 325a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee mBluetoothManager.getBluetoothAdapter(), 326a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee mBluetoothManager.getProfileManager(), 327a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee mDevice); 328a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee } 329a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee cachedDevice.setPhonebookPermissionChoice(CachedBluetoothDevice.ACCESS_ALLOWED); 330a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee } 331a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee 3323a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh private void onPair(String value) { 333a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee allowPhonebookAccess(); 334a539716a94cbfe33e32229549b70d7cb418d8840Edward Jee 335436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby switch (mType) { 336436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby case BluetoothDevice.PAIRING_VARIANT_PIN: 337436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby byte[] pinBytes = BluetoothDevice.convertPinToBytes(value); 338436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby if (pinBytes == null) { 339436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby return; 340436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby } 341436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby mDevice.setPin(pinBytes); 342436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby break; 343436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby 344436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby case BluetoothDevice.PAIRING_VARIANT_PASSKEY: 345436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby int passkey = Integer.parseInt(value); 346436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby mDevice.setPasskey(passkey); 347436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby break; 348436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby 349436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby case BluetoothDevice.PAIRING_VARIANT_PASSKEY_CONFIRMATION: 350436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby case BluetoothDevice.PAIRING_VARIANT_CONSENT: 351436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby mDevice.setPairingConfirmation(true); 352436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby break; 353436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby 354436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby case BluetoothDevice.PAIRING_VARIANT_DISPLAY_PASSKEY: 355436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby case BluetoothDevice.PAIRING_VARIANT_DISPLAY_PIN: 356436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby // Do nothing. 357436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby break; 358436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby 359436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby case BluetoothDevice.PAIRING_VARIANT_OOB_CONSENT: 360436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby mDevice.setRemoteOutOfBandData(); 361436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby break; 362436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby 363436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby default: 364436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby Log.e(TAG, "Incorrect pairing type received"); 365afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project } 366afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project } 367afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project 368afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project private void onCancel() { 369cb6a3b3d9e39d63bbf10d947579989e44bcc0b98Jaikumar Ganesh mDevice.cancelPairingUserInput(); 370afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project } 371aaf8ffff79a73c71d3fb77a31950e344f4c7eab5jhtop.kim 372aaf8ffff79a73c71d3fb77a31950e344f4c7eab5jhtop.kim public boolean onKeyDown(int keyCode, KeyEvent event) { 373aaf8ffff79a73c71d3fb77a31950e344f4c7eab5jhtop.kim if (keyCode == KeyEvent.KEYCODE_BACK) { 374aaf8ffff79a73c71d3fb77a31950e344f4c7eab5jhtop.kim onCancel(); 375aaf8ffff79a73c71d3fb77a31950e344f4c7eab5jhtop.kim } 376aaf8ffff79a73c71d3fb77a31950e344f4c7eab5jhtop.kim return super.onKeyDown(keyCode,event); 377aaf8ffff79a73c71d3fb77a31950e344f4c7eab5jhtop.kim } 3783a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh 379afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project public void onClick(DialogInterface dialog, int which) { 380afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project switch (which) { 381436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby case BUTTON_POSITIVE: 382ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby if (mPairingView != null) { 383ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby onPair(mPairingView.getText().toString()); 384ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby } else { 385ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby onPair(null); 386ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby } 387afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project break; 3883a76bcaa83c15f96832f934e67e6f0190e72a3dcJaikumar Ganesh 389436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby case BUTTON_NEGATIVE: 390436b29e68e6608bed9e8e7d54385b8f62d89208eJake Hamby default: 391afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project onCancel(); 392afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project break; 393afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project } 394afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project } 395afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project 396afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project /* Not used */ 397afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project public void beforeTextChanged(CharSequence s, int start, int count, int after) { 398afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project } 399afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project 400afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project /* Not used */ 401afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project public void onTextChanged(CharSequence s, int start, int before, int count) { 402afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project } 403afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project 404ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { 405ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby // change input type for soft keyboard to numeric or alphanumeric 406ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby if (isChecked) { 407ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby mPairingView.setInputType(InputType.TYPE_CLASS_TEXT); 408ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby } else { 409ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby mPairingView.setInputType(InputType.TYPE_CLASS_NUMBER); 410ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby } 411ca9812a8521fcc483e821fd5a88ec421de0b8f66Jake Hamby } 412afc4ab2ffbb8327ddce9907961295a32cbf49d0fThe Android Open Source Project} 413