am 41140098: Merge change 24274 into eclair
Merge commit '411400980720895c4195c71e181831bc771a5a7b' into eclair-plus-aosp * commit '411400980720895c4195c71e181831bc771a5a7b': API_CHANGE
This commit is contained in:
@@ -25610,6 +25610,17 @@
|
|||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
</field>
|
</field>
|
||||||
|
<field name="ERROR"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="-1"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
<field name="EXTRA_PREVIOUS_SCAN_MODE"
|
<field name="EXTRA_PREVIOUS_SCAN_MODE"
|
||||||
type="java.lang.String"
|
type="java.lang.String"
|
||||||
transient="false"
|
transient="false"
|
||||||
@@ -25805,6 +25816,17 @@
|
|||||||
<parameter name="flags" type="int">
|
<parameter name="flags" type="int">
|
||||||
</parameter>
|
</parameter>
|
||||||
</method>
|
</method>
|
||||||
|
<field name="ERROR"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="-1"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
</class>
|
</class>
|
||||||
<class name="BluetoothServerSocket"
|
<class name="BluetoothServerSocket"
|
||||||
extends="java.lang.Object"
|
extends="java.lang.Object"
|
||||||
|
|||||||
@@ -42,9 +42,6 @@ import java.util.HashSet;
|
|||||||
*
|
*
|
||||||
* Currently the BluetoothA2dp service runs in the system server and this
|
* Currently the BluetoothA2dp service runs in the system server and this
|
||||||
* proxy object will be immediately bound to the service on construction.
|
* proxy object will be immediately bound to the service on construction.
|
||||||
* However this may change in future releases, and error codes such as
|
|
||||||
* BluetoothError.ERROR_IPC_NOT_READY will be returned from this API when the
|
|
||||||
* proxy object is not yet attached.
|
|
||||||
*
|
*
|
||||||
* Currently this class provides methods to connect to A2DP audio sinks.
|
* Currently this class provides methods to connect to A2DP audio sinks.
|
||||||
*
|
*
|
||||||
@@ -105,16 +102,16 @@ public final class BluetoothA2dp {
|
|||||||
* Listen for SINK_STATE_CHANGED_ACTION to find out when the
|
* Listen for SINK_STATE_CHANGED_ACTION to find out when the
|
||||||
* connection is completed.
|
* connection is completed.
|
||||||
* @param device Remote BT device.
|
* @param device Remote BT device.
|
||||||
* @return Result code, negative indicates an immediate error.
|
* @return false on immediate error, true otherwise
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public int connectSink(BluetoothDevice device) {
|
public boolean connectSink(BluetoothDevice device) {
|
||||||
if (DBG) log("connectSink(" + device + ")");
|
if (DBG) log("connectSink(" + device + ")");
|
||||||
try {
|
try {
|
||||||
return mService.connectSink(device);
|
return mService.connectSink(device);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.w(TAG, "", e);
|
Log.e(TAG, "", e);
|
||||||
return BluetoothError.ERROR_IPC;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,16 +119,16 @@ public final class BluetoothA2dp {
|
|||||||
* Listen for SINK_STATE_CHANGED_ACTION to find out when
|
* Listen for SINK_STATE_CHANGED_ACTION to find out when
|
||||||
* disconnect is completed.
|
* disconnect is completed.
|
||||||
* @param device Remote BT device.
|
* @param device Remote BT device.
|
||||||
* @return Result code, negative indicates an immediate error.
|
* @return false on immediate error, true otherwise
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public int disconnectSink(BluetoothDevice device) {
|
public boolean disconnectSink(BluetoothDevice device) {
|
||||||
if (DBG) log("disconnectSink(" + device + ")");
|
if (DBG) log("disconnectSink(" + device + ")");
|
||||||
try {
|
try {
|
||||||
return mService.disconnectSink(device);
|
return mService.disconnectSink(device);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.w(TAG, "", e);
|
Log.e(TAG, "", e);
|
||||||
return BluetoothError.ERROR_IPC;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,14 +153,14 @@ public final class BluetoothA2dp {
|
|||||||
return Collections.unmodifiableSet(
|
return Collections.unmodifiableSet(
|
||||||
new HashSet<BluetoothDevice>(Arrays.asList(mService.getConnectedSinks())));
|
new HashSet<BluetoothDevice>(Arrays.asList(mService.getConnectedSinks())));
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.w(TAG, "", e);
|
Log.e(TAG, "", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the state of an A2DP sink
|
/** Get the state of an A2DP sink
|
||||||
* @param device Remote BT device.
|
* @param device Remote BT device.
|
||||||
* @return State code, or negative on error
|
* @return State code, one of STATE_
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public int getSinkState(BluetoothDevice device) {
|
public int getSinkState(BluetoothDevice device) {
|
||||||
@@ -171,8 +168,8 @@ public final class BluetoothA2dp {
|
|||||||
try {
|
try {
|
||||||
return mService.getSinkState(device);
|
return mService.getSinkState(device);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.w(TAG, "", e);
|
Log.e(TAG, "", e);
|
||||||
return BluetoothError.ERROR_IPC;
|
return BluetoothA2dp.STATE_DISCONNECTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,15 +183,15 @@ public final class BluetoothA2dp {
|
|||||||
* @param device Paired sink
|
* @param device Paired sink
|
||||||
* @param priority Integer priority, for example PRIORITY_AUTO or
|
* @param priority Integer priority, for example PRIORITY_AUTO or
|
||||||
* PRIORITY_NONE
|
* PRIORITY_NONE
|
||||||
* @return Result code, negative indicates an error
|
* @return true if priority is set, false on error
|
||||||
*/
|
*/
|
||||||
public int setSinkPriority(BluetoothDevice device, int priority) {
|
public boolean setSinkPriority(BluetoothDevice device, int priority) {
|
||||||
if (DBG) log("setSinkPriority(" + device + ", " + priority + ")");
|
if (DBG) log("setSinkPriority(" + device + ", " + priority + ")");
|
||||||
try {
|
try {
|
||||||
return mService.setSinkPriority(device, priority);
|
return mService.setSinkPriority(device, priority);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.w(TAG, "", e);
|
Log.e(TAG, "", e);
|
||||||
return BluetoothError.ERROR_IPC;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,8 +205,8 @@ public final class BluetoothA2dp {
|
|||||||
try {
|
try {
|
||||||
return mService.getSinkPriority(device);
|
return mService.getSinkPriority(device);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.w(TAG, "", e);
|
Log.e(TAG, "", e);
|
||||||
return BluetoothError.ERROR_IPC;
|
return PRIORITY_OFF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,15 @@ import java.util.HashSet;
|
|||||||
public final class BluetoothAdapter {
|
public final class BluetoothAdapter {
|
||||||
private static final String TAG = "BluetoothAdapter";
|
private static final String TAG = "BluetoothAdapter";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sentinel error value for this class. Guaranteed to not equal any other
|
||||||
|
* integer constant in this class. Provided as a convenience for functions
|
||||||
|
* that require a sentinel error value, for example:
|
||||||
|
* <p><code>Intent.getIntExtra(BluetoothAdapter.EXTRA_STATE,
|
||||||
|
* BluetoothAdapter.ERROR)</code>
|
||||||
|
*/
|
||||||
|
public static final int ERROR = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Broadcast Action: The state of the local Bluetooth adapter has been
|
* Broadcast Action: The state of the local Bluetooth adapter has been
|
||||||
* changed.
|
* changed.
|
||||||
|
|||||||
@@ -44,6 +44,15 @@ import java.io.UnsupportedEncodingException;
|
|||||||
public final class BluetoothDevice implements Parcelable {
|
public final class BluetoothDevice implements Parcelable {
|
||||||
private static final String TAG = "BluetoothDevice";
|
private static final String TAG = "BluetoothDevice";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sentinel error value for this class. Guaranteed to not equal any other
|
||||||
|
* integer constant in this class. Provided as a convenience for functions
|
||||||
|
* that require a sentinel error value, for example:
|
||||||
|
* <p><code>Intent.getIntExtra(BluetoothAdapter.EXTRA_STATE,
|
||||||
|
* BluetoothAdapter.ERROR)</code>
|
||||||
|
*/
|
||||||
|
public static final int ERROR = -1;
|
||||||
|
|
||||||
/** We do not have a link key for the remote device, and are therefore not
|
/** We do not have a link key for the remote device, and are therefore not
|
||||||
* bonded
|
* bonded
|
||||||
* @hide*/
|
* @hide*/
|
||||||
@@ -65,7 +74,9 @@ public final class BluetoothDevice implements Parcelable {
|
|||||||
* @hide */
|
* @hide */
|
||||||
public static final int DEVICE_PICKER_FILTER_TYPE_TRANSFER = 2;
|
public static final int DEVICE_PICKER_FILTER_TYPE_TRANSFER = 2;
|
||||||
|
|
||||||
//TODO: Unify these result codes in BluetoothResult or BluetoothError
|
/** A bond attempt succeeded
|
||||||
|
* @hide */
|
||||||
|
public static final int BOND_SUCCESS = 0;
|
||||||
/** A bond attempt failed because pins did not match, or remote device did
|
/** A bond attempt failed because pins did not match, or remote device did
|
||||||
* not respond to pin request in time
|
* not respond to pin request in time
|
||||||
* @hide */
|
* @hide */
|
||||||
@@ -252,8 +263,8 @@ public final class BluetoothDevice implements Parcelable {
|
|||||||
* Get the bonding state of a remote device.
|
* Get the bonding state of a remote device.
|
||||||
*
|
*
|
||||||
* Result is one of:
|
* Result is one of:
|
||||||
* BluetoothError.*
|
|
||||||
* BOND_*
|
* BOND_*
|
||||||
|
* ERROR
|
||||||
*
|
*
|
||||||
* @param address Bluetooth hardware address of the remote device to check.
|
* @param address Bluetooth hardware address of the remote device to check.
|
||||||
* @return Result code
|
* @return Result code
|
||||||
@@ -263,7 +274,7 @@ public final class BluetoothDevice implements Parcelable {
|
|||||||
try {
|
try {
|
||||||
return sService.getBondState(mAddress);
|
return sService.getBondState(mAddress);
|
||||||
} catch (RemoteException e) {Log.e(TAG, "", e);}
|
} catch (RemoteException e) {Log.e(TAG, "", e);}
|
||||||
return BluetoothError.ERROR_IPC;
|
return BluetoothDevice.ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -298,7 +309,7 @@ public final class BluetoothDevice implements Parcelable {
|
|||||||
try {
|
try {
|
||||||
return sService.getRemoteClass(mAddress);
|
return sService.getRemoteClass(mAddress);
|
||||||
} catch (RemoteException e) {Log.e(TAG, "", e);}
|
} catch (RemoteException e) {Log.e(TAG, "", e);}
|
||||||
return BluetoothError.ERROR_IPC;
|
return BluetoothDevice.ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@@ -314,7 +325,7 @@ public final class BluetoothDevice implements Parcelable {
|
|||||||
try {
|
try {
|
||||||
return sService.getRemoteServiceChannel(mAddress, uuid);
|
return sService.getRemoteServiceChannel(mAddress, uuid);
|
||||||
} catch (RemoteException e) {Log.e(TAG, "", e);}
|
} catch (RemoteException e) {Log.e(TAG, "", e);}
|
||||||
return BluetoothError.ERROR_IPC;
|
return BluetoothDevice.ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2008 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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Bluetooth API error codes.
|
|
||||||
*
|
|
||||||
* Errors are always negative.
|
|
||||||
*
|
|
||||||
* TODO: Deprecate this class.
|
|
||||||
*
|
|
||||||
* @hide
|
|
||||||
*/
|
|
||||||
public class BluetoothError {
|
|
||||||
/** No error */
|
|
||||||
public static final int SUCCESS = 0;
|
|
||||||
|
|
||||||
/** Generic error */
|
|
||||||
public static final int ERROR = -1000;
|
|
||||||
|
|
||||||
/** Bluetooth currently disabled */
|
|
||||||
public static final int ERROR_DISABLED = -1001;
|
|
||||||
|
|
||||||
/** IPC is not ready, for example service is not yet bound */
|
|
||||||
public static final int ERROR_IPC_NOT_READY = -1011;
|
|
||||||
|
|
||||||
/** Some other IPC error, for example a RemoteException */
|
|
||||||
public static final int ERROR_IPC = -1012;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -24,10 +24,10 @@ import android.bluetooth.BluetoothDevice;
|
|||||||
* {@hide}
|
* {@hide}
|
||||||
*/
|
*/
|
||||||
interface IBluetoothA2dp {
|
interface IBluetoothA2dp {
|
||||||
int connectSink(in BluetoothDevice device);
|
boolean connectSink(in BluetoothDevice device);
|
||||||
int disconnectSink(in BluetoothDevice device);
|
boolean disconnectSink(in BluetoothDevice device);
|
||||||
BluetoothDevice[] getConnectedSinks(); // change to Set<> once AIDL supports
|
BluetoothDevice[] getConnectedSinks(); // change to Set<> once AIDL supports
|
||||||
int getSinkState(in BluetoothDevice device);
|
int getSinkState(in BluetoothDevice device);
|
||||||
int setSinkPriority(in BluetoothDevice device, int priority);
|
boolean setSinkPriority(in BluetoothDevice device, int priority);
|
||||||
int getSinkPriority(in BluetoothDevice device);
|
int getSinkPriority(in BluetoothDevice device);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ package android.server;
|
|||||||
import android.bluetooth.BluetoothA2dp;
|
import android.bluetooth.BluetoothA2dp;
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
import android.bluetooth.BluetoothError;
|
|
||||||
import android.bluetooth.BluetoothIntent;
|
import android.bluetooth.BluetoothIntent;
|
||||||
import android.bluetooth.BluetoothUuid;
|
import android.bluetooth.BluetoothUuid;
|
||||||
import android.bluetooth.IBluetoothA2dp;
|
import android.bluetooth.IBluetoothA2dp;
|
||||||
@@ -83,7 +82,7 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub {
|
|||||||
intent.getParcelableExtra(BluetoothIntent.DEVICE);
|
intent.getParcelableExtra(BluetoothIntent.DEVICE);
|
||||||
if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
|
if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
|
||||||
int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE,
|
int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE,
|
||||||
BluetoothError.ERROR);
|
BluetoothAdapter.ERROR);
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case BluetoothAdapter.STATE_ON:
|
case BluetoothAdapter.STATE_ON:
|
||||||
onBluetoothEnable();
|
onBluetoothEnable();
|
||||||
@@ -94,7 +93,7 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub {
|
|||||||
}
|
}
|
||||||
} else if (action.equals(BluetoothIntent.BOND_STATE_CHANGED_ACTION)) {
|
} else if (action.equals(BluetoothIntent.BOND_STATE_CHANGED_ACTION)) {
|
||||||
int bondState = intent.getIntExtra(BluetoothIntent.BOND_STATE,
|
int bondState = intent.getIntExtra(BluetoothIntent.BOND_STATE,
|
||||||
BluetoothError.ERROR);
|
BluetoothDevice.ERROR);
|
||||||
switch(bondState) {
|
switch(bondState) {
|
||||||
case BluetoothDevice.BOND_BONDED:
|
case BluetoothDevice.BOND_BONDED:
|
||||||
setSinkPriority(device, BluetoothA2dp.PRIORITY_AUTO);
|
setSinkPriority(device, BluetoothA2dp.PRIORITY_AUTO);
|
||||||
@@ -273,7 +272,7 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub {
|
|||||||
mAudioManager.setParameters(BLUETOOTH_ENABLED + "=false");
|
mAudioManager.setParameters(BLUETOOTH_ENABLED + "=false");
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized int connectSink(BluetoothDevice device) {
|
public synchronized boolean connectSink(BluetoothDevice device) {
|
||||||
mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
|
mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
|
||||||
"Need BLUETOOTH_ADMIN permission");
|
"Need BLUETOOTH_ADMIN permission");
|
||||||
if (DBG) log("connectSink(" + device + ")");
|
if (DBG) log("connectSink(" + device + ")");
|
||||||
@@ -284,11 +283,11 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub {
|
|||||||
BluetoothA2dp.STATE_CONNECTED,
|
BluetoothA2dp.STATE_CONNECTED,
|
||||||
BluetoothA2dp.STATE_PLAYING,
|
BluetoothA2dp.STATE_PLAYING,
|
||||||
BluetoothA2dp.STATE_DISCONNECTING}).size() != 0) {
|
BluetoothA2dp.STATE_DISCONNECTING}).size() != 0) {
|
||||||
return BluetoothError.ERROR;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mAudioDevices.get(device) == null && !addAudioSink(device))
|
if (mAudioDevices.get(device) == null && !addAudioSink(device))
|
||||||
return BluetoothError.ERROR;
|
return false;
|
||||||
|
|
||||||
int state = mAudioDevices.get(device);
|
int state = mAudioDevices.get(device);
|
||||||
|
|
||||||
@@ -296,44 +295,44 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub {
|
|||||||
case BluetoothA2dp.STATE_CONNECTED:
|
case BluetoothA2dp.STATE_CONNECTED:
|
||||||
case BluetoothA2dp.STATE_PLAYING:
|
case BluetoothA2dp.STATE_PLAYING:
|
||||||
case BluetoothA2dp.STATE_DISCONNECTING:
|
case BluetoothA2dp.STATE_DISCONNECTING:
|
||||||
return BluetoothError.ERROR;
|
return false;
|
||||||
case BluetoothA2dp.STATE_CONNECTING:
|
case BluetoothA2dp.STATE_CONNECTING:
|
||||||
return BluetoothError.SUCCESS;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String path = mBluetoothService.getObjectPathFromAddress(device.getAddress());
|
String path = mBluetoothService.getObjectPathFromAddress(device.getAddress());
|
||||||
if (path == null)
|
if (path == null)
|
||||||
return BluetoothError.ERROR;
|
return false;
|
||||||
|
|
||||||
// State is DISCONNECTED
|
// State is DISCONNECTED
|
||||||
if (!connectSinkNative(path)) {
|
if (!connectSinkNative(path)) {
|
||||||
return BluetoothError.ERROR;
|
return false;
|
||||||
}
|
}
|
||||||
return BluetoothError.SUCCESS;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized int disconnectSink(BluetoothDevice device) {
|
public synchronized boolean disconnectSink(BluetoothDevice device) {
|
||||||
mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
|
mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
|
||||||
"Need BLUETOOTH_ADMIN permission");
|
"Need BLUETOOTH_ADMIN permission");
|
||||||
if (DBG) log("disconnectSink(" + device + ")");
|
if (DBG) log("disconnectSink(" + device + ")");
|
||||||
|
|
||||||
String path = mBluetoothService.getObjectPathFromAddress(device.getAddress());
|
String path = mBluetoothService.getObjectPathFromAddress(device.getAddress());
|
||||||
if (path == null) {
|
if (path == null) {
|
||||||
return BluetoothError.ERROR;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (getSinkState(device)) {
|
switch (getSinkState(device)) {
|
||||||
case BluetoothA2dp.STATE_DISCONNECTED:
|
case BluetoothA2dp.STATE_DISCONNECTED:
|
||||||
return BluetoothError.ERROR;
|
return false;
|
||||||
case BluetoothA2dp.STATE_DISCONNECTING:
|
case BluetoothA2dp.STATE_DISCONNECTING:
|
||||||
return BluetoothError.SUCCESS;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// State is CONNECTING or CONNECTED or PLAYING
|
// State is CONNECTING or CONNECTED or PLAYING
|
||||||
if (!disconnectSinkNative(path)) {
|
if (!disconnectSinkNative(path)) {
|
||||||
return BluetoothError.ERROR;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return BluetoothError.SUCCESS;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,15 +358,14 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub {
|
|||||||
BluetoothA2dp.PRIORITY_OFF);
|
BluetoothA2dp.PRIORITY_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized int setSinkPriority(BluetoothDevice device, int priority) {
|
public synchronized boolean setSinkPriority(BluetoothDevice device, int priority) {
|
||||||
mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
|
mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
|
||||||
"Need BLUETOOTH_ADMIN permission");
|
"Need BLUETOOTH_ADMIN permission");
|
||||||
if (!BluetoothDevice.checkBluetoothAddress(device.getAddress())) {
|
if (!BluetoothDevice.checkBluetoothAddress(device.getAddress())) {
|
||||||
return BluetoothError.ERROR;
|
return false;
|
||||||
}
|
}
|
||||||
return Settings.Secure.putInt(mContext.getContentResolver(),
|
return Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
Settings.Secure.getBluetoothA2dpSinkPriorityKey(device.getAddress()), priority) ?
|
Settings.Secure.getBluetoothA2dpSinkPriorityKey(device.getAddress()), priority);
|
||||||
BluetoothError.SUCCESS : BluetoothError.ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void onSinkPropertyChanged(String path, String []propValues) {
|
private synchronized void onSinkPropertyChanged(String path, String []propValues) {
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import android.bluetooth.BluetoothA2dp;
|
|||||||
import android.bluetooth.BluetoothClass;
|
import android.bluetooth.BluetoothClass;
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
import android.bluetooth.BluetoothError;
|
|
||||||
import android.bluetooth.BluetoothIntent;
|
import android.bluetooth.BluetoothIntent;
|
||||||
import android.bluetooth.BluetoothUuid;
|
import android.bluetooth.BluetoothUuid;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -169,7 +168,7 @@ class BluetoothEventLoop {
|
|||||||
|
|
||||||
private void onCreatePairedDeviceResult(String address, int result) {
|
private void onCreatePairedDeviceResult(String address, int result) {
|
||||||
address = address.toUpperCase();
|
address = address.toUpperCase();
|
||||||
if (result == BluetoothError.SUCCESS) {
|
if (result == BluetoothDevice.BOND_SUCCESS) {
|
||||||
mBluetoothService.getBondState().setBondState(address, BluetoothDevice.BOND_BONDED);
|
mBluetoothService.getBondState().setBondState(address, BluetoothDevice.BOND_BONDED);
|
||||||
if (mBluetoothService.getBondState().isAutoPairingAttemptsInProgress(address)) {
|
if (mBluetoothService.getBondState().isAutoPairingAttemptsInProgress(address)) {
|
||||||
mBluetoothService.getBondState().clearPinAttempts(address);
|
mBluetoothService.getBondState().clearPinAttempts(address);
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ package android.server;
|
|||||||
import android.bluetooth.BluetoothClass;
|
import android.bluetooth.BluetoothClass;
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
import android.bluetooth.BluetoothError;
|
|
||||||
import android.bluetooth.BluetoothHeadset;
|
import android.bluetooth.BluetoothHeadset;
|
||||||
import android.bluetooth.BluetoothIntent;
|
import android.bluetooth.BluetoothIntent;
|
||||||
import android.bluetooth.IBluetooth;
|
import android.bluetooth.IBluetooth;
|
||||||
@@ -810,7 +809,7 @@ public class BluetoothService extends IBluetooth.Stub {
|
|||||||
public synchronized int getBondState(String address) {
|
public synchronized int getBondState(String address) {
|
||||||
mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
|
mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
|
||||||
if (!BluetoothDevice.checkBluetoothAddress(address)) {
|
if (!BluetoothDevice.checkBluetoothAddress(address)) {
|
||||||
return BluetoothError.ERROR;
|
return BluetoothDevice.ERROR;
|
||||||
}
|
}
|
||||||
return mBondState.getBondState(address.toUpperCase());
|
return mBondState.getBondState(address.toUpperCase());
|
||||||
}
|
}
|
||||||
@@ -984,7 +983,7 @@ public class BluetoothService extends IBluetooth.Stub {
|
|||||||
public int getRemoteServiceChannel(String address, String uuid) {
|
public int getRemoteServiceChannel(String address, String uuid) {
|
||||||
mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
|
mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
|
||||||
if (!BluetoothDevice.checkBluetoothAddress(address)) {
|
if (!BluetoothDevice.checkBluetoothAddress(address)) {
|
||||||
return BluetoothError.ERROR_IPC;
|
return BluetoothDevice.ERROR;
|
||||||
}
|
}
|
||||||
return getDeviceServiceChannelNative(getObjectPathFromAddress(address), uuid, 0x0004);
|
return getDeviceServiceChannelNative(getObjectPathFromAddress(address), uuid, 0x0004);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package com.android.server.status;
|
|||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.bluetooth.BluetoothA2dp;
|
import android.bluetooth.BluetoothA2dp;
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothError;
|
|
||||||
import android.bluetooth.BluetoothHeadset;
|
import android.bluetooth.BluetoothHeadset;
|
||||||
import android.bluetooth.BluetoothIntent;
|
import android.bluetooth.BluetoothIntent;
|
||||||
import android.bluetooth.BluetoothPbap;
|
import android.bluetooth.BluetoothPbap;
|
||||||
@@ -1073,8 +1072,7 @@ public class StatusBarPolicy {
|
|||||||
|
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
|
if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
|
||||||
int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE,
|
int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR);
|
||||||
BluetoothError.ERROR);
|
|
||||||
mBluetoothEnabled = state == BluetoothAdapter.STATE_ON;
|
mBluetoothEnabled = state == BluetoothAdapter.STATE_ON;
|
||||||
} else if (action.equals(BluetoothIntent.HEADSET_STATE_CHANGED_ACTION)) {
|
} else if (action.equals(BluetoothIntent.HEADSET_STATE_CHANGED_ACTION)) {
|
||||||
mBluetoothHeadsetState = intent.getIntExtra(BluetoothIntent.HEADSET_STATE,
|
mBluetoothHeadsetState = intent.getIntExtra(BluetoothIntent.HEADSET_STATE,
|
||||||
|
|||||||
Reference in New Issue
Block a user