summaryrefslogtreecommitdiffstats
path: root/core/java/android/server
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-01-22 00:13:42 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-01-22 00:13:42 -0800
commitf1e484acb594a726fb57ad0ae4cfe902c7f35858 (patch)
tree99d2b34512f0dc2ae67666e756c1cfcd331e5fe3 /core/java/android/server
parent22f7dfd23490a3de2f21ff96949ba47003aac8f8 (diff)
downloadframeworks_base-f1e484acb594a726fb57ad0ae4cfe902c7f35858.zip
frameworks_base-f1e484acb594a726fb57ad0ae4cfe902c7f35858.tar.gz
frameworks_base-f1e484acb594a726fb57ad0ae4cfe902c7f35858.tar.bz2
auto import from //branches/cupcake/...@127436
Diffstat (limited to 'core/java/android/server')
-rw-r--r--core/java/android/server/BluetoothA2dpService.java19
-rw-r--r--core/java/android/server/BluetoothDeviceService.java270
-rw-r--r--core/java/android/server/BluetoothEventLoop.java92
-rw-r--r--core/java/android/server/search/SearchableInfo.java2
4 files changed, 219 insertions, 164 deletions
diff --git a/core/java/android/server/BluetoothA2dpService.java b/core/java/android/server/BluetoothA2dpService.java
index be784ff..8486e4b 100644
--- a/core/java/android/server/BluetoothA2dpService.java
+++ b/core/java/android/server/BluetoothA2dpService.java
@@ -84,8 +84,7 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub {
mIntentFilter = new IntentFilter(BluetoothIntent.ENABLED_ACTION);
mIntentFilter.addAction(BluetoothIntent.DISABLED_ACTION);
- mIntentFilter.addAction(BluetoothIntent.BONDING_CREATED_ACTION);
- mIntentFilter.addAction(BluetoothIntent.BONDING_REMOVED_ACTION);
+ mIntentFilter.addAction(BluetoothIntent.BOND_STATE_CHANGED_ACTION);
mContext.registerReceiver(mReceiver, mIntentFilter);
if (device.isEnabled()) {
@@ -111,10 +110,18 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub {
onBluetoothEnable();
} else if (action.equals(BluetoothIntent.DISABLED_ACTION)) {
onBluetoothDisable();
- } else if (action.equals(BluetoothIntent.BONDING_CREATED_ACTION)) {
- setSinkPriority(address, BluetoothA2dp.PRIORITY_AUTO);
- } else if (action.equals(BluetoothIntent.BONDING_REMOVED_ACTION)) {
- setSinkPriority(address, BluetoothA2dp.PRIORITY_OFF);
+ } else if (action.equals(BluetoothIntent.BOND_STATE_CHANGED_ACTION)) {
+ int bondState = intent.getIntExtra(BluetoothIntent.BOND_STATE,
+ BluetoothError.ERROR);
+ switch(bondState) {
+ case BluetoothDevice.BOND_BONDED:
+ setSinkPriority(address, BluetoothA2dp.PRIORITY_AUTO);
+ break;
+ case BluetoothDevice.BOND_BONDING:
+ case BluetoothDevice.BOND_NOT_BONDED:
+ setSinkPriority(address, BluetoothA2dp.PRIORITY_OFF);
+ break;
+ }
}
}
};
diff --git a/core/java/android/server/BluetoothDeviceService.java b/core/java/android/server/BluetoothDeviceService.java
index 9bdab9f..3ce34c3 100644
--- a/core/java/android/server/BluetoothDeviceService.java
+++ b/core/java/android/server/BluetoothDeviceService.java
@@ -26,6 +26,7 @@ package android.server;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHeadset; // just for dump()
+import android.bluetooth.BluetoothError;
import android.bluetooth.BluetoothIntent;
import android.bluetooth.IBluetoothDevice;
import android.bluetooth.IBluetoothDeviceCallback;
@@ -49,14 +50,19 @@ import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Map;
public class BluetoothDeviceService extends IBluetoothDevice.Stub {
private static final String TAG = "BluetoothDeviceService";
+ private static final boolean DBG = true;
+
private int mNativeData;
private BluetoothEventLoop mEventLoop;
private IntentFilter mIntentFilter;
private boolean mIsAirplaneSensitive;
+ private final BondState mBondState = new BondState(); // local cache of bondings
private volatile boolean mIsEnabled; // local cache of isEnabledNative()
private boolean mIsDiscovering;
@@ -79,10 +85,13 @@ public class BluetoothDeviceService extends IBluetoothDevice.Stub {
public synchronized void init() {
initializeNativeDataNative();
mIsEnabled = (isEnabledNative() == 1);
+ if (mIsEnabled) {
+ mBondState.loadBondState();
+ }
mIsDiscovering = false;
mEventLoop = new BluetoothEventLoop(mContext, this);
registerForAirplaneMode();
-
+
disableEsco(); // TODO: enable eSCO support once its fully supported
}
private native void initializeNativeDataNative();
@@ -112,7 +121,7 @@ public class BluetoothDeviceService extends IBluetoothDevice.Stub {
public synchronized boolean disable() {
mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
"Need BLUETOOTH_ADMIN permission");
-
+
if (mEnableThread != null && mEnableThread.isAlive()) {
return false;
}
@@ -171,7 +180,6 @@ public class BluetoothDeviceService extends IBluetoothDevice.Stub {
};
private EnableThread mEnableThread;
- private String mOutgoingBondingDevAddress = null;
private class EnableThread extends Thread {
private final IBluetoothDeviceCallback mEnableCallback;
@@ -198,6 +206,7 @@ public class BluetoothDeviceService extends IBluetoothDevice.Stub {
Settings.Secure.BLUETOOTH_ON, 1);
mIsDiscovering = false;
Intent intent = new Intent(BluetoothIntent.ENABLED_ACTION);
+ mBondState.loadBondState();
mContext.sendBroadcast(intent, BLUETOOTH_PERM);
mHandler.sendMessageDelayed(mHandler.obtainMessage(REGISTER_SDP_RECORDS), 3000);
}
@@ -208,6 +217,119 @@ public class BluetoothDeviceService extends IBluetoothDevice.Stub {
private native int enableNative();
private native int disableNative();
+ /* package */ BondState getBondState() {
+ return mBondState;
+ }
+
+ /** local cache of bonding state.
+ /* we keep our own state to track the intermediate state BONDING, which
+ /* bluez does not track.
+ * All addreses must be passed in upper case.
+ */
+ public class BondState {
+ private final HashMap<String, Integer> mState = new HashMap<String, Integer>();
+ private final HashMap<String, Integer> mPinAttempt = new HashMap<String, Integer>();
+
+ public synchronized void loadBondState() {
+ if (!mIsEnabled) {
+ return;
+ }
+ String[] bonds = listBondingsNative();
+ if (bonds == null) {
+ return;
+ }
+ mState.clear();
+ if (DBG) log("found " + bonds.length + " bonded devices");
+ for (String address : bonds) {
+ mState.put(address.toUpperCase(), BluetoothDevice.BOND_BONDED);
+ }
+ }
+
+ public synchronized void setBondState(String address, int state) {
+ setBondState(address, state, 0);
+ }
+
+ /** reason is ignored unless state == BOND_NOT_BONDED */
+ public synchronized void setBondState(String address, int state, int reason) {
+ int oldState = getBondState(address);
+ if (oldState == state) {
+ return;
+ }
+ if (DBG) log(address + " bond state " + oldState + " -> " + state + " (" +
+ reason + ")");
+ Intent intent = new Intent(BluetoothIntent.BOND_STATE_CHANGED_ACTION);
+ intent.putExtra(BluetoothIntent.ADDRESS, address);
+ intent.putExtra(BluetoothIntent.BOND_STATE, state);
+ intent.putExtra(BluetoothIntent.BOND_PREVIOUS_STATE, oldState);
+ if (state == BluetoothDevice.BOND_NOT_BONDED) {
+ if (reason <= 0) {
+ Log.w(TAG, "setBondState() called to unbond device with invalid reason code " +
+ "Setting reason = BOND_RESULT_REMOVED");
+ reason = BluetoothDevice.UNBOND_REASON_REMOVED;
+ }
+ intent.putExtra(BluetoothIntent.REASON, reason);
+ mState.remove(address);
+ } else {
+ mState.put(address, state);
+ }
+ if (state == BluetoothDevice.BOND_BONDING) {
+ mPinAttempt.put(address, Integer.valueOf(0));
+ } else {
+ mPinAttempt.remove(address);
+ }
+ mContext.sendBroadcast(intent, BLUETOOTH_PERM);
+ }
+
+ public synchronized int getBondState(String address) {
+ Integer state = mState.get(address);
+ if (state == null) {
+ return BluetoothDevice.BOND_NOT_BONDED;
+ }
+ return state.intValue();
+ }
+
+ public synchronized String[] listBonds() {
+ ArrayList<String> result = new ArrayList<String>(mState.size());
+ for (Map.Entry<String, Integer> e : mState.entrySet()) {
+ if (e.getValue().intValue() == BluetoothDevice.BOND_BONDED) {
+ result.add(e.getKey());
+ }
+ }
+ return result.toArray(new String[result.size()]);
+ }
+
+ public synchronized int getAttempt(String address) {
+ Integer attempt = mPinAttempt.get(address);
+ if (attempt == null) {
+ return 0;
+ }
+ return attempt.intValue();
+ }
+
+ public synchronized void attempt(String address) {
+ Integer attempt = mPinAttempt.get(address);
+ if (attempt == null) {
+ return;
+ }
+ mPinAttempt.put(address, new Integer(attempt.intValue() + 1));
+ }
+
+ }
+ private native String[] listBondingsNative();
+
+ private static String toBondStateString(int bondState) {
+ switch (bondState) {
+ case BluetoothDevice.BOND_NOT_BONDED:
+ return "not bonded";
+ case BluetoothDevice.BOND_BONDING:
+ return "bonding";
+ case BluetoothDevice.BOND_BONDED:
+ return "bonded";
+ default:
+ return "??????";
+ }
+ }
+
public synchronized String getAddress() {
mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
return getAddressNative();
@@ -231,12 +353,6 @@ public class BluetoothDeviceService extends IBluetoothDevice.Stub {
}
private native boolean setNameNative(String name);
- public synchronized String[] listBondings() {
- mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
- return listBondingsNative();
- }
- private native String[] listBondingsNative();
-
public synchronized String getMajorClass() {
mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
return getMajorClassNative();
@@ -551,106 +667,45 @@ public class BluetoothDeviceService extends IBluetoothDevice.Stub {
}
private native boolean disconnectRemoteDeviceNative(String address);
- private static final int MAX_OUTSTANDING_ASYNC = 32;
- /**
- * This method initiates a Bonding request to a remote device.
- *
- *
- * @param address The Bluetooth address of the remote device
- *
- * @see #createBonding
- * @see #cancelBondingProcess
- * @see #removeBonding
- * @see #hasBonding
- * @see #listBondings
- *
- * @see android.bluetooth.PasskeyAgent
- */
- public synchronized boolean createBonding(String address, IBluetoothDeviceCallback callback) {
+ public synchronized boolean createBond(String address) {
mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
"Need BLUETOOTH_ADMIN permission");
if (!BluetoothDevice.checkBluetoothAddress(address)) {
return false;
}
-
- HashMap<String, IBluetoothDeviceCallback> callbacks = mEventLoop.getCreateBondingCallbacks();
- if (callbacks.containsKey(address)) {
- Log.w(TAG, "createBonding() already in progress for " + address);
+ address = address.toUpperCase();
+ if (mBondState.getBondState(address) != BluetoothDevice.BOND_NOT_BONDED) {
return false;
}
- // Protect from malicious clients - limit number of outstanding requests
- if (callbacks.size() > MAX_OUTSTANDING_ASYNC) {
- Log.w(TAG, "Too many outstanding bonding requests, dropping request for " + address);
- return false;
- }
-
- callbacks.put(address, callback);
if (!createBondingNative(address, 60000 /* 1 minute */)) {
- callbacks.remove(address);
return false;
}
- mOutgoingBondingDevAddress = address;
+
+ mBondState.setBondState(address, BluetoothDevice.BOND_BONDING);
return true;
}
-
private native boolean createBondingNative(String address, int timeout_ms);
-
- /*package*/ String getOutgoingBondingDevAddress() {
- return mOutgoingBondingDevAddress;
- }
- /*package*/ void setOutgoingBondingDevAddress(String outgoingBondingDevAddress) {
- mOutgoingBondingDevAddress = outgoingBondingDevAddress;
- }
-
- /**
- * This method cancels a pending bonding request.
- *
- * @param address The Bluetooth address of the remote device to which a
- * bonding request has been initiated.
- *
- * Note: When a request is canceled, method
- * {@link CreateBondingResultNotifier#notifyAuthenticationFailed}
- * will be called on the object passed to method
- * {@link #createBonding}.
- *
- * Note: it is safe to call this method when there is no outstanding
- * bonding request.
- *
- * @see #createBonding
- * @see #cancelBondingProcess
- * @see #removeBonding
- * @see #hasBonding
- * @see #listBondings
- */
- public synchronized boolean cancelBondingProcess(String address) {
+ public synchronized boolean cancelBondProcess(String address) {
mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
"Need BLUETOOTH_ADMIN permission");
if (!BluetoothDevice.checkBluetoothAddress(address)) {
return false;
}
- return cancelBondingProcessNative(address);
+ address = address.toUpperCase();
+ if (mBondState.getBondState(address) != BluetoothDevice.BOND_BONDING) {
+ return false;
+ }
+
+ mBondState.setBondState(address, BluetoothDevice.BOND_NOT_BONDED,
+ BluetoothDevice.UNBOND_REASON_CANCELLED);
+ cancelBondingProcessNative(address);
+ return true;
}
private native boolean cancelBondingProcessNative(String address);
- /**
- * This method removes a bonding to a remote device. This is a local
- * operation only, resulting in this adapter "forgetting" the bonding
- * information about the specified remote device. The other device itself
- * does not know what the bonding has been torn down. The next time either
- * device attemps to connect to the other, the connection will fail, and
- * the pairing procedure will have to be re-initiated.
- *
- * @param address The Bluetooth address of the remote device.
- *
- * @see #createBonding
- * @see #cancelBondingProcess
- * @see #removeBonding
- * @see #hasBonding
- * @see #listBondings
- */
- public synchronized boolean removeBonding(String address) {
+ public synchronized boolean removeBond(String address) {
mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
"Need BLUETOOTH_ADMIN permission");
if (!BluetoothDevice.checkBluetoothAddress(address)) {
@@ -660,14 +715,18 @@ public class BluetoothDeviceService extends IBluetoothDevice.Stub {
}
private native boolean removeBondingNative(String address);
- public synchronized boolean hasBonding(String address) {
+ public synchronized String[] listBonds() {
+ mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
+ return mBondState.listBonds();
+ }
+
+ public synchronized int getBondState(String address) {
mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
if (!BluetoothDevice.checkBluetoothAddress(address)) {
- return false;
+ return BluetoothError.ERROR;
}
- return hasBondingNative(address);
+ return mBondState.getBondState(address.toUpperCase());
}
- private native boolean hasBondingNative(String address);
public synchronized String[] listAclConnections() {
mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
@@ -1016,6 +1075,8 @@ public class BluetoothDeviceService extends IBluetoothDevice.Stub {
}
private native byte[] getRemoteServiceRecordNative(String address, int handle);
+ private static final int MAX_OUTSTANDING_ASYNC = 32;
+
// AIDL does not yet support short's
public synchronized boolean getRemoteServiceChannel(String address, int uuid16,
IBluetoothDeviceCallback callback) {
@@ -1051,6 +1112,7 @@ public class BluetoothDeviceService extends IBluetoothDevice.Stub {
!BluetoothDevice.checkBluetoothAddress(address)) {
return false;
}
+ address = address.toUpperCase();
Integer data = mEventLoop.getPasskeyAgentRequestData().remove(address);
if (data == null) {
Log.w(TAG, "setPin(" + address + ") called but no native data available, " +
@@ -1076,6 +1138,7 @@ public class BluetoothDeviceService extends IBluetoothDevice.Stub {
if (!BluetoothDevice.checkBluetoothAddress(address)) {
return false;
}
+ address = address.toUpperCase();
Integer data = mEventLoop.getPasskeyAgentRequestData().remove(address);
if (data == null) {
Log.w(TAG, "cancelPin(" + address + ") called but no native data available, " +
@@ -1143,25 +1206,20 @@ public class BluetoothDeviceService extends IBluetoothDevice.Stub {
BluetoothHeadset headset = new BluetoothHeadset(mContext, null);
- pw.println("\n--Bondings--");
- String[] addresses = listBondings();
- for (String address : addresses) {
- String name = getRemoteName(address);
- pw.println(address + " (" + name + ")");
- }
+ String[] addresses = listRemoteDevices();
- pw.println("\n--Current ACL Connections--");
- addresses = listAclConnections();
+ pw.println("\n--Known devices--");
for (String address : addresses) {
- String name = getRemoteName(address);
- pw.println(address + " (" + name + ")");
+ pw.printf("%s %10s (%d) %s\n", address,
+ toBondStateString(mBondState.getBondState(address)),
+ mBondState.getAttempt(address),
+ getRemoteName(address));
}
- pw.println("\n--Known Devices--");
- addresses = listRemoteDevices();
+ addresses = listAclConnections();
+ pw.println("\n--ACL connected devices--");
for (String address : addresses) {
- String name = getRemoteName(address);
- pw.println(address + " (" + name + ")");
+ pw.println(address);
}
// Rather not do this from here, but no-where else and I need this
@@ -1189,4 +1247,8 @@ public class BluetoothDeviceService extends IBluetoothDevice.Stub {
}
pw.println("\nmIsAirplaneSensitive = " + mIsAirplaneSensitive);
}
+
+ private static void log(String msg) {
+ Log.d(TAG, msg);
+ }
}
diff --git a/core/java/android/server/BluetoothEventLoop.java b/core/java/android/server/BluetoothEventLoop.java
index 2d8aacc..4f63f98 100644
--- a/core/java/android/server/BluetoothEventLoop.java
+++ b/core/java/android/server/BluetoothEventLoop.java
@@ -16,8 +16,9 @@
package android.server;
-import android.bluetooth.BluetoothClass.Device;
+import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
+import android.bluetooth.BluetoothError;
import android.bluetooth.BluetoothIntent;
import android.bluetooth.IBluetoothDeviceCallback;
import android.content.Context;
@@ -41,11 +42,9 @@ class BluetoothEventLoop {
private int mNativeData;
private Thread mThread;
private boolean mInterrupted;
- private HashMap<String, IBluetoothDeviceCallback> mCreateBondingCallbacks;
private HashMap<String, Integer> mPasskeyAgentRequestData;
private HashMap<String, IBluetoothDeviceCallback> mGetRemoteServiceChannelCallbacks;
- private HashMap<String, Boolean> mDefaultPinData;
- private BluetoothDeviceService mBluetoothService;
+ private BluetoothDeviceService mBluetoothService;
private Context mContext;
private static final String BLUETOOTH_ADMIN_PERM = android.Manifest.permission.BLUETOOTH_ADMIN;
@@ -57,10 +56,8 @@ class BluetoothEventLoop {
/* pacakge */ BluetoothEventLoop(Context context, BluetoothDeviceService bluetoothService) {
mBluetoothService = bluetoothService;
mContext = context;
- mCreateBondingCallbacks = new HashMap();
mPasskeyAgentRequestData = new HashMap();
mGetRemoteServiceChannelCallbacks = new HashMap();
- mDefaultPinData = new HashMap();
initializeNativeDataNative();
}
private native void initializeNativeDataNative();
@@ -74,9 +71,6 @@ class BluetoothEventLoop {
}
private native void cleanupNativeDataNative();
- /* pacakge */ HashMap<String, IBluetoothDeviceCallback> getCreateBondingCallbacks() {
- return mCreateBondingCallbacks;
- }
/* pacakge */ HashMap<String, IBluetoothDeviceCallback> getRemoteServiceChannelCallbacks() {
return mGetRemoteServiceChannelCallbacks;
}
@@ -235,33 +229,24 @@ class BluetoothEventLoop {
mContext.sendBroadcast(intent, BLUETOOTH_PERM);
}
- private void onCreateBondingResult(String address, boolean result) {
- mBluetoothService.setOutgoingBondingDevAddress(null);
- IBluetoothDeviceCallback callback = mCreateBondingCallbacks.get(address);
- if (callback != null) {
- try {
- callback.onCreateBondingResult(address,
- result ? BluetoothDevice.RESULT_SUCCESS :
- BluetoothDevice.RESULT_FAILURE);
- } catch (RemoteException e) {}
- mCreateBondingCallbacks.remove(address);
- }
+ private void onCreateBondingResult(String address, int result) {
+ address = address.toUpperCase();
+ if (result == BluetoothError.SUCCESS) {
+ mBluetoothService.getBondState().setBondState(address, BluetoothDevice.BOND_BONDED);
+ } else {
+ mBluetoothService.getBondState().setBondState(address,
+ BluetoothDevice.BOND_NOT_BONDED, result);
+ }
}
-
+
public void onBondingCreated(String address) {
- Intent intent = new Intent(BluetoothIntent.BONDING_CREATED_ACTION);
- intent.putExtra(BluetoothIntent.ADDRESS, address);
- mContext.sendBroadcast(intent, BLUETOOTH_PERM);
+ mBluetoothService.getBondState().setBondState(address.toUpperCase(),
+ BluetoothDevice.BOND_BONDED);
}
-
- public void onBondingRemoved(String address) {
- Intent intent = new Intent(BluetoothIntent.BONDING_REMOVED_ACTION);
- intent.putExtra(BluetoothIntent.ADDRESS, address);
- mContext.sendBroadcast(intent, BLUETOOTH_PERM);
- if (mDefaultPinData.containsKey(address)) {
- mDefaultPinData.remove(address);
- }
+ public void onBondingRemoved(String address) {
+ mBluetoothService.getBondState().setBondState(address.toUpperCase(),
+ BluetoothDevice.BOND_NOT_BONDED, BluetoothDevice.UNBOND_REASON_REMOVED);
}
public void onNameChanged(String name) {
@@ -271,24 +256,24 @@ class BluetoothEventLoop {
}
public void onPasskeyAgentRequest(String address, int nativeData) {
- mPasskeyAgentRequestData.put(address, new Integer(nativeData));
-
- if (address.equals(mBluetoothService.getOutgoingBondingDevAddress())) {
+ address = address.toUpperCase();
+ mPasskeyAgentRequestData.put(address, new Integer(nativeData));
+
+ if (mBluetoothService.getBondState().getBondState(address) ==
+ BluetoothDevice.BOND_BONDING) {
+ // we initiated the bonding
int btClass = mBluetoothService.getRemoteClass(address);
- int remoteDeviceClass = Device.getDevice(btClass);
- if (remoteDeviceClass == Device.AUDIO_VIDEO_WEARABLE_HEADSET ||
- remoteDeviceClass == Device.AUDIO_VIDEO_HANDSFREE ||
- remoteDeviceClass == Device.AUDIO_VIDEO_HEADPHONES ||
- remoteDeviceClass == Device.AUDIO_VIDEO_PORTABLE_AUDIO ||
- remoteDeviceClass == Device.AUDIO_VIDEO_CAR_AUDIO ||
- remoteDeviceClass == Device.AUDIO_VIDEO_HIFI_AUDIO) {
- if (!mDefaultPinData.containsKey(address)) {
- mDefaultPinData.put(address, false);
- }
- if (!mDefaultPinData.get(address)) {
- mDefaultPinData.remove(address);
- mDefaultPinData.put(address, true);
+ // try 0000 once if the device looks dumb
+ switch (BluetoothClass.Device.getDevice(btClass)) {
+ case BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET:
+ case BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE:
+ case BluetoothClass.Device.AUDIO_VIDEO_HEADPHONES:
+ case BluetoothClass.Device.AUDIO_VIDEO_PORTABLE_AUDIO:
+ case BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO:
+ case BluetoothClass.Device.AUDIO_VIDEO_HIFI_AUDIO:
+ if (mBluetoothService.getBondState().getAttempt(address) < 1) {
+ mBluetoothService.getBondState().attempt(address);
mBluetoothService.setPin(address, BluetoothDevice.convertPinToBytes("0000"));
return;
}
@@ -298,18 +283,17 @@ class BluetoothEventLoop {
intent.putExtra(BluetoothIntent.ADDRESS, address);
mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM);
}
-
+
public void onPasskeyAgentCancel(String address) {
+ address = address.toUpperCase();
mPasskeyAgentRequestData.remove(address);
- if (mDefaultPinData.containsKey(address)) {
- mDefaultPinData.remove(address);
- mDefaultPinData.put(address, false);
- }
Intent intent = new Intent(BluetoothIntent.PAIRING_CANCEL_ACTION);
intent.putExtra(BluetoothIntent.ADDRESS, address);
mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM);
+ mBluetoothService.getBondState().setBondState(address, BluetoothDevice.BOND_NOT_BONDED,
+ BluetoothDevice.UNBOND_REASON_CANCELLED);
}
-
+
private void onGetRemoteServiceChannelResult(String address, int channel) {
IBluetoothDeviceCallback callback = mGetRemoteServiceChannelCallbacks.get(address);
if (callback != null) {
diff --git a/core/java/android/server/search/SearchableInfo.java b/core/java/android/server/search/SearchableInfo.java
index ac4cdb9..c8f395e 100644
--- a/core/java/android/server/search/SearchableInfo.java
+++ b/core/java/android/server/search/SearchableInfo.java
@@ -704,6 +704,7 @@ public final class SearchableInfo implements Parcelable {
* positioned at the location in the buffer where it was written.
*/
public SearchableInfo(Parcel in) {
+ mSearchable = in.readInt() != 0;
mLabelId = in.readInt();
mSearchActivity = ComponentName.readFromParcel(in);
mHintId = in.readInt();
@@ -733,6 +734,7 @@ public final class SearchableInfo implements Parcelable {
}
public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(mSearchable ? 1 : 0);
dest.writeInt(mLabelId);
mSearchActivity.writeToParcel(dest, flags);
dest.writeInt(mHintId);