diff options
Diffstat (limited to 'src/com')
4 files changed, 37 insertions, 43 deletions
diff --git a/src/com/android/settings/bluetooth/BluetoothPairingDialog.java b/src/com/android/settings/bluetooth/BluetoothPairingDialog.java index 4b7a0e071..1822e73f8 100644 --- a/src/com/android/settings/bluetooth/BluetoothPairingDialog.java +++ b/src/com/android/settings/bluetooth/BluetoothPairingDialog.java @@ -51,7 +51,7 @@ public class BluetoothPairingDialog extends AlertActivity implements DialogInter private LocalBluetoothManager mLocalManager; private BluetoothDevice mDevice; private int mType; - private String mPasskey; + private String mPairingKey; private EditText mPairingView; private Button mOkButton; @@ -96,24 +96,29 @@ public class BluetoothPairingDialog extends AlertActivity implements DialogInter createUserEntryDialog(); } else if (mType == BluetoothDevice.PAIRING_VARIANT_PASSKEY_CONFIRMATION){ int passkey = - intent.getIntExtra(BluetoothDevice.EXTRA_PASSKEY, BluetoothDevice.ERROR); + intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_KEY, BluetoothDevice.ERROR); if (passkey == BluetoothDevice.ERROR) { Log.e(TAG, "Invalid ConfirmationPasskey received, not showing any dialog"); return; } - mPasskey = String.format("%06d", passkey); + mPairingKey = 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"); + } else if (mType == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PASSKEY || + mType == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PIN) { + int pairingKey = + intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_KEY, BluetoothDevice.ERROR); + if (pairingKey == BluetoothDevice.ERROR) { + Log.e(TAG, "Invalid Confirmation Passkey or PIN received, not showing any dialog"); return; } - mPasskey = String.format("%06d", passkey); - createDisplayPasskeyDialog(); + if (mType == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PASSKEY) { + mPairingKey = String.format("%06d", pairingKey); + } else { + mPairingKey = String.format("%04d", pairingKey); + } + createDisplayPasskeyOrPinDialog(); } else if (mType == BluetoothDevice.PAIRING_VARIANT_OOB_CONSENT) { createConsentDialog(); } else { @@ -166,13 +171,15 @@ public class BluetoothPairingDialog extends AlertActivity implements DialogInter } else if (mType == BluetoothDevice.PAIRING_VARIANT_PASSKEY_CONFIRMATION) { mPairingView.setVisibility(View.GONE); messageView.setText(getString(R.string.bluetooth_confirm_passkey_msg, name, - mPasskey)); + mPairingKey)); } 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) { + } else if (mType == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PASSKEY || + mType == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PIN) { mPairingView.setVisibility(View.GONE); - messageView.setText(getString(R.string.bluetooth_display_passkey_msg, name, mPasskey)); + messageView.setText(getString(R.string.bluetooth_display_passkey_pin_msg, name, + mPairingKey)); } else if (mType == BluetoothDevice.PAIRING_VARIANT_OOB_CONSENT) { mPairingView.setVisibility(View.GONE); messageView.setText(getString(R.string.bluetooth_incoming_pairing_msg, name)); @@ -206,18 +213,23 @@ public class BluetoothPairingDialog extends AlertActivity implements DialogInter setupAlert(); } - private void createDisplayPasskeyDialog() { + private void createDisplayPasskeyOrPinDialog() { 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; + p.mNegativeButtonText = getString(android.R.string.cancel); + p.mNegativeButtonListener = this; setupAlert(); // Since its only a notification, send an OK to the framework, // indicating that the dialog has been displayed. - mDevice.setPairingConfirmation(true); + if (mType == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PASSKEY) { + mDevice.setPairingConfirmation(true); + } else if (mType == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PIN) { + byte[] pinBytes = BluetoothDevice.convertPinToBytes(mPairingKey); + mDevice.setPin(pinBytes); + } } @Override @@ -252,6 +264,8 @@ public class BluetoothPairingDialog extends AlertActivity implements DialogInter mDevice.setPairingConfirmation(true); } else if (mType == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PASSKEY) { // Do Nothing. + } else if (mType == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PIN) { + // Do Nothing } else if (mType == BluetoothDevice.PAIRING_VARIANT_OOB_CONSENT) { mDevice.setRemoteOutOfBandData(); } else { diff --git a/src/com/android/settings/bluetooth/BluetoothPairingRequest.java b/src/com/android/settings/bluetooth/BluetoothPairingRequest.java index 000020544..6037c82a9 100644 --- a/src/com/android/settings/bluetooth/BluetoothPairingRequest.java +++ b/src/com/android/settings/bluetooth/BluetoothPairingRequest.java @@ -55,9 +55,11 @@ public class BluetoothPairingRequest extends BroadcastReceiver { pairingIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, device); pairingIntent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, type); 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); + type == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PASSKEY || + type == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PIN) { + int pairingKey = intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_KEY, + BluetoothDevice.ERROR); + pairingIntent.putExtra(BluetoothDevice.EXTRA_PAIRING_KEY, pairingKey); } pairingIntent.setAction(BluetoothDevice.ACTION_PAIRING_REQUEST); pairingIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java index 510292a18..7bdc6e6e2 100644 --- a/src/com/android/settings/wifi/WifiSettings.java +++ b/src/com/android/settings/wifi/WifiSettings.java @@ -356,15 +356,6 @@ public class WifiSettings extends SettingsPreferenceFragment mDialog.show(); } - /** - * Called from {@link WifiSettingsForSetupWizardXL} when the object wants to open - * {@link WifiDialog} anyway, though usually it prepares its own simplified UI for - * configuring a wifi network. - */ - /* package */ void showDialogForSelectedPreference() { - showDialog(mSelectedAccessPoint, mEdit); - } - private boolean requireKeyStore(WifiConfiguration config) { if (WifiConfigController.requireKeyStore(config) && KeyStore.getInstance().test() != KeyStore.NO_ERROR) { diff --git a/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java b/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java index 5e0b104ea..d55cbe456 100644 --- a/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java +++ b/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java @@ -77,9 +77,6 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis private Button mForgetButton; private Button mBackButton; - // Not used now. - private Button mDetailButton; - // true when a user already pressed "Connect" button and waiting for connection. // Also true when the device is already connected to a wifi network on launch. private boolean mAfterConnectAction; @@ -98,6 +95,7 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis // To let users exit this Activity, we enable the button after waiting for a moment. private final int DELAYED_SKIP_ENABLE_TIME = 10000; // Unit: millis private final Runnable mSkipButtonEnabler = new Runnable() { + @Override public void run() { if (DEBUG) Log.d(TAG, "Delayed skip enabler starts running."); mSkipOrNextButton.setEnabled(true); @@ -145,8 +143,6 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis mForgetButton.setOnClickListener(this); mBackButton = (Button)findViewById(R.id.wifi_setup_cancel); mBackButton.setOnClickListener(this); - mDetailButton = (Button)findViewById(R.id.wifi_setup_detail); - mDetailButton.setOnClickListener(this); // At first, Wifi module doesn't return SCANNING state (it's too early), so we manually // show it. @@ -161,7 +157,6 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis mConnectButton.setVisibility(View.GONE); mForgetButton.setVisibility(View.GONE); mBackButton.setVisibility(View.GONE); - mDetailButton.setVisibility(View.GONE); } @Override @@ -191,9 +186,6 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis } else if (view == mBackButton) { if (DEBUG) Log.d(TAG, "Back button pressed"); onBackButtonPressed(); - } else if (view == mDetailButton) { - if (DEBUG) Log.d(TAG, "Detail button pressed"); - mWifiSettings.showDialogForSelectedPreference(); } } @@ -292,8 +284,6 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis // onConfigUiShown() will be called. mWifiSettings.onAddNetworkPressed(); - // We don't need detail button since all the details are in the main screen. - mDetailButton.setVisibility(View.GONE); } /** @@ -338,8 +328,6 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis mRefreshButton.setVisibility(View.GONE); mSkipOrNextButton.setVisibility(View.GONE); mBackButton.setVisibility(View.VISIBLE); - // TODO: remove this after UI fix. - // mDetailButton.setVisibility(View.VISIBLE); } // May be called when user press "connect" button in WifiDialog @@ -366,7 +354,6 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis mConnectButton.setVisibility(View.GONE); mAddNetworkButton.setVisibility(View.GONE); mRefreshButton.setVisibility(View.GONE); - mDetailButton.setVisibility(View.GONE); } // May be called when user press "forget" button in WifiDialog |