Changes for new Bluetooth APIs.
Changes to Bluetooth Adapter, Device and IBluetooth interfaces
for new Bluetooth APIs. Delete AudioGateway.
Change-Id: Ib51b31187eafde261441b9311b5e7e13c8bff82f
diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java
index 8e3df47..755884c 100644
--- a/core/java/android/bluetooth/BluetoothAdapter.java
+++ b/core/java/android/bluetooth/BluetoothAdapter.java
@@ -367,10 +367,12 @@
*/
public static synchronized BluetoothAdapter getDefaultAdapter() {
if (sAdapter == null) {
- IBinder b = ServiceManager.getService(BluetoothAdapter.BLUETOOTH_SERVICE);
+ IBinder b = ServiceManager.getService("bluetooth");
if (b != null) {
IBluetooth service = IBluetooth.Stub.asInterface(b);
sAdapter = new BluetoothAdapter(service);
+ } else {
+ Log.e(TAG, "Bluetooth binder is null");
}
}
return sAdapter;
@@ -378,9 +380,8 @@
/**
* Use {@link #getDefaultAdapter} to get the BluetoothAdapter instance.
- * @hide
*/
- public BluetoothAdapter(IBluetooth service) {
+ BluetoothAdapter(IBluetooth service) {
if (service == null) {
throw new IllegalArgumentException("service is null");
}
@@ -450,8 +451,9 @@
* @return current state of Bluetooth adapter
*/
public int getState() {
+ if (mService == null) return STATE_OFF;
try {
- return mService.getBluetoothState();
+ return mService.getState();
} catch (RemoteException e) {Log.e(TAG, "", e);}
return STATE_OFF;
}
@@ -516,7 +518,7 @@
*/
public boolean disable() {
try {
- return mService.disable(true);
+ return mService.disable();
} catch (RemoteException e) {Log.e(TAG, "", e);}
return false;
}
@@ -774,10 +776,10 @@
*/
public Set<BluetoothDevice> getBondedDevices() {
if (getState() != STATE_ON) {
- return toDeviceSet(new String[0]);
+ return toDeviceSet(new BluetoothDevice[0]);
}
try {
- return toDeviceSet(mService.listBonds());
+ return toDeviceSet(mService.getBondedDevices());
} catch (RemoteException e) {Log.e(TAG, "", e);}
return null;
}
@@ -999,7 +1001,6 @@
private BluetoothServerSocket createNewRfcommSocketAndRecord(String name, UUID uuid,
boolean auth, boolean encrypt) throws IOException {
RfcommChannelPicker picker = new RfcommChannelPicker(uuid);
-
BluetoothServerSocket socket;
int channel;
int errno;
@@ -1031,10 +1032,11 @@
}
int handle = -1;
- try {
+ //TODO(BT):
+ /*try {
handle = mService.addRfcommServiceRecord(name, new ParcelUuid(uuid), channel,
new Binder());
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ } catch (RemoteException e) {Log.e(TAG, "", e);}*/
if (handle == -1) {
try {
socket.close();
@@ -1047,11 +1049,13 @@
public void handleMessage(Message msg) {
/* handle socket closing */
int handle = msg.what;
+ // TODO(BT):
+ /*
try {
if (DBG) Log.d(TAG, "Removing service record " +
- Integer.toHexString(handle));
- mService.removeServiceRecord(handle);
+ Integer.toHexString(handle));
} catch (RemoteException e) {Log.e(TAG, "", e);}
+ */
}
};
}
@@ -1134,6 +1138,8 @@
*/
public Pair<byte[], byte[]> readOutOfBandData() {
if (getState() != STATE_ON) return null;
+ //TODO(BT
+ /*
try {
byte[] hash;
byte[] randomizer;
@@ -1151,7 +1157,7 @@
}
return new Pair<byte[], byte[]>(hash, randomizer);
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ } catch (RemoteException e) {Log.e(TAG, "", e);}*/
return null;
}
@@ -1276,12 +1282,14 @@
BluetoothStateChangeCallback callback) {
if (callback == null) return false;
+ //TODO(BT)
+ /*
try {
return mService.changeApplicationBluetoothState(on, new
StateChangeCallbackWrapper(callback), new Binder());
} catch (RemoteException e) {
Log.e(TAG, "changeBluetoothState", e);
- }
+ }*/
return false;
}
@@ -1309,12 +1317,9 @@
}
}
- private Set<BluetoothDevice> toDeviceSet(String[] addresses) {
- Set<BluetoothDevice> devices = new HashSet<BluetoothDevice>(addresses.length);
- for (int i = 0; i < addresses.length; i++) {
- devices.add(getRemoteDevice(addresses[i]));
- }
- return Collections.unmodifiableSet(devices);
+ private Set<BluetoothDevice> toDeviceSet(BluetoothDevice[] devices) {
+ Set<BluetoothDevice> deviceSet = new HashSet<BluetoothDevice>(Arrays.asList(devices));
+ return Collections.unmodifiableSet(deviceSet);
}
/**
diff --git a/core/java/android/bluetooth/BluetoothAudioGateway.java b/core/java/android/bluetooth/BluetoothAudioGateway.java
deleted file mode 100644
index 9351393..0000000
--- a/core/java/android/bluetooth/BluetoothAudioGateway.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.bluetooth;
-
-import java.lang.Thread;
-
-import android.os.Message;
-import android.os.Handler;
-import android.util.Log;
-
-/**
- * Listens for incoming RFCOMM connection for the headset / handsfree service.
- *
- * TODO: Use the new generic BluetoothSocket class instead of this legacy code
- *
- * @hide
- */
-public final class BluetoothAudioGateway {
- private static final String TAG = "BT Audio Gateway";
- private static final boolean DBG = false;
-
- private int mNativeData;
- static { classInitNative(); }
-
- /* in */
- private int mHandsfreeAgRfcommChannel = -1;
- private int mHeadsetAgRfcommChannel = -1;
-
- /* out - written by native code */
- private String mConnectingHeadsetAddress;
- private int mConnectingHeadsetRfcommChannel; /* -1 when not connected */
- private int mConnectingHeadsetSocketFd;
- private String mConnectingHandsfreeAddress;
- private int mConnectingHandsfreeRfcommChannel; /* -1 when not connected */
- private int mConnectingHandsfreeSocketFd;
- private int mTimeoutRemainingMs; /* in/out */
-
- private final BluetoothAdapter mAdapter;
-
- public static final int DEFAULT_HF_AG_CHANNEL = 10;
- public static final int DEFAULT_HS_AG_CHANNEL = 11;
-
- public BluetoothAudioGateway(BluetoothAdapter adapter) {
- this(adapter, DEFAULT_HF_AG_CHANNEL, DEFAULT_HS_AG_CHANNEL);
- }
-
- public BluetoothAudioGateway(BluetoothAdapter adapter, int handsfreeAgRfcommChannel,
- int headsetAgRfcommChannel) {
- mAdapter = adapter;
- mHandsfreeAgRfcommChannel = handsfreeAgRfcommChannel;
- mHeadsetAgRfcommChannel = headsetAgRfcommChannel;
- initializeNativeDataNative();
- }
-
- private Thread mConnectThead;
- private volatile boolean mInterrupted;
- private static final int SELECT_WAIT_TIMEOUT = 1000;
-
- private Handler mCallback;
-
- public class IncomingConnectionInfo {
- public BluetoothAdapter mAdapter;
- public BluetoothDevice mRemoteDevice;
- public int mSocketFd;
- public int mRfcommChan;
- IncomingConnectionInfo(BluetoothAdapter adapter, BluetoothDevice remoteDevice,
- int socketFd, int rfcommChan) {
- mAdapter = adapter;
- mRemoteDevice = remoteDevice;
- mSocketFd = socketFd;
- mRfcommChan = rfcommChan;
- }
- }
-
- public static final int MSG_INCOMING_HEADSET_CONNECTION = 100;
- public static final int MSG_INCOMING_HANDSFREE_CONNECTION = 101;
-
- public synchronized boolean start(Handler callback) {
-
- if (mConnectThead == null) {
- mCallback = callback;
- mConnectThead = new Thread(TAG) {
- public void run() {
- if (DBG) log("Connect Thread starting");
- while (!mInterrupted) {
- //Log.i(TAG, "waiting for connect");
- mConnectingHeadsetRfcommChannel = -1;
- mConnectingHandsfreeRfcommChannel = -1;
- if (waitForHandsfreeConnectNative(SELECT_WAIT_TIMEOUT) == false) {
- if (mTimeoutRemainingMs > 0) {
- try {
- Log.i(TAG, "select thread timed out, but " +
- mTimeoutRemainingMs + "ms of waiting remain.");
- Thread.sleep(mTimeoutRemainingMs);
- } catch (InterruptedException e) {
- Log.i(TAG, "select thread was interrupted (2), exiting");
- mInterrupted = true;
- }
- }
- }
- else {
- Log.i(TAG, "connect notification!");
- /* A device connected (most likely just one, but
- it is possible for two separate devices, one
- a headset and one a handsfree, to connect
- simultaneously.
- */
- if (mConnectingHeadsetRfcommChannel >= 0) {
- Log.i(TAG, "Incoming connection from headset " +
- mConnectingHeadsetAddress + " on channel " +
- mConnectingHeadsetRfcommChannel);
- Message msg = Message.obtain(mCallback);
- msg.what = MSG_INCOMING_HEADSET_CONNECTION;
- msg.obj = new IncomingConnectionInfo(
- mAdapter,
- mAdapter.getRemoteDevice(mConnectingHeadsetAddress),
- mConnectingHeadsetSocketFd,
- mConnectingHeadsetRfcommChannel);
- msg.sendToTarget();
- }
- if (mConnectingHandsfreeRfcommChannel >= 0) {
- Log.i(TAG, "Incoming connection from handsfree " +
- mConnectingHandsfreeAddress + " on channel " +
- mConnectingHandsfreeRfcommChannel);
- Message msg = Message.obtain();
- msg.setTarget(mCallback);
- msg.what = MSG_INCOMING_HANDSFREE_CONNECTION;
- msg.obj = new IncomingConnectionInfo(
- mAdapter,
- mAdapter.getRemoteDevice(mConnectingHandsfreeAddress),
- mConnectingHandsfreeSocketFd,
- mConnectingHandsfreeRfcommChannel);
- msg.sendToTarget();
- }
- }
- }
- if (DBG) log("Connect Thread finished");
- }
- };
-
- if (setUpListeningSocketsNative() == false) {
- Log.e(TAG, "Could not set up listening socket, exiting");
- return false;
- }
-
- mInterrupted = false;
- mConnectThead.start();
- }
-
- return true;
- }
-
- public synchronized void stop() {
- if (mConnectThead != null) {
- if (DBG) log("stopping Connect Thread");
- mInterrupted = true;
- try {
- mConnectThead.interrupt();
- if (DBG) log("waiting for thread to terminate");
- mConnectThead.join();
- mConnectThead = null;
- mCallback = null;
- tearDownListeningSocketsNative();
- } catch (InterruptedException e) {
- Log.w(TAG, "Interrupted waiting for Connect Thread to join");
- }
- }
- }
-
- protected void finalize() throws Throwable {
- try {
- cleanupNativeDataNative();
- } finally {
- super.finalize();
- }
- }
-
- private static native void classInitNative();
- private native void initializeNativeDataNative();
- private native void cleanupNativeDataNative();
- private native boolean waitForHandsfreeConnectNative(int timeoutMs);
- private native boolean setUpListeningSocketsNative();
- private native void tearDownListeningSocketsNative();
-
- private static void log(String msg) {
- Log.d(TAG, msg);
- }
-}
diff --git a/core/java/android/bluetooth/BluetoothDevice.java b/core/java/android/bluetooth/BluetoothDevice.java
index 56e1735..bd089ff 100644
--- a/core/java/android/bluetooth/BluetoothDevice.java
+++ b/core/java/android/bluetooth/BluetoothDevice.java
@@ -576,7 +576,7 @@
*/
public String getName() {
try {
- return sService.getRemoteName(mAddress);
+ return sService.getRemoteName(this);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return null;
}
@@ -590,7 +590,7 @@
*/
public String getAlias() {
try {
- return sService.getRemoteAlias(mAddress);
+ return sService.getRemoteAlias(this);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return null;
}
@@ -607,7 +607,7 @@
*/
public boolean setAlias(String alias) {
try {
- return sService.setRemoteAlias(mAddress, alias);
+ return sService.setRemoteAlias(this, alias);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return false;
}
@@ -643,7 +643,7 @@
*/
public boolean createBond() {
try {
- return sService.createBond(mAddress);
+ return sService.createBond(this);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return false;
}
@@ -668,9 +668,11 @@
* @hide
*/
public boolean createBondOutOfBand(byte[] hash, byte[] randomizer) {
+ //TODO(BT)
+ /*
try {
- return sService.createBondOutOfBand(mAddress, hash, randomizer);
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ return sService.createBondOutOfBand(this, hash, randomizer);
+ } catch (RemoteException e) {Log.e(TAG, "", e);}*/
return false;
}
@@ -688,9 +690,11 @@
* @hide
*/
public boolean setDeviceOutOfBandData(byte[] hash, byte[] randomizer) {
+ //TODO(BT)
+ /*
try {
- return sService.setDeviceOutOfBandData(mAddress, hash, randomizer);
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ return sService.setDeviceOutOfBandData(this, hash, randomizer);
+ } catch (RemoteException e) {Log.e(TAG, "", e);} */
return false;
}
@@ -703,7 +707,7 @@
*/
public boolean cancelBondProcess() {
try {
- return sService.cancelBondProcess(mAddress);
+ return sService.cancelBondProcess(this);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return false;
}
@@ -720,7 +724,7 @@
*/
public boolean removeBond() {
try {
- return sService.removeBond(mAddress);
+ return sService.removeBond(this);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return false;
}
@@ -737,7 +741,7 @@
*/
public int getBondState() {
try {
- return sService.getBondState(mAddress);
+ return sService.getBondState(this);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return BOND_NONE;
}
@@ -750,7 +754,7 @@
*/
public BluetoothClass getBluetoothClass() {
try {
- int classInt = sService.getRemoteClass(mAddress);
+ int classInt = sService.getRemoteClass(this);
if (classInt == BluetoothClass.ERROR) return null;
return new BluetoothClass(classInt);
} catch (RemoteException e) {Log.e(TAG, "", e);}
@@ -763,11 +767,13 @@
* @hide
*/
public boolean getTrustState() {
+ //TODO(BT)
+ /*
try {
- return sService.getTrustState(mAddress);
+ return sService.getTrustState(this);
} catch (RemoteException e) {
Log.e(TAG, "", e);
- }
+ }*/
return false;
}
@@ -778,11 +784,13 @@
* @hide
*/
public boolean setTrust(boolean value) {
+ //TODO(BT)
+ /*
try {
- return sService.setTrust(mAddress, value);
+ return sService.setTrust(this, value);
} catch (RemoteException e) {
Log.e(TAG, "", e);
- }
+ }*/
return false;
}
@@ -800,7 +808,7 @@
*/
public ParcelUuid[] getUuids() {
try {
- return sService.getRemoteUuids(mAddress);
+ return sService.getRemoteUuids(this);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return null;
}
@@ -821,65 +829,77 @@
* was started.
*/
public boolean fetchUuidsWithSdp() {
+ //TODO(BT)
+ /*
try {
- return sService.fetchRemoteUuids(mAddress, null, null);
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ return sService.fetchRemoteUuids(this, null, null);
+ } catch (RemoteException e) {Log.e(TAG, "", e);}*/
return false;
}
/** @hide */
public int getServiceChannel(ParcelUuid uuid) {
+ //TODO(BT)
+ /*
try {
- return sService.getRemoteServiceChannel(mAddress, uuid);
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ return sService.getRemoteServiceChannel(this, uuid);
+ } catch (RemoteException e) {Log.e(TAG, "", e);}*/
return BluetoothDevice.ERROR;
}
/** @hide */
public boolean setPin(byte[] pin) {
try {
- return sService.setPin(mAddress, pin);
+ return sService.setPin(this, true, pin.length, pin);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return false;
}
/** @hide */
public boolean setPasskey(int passkey) {
+ //TODO(BT)
+ /*
try {
- return sService.setPasskey(mAddress, passkey);
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ return sService.setPasskey(this, true, 4, passkey);
+ } catch (RemoteException e) {Log.e(TAG, "", e);}*/
return false;
}
/** @hide */
public boolean setPairingConfirmation(boolean confirm) {
try {
- return sService.setPairingConfirmation(mAddress, confirm);
+ return sService.setPairingConfirmation(this, confirm);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return false;
}
/** @hide */
public boolean setRemoteOutOfBandData() {
+ // TODO(BT)
+ /*
try {
- return sService.setRemoteOutOfBandData(mAddress);
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ return sService.setRemoteOutOfBandData(this);
+ } catch (RemoteException e) {Log.e(TAG, "", e);}*/
return false;
}
/** @hide */
public boolean cancelPairingUserInput() {
+ // TODO(BT)
+ /*
try {
- return sService.cancelPairingUserInput(mAddress);
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ return sService.cancelPairingUserInput(this);
+ } catch (RemoteException e) {Log.e(TAG, "", e);}*/
return false;
}
/** @hide */
public boolean isBluetoothDock() {
+ // TODO(BT)
+ /*
try {
- return sService.isBluetoothDock(mAddress);
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ return sService.isBluetoothDock(this);
+ } catch (RemoteException e) {Log.e(TAG, "", e);}*/
return false;
}
diff --git a/core/java/android/bluetooth/BluetoothHealth.java b/core/java/android/bluetooth/BluetoothHealth.java
index f850c02..f4aee98 100644
--- a/core/java/android/bluetooth/BluetoothHealth.java
+++ b/core/java/android/bluetooth/BluetoothHealth.java
@@ -146,11 +146,13 @@
new BluetoothHealthAppConfiguration(name, dataType, role, channelType);
if (mService != null) {
+ //TODO(BT
+ /*
try {
result = mService.registerAppConfiguration(config, wrapper);
} catch (RemoteException e) {
Log.e(TAG, e.toString());
- }
+ }*/
} else {
Log.w(TAG, "Proxy not attached to service");
if (DBG) Log.d(TAG, Log.getStackTraceString(new Throwable()));
@@ -170,11 +172,13 @@
public boolean unregisterAppConfiguration(BluetoothHealthAppConfiguration config) {
boolean result = false;
if (mService != null && isEnabled() && config != null) {
+ //TODO(BT
+ /*
try {
result = mService.unregisterAppConfiguration(config);
} catch (RemoteException e) {
Log.e(TAG, e.toString());
- }
+ }*/
} else {
Log.w(TAG, "Proxy not attached to service");
if (DBG) Log.d(TAG, Log.getStackTraceString(new Throwable()));
@@ -199,11 +203,13 @@
BluetoothHealthAppConfiguration config) {
if (mService != null && isEnabled() && isValidDevice(device) &&
config != null) {
+ //TODO(BT
+ /*
try {
return mService.connectChannelToSource(device, config);
} catch (RemoteException e) {
Log.e(TAG, e.toString());
- }
+ }*/
} else {
Log.w(TAG, "Proxy not attached to service");
if (DBG) Log.d(TAG, Log.getStackTraceString(new Throwable()));
@@ -228,11 +234,13 @@
BluetoothHealthAppConfiguration config, int channelType) {
if (mService != null && isEnabled() && isValidDevice(device) &&
config != null) {
+ //TODO(BT
+ /*
try {
return mService.connectChannelToSink(device, config, channelType);
} catch (RemoteException e) {
Log.e(TAG, e.toString());
- }
+ }*/
} else {
Log.w(TAG, "Proxy not attached to service");
if (DBG) Log.d(TAG, Log.getStackTraceString(new Throwable()));
@@ -257,11 +265,13 @@
BluetoothHealthAppConfiguration config, int channelId) {
if (mService != null && isEnabled() && isValidDevice(device) &&
config != null) {
+ //TODO(BT
+ /*
try {
return mService.disconnectChannel(device, config, channelId);
} catch (RemoteException e) {
Log.e(TAG, e.toString());
- }
+ }*/
} else {
Log.w(TAG, "Proxy not attached to service");
if (DBG) Log.d(TAG, Log.getStackTraceString(new Throwable()));
@@ -286,11 +296,13 @@
BluetoothHealthAppConfiguration config) {
if (mService != null && isEnabled() && isValidDevice(device) &&
config != null) {
+ //TODO(BT
+ /*
try {
return mService.getMainChannelFd(device, config);
} catch (RemoteException e) {
Log.e(TAG, e.toString());
- }
+ }*/
} else {
Log.w(TAG, "Proxy not attached to service");
if (DBG) Log.d(TAG, Log.getStackTraceString(new Throwable()));
@@ -316,11 +328,13 @@
@Override
public int getConnectionState(BluetoothDevice device) {
if (mService != null && isEnabled() && isValidDevice(device)) {
+ //TODO(BT
+ /*
try {
return mService.getHealthDeviceConnectionState(device);
} catch (RemoteException e) {
Log.e(TAG, e.toString());
- }
+ }*/
} else {
Log.w(TAG, "Proxy not attached to service");
if (DBG) Log.d(TAG, Log.getStackTraceString(new Throwable()));
@@ -344,12 +358,14 @@
@Override
public List<BluetoothDevice> getConnectedDevices() {
if (mService != null && isEnabled()) {
+ //TODO(BT
+ /*
try {
return mService.getConnectedHealthDevices();
} catch (RemoteException e) {
Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
return new ArrayList<BluetoothDevice>();
- }
+ }*/
}
if (mService == null) Log.w(TAG, "Proxy not attached to service");
return new ArrayList<BluetoothDevice>();
@@ -376,12 +392,14 @@
@Override
public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
if (mService != null && isEnabled()) {
+ //TODO(BT
+ /*
try {
return mService.getHealthDevicesMatchingConnectionStates(states);
} catch (RemoteException e) {
Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
return new ArrayList<BluetoothDevice>();
- }
+ }*/
}
if (mService == null) Log.w(TAG, "Proxy not attached to service");
return new ArrayList<BluetoothDevice>();
diff --git a/core/java/android/bluetooth/BluetoothInputDevice.java b/core/java/android/bluetooth/BluetoothInputDevice.java
index 1a9e011..62c7bde 100644
--- a/core/java/android/bluetooth/BluetoothInputDevice.java
+++ b/core/java/android/bluetooth/BluetoothInputDevice.java
@@ -146,12 +146,14 @@
if (DBG) log("connect(" + device + ")");
if (mService != null && isEnabled() &&
isValidDevice(device)) {
+ //TODO(BT)
+ /*
try {
return mService.connectInputDevice(device);
} catch (RemoteException e) {
Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
return false;
- }
+ }*/
}
if (mService == null) Log.w(TAG, "Proxy not attached to service");
return false;
@@ -187,12 +189,14 @@
if (DBG) log("disconnect(" + device + ")");
if (mService != null && isEnabled() &&
isValidDevice(device)) {
+ //TODO(BT)
+ /*
try {
return mService.disconnectInputDevice(device);
} catch (RemoteException e) {
Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
return false;
- }
+ }*/
}
if (mService == null) Log.w(TAG, "Proxy not attached to service");
return false;
@@ -204,12 +208,14 @@
public List<BluetoothDevice> getConnectedDevices() {
if (DBG) log("getConnectedDevices()");
if (mService != null && isEnabled()) {
+ //TODO(BT)
+ /*
try {
return mService.getConnectedInputDevices();
} catch (RemoteException e) {
Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
return new ArrayList<BluetoothDevice>();
- }
+ }*/
}
if (mService == null) Log.w(TAG, "Proxy not attached to service");
return new ArrayList<BluetoothDevice>();
@@ -221,12 +227,14 @@
public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
if (DBG) log("getDevicesMatchingStates()");
if (mService != null && isEnabled()) {
+ //TODO(BT)
+ /*
try {
return mService.getInputDevicesMatchingConnectionStates(states);
} catch (RemoteException e) {
Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
return new ArrayList<BluetoothDevice>();
- }
+ }*/
}
if (mService == null) Log.w(TAG, "Proxy not attached to service");
return new ArrayList<BluetoothDevice>();
@@ -239,12 +247,14 @@
if (DBG) log("getState(" + device + ")");
if (mService != null && isEnabled()
&& isValidDevice(device)) {
+ //TODO(BT)
+ /*
try {
return mService.getInputDeviceConnectionState(device);
} catch (RemoteException e) {
Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
return BluetoothProfile.STATE_DISCONNECTED;
- }
+ }*/
}
if (mService == null) Log.w(TAG, "Proxy not attached to service");
return BluetoothProfile.STATE_DISCONNECTED;
@@ -273,12 +283,14 @@
priority != BluetoothProfile.PRIORITY_ON) {
return false;
}
+ //TODO(BT)
+ /*
try {
return mService.setInputDevicePriority(device, priority);
} catch (RemoteException e) {
Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
return false;
- }
+ }*/
}
if (mService == null) Log.w(TAG, "Proxy not attached to service");
return false;
@@ -301,12 +313,14 @@
if (DBG) log("getPriority(" + device + ")");
if (mService != null && isEnabled()
&& isValidDevice(device)) {
+ //TODO(BT)
+ /*
try {
return mService.getInputDevicePriority(device);
} catch (RemoteException e) {
Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
return BluetoothProfile.PRIORITY_OFF;
- }
+ }*/
}
if (mService == null) Log.w(TAG, "Proxy not attached to service");
return BluetoothProfile.PRIORITY_OFF;
diff --git a/core/java/android/bluetooth/BluetoothPan.java b/core/java/android/bluetooth/BluetoothPan.java
index 5d9d8be..13526e8 100644
--- a/core/java/android/bluetooth/BluetoothPan.java
+++ b/core/java/android/bluetooth/BluetoothPan.java
@@ -165,12 +165,14 @@
if (DBG) log("connect(" + device + ")");
if (mService != null && isEnabled() &&
isValidDevice(device)) {
+ //TODO(BT
+ /*
try {
return mService.connectPanDevice(device);
} catch (RemoteException e) {
Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
return false;
- }
+ }*/
}
if (mService == null) Log.w(TAG, "Proxy not attached to service");
return false;
@@ -206,12 +208,14 @@
if (DBG) log("disconnect(" + device + ")");
if (mService != null && isEnabled() &&
isValidDevice(device)) {
+ //TODO(BT
+ /*
try {
return mService.disconnectPanDevice(device);
} catch (RemoteException e) {
Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
return false;
- }
+ }*/
}
if (mService == null) Log.w(TAG, "Proxy not attached to service");
return false;
@@ -223,12 +227,14 @@
public List<BluetoothDevice> getConnectedDevices() {
if (DBG) log("getConnectedDevices()");
if (mService != null && isEnabled()) {
+ //TODO(BT
+ /*
try {
return mService.getConnectedPanDevices();
} catch (RemoteException e) {
Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
return new ArrayList<BluetoothDevice>();
- }
+ }*/
}
if (mService == null) Log.w(TAG, "Proxy not attached to service");
return new ArrayList<BluetoothDevice>();
@@ -240,12 +246,14 @@
public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
if (DBG) log("getDevicesMatchingStates()");
if (mService != null && isEnabled()) {
+ //TODO(BT
+ /*
try {
return mService.getPanDevicesMatchingConnectionStates(states);
} catch (RemoteException e) {
Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
return new ArrayList<BluetoothDevice>();
- }
+ }*/
}
if (mService == null) Log.w(TAG, "Proxy not attached to service");
return new ArrayList<BluetoothDevice>();
@@ -258,12 +266,14 @@
if (DBG) log("getState(" + device + ")");
if (mService != null && isEnabled()
&& isValidDevice(device)) {
+ //TODO(BT
+ /*
try {
return mService.getPanDeviceConnectionState(device);
} catch (RemoteException e) {
Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
return BluetoothProfile.STATE_DISCONNECTED;
- }
+ }*/
}
if (mService == null) Log.w(TAG, "Proxy not attached to service");
return BluetoothProfile.STATE_DISCONNECTED;
@@ -271,21 +281,26 @@
public void setBluetoothTethering(boolean value) {
if (DBG) log("setBluetoothTethering(" + value + ")");
+ //TODO(BT
+ /*
try {
mService.setBluetoothTethering(value);
} catch (RemoteException e) {
Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
- }
+ }*/
}
public boolean isTetheringOn() {
if (DBG) log("isTetheringOn()");
+ //TODO(BT
+ /*
try {
return mService.isTetheringOn();
} catch (RemoteException e) {
Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
return false;
- }
+ }*/
+ return false;
}
private boolean isEnabled() {
diff --git a/core/java/android/bluetooth/BluetoothSocket.java b/core/java/android/bluetooth/BluetoothSocket.java
index 20e8515..2662f39 100644
--- a/core/java/android/bluetooth/BluetoothSocket.java
+++ b/core/java/android/bluetooth/BluetoothSocket.java
@@ -150,11 +150,14 @@
} else {
mAddress = device.getAddress();
}
+
+ //TODO(BT)
+ /*
if (fd == -1) {
initSocketNative();
} else {
initSocketFromFdNative(fd);
- }
+ }*/
mInputStream = new BluetoothInputStream(this);
mOutputStream = new BluetoothOutputStream(this);
mSocketState = SocketState.INIT;
@@ -227,6 +230,8 @@
*/
public void close() throws IOException {
// abort blocking operations on the socket
+ //TODO(BT)
+ /*
mLock.readLock().lock();
try {
if (mSocketState == SocketState.CLOSED) return;
@@ -248,7 +253,7 @@
}
} finally {
mLock.writeLock().unlock();
- }
+ }*/
}
/**
@@ -296,13 +301,16 @@
* so that BluetoothAdapter can check the error code for EADDRINUSE
*/
/*package*/ int bindListen() {
+ return -1;
+ //TODO(BT)
+ /*
mLock.readLock().lock();
try {
if (mSocketState == SocketState.CLOSED) return EBADFD;
return bindListenNative();
} finally {
mLock.readLock().unlock();
- }
+ }*/
}
/*package*/ BluetoothSocket accept(int timeout) throws IOException {
@@ -388,9 +396,11 @@
channel = -1;
boolean inProgress = false;
+ //TODO(BT)
+ /*
try {
inProgress = service.fetchRemoteUuids(device.getAddress(), uuid, this);
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ } catch (RemoteException e) {Log.e(TAG, "", e);}*/
if (!inProgress) throw new IOException("Unable to start Service Discovery");
diff --git a/core/java/android/bluetooth/IBluetooth.aidl b/core/java/android/bluetooth/IBluetooth.aidl
index 6075363..21f2ae3 100644
--- a/core/java/android/bluetooth/IBluetooth.aidl
+++ b/core/java/android/bluetooth/IBluetooth.aidl
@@ -32,15 +32,14 @@
interface IBluetooth
{
boolean isEnabled();
- int getBluetoothState();
+ int getState();
boolean enable();
- boolean enableNoAutoConnect();
- boolean disable(boolean persistSetting);
+ boolean disable();
String getAddress();
- String getName();
- boolean setName(in String name);
ParcelUuid[] getUuids();
+ boolean setName(in String name);
+ String getName();
int getScanMode();
boolean setScanMode(int mode, int duration);
@@ -51,77 +50,29 @@
boolean startDiscovery();
boolean cancelDiscovery();
boolean isDiscovering();
- byte[] readOutOfBandData();
int getAdapterConnectionState();
int getProfileConnectionState(int profile);
- boolean changeApplicationBluetoothState(boolean on,
- in IBluetoothStateChangeCallback callback, in
- IBinder b);
- boolean createBond(in String address);
- boolean createBondOutOfBand(in String address, in byte[] hash, in byte[] randomizer);
- boolean cancelBondProcess(in String address);
- boolean removeBond(in String address);
- String[] listBonds();
- int getBondState(in String address);
- boolean setDeviceOutOfBandData(in String address, in byte[] hash, in byte[] randomizer);
+ BluetoothDevice[] getBondedDevices();
+ boolean createBond(in BluetoothDevice device);
+ boolean cancelBondProcess(in BluetoothDevice device);
+ boolean removeBond(in BluetoothDevice device);
+ int getBondState(in BluetoothDevice device);
- String getRemoteName(in String address);
- String getRemoteAlias(in String address);
- boolean setRemoteAlias(in String address, in String name);
- int getRemoteClass(in String address);
- ParcelUuid[] getRemoteUuids(in String address);
- boolean fetchRemoteUuids(in String address, in ParcelUuid uuid, in IBluetoothCallback callback);
- int getRemoteServiceChannel(in String address, in ParcelUuid uuid);
+ String getRemoteName(in BluetoothDevice device);
+ String getRemoteAlias(in BluetoothDevice device);
+ boolean setRemoteAlias(in BluetoothDevice device, in String name);
+ int getRemoteClass(in BluetoothDevice device);
+ ParcelUuid[] getRemoteUuids(in BluetoothDevice device);
+ //TODO(BT)
+ //boolean fetchRemoteUuids(in BluetoothDevice device, in ParcelUuid uuid,
+ // in IBluetoothCallback callback);
- boolean setPin(in String address, in byte[] pin);
- boolean setPasskey(in String address, int passkey);
- boolean setPairingConfirmation(in String address, boolean confirm);
- boolean setRemoteOutOfBandData(in String addres);
- boolean cancelPairingUserInput(in String address);
-
- boolean setTrust(in String address, in boolean value);
- boolean getTrustState(in String address);
- boolean isBluetoothDock(in String address);
-
- int addRfcommServiceRecord(in String serviceName, in ParcelUuid uuid, int channel, IBinder b);
- void removeServiceRecord(int handle);
- boolean allowIncomingProfileConnect(in BluetoothDevice device, boolean value);
-
- boolean connectHeadset(String address);
- boolean disconnectHeadset(String address);
- boolean notifyIncomingConnection(String address, boolean rejected);
-
- // HID profile APIs
- boolean connectInputDevice(in BluetoothDevice device);
- boolean disconnectInputDevice(in BluetoothDevice device);
- List<BluetoothDevice> getConnectedInputDevices();
- List<BluetoothDevice> getInputDevicesMatchingConnectionStates(in int[] states);
- int getInputDeviceConnectionState(in BluetoothDevice device);
- boolean setInputDevicePriority(in BluetoothDevice device, int priority);
- int getInputDevicePriority(in BluetoothDevice device);
-
- boolean isTetheringOn();
- void setBluetoothTethering(boolean value);
- int getPanDeviceConnectionState(in BluetoothDevice device);
- List<BluetoothDevice> getConnectedPanDevices();
- List<BluetoothDevice> getPanDevicesMatchingConnectionStates(in int[] states);
- boolean connectPanDevice(in BluetoothDevice device);
- boolean disconnectPanDevice(in BluetoothDevice device);
-
- // HDP profile APIs
- boolean registerAppConfiguration(in BluetoothHealthAppConfiguration config,
- in IBluetoothHealthCallback callback);
- boolean unregisterAppConfiguration(in BluetoothHealthAppConfiguration config);
- boolean connectChannelToSource(in BluetoothDevice device, in BluetoothHealthAppConfiguration config);
- boolean connectChannelToSink(in BluetoothDevice device, in BluetoothHealthAppConfiguration config,
- int channelType);
- boolean disconnectChannel(in BluetoothDevice device, in BluetoothHealthAppConfiguration config, int id);
- ParcelFileDescriptor getMainChannelFd(in BluetoothDevice device, in BluetoothHealthAppConfiguration config);
- List<BluetoothDevice> getConnectedHealthDevices();
- List<BluetoothDevice> getHealthDevicesMatchingConnectionStates(in int[] states);
- int getHealthDeviceConnectionState(in BluetoothDevice device);
+ boolean setPin(in BluetoothDevice device, boolean accept, int len, in byte[] pinCode);
+ boolean setPasskey(in BluetoothDevice device, boolean accept, int len, in byte[]
+ passkey);
+ boolean setPairingConfirmation(in BluetoothDevice device, boolean accept);
void sendConnectionStateChange(in BluetoothDevice device, int profile, int state, int prevState);
}