SAP: Make it possible to enforce a 16-digit pin code (5/5)
This change enable the posibility to enforce using a 16-digit pin or MITM for a RFCOMM or L2CAP connection. This is needed for the SIM access profile. Change-Id: I6bb2b0dff1ebf4b4f1d8faad97aa7c480000d3ea Signed-off-by: Casper Bonde <c.bonde@samsung.com>
This commit is contained in:
committed by
Andre Eisenbach
parent
2114e386a4
commit
e278a208bc
@@ -1170,6 +1170,9 @@
|
|||||||
<!-- Bluetooth PIN hint text (below the text entry box). [CHAR LIMIT=30] -->
|
<!-- Bluetooth PIN hint text (below the text entry box). [CHAR LIMIT=30] -->
|
||||||
<string name="bluetooth_pin_values_hint">Usually 0000 or 1234</string>
|
<string name="bluetooth_pin_values_hint">Usually 0000 or 1234</string>
|
||||||
|
|
||||||
|
<!-- Bluetooth PIN hint text (below the text entry box). [CHAR LIMIT=30] -->
|
||||||
|
<string name="bluetooth_pin_values_hint_16_digits">Must be 16 digits</string>
|
||||||
|
|
||||||
<!-- Pairing dialog text to remind user to enter the PIN on the other device. [CHAR LIMIT=NONE] -->
|
<!-- Pairing dialog text to remind user to enter the PIN on the other device. [CHAR LIMIT=NONE] -->
|
||||||
<string name="bluetooth_enter_pin_other_device">You may also need to type this PIN on the other device.</string>
|
<string name="bluetooth_enter_pin_other_device">You may also need to type this PIN on the other device.</string>
|
||||||
<!-- Pairing dialog text to remind user to enter the passkey on the other device. [CHAR LIMIT=NONE] -->
|
<!-- Pairing dialog text to remind user to enter the passkey on the other device. [CHAR LIMIT=NONE] -->
|
||||||
|
@@ -116,6 +116,7 @@ public final class BluetoothPairingDialog extends AlertActivity implements
|
|||||||
|
|
||||||
switch (mType) {
|
switch (mType) {
|
||||||
case BluetoothDevice.PAIRING_VARIANT_PIN:
|
case BluetoothDevice.PAIRING_VARIANT_PIN:
|
||||||
|
case BluetoothDevice.PAIRING_VARIANT_PIN_16_DIGITS:
|
||||||
case BluetoothDevice.PAIRING_VARIANT_PASSKEY:
|
case BluetoothDevice.PAIRING_VARIANT_PASSKEY:
|
||||||
createUserEntryDialog();
|
createUserEntryDialog();
|
||||||
break;
|
break;
|
||||||
@@ -181,6 +182,7 @@ public final class BluetoothPairingDialog extends AlertActivity implements
|
|||||||
private View createPinEntryView() {
|
private View createPinEntryView() {
|
||||||
View view = getLayoutInflater().inflate(R.layout.bluetooth_pin_entry, null);
|
View view = getLayoutInflater().inflate(R.layout.bluetooth_pin_entry, null);
|
||||||
TextView messageViewCaption = (TextView) view.findViewById(R.id.message_caption);
|
TextView messageViewCaption = (TextView) view.findViewById(R.id.message_caption);
|
||||||
|
TextView messageViewCaptionHint = (TextView) view.findViewById(R.id.pin_values_hint);
|
||||||
TextView messageViewContent = (TextView) view.findViewById(R.id.message_subhead);
|
TextView messageViewContent = (TextView) view.findViewById(R.id.message_subhead);
|
||||||
TextView messageView2 = (TextView) view.findViewById(R.id.message_below_pin);
|
TextView messageView2 = (TextView) view.findViewById(R.id.message_below_pin);
|
||||||
CheckBox alphanumericPin = (CheckBox) view.findViewById(R.id.alphanumeric_pin);
|
CheckBox alphanumericPin = (CheckBox) view.findViewById(R.id.alphanumeric_pin);
|
||||||
@@ -190,8 +192,12 @@ public final class BluetoothPairingDialog extends AlertActivity implements
|
|||||||
|
|
||||||
int messageId1;
|
int messageId1;
|
||||||
int messageId2;
|
int messageId2;
|
||||||
|
int messageIdHint = R.string.bluetooth_pin_values_hint;
|
||||||
int maxLength;
|
int maxLength;
|
||||||
switch (mType) {
|
switch (mType) {
|
||||||
|
case BluetoothDevice.PAIRING_VARIANT_PIN_16_DIGITS:
|
||||||
|
messageIdHint = R.string.bluetooth_pin_values_hint_16_digits;
|
||||||
|
// FALLTHROUGH
|
||||||
case BluetoothDevice.PAIRING_VARIANT_PIN:
|
case BluetoothDevice.PAIRING_VARIANT_PIN:
|
||||||
messageId1 = R.string.bluetooth_enter_pin_msg;
|
messageId1 = R.string.bluetooth_enter_pin_msg;
|
||||||
messageId2 = R.string.bluetooth_enter_pin_other_device;
|
messageId2 = R.string.bluetooth_enter_pin_other_device;
|
||||||
@@ -213,6 +219,7 @@ public final class BluetoothPairingDialog extends AlertActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
messageViewCaption.setText(messageId1);
|
messageViewCaption.setText(messageId1);
|
||||||
|
messageViewCaptionHint.setText(messageIdHint);
|
||||||
messageViewContent.setText(mCachedDeviceManager.getName(mDevice));
|
messageViewContent.setText(mCachedDeviceManager.getName(mDevice));
|
||||||
messageView2.setText(messageId2);
|
messageView2.setText(messageId2);
|
||||||
mPairingView.setInputType(InputType.TYPE_CLASS_NUMBER);
|
mPairingView.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||||
@@ -316,13 +323,18 @@ public final class BluetoothPairingDialog extends AlertActivity implements
|
|||||||
|
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
if (mOkButton != null) {
|
if (mOkButton != null) {
|
||||||
mOkButton.setEnabled(s.length() > 0);
|
if (mType == BluetoothDevice.PAIRING_VARIANT_PIN_16_DIGITS) {
|
||||||
|
mOkButton.setEnabled(s.length() >= 16);
|
||||||
|
} else {
|
||||||
|
mOkButton.setEnabled(s.length() > 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onPair(String value) {
|
private void onPair(String value) {
|
||||||
switch (mType) {
|
switch (mType) {
|
||||||
case BluetoothDevice.PAIRING_VARIANT_PIN:
|
case BluetoothDevice.PAIRING_VARIANT_PIN:
|
||||||
|
case BluetoothDevice.PAIRING_VARIANT_PIN_16_DIGITS:
|
||||||
byte[] pinBytes = BluetoothDevice.convertPinToBytes(value);
|
byte[] pinBytes = BluetoothDevice.convertPinToBytes(value);
|
||||||
if (pinBytes == null) {
|
if (pinBytes == null) {
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user