From 55e66f1b739097095f6b3c47f88de258898fc1c9 Mon Sep 17 00:00:00 2001 From: Nick Pelly Date: Fri, 18 Sep 2009 11:37:06 -0700 Subject: Reject lowercase characters in checkBluetoothAddress(). This keeps consistency with Bluez which uses upper case string address. It's important to keep the case the same so that .equals() in BluetoothService.java work. Change-Id: I6404ca137d0aec3cc2e6e7cb79763d5305a03547 --- core/java/android/bluetooth/BluetoothAdapter.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'core/java') diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java index 96a927b..1fc22fe 100644 --- a/core/java/android/bluetooth/BluetoothAdapter.java +++ b/core/java/android/bluetooth/BluetoothAdapter.java @@ -573,6 +573,7 @@ public final class BluetoothAdapter { /** * Validate a Bluetooth address, such as "00:43:A8:23:10:F0" + *

Alphabetic characters must be uppercase to be valid. * * @param address Bluetooth address as string * @return true if the address is valid, false otherwise @@ -586,8 +587,9 @@ public final class BluetoothAdapter { switch (i % 3) { case 0: case 1: - if (Character.digit(c, 16) != -1) { - break; // hex character, OK + if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F')) { + // hex character, OK + break; } return false; case 2: -- cgit v1.1