diff options
author | Nick Pelly <npelly@google.com> | 2009-09-10 10:21:56 -0700 |
---|---|---|
committer | Nick Pelly <npelly@google.com> | 2009-09-10 18:52:21 -0700 |
commit | 005b228cdfb369d9b3b325884c0337ba5968bf8c (patch) | |
tree | d1ee610898b65acd5c472014d395748b9d950150 /core/java/android/server | |
parent | 9b6911cb85a9c9a0fef145f91c9999da5a75ce21 (diff) | |
download | frameworks_base-005b228cdfb369d9b3b325884c0337ba5968bf8c.zip frameworks_base-005b228cdfb369d9b3b325884c0337ba5968bf8c.tar.gz frameworks_base-005b228cdfb369d9b3b325884c0337ba5968bf8c.tar.bz2 |
API_CHANGE: Cleanup, javadoc and unhide more Bluetooth API.
This is a large batch, and covers:
-- Bluetooth Device Discovery --
BluetoothAdapter.ACTION_DISCOVERY_STARTED
BluetoothAdapter.ACTION_DISCOVERY_FINISHED
BluetoothAdapter.startDiscovery()
BluetoothAdapter.cancelDiscovery()
BluetoothAdapter.isDiscovering()
-- Bluetooth bonding (pairing) --
BluetoothAdapter.getBondedDevices()
BluetoothDevice.ACTION_BOND_STATE_CHANGED
BluetoothDevice.EXTRA_BOND_STATE
BluetoothDevice.EXTRA_PREVIOUS_BOND_STATE
BluetoothDevice.BOND_NONE
BluetoothDevice.BOND_BONDING
BluetoothDevice.BOND_BONDED
BluetoothDevice.getBondState()
BluetoothDevice.createBond()
BluetoothDevice.cancelBondProcess()
BluetoothDevice.removeBond()
-- BluetoothClass --
BluetoothDevice.ACTION_CLASS_CHANGED
BluetoothDevice.EXTRA_CLASS
BluetoothDevice.getBluetoothClass()
BluetoothClass.Service.*
BluetoothClass.Device.Major.*
BluetoothClass.Device.*
BluetoothClass.getDeviceClass()
BluetoothClass.getMajorDeviceClass()
BluetoothClass.hasService()
-- Misc BluetoothDevice --
BluetoothDevice.ACTION_ACL_CONNECTED
BluetoothDevice.ACTION_ACL_DISCONNECTED_REQUESTED
BluetoothDevice.ACTION_ACL_DISCONNECTED
BluetoothDevice.ACTION_DISCOVERED
BluetoothDevice.ACTION_NAME_CHANGED
BluetoothDevice.EXTRA_DEVICE
BluetoothDevice.EXTRA_NAME
BluetoothDevice.EXTRA_RSSI
-- Misc BluetoothAdapter --
BluetoothAdapter.ACTION_LOCAL_NAME_CHANGED
BluetoothAdapter.EXTRA_LOCAL_NAME
BluetoothAdapter.checkBluetoothAddress()
I deprecated BluetoothIntent and moved each intent into the class it relates
to.
Change-Id: I877b1280428ab46278b2bc25668bb44cda22dc36
Diffstat (limited to 'core/java/android/server')
-rw-r--r-- | core/java/android/server/BluetoothA2dpService.java | 25 | ||||
-rw-r--r-- | core/java/android/server/BluetoothEventLoop.java | 80 | ||||
-rw-r--r-- | core/java/android/server/BluetoothService.java | 53 |
3 files changed, 80 insertions, 78 deletions
diff --git a/core/java/android/server/BluetoothA2dpService.java b/core/java/android/server/BluetoothA2dpService.java index a24e0d2..9c687e2 100644 --- a/core/java/android/server/BluetoothA2dpService.java +++ b/core/java/android/server/BluetoothA2dpService.java @@ -25,7 +25,6 @@ package android.server; import android.bluetooth.BluetoothA2dp; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; -import android.bluetooth.BluetoothIntent; import android.bluetooth.BluetoothUuid; import android.bluetooth.IBluetoothA2dp; import android.content.BroadcastReceiver; @@ -79,7 +78,7 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { public void onReceive(Context context, Intent intent) { String action = intent.getAction(); BluetoothDevice device = - intent.getParcelableExtra(BluetoothIntent.DEVICE); + intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) { int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR); @@ -91,19 +90,19 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { onBluetoothDisable(); break; } - } else if (action.equals(BluetoothIntent.BOND_STATE_CHANGED_ACTION)) { - int bondState = intent.getIntExtra(BluetoothIntent.BOND_STATE, + } else if (action.equals(BluetoothDevice.ACTION_BOND_STATE_CHANGED)) { + int bondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.ERROR); switch(bondState) { case BluetoothDevice.BOND_BONDED: setSinkPriority(device, BluetoothA2dp.PRIORITY_AUTO); break; case BluetoothDevice.BOND_BONDING: - case BluetoothDevice.BOND_NOT_BONDED: + case BluetoothDevice.BOND_NONE: setSinkPriority(device, BluetoothA2dp.PRIORITY_OFF); break; } - } else if (action.equals(BluetoothIntent.REMOTE_DEVICE_CONNECTED_ACTION)) { + } else if (action.equals(BluetoothDevice.ACTION_ACL_CONNECTED)) { if (getSinkPriority(device) > BluetoothA2dp.PRIORITY_OFF && isSinkDevice(device)) { // This device is a preferred sink. Make an A2DP connection @@ -134,8 +133,8 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { mAdapter = (BluetoothAdapter) context.getSystemService(Context.BLUETOOTH_SERVICE); mIntentFilter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED); - mIntentFilter.addAction(BluetoothIntent.BOND_STATE_CHANGED_ACTION); - mIntentFilter.addAction(BluetoothIntent.REMOTE_DEVICE_CONNECTED_ACTION); + mIntentFilter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED); + mIntentFilter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED); mContext.registerReceiver(mReceiver, mIntentFilter); mAudioDevices = new HashMap<BluetoothDevice, Integer>(); @@ -361,7 +360,7 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { public synchronized boolean setSinkPriority(BluetoothDevice device, int priority) { mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); - if (!BluetoothDevice.checkBluetoothAddress(device.getAddress())) { + if (!BluetoothAdapter.checkBluetoothAddress(device.getAddress())) { return false; } return Settings.Secure.putInt(mContext.getContentResolver(), @@ -411,10 +410,10 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { } mAudioDevices.put(device, state); - Intent intent = new Intent(BluetoothA2dp.SINK_STATE_CHANGED_ACTION); - intent.putExtra(BluetoothIntent.DEVICE, device); - intent.putExtra(BluetoothA2dp.SINK_PREVIOUS_STATE, prevState); - intent.putExtra(BluetoothA2dp.SINK_STATE, state); + Intent intent = new Intent(BluetoothA2dp.ACTION_SINK_STATE_CHANGED); + intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device); + intent.putExtra(BluetoothA2dp.EXTRA_PREVIOUS_SINK_STATE, prevState); + intent.putExtra(BluetoothA2dp.EXTRA_SINK_STATE, state); mContext.sendBroadcast(intent, BLUETOOTH_PERM); if (DBG) log("A2DP state : device: " + device + " State:" + prevState + "->" + state); diff --git a/core/java/android/server/BluetoothEventLoop.java b/core/java/android/server/BluetoothEventLoop.java index b5eb9ac..4c24c50 100644 --- a/core/java/android/server/BluetoothEventLoop.java +++ b/core/java/android/server/BluetoothEventLoop.java @@ -20,7 +20,6 @@ import android.bluetooth.BluetoothA2dp; import android.bluetooth.BluetoothClass; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; -import android.bluetooth.BluetoothIntent; import android.bluetooth.BluetoothUuid; import android.content.Context; import android.content.Intent; @@ -140,11 +139,12 @@ class BluetoothEventLoop { rssiValue = Short.MIN_VALUE; } if (classValue != null) { - Intent intent = new Intent(BluetoothIntent.REMOTE_DEVICE_FOUND_ACTION); - intent.putExtra(BluetoothIntent.DEVICE, mAdapter.getRemoteDevice(address)); - intent.putExtra(BluetoothIntent.CLASS, Integer.valueOf(classValue)); - intent.putExtra(BluetoothIntent.RSSI, rssiValue); - intent.putExtra(BluetoothIntent.NAME, name); + Intent intent = new Intent(BluetoothDevice.ACTION_FOUND); + intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mAdapter.getRemoteDevice(address)); + intent.putExtra(BluetoothDevice.EXTRA_CLASS, + new BluetoothClass(Integer.valueOf(classValue))); + intent.putExtra(BluetoothDevice.EXTRA_RSSI, rssiValue); + intent.putExtra(BluetoothDevice.EXTRA_NAME, name); mContext.sendBroadcast(intent, BLUETOOTH_PERM); } else { @@ -161,8 +161,8 @@ class BluetoothEventLoop { } private void onDeviceDisappeared(String address) { - Intent intent = new Intent(BluetoothIntent.REMOTE_DEVICE_DISAPPEARED_ACTION); - intent.putExtra(BluetoothIntent.DEVICE, mAdapter.getRemoteDevice(address)); + Intent intent = new Intent(BluetoothDevice.ACTION_DISAPPEARED); + intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mAdapter.getRemoteDevice(address)); mContext.sendBroadcast(intent, BLUETOOTH_PERM); } @@ -182,7 +182,7 @@ class BluetoothEventLoop { pairingAttempt(address, result); } else { mBluetoothService.getBondState().setBondState(address, - BluetoothDevice.BOND_NOT_BONDED, result); + BluetoothDevice.BOND_NONE, result); if (mBluetoothService.getBondState().isAutoPairingAttemptsInProgress(address)) { mBluetoothService.getBondState().clearPinAttempts(address); } @@ -202,7 +202,7 @@ class BluetoothEventLoop { MAX_AUTO_PAIRING_FAILURE_ATTEMPT_DELAY) { mBluetoothService.getBondState().clearPinAttempts(address); mBluetoothService.getBondState().setBondState(address, - BluetoothDevice.BOND_NOT_BONDED, result); + BluetoothDevice.BOND_NONE, result); return; } @@ -213,7 +213,7 @@ class BluetoothEventLoop { if (!postResult) { mBluetoothService.getBondState().clearPinAttempts(address); mBluetoothService.getBondState().setBondState(address, - BluetoothDevice.BOND_NOT_BONDED, result); + BluetoothDevice.BOND_NONE, result); return; } mBluetoothService.getBondState().attempt(address); @@ -235,7 +235,7 @@ class BluetoothEventLoop { String address = mBluetoothService.getAddressFromObjectPath(deviceObjectPath); if (address != null) mBluetoothService.getBondState().setBondState(address.toUpperCase(), - BluetoothDevice.BOND_NOT_BONDED, BluetoothDevice.UNBOND_REASON_REMOVED); + BluetoothDevice.BOND_NONE, BluetoothDevice.UNBOND_REASON_REMOVED); } /*package*/ void onPropertyChanged(String[] propValues) { @@ -246,8 +246,8 @@ class BluetoothEventLoop { } String name = propValues[0]; if (name.equals("Name")) { - Intent intent = new Intent(BluetoothIntent.NAME_CHANGED_ACTION); - intent.putExtra(BluetoothIntent.NAME, propValues[1]); + Intent intent = new Intent(BluetoothDevice.ACTION_NAME_CHANGED); + intent.putExtra(BluetoothDevice.EXTRA_NAME, propValues[1]); mContext.sendBroadcast(intent, BLUETOOTH_PERM); mBluetoothService.setProperty(name, propValues[1]); } else if (name.equals("Pairable") || name.equals("Discoverable")) { @@ -274,12 +274,12 @@ class BluetoothEventLoop { Intent intent; if (propValues[1].equals("true")) { mBluetoothService.setIsDiscovering(true); - intent = new Intent(BluetoothIntent.DISCOVERY_STARTED_ACTION); + intent = new Intent(BluetoothAdapter.ACTION_DISCOVERY_STARTED); } else { // Stop the discovery. mBluetoothService.cancelDiscovery(); mBluetoothService.setIsDiscovering(false); - intent = new Intent(BluetoothIntent.DISCOVERY_COMPLETED_ACTION); + intent = new Intent(BluetoothAdapter.ACTION_DISCOVERY_FINISHED); } mContext.sendBroadcast(intent, BLUETOOTH_PERM); mBluetoothService.setProperty(name, propValues[1]); @@ -312,25 +312,26 @@ class BluetoothEventLoop { } BluetoothDevice device = mAdapter.getRemoteDevice(address); if (name.equals("Name")) { - Intent intent = new Intent(BluetoothIntent.REMOTE_NAME_UPDATED_ACTION); - intent.putExtra(BluetoothIntent.DEVICE, device); - intent.putExtra(BluetoothIntent.NAME, propValues[1]); + Intent intent = new Intent(BluetoothDevice.ACTION_NAME_CHANGED); + intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device); + intent.putExtra(BluetoothDevice.EXTRA_NAME, propValues[1]); mContext.sendBroadcast(intent, BLUETOOTH_PERM); mBluetoothService.setRemoteDeviceProperty(address, name, propValues[1]); } else if (name.equals("Class")) { - Intent intent = new Intent(BluetoothIntent.REMOTE_DEVICE_CLASS_UPDATED_ACTION); - intent.putExtra(BluetoothIntent.DEVICE, device); - intent.putExtra(BluetoothIntent.CLASS, propValues[1]); + Intent intent = new Intent(BluetoothDevice.ACTION_CLASS_CHANGED); + intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device); + intent.putExtra(BluetoothDevice.EXTRA_CLASS, + new BluetoothClass(Integer.valueOf(propValues[1]))); mContext.sendBroadcast(intent, BLUETOOTH_PERM); mBluetoothService.setRemoteDeviceProperty(address, name, propValues[1]); } else if (name.equals("Connected")) { Intent intent = null; if (propValues[1].equals("true")) { - intent = new Intent(BluetoothIntent.REMOTE_DEVICE_CONNECTED_ACTION); + intent = new Intent(BluetoothDevice.ACTION_ACL_CONNECTED); } else { - intent = new Intent(BluetoothIntent.REMOTE_DEVICE_DISCONNECTED_ACTION); + intent = new Intent(BluetoothDevice.ACTION_ACL_DISCONNECTED); } - intent.putExtra(BluetoothIntent.DEVICE, device); + intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device); mContext.sendBroadcast(intent, BLUETOOTH_PERM); mBluetoothService.setRemoteDeviceProperty(address, name, propValues[1]); } else if (name.equals("UUIDs")) { @@ -350,7 +351,7 @@ class BluetoothEventLoop { mBluetoothService.getBondState().setBondState(address, BluetoothDevice.BOND_BONDED); } else { mBluetoothService.getBondState().setBondState(address, - BluetoothDevice.BOND_NOT_BONDED); + BluetoothDevice.BOND_NONE); mBluetoothService.setRemoteDeviceProperty(address, "Trusted", "false"); } } else if (name.equals("Trusted")) { @@ -382,10 +383,10 @@ class BluetoothEventLoop { String address = checkPairingRequestAndGetAddress(objectPath, nativeData); if (address == null) return; - Intent intent = new Intent(BluetoothIntent.PAIRING_REQUEST_ACTION); - intent.putExtra(BluetoothIntent.DEVICE, mAdapter.getRemoteDevice(address)); - intent.putExtra(BluetoothIntent.PASSKEY, passkey); - intent.putExtra(BluetoothIntent.PAIRING_VARIANT, + Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_REQUEST); + intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mAdapter.getRemoteDevice(address)); + intent.putExtra(BluetoothDevice.EXTRA_PASSKEY, passkey); + intent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, BluetoothDevice.PAIRING_VARIANT_CONFIRMATION); mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM); return; @@ -395,9 +396,10 @@ class BluetoothEventLoop { String address = checkPairingRequestAndGetAddress(objectPath, nativeData); if (address == null) return; - Intent intent = new Intent(BluetoothIntent.PAIRING_REQUEST_ACTION); - intent.putExtra(BluetoothIntent.DEVICE, mAdapter.getRemoteDevice(address)); - intent.putExtra(BluetoothIntent.PAIRING_VARIANT, BluetoothDevice.PAIRING_VARIANT_PASSKEY); + Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_REQUEST); + intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mAdapter.getRemoteDevice(address)); + intent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, + BluetoothDevice.PAIRING_VARIANT_PASSKEY); mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM); return; } @@ -409,10 +411,10 @@ class BluetoothEventLoop { if (mBluetoothService.getBondState().getBondState(address) == BluetoothDevice.BOND_BONDING) { // we initiated the bonding - int btClass = mBluetoothService.getRemoteClass(address); + BluetoothClass btClass = new BluetoothClass(mBluetoothService.getRemoteClass(address)); // try 0000 once if the device looks dumb - switch (BluetoothClass.Device.getDevice(btClass)) { + switch (btClass.getDeviceClass()) { case BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET: case BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE: case BluetoothClass.Device.AUDIO_VIDEO_HEADPHONES: @@ -427,9 +429,9 @@ class BluetoothEventLoop { } } } - Intent intent = new Intent(BluetoothIntent.PAIRING_REQUEST_ACTION); - intent.putExtra(BluetoothIntent.DEVICE, mAdapter.getRemoteDevice(address)); - intent.putExtra(BluetoothIntent.PAIRING_VARIANT, BluetoothDevice.PAIRING_VARIANT_PIN); + Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_REQUEST); + intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mAdapter.getRemoteDevice(address)); + intent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, BluetoothDevice.PAIRING_VARIANT_PIN); mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM); return; } @@ -464,7 +466,7 @@ class BluetoothEventLoop { } private void onAgentCancel() { - Intent intent = new Intent(BluetoothIntent.PAIRING_CANCEL_ACTION); + Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_CANCEL); mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM); return; } diff --git a/core/java/android/server/BluetoothService.java b/core/java/android/server/BluetoothService.java index 6482c4c..53fb03c 100644 --- a/core/java/android/server/BluetoothService.java +++ b/core/java/android/server/BluetoothService.java @@ -28,7 +28,6 @@ import android.bluetooth.BluetoothClass; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothHeadset; -import android.bluetooth.BluetoothIntent; import android.bluetooth.IBluetooth; import android.content.BroadcastReceiver; import android.content.ContentResolver; @@ -183,7 +182,7 @@ public class BluetoothService extends IBluetooth.Stub { // mark in progress bondings as cancelled for (String address : mBondState.listInState(BluetoothDevice.BOND_BONDING)) { - mBondState.setBondState(address, BluetoothDevice.BOND_NOT_BONDED, + mBondState.setBondState(address, BluetoothDevice.BOND_NONE, BluetoothDevice.UNBOND_REASON_AUTH_CANCELED); } @@ -441,17 +440,17 @@ public class BluetoothService extends IBluetooth.Stub { } if (DBG) log(address + " bond state " + oldState + " -> " + state + " (" + reason + ")"); - Intent intent = new Intent(BluetoothIntent.BOND_STATE_CHANGED_ACTION); - intent.putExtra(BluetoothIntent.DEVICE, mAdapter.getRemoteDevice(address)); - intent.putExtra(BluetoothIntent.BOND_STATE, state); - intent.putExtra(BluetoothIntent.BOND_PREVIOUS_STATE, oldState); - if (state == BluetoothDevice.BOND_NOT_BONDED) { + Intent intent = new Intent(BluetoothDevice.ACTION_BOND_STATE_CHANGED); + intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mAdapter.getRemoteDevice(address)); + intent.putExtra(BluetoothDevice.EXTRA_BOND_STATE, state); + intent.putExtra(BluetoothDevice.EXTRA_PREVIOUS_BOND_STATE, oldState); + if (state == BluetoothDevice.BOND_NONE) { if (reason <= 0) { Log.w(TAG, "setBondState() called to unbond device, but reason code is " + "invalid. Overriding reason code with BOND_RESULT_REMOVED"); reason = BluetoothDevice.UNBOND_REASON_REMOVED; } - intent.putExtra(BluetoothIntent.REASON, reason); + intent.putExtra(BluetoothDevice.EXTRA_REASON, reason); mState.remove(address); } else { mState.put(address, state); @@ -470,7 +469,7 @@ public class BluetoothService extends IBluetooth.Stub { public synchronized int getBondState(String address) { Integer state = mState.get(address); if (state == null) { - return BluetoothDevice.BOND_NOT_BONDED; + return BluetoothDevice.BOND_NONE; } return state.intValue(); } @@ -526,7 +525,7 @@ public class BluetoothService extends IBluetooth.Stub { private static String toBondStateString(int bondState) { switch (bondState) { - case BluetoothDevice.BOND_NOT_BONDED: + case BluetoothDevice.BOND_NONE: return "not bonded"; case BluetoothDevice.BOND_BONDING: return "bonding"; @@ -642,9 +641,11 @@ public class BluetoothService extends IBluetooth.Stub { case BluetoothAdapter.SCAN_MODE_CONNECTABLE: pairable = true; discoverable = false; + break; case BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE: pairable = true; discoverable = true; + break; default: Log.w(TAG, "Requested invalid scan mode " + mode); return false; @@ -685,7 +686,7 @@ public class BluetoothService extends IBluetooth.Stub { */ public synchronized String getRemoteName(String address) { mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); - if (!BluetoothDevice.checkBluetoothAddress(address)) { + if (!BluetoothAdapter.checkBluetoothAddress(address)) { return null; } Map <String, String> properties = mDeviceProperties.get(address); @@ -747,7 +748,7 @@ public class BluetoothService extends IBluetooth.Stub { public synchronized boolean createBond(String address) { mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); - if (!BluetoothDevice.checkBluetoothAddress(address)) { + if (!BluetoothAdapter.checkBluetoothAddress(address)) { return false; } address = address.toUpperCase(); @@ -762,7 +763,7 @@ public class BluetoothService extends IBluetooth.Stub { // Check for bond state only if we are not performing auto // pairing exponential back-off attempts. if (!mBondState.isAutoPairingAttemptsInProgress(address) && - mBondState.getBondState(address) != BluetoothDevice.BOND_NOT_BONDED) { + mBondState.getBondState(address) != BluetoothDevice.BOND_NONE) { log("Ignoring createBond(): this device is already bonding or bonded"); return false; } @@ -778,7 +779,7 @@ public class BluetoothService extends IBluetooth.Stub { public synchronized boolean cancelBondProcess(String address) { mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); - if (!BluetoothDevice.checkBluetoothAddress(address)) { + if (!BluetoothAdapter.checkBluetoothAddress(address)) { return false; } address = address.toUpperCase(); @@ -786,7 +787,7 @@ public class BluetoothService extends IBluetooth.Stub { return false; } - mBondState.setBondState(address, BluetoothDevice.BOND_NOT_BONDED, + mBondState.setBondState(address, BluetoothDevice.BOND_NONE, BluetoothDevice.UNBOND_REASON_AUTH_CANCELED); cancelDeviceCreationNative(address); return true; @@ -795,7 +796,7 @@ public class BluetoothService extends IBluetooth.Stub { public synchronized boolean removeBond(String address) { mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); - if (!BluetoothDevice.checkBluetoothAddress(address)) { + if (!BluetoothAdapter.checkBluetoothAddress(address)) { return false; } return removeDeviceNative(getObjectPathFromAddress(address)); @@ -808,7 +809,7 @@ public class BluetoothService extends IBluetooth.Stub { public synchronized int getBondState(String address) { mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); - if (!BluetoothDevice.checkBluetoothAddress(address)) { + if (!BluetoothAdapter.checkBluetoothAddress(address)) { return BluetoothDevice.ERROR; } return mBondState.getBondState(address.toUpperCase()); @@ -898,7 +899,7 @@ public class BluetoothService extends IBluetooth.Stub { * @return boolean to indicate operation success or fail */ public synchronized boolean setTrust(String address, boolean value) { - if (!BluetoothDevice.checkBluetoothAddress(address)) { + if (!BluetoothAdapter.checkBluetoothAddress(address)) { mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); return false; } @@ -915,7 +916,7 @@ public class BluetoothService extends IBluetooth.Stub { * @return boolean to indicate trust or untrust state */ public synchronized boolean getTrustState(String address) { - if (!BluetoothDevice.checkBluetoothAddress(address)) { + if (!BluetoothAdapter.checkBluetoothAddress(address)) { mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); return false; } @@ -939,7 +940,7 @@ public class BluetoothService extends IBluetooth.Stub { * classes. */ public synchronized int getRemoteClass(String address) { - if (!BluetoothDevice.checkBluetoothAddress(address)) { + if (!BluetoothAdapter.checkBluetoothAddress(address)) { mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); return BluetoothClass.ERROR; } @@ -961,7 +962,7 @@ public class BluetoothService extends IBluetooth.Stub { */ public synchronized String[] getRemoteUuids(String address) { mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); - if (!BluetoothDevice.checkBluetoothAddress(address)) { + if (!BluetoothAdapter.checkBluetoothAddress(address)) { return null; } String value = getRemoteDeviceProperty(address, "UUIDs"); @@ -982,7 +983,7 @@ public class BluetoothService extends IBluetooth.Stub { */ public int getRemoteServiceChannel(String address, String uuid) { mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); - if (!BluetoothDevice.checkBluetoothAddress(address)) { + if (!BluetoothAdapter.checkBluetoothAddress(address)) { return BluetoothDevice.ERROR; } return getDeviceServiceChannelNative(getObjectPathFromAddress(address), uuid, 0x0004); @@ -992,7 +993,7 @@ public class BluetoothService extends IBluetooth.Stub { mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); if (pin == null || pin.length <= 0 || pin.length > 16 || - !BluetoothDevice.checkBluetoothAddress(address)) { + !BluetoothAdapter.checkBluetoothAddress(address)) { return false; } address = address.toUpperCase(); @@ -1017,7 +1018,7 @@ public class BluetoothService extends IBluetooth.Stub { public synchronized boolean setPasskey(String address, int passkey) { mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); - if (passkey < 0 || passkey > 999999 || !BluetoothDevice.checkBluetoothAddress(address)) { + if (passkey < 0 || passkey > 999999 || !BluetoothAdapter.checkBluetoothAddress(address)) { return false; } address = address.toUpperCase(); @@ -1048,10 +1049,10 @@ public class BluetoothService extends IBluetooth.Stub { public synchronized boolean cancelPairingUserInput(String address) { mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); - if (!BluetoothDevice.checkBluetoothAddress(address)) { + if (!BluetoothAdapter.checkBluetoothAddress(address)) { return false; } - mBondState.setBondState(address, BluetoothDevice.BOND_NOT_BONDED, + mBondState.setBondState(address, BluetoothDevice.BOND_NONE, BluetoothDevice.UNBOND_REASON_AUTH_CANCELED); address = address.toUpperCase(); Integer data = mEventLoop.getPasskeyAgentRequestData().remove(address); |