Loading api/current.xml +257 −0 Original line number Original line Diff line number Diff line Loading @@ -25457,6 +25457,50 @@ deprecated="not deprecated" deprecated="not deprecated" visibility="public" visibility="public" > > <method name="disable" return="boolean" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="enable" return="boolean" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="getAddress" return="java.lang.String" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="getName" return="java.lang.String" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="getRemoteDevice" <method name="getRemoteDevice" return="android.bluetooth.BluetoothDevice" return="android.bluetooth.BluetoothDevice" abstract="false" abstract="false" Loading @@ -25470,6 +25514,39 @@ <parameter name="address" type="java.lang.String"> <parameter name="address" type="java.lang.String"> </parameter> </parameter> </method> </method> <method name="getScanMode" return="int" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="getState" return="int" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="isEnabled" return="boolean" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="listenUsingRfcommOn" <method name="listenUsingRfcommOn" return="android.bluetooth.BluetoothServerSocket" return="android.bluetooth.BluetoothServerSocket" abstract="false" abstract="false" Loading @@ -25485,6 +25562,175 @@ <exception name="IOException" type="java.io.IOException"> <exception name="IOException" type="java.io.IOException"> </exception> </exception> </method> </method> <method name="setName" return="boolean" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="name" type="java.lang.String"> </parameter> </method> <method name="setScanMode" return="boolean" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="mode" type="int"> </parameter> </method> <field name="ACTION_SCAN_MODE_CHANGED" type="java.lang.String" transient="false" volatile="false" value=""android.bluetooth.intent.action.SCAN_MODE_CHANGED"" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="ACTION_STATE_CHANGED" type="java.lang.String" transient="false" volatile="false" value=""android.bluetooth.intent.action.STATE_CHANGED"" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="EXTRA_PREVIOUS_SCAN_MODE" type="java.lang.String" transient="false" volatile="false" value=""android.bluetooth.intent.extra.PREVIOUS_SCAN_MODE"" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="EXTRA_PREVIOUS_STATE" type="java.lang.String" transient="false" volatile="false" value=""android.bluetooth.intent.extra.PREVIOUS_STATE"" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="EXTRA_SCAN_MODE" type="java.lang.String" transient="false" volatile="false" value=""android.bluetooth.intent.extra.SCAN_MODE"" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="EXTRA_STATE" type="java.lang.String" transient="false" volatile="false" value=""android.bluetooth.intent.extra.STATE"" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="SCAN_MODE_CONNECTABLE" type="int" transient="false" volatile="false" value="51" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="SCAN_MODE_CONNECTABLE_DISCOVERABLE" type="int" transient="false" volatile="false" value="53" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="SCAN_MODE_NONE" type="int" transient="false" volatile="false" value="50" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="STATE_OFF" type="int" transient="false" volatile="false" value="40" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="STATE_ON" type="int" transient="false" volatile="false" value="42" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="STATE_TURNING_OFF" type="int" transient="false" volatile="false" value="43" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="STATE_TURNING_ON" type="int" transient="false" volatile="false" value="41" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> </class> </class> <class name="BluetoothDevice" <class name="BluetoothDevice" extends="java.lang.Object" extends="java.lang.Object" Loading Loading @@ -25533,6 +25779,17 @@ visibility="public" visibility="public" > > </method> </method> <method name="getName" return="java.lang.String" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="writeToParcel" <method name="writeToParcel" return="void" return="void" abstract="false" abstract="false" core/java/android/bluetooth/BluetoothAdapter.java +199 −71 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.bluetooth; package android.bluetooth; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.os.RemoteException; import android.os.RemoteException; import android.util.Log; import android.util.Log; Loading @@ -40,32 +42,109 @@ import java.util.HashSet; public final class BluetoothAdapter { public final class BluetoothAdapter { private static final String TAG = "BluetoothAdapter"; private static final String TAG = "BluetoothAdapter"; /** @hide */ /** public static final int BLUETOOTH_STATE_OFF = 0; * Broadcast Action: The state of the local Bluetooth adapter has been /** @hide */ * changed. public static final int BLUETOOTH_STATE_TURNING_ON = 1; * <p>For example, Bluetooth has been turned on or off. /** @hide */ * <p>Contains the extra fields {@link #EXTRA_STATE} and {@link public static final int BLUETOOTH_STATE_ON = 2; * #EXTRA_PREVIOUS_STATE} containing the new and old states /** @hide */ * respectively. public static final int BLUETOOTH_STATE_TURNING_OFF = 3; * <p>Requires {@link android.Manifest.permission#BLUETOOTH} to receive. */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String ACTION_STATE_CHANGED = "android.bluetooth.intent.action.STATE_CHANGED"; /** Inquiry scan and page scan are both off. /** * Device is neither discoverable nor connectable * Used as an int extra field in {@link #ACTION_STATE_CHANGED} * @hide */ * intents to request the current power state. Possible values are: public static final int SCAN_MODE_NONE = 0; * {@link #STATE_OFF}, /** Page scan is on, inquiry scan is off. * {@link #STATE_TURNING_ON}, * Device is connectable, but not discoverable * {@link #STATE_ON}, * @hide*/ * {@link #STATE_TURNING_OFF}, public static final int SCAN_MODE_CONNECTABLE = 1; */ /** Page scan and inquiry scan are on. public static final String EXTRA_STATE = * Device is connectable and discoverable "android.bluetooth.intent.extra.STATE"; * @hide*/ /** public static final int SCAN_MODE_CONNECTABLE_DISCOVERABLE = 3; * Used as an int extra field in {@link #ACTION_STATE_CHANGED} * intents to request the previous power state. Possible values are: * {@link #STATE_OFF}, * {@link #STATE_TURNING_ON}, * {@link #STATE_ON}, * {@link #STATE_TURNING_OFF}, */ public static final String EXTRA_PREVIOUS_STATE = "android.bluetooth.intent.extra.PREVIOUS_STATE"; /** @hide */ /** public static final int RESULT_FAILURE = -1; * Indicates the local Bluetooth adapter is off. /** @hide */ */ public static final int RESULT_SUCCESS = 0; public static final int STATE_OFF = 40; /** * Indicates the local Bluetooth adapter is turning on. However local * clients should wait for {@link #STATE_ON} before attempting to * use the adapter. */ public static final int STATE_TURNING_ON = 41; /** * Indicates the local Bluetooth adapter is on, and ready for use. */ public static final int STATE_ON = 42; /** * Indicates the local Bluetooth adapter is turning off. Local clients * should immediately attempt graceful disconnection of any remote links. */ public static final int STATE_TURNING_OFF = 43; /** * Broadcast Action: Indicates the Bluetooth scan mode of the local Adapter * has changed. * <p>Contains the extra fields {@link #EXTRA_SCAN_MODE} and {@link * #EXTRA_PREVIOUS_SCAN_MODE} containing the new and old scan modes * respectively. * <p>Requires {@link android.Manifest.permission#BLUETOOTH} */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String ACTION_SCAN_MODE_CHANGED = "android.bluetooth.intent.action.SCAN_MODE_CHANGED"; /** * Used as an int extra field in {@link #ACTION_SCAN_MODE_CHANGED} * intents to request the current scan mode. Possible values are: * {@link #SCAN_MODE_NONE}, * {@link #SCAN_MODE_CONNECTABLE}, * {@link #SCAN_MODE_CONNECTABLE_DISCOVERABLE}, */ public static final String EXTRA_SCAN_MODE = "android.bluetooth.intent.extra.SCAN_MODE"; /** * Used as an int extra field in {@link #ACTION_SCAN_MODE_CHANGED} * intents to request the previous scan mode. Possible values are: * {@link #SCAN_MODE_NONE}, * {@link #SCAN_MODE_CONNECTABLE}, * {@link #SCAN_MODE_CONNECTABLE_DISCOVERABLE}, */ public static final String EXTRA_PREVIOUS_SCAN_MODE = "android.bluetooth.intent.extra.PREVIOUS_SCAN_MODE"; /** * Indicates that both inquiry scan and page scan are disabled on the local * Bluetooth adapter. Therefore this device is neither discoverable * nor connectable from remote Bluetooth devices. */ public static final int SCAN_MODE_NONE = 50; /** * Indicates that inquiry scan is disabled, but page scan is enabled on the * local Bluetooth adapter. Therefore this device is not discoverable from * remote Bluetooth devices, but is connectable from remote devices that * have previously discovered this device. */ public static final int SCAN_MODE_CONNECTABLE = 51; /** * Indicates that both inquiry scan and page scan are enabled on the local * Bluetooth adapter. Therefore this device is both discoverable and * connectable from remote Bluetooth devices. */ public static final int SCAN_MODE_CONNECTABLE_DISCOVERABLE = 53; /** The user will be prompted to enter a pin /** The user will be prompted to enter a pin * @hide */ * @hide */ Loading Loading @@ -97,6 +176,7 @@ public final class BluetoothAdapter { * such as "00:11:22:33:AA:BB". * such as "00:11:22:33:AA:BB". * <p>A {@link BluetoothDevice} will always be returned for a valid * <p>A {@link BluetoothDevice} will always be returned for a valid * hardware address, even if this adapter has never seen that device. * hardware address, even if this adapter has never seen that device. * * @param address valid Bluetooth MAC address * @param address valid Bluetooth MAC address * @throws IllegalArgumentException if address is invalid * @throws IllegalArgumentException if address is invalid */ */ Loading @@ -105,10 +185,12 @@ public final class BluetoothAdapter { } } /** /** * Is Bluetooth currently turned on. * Return true if Bluetooth is currently enabled and ready for use. * <p>Equivalent to: * <code>getBluetoothState() == STATE_ON</code> * <p>Requires {@link android.Manifest.permission#BLUETOOTH} * * * @return true if Bluetooth enabled, false otherwise. * @return true if the local adapter is turned on * @hide */ */ public boolean isEnabled() { public boolean isEnabled() { try { try { Loading @@ -118,28 +200,40 @@ public final class BluetoothAdapter { } } /** /** * Get the current state of Bluetooth. * Get the current state of the local Bluetooth adapter. * <p>Possible return values are * {@link #STATE_OFF}, * {@link #STATE_TURNING_ON}, * {@link #STATE_ON}, * {@link #STATE_TURNING_OFF}. * <p>Requires {@link android.Manifest.permission#BLUETOOTH} * * * @return One of BLUETOOTH_STATE_ or BluetoothError.ERROR. * @return current state of Bluetooth adapter * @hide */ */ public int getBluetoothState() { public int getState() { try { try { return mService.getBluetoothState(); return mService.getBluetoothState(); } catch (RemoteException e) {Log.e(TAG, "", e);} } catch (RemoteException e) {Log.e(TAG, "", e);} return BluetoothError.ERROR; return STATE_OFF; } } /** /** * Enable the Bluetooth device. * Turn on the local Bluetooth adapter. * Turn on the underlying hardware. * <p>This powers on the underlying Bluetooth hardware, and starts all * This is an asynchronous call, * Bluetooth system services. * BluetoothIntent.BLUETOOTH_STATE_CHANGED_ACTION can be used to check if * <p>This is an asynchronous call: it will return immediatley, and * and when the device is sucessfully enabled. * clients should listen for {@link #ACTION_STATE_CHANGED} * @return false if we cannot enable the Bluetooth device. True does not * to be notified of subsequent adapter state changes. If this call returns * imply the device was enabled, it only implies that so far there were no * true, then the adapter state will immediately transition from {@link * problems. * #STATE_OFF} to {@link #STATE_TURNING_ON}, and some time * @hide * later transition to either {@link #STATE_OFF} or {@link * #STATE_ON}. If this call returns false then there was an * immediate problem that will prevent the adapter from being turned on - * such as Airplane mode, or the adapter is already turned on. * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} * * @return true to indicate adapter startup has begun, or false on * immediate error */ */ public boolean enable() { public boolean enable() { try { try { Loading @@ -149,11 +243,22 @@ public final class BluetoothAdapter { } } /** /** * Disable the Bluetooth device. * Turn off the local Bluetooth adapter. * This turns off the underlying hardware. * <p>This gracefully shuts down all Bluetooth connections, stops Bluetooth * system services, and powers down the underlying Bluetooth hardware. * <p>This is an asynchronous call: it will return immediatley, and * clients should listen for {@link #ACTION_STATE_CHANGED} * to be notified of subsequent adapter state changes. If this call returns * true, then the adapter state will immediately transition from {@link * #STATE_ON} to {@link #STATE_TURNING_OFF}, and some time * later transition to either {@link #STATE_OFF} or {@link * #STATE_ON}. If this call returns false then there was an * immediate problem that will prevent the adapter from being turned off - * such as the adapter already being turned off. * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} * * * @return true if successful, false otherwise. * @return true to indicate adapter shutdown has begun, or false on * @hide * immediate error */ */ public boolean disable() { public boolean disable() { try { try { Loading @@ -162,7 +267,13 @@ public final class BluetoothAdapter { return false; return false; } } /** @hide */ /** * Returns the hardware address of the local Bluetooth adapter. * <p>For example, "00:11:22:AA:BB:CC". * <p>Requires {@link android.Manifest.permission#BLUETOOTH} * * @return Bluetooth hardware address as string */ public String getAddress() { public String getAddress() { try { try { return mService.getAddress(); return mService.getAddress(); Loading @@ -171,13 +282,11 @@ public final class BluetoothAdapter { } } /** /** * Get the friendly Bluetooth name of this device. * Get the friendly Bluetooth name of the local Bluetooth adapter. * * <p>This name is visible to remote Bluetooth devices. * This name is visible to remote Bluetooth devices. Currently it is only * <p>Requires {@link android.Manifest.permission#BLUETOOTH} * possible to retrieve the Bluetooth name when Bluetooth is enabled. * * * @return the Bluetooth name, or null if there was a problem. * @return the Bluetooth name, or null on error * @hide */ */ public String getName() { public String getName() { try { try { Loading @@ -187,14 +296,15 @@ public final class BluetoothAdapter { } } /** /** * Set the friendly Bluetooth name of this device. * Set the friendly Bluetooth name of the local Bluetoth adapter. * * <p>This name is visible to remote Bluetooth devices. * This name is visible to remote Bluetooth devices. The Bluetooth Service * <p>Valid Bluetooth names are a maximum of 248 UTF-8 characters, however * is responsible for persisting this name. * many remote devices can only display the first 40 characters, and some * may be limited to just 20. * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} * * * @param name the name to set * @param name a valid Bluetooth name * @return true, if the name was successfully set. False otherwise. * @return true if the name was set, false otherwise * @hide */ */ public boolean setName(String name) { public boolean setName(String name) { try { try { Loading @@ -204,28 +314,46 @@ public final class BluetoothAdapter { } } /** /** * Get the current scan mode. * Get the current Bluetooth scan mode of the local Bluetooth adaper. * Used to determine if the local device is connectable and/or discoverable * <p>The Bluetooth scan mode determines if the local adapter is * @return Scan mode, one of SCAN_MODE_* or an error code * connectable and/or discoverable from remote Bluetooth devices. * @hide * <p>Possible values are: * {@link #SCAN_MODE_NONE}, * {@link #SCAN_MODE_CONNECTABLE}, * {@link #SCAN_MODE_CONNECTABLE_DISCOVERABLE}. * <p>Requires {@link android.Manifest.permission#BLUETOOTH} * * @return scan mode */ */ public int getScanMode() { public int getScanMode() { try { try { return mService.getScanMode(); return mService.getScanMode(); } catch (RemoteException e) {Log.e(TAG, "", e);} } catch (RemoteException e) {Log.e(TAG, "", e);} return BluetoothError.ERROR_IPC; return SCAN_MODE_NONE; } } /** /** * Set the current scan mode. * Set the Bluetooth scan mode of the local Bluetooth adapter. * Used to make the local device connectable and/or discoverable * <p>The Bluetooth scan mode determines if the local adapter is * @param scanMode One of SCAN_MODE_* * connectable and/or discoverable from remote Bluetooth devices. * @hide * <p>For privacy reasons, it is recommended to limit the duration of time * that the local adapter remains in a discoverable scan mode. For example, * 2 minutes is a generous time to allow a remote Bluetooth device to * initiate and complete its discovery process. * <p>Valid scan mode values are: * {@link #SCAN_MODE_NONE}, * {@link #SCAN_MODE_CONNECTABLE}, * {@link #SCAN_MODE_CONNECTABLE_DISCOVERABLE}. * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} * * @param mode valid scan mode * @return true if the scan mode was set, false otherwise */ */ public void setScanMode(int scanMode) { public boolean setScanMode(int mode) { try { try { mService.setScanMode(scanMode); return mService.setScanMode(mode); } catch (RemoteException e) {Log.e(TAG, "", e);} } catch (RemoteException e) {Log.e(TAG, "", e);} return false; } } /** @hide */ /** @hide */ Loading core/java/android/bluetooth/BluetoothDevice.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -193,9 +193,9 @@ public final class BluetoothDevice implements Parcelable { * <p>The local adapter will automatically retrieve remote names when * <p>The local adapter will automatically retrieve remote names when * performing a device scan, and will cache them. This method just returns * performing a device scan, and will cache them. This method just returns * the name for this device from the cache. * the name for this device from the cache. * <p>Requires {@link android.Manifest.permission#BLUETOOTH} * * * @return the Bluetooth name, or null if there was a problem. * @return the Bluetooth name, or null if there was a problem. * @hide */ */ public String getName() { public String getName() { try { try { Loading Loading @@ -358,6 +358,7 @@ public final class BluetoothDevice implements Parcelable { * connection. * connection. * <p>Valid RFCOMM channels are in range 1 to 30. * <p>Valid RFCOMM channels are in range 1 to 30. * <p>Requires {@link android.Manifest.permission#BLUETOOTH} * <p>Requires {@link android.Manifest.permission#BLUETOOTH} * * @param channel RFCOMM channel to connect to * @param channel RFCOMM channel to connect to * @return a RFCOMM BluetoothServerSocket ready for an outgoing connection * @return a RFCOMM BluetoothServerSocket ready for an outgoing connection * @throws IOException on error, for example Bluetooth not available, or * @throws IOException on error, for example Bluetooth not available, or Loading core/java/android/bluetooth/BluetoothError.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -21,6 +21,8 @@ package android.bluetooth; * * * Errors are always negative. * Errors are always negative. * * * TODO: Deprecate this class. * * @hide * @hide */ */ public class BluetoothError { public class BluetoothError { Loading core/java/android/bluetooth/BluetoothIntent.java +2 −26 Original line number Original line Diff line number Diff line Loading @@ -20,17 +20,12 @@ import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.annotation.SdkConstant.SdkConstantType; /** /** * The Android Bluetooth API is not finalized, and *will* change. Use at your * Bluetooth API constants. * own risk. * * Manages the local Bluetooth device. Scan for devices, create bondings, * power up and down the adapter. * * * TODO: Deprecate this class * @hide * @hide */ */ public interface BluetoothIntent { public interface BluetoothIntent { public static final String SCAN_MODE = "android.bluetooth.intent.SCAN_MODE"; public static final String DEVICE = public static final String DEVICE = "android.bluetooth.intent.DEVICE"; "android.bluetooth.intent.DEVICE"; public static final String NAME = public static final String NAME = Loading @@ -41,10 +36,6 @@ public interface BluetoothIntent { "android.bluetooth.intent.RSSI"; "android.bluetooth.intent.RSSI"; public static final String CLASS = public static final String CLASS = "android.bluetooth.intent.CLASS"; "android.bluetooth.intent.CLASS"; public static final String BLUETOOTH_STATE = "android.bluetooth.intent.BLUETOOTH_STATE"; public static final String BLUETOOTH_PREVIOUS_STATE = "android.bluetooth.intent.BLUETOOTH_PREVIOUS_STATE"; public static final String HEADSET_STATE = public static final String HEADSET_STATE = "android.bluetooth.intent.HEADSET_STATE"; "android.bluetooth.intent.HEADSET_STATE"; public static final String HEADSET_PREVIOUS_STATE = public static final String HEADSET_PREVIOUS_STATE = Loading Loading @@ -91,25 +82,10 @@ public interface BluetoothIntent { public static final String DEVICE_PICKER_DEVICE_PICKER = public static final String DEVICE_PICKER_DEVICE_PICKER = "android.bluetooth.intent.action.DEVICE_PICKER"; "android.bluetooth.intent.action.DEVICE_PICKER"; /** Broadcast when the local Bluetooth device state changes, for example * when Bluetooth is enabled. Will contain int extra's BLUETOOTH_STATE and * BLUETOOTH_PREVIOUS_STATE. */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String BLUETOOTH_STATE_CHANGED_ACTION = "android.bluetooth.intent.action.BLUETOOTH_STATE_CHANGED"; @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String NAME_CHANGED_ACTION = public static final String NAME_CHANGED_ACTION = "android.bluetooth.intent.action.NAME_CHANGED"; "android.bluetooth.intent.action.NAME_CHANGED"; /** * Broadcast when the scan mode changes. Always contains an int extra * named SCAN_MODE that contains the new scan mode. */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String SCAN_MODE_CHANGED_ACTION = "android.bluetooth.intent.action.SCAN_MODE_CHANGED"; @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String DISCOVERY_STARTED_ACTION = public static final String DISCOVERY_STARTED_ACTION = "android.bluetooth.intent.action.DISCOVERY_STARTED"; "android.bluetooth.intent.action.DISCOVERY_STARTED"; Loading Loading
api/current.xml +257 −0 Original line number Original line Diff line number Diff line Loading @@ -25457,6 +25457,50 @@ deprecated="not deprecated" deprecated="not deprecated" visibility="public" visibility="public" > > <method name="disable" return="boolean" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="enable" return="boolean" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="getAddress" return="java.lang.String" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="getName" return="java.lang.String" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="getRemoteDevice" <method name="getRemoteDevice" return="android.bluetooth.BluetoothDevice" return="android.bluetooth.BluetoothDevice" abstract="false" abstract="false" Loading @@ -25470,6 +25514,39 @@ <parameter name="address" type="java.lang.String"> <parameter name="address" type="java.lang.String"> </parameter> </parameter> </method> </method> <method name="getScanMode" return="int" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="getState" return="int" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="isEnabled" return="boolean" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="listenUsingRfcommOn" <method name="listenUsingRfcommOn" return="android.bluetooth.BluetoothServerSocket" return="android.bluetooth.BluetoothServerSocket" abstract="false" abstract="false" Loading @@ -25485,6 +25562,175 @@ <exception name="IOException" type="java.io.IOException"> <exception name="IOException" type="java.io.IOException"> </exception> </exception> </method> </method> <method name="setName" return="boolean" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="name" type="java.lang.String"> </parameter> </method> <method name="setScanMode" return="boolean" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="mode" type="int"> </parameter> </method> <field name="ACTION_SCAN_MODE_CHANGED" type="java.lang.String" transient="false" volatile="false" value=""android.bluetooth.intent.action.SCAN_MODE_CHANGED"" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="ACTION_STATE_CHANGED" type="java.lang.String" transient="false" volatile="false" value=""android.bluetooth.intent.action.STATE_CHANGED"" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="EXTRA_PREVIOUS_SCAN_MODE" type="java.lang.String" transient="false" volatile="false" value=""android.bluetooth.intent.extra.PREVIOUS_SCAN_MODE"" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="EXTRA_PREVIOUS_STATE" type="java.lang.String" transient="false" volatile="false" value=""android.bluetooth.intent.extra.PREVIOUS_STATE"" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="EXTRA_SCAN_MODE" type="java.lang.String" transient="false" volatile="false" value=""android.bluetooth.intent.extra.SCAN_MODE"" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="EXTRA_STATE" type="java.lang.String" transient="false" volatile="false" value=""android.bluetooth.intent.extra.STATE"" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="SCAN_MODE_CONNECTABLE" type="int" transient="false" volatile="false" value="51" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="SCAN_MODE_CONNECTABLE_DISCOVERABLE" type="int" transient="false" volatile="false" value="53" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="SCAN_MODE_NONE" type="int" transient="false" volatile="false" value="50" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="STATE_OFF" type="int" transient="false" volatile="false" value="40" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="STATE_ON" type="int" transient="false" volatile="false" value="42" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="STATE_TURNING_OFF" type="int" transient="false" volatile="false" value="43" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="STATE_TURNING_ON" type="int" transient="false" volatile="false" value="41" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> </class> </class> <class name="BluetoothDevice" <class name="BluetoothDevice" extends="java.lang.Object" extends="java.lang.Object" Loading Loading @@ -25533,6 +25779,17 @@ visibility="public" visibility="public" > > </method> </method> <method name="getName" return="java.lang.String" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="writeToParcel" <method name="writeToParcel" return="void" return="void" abstract="false" abstract="false"
core/java/android/bluetooth/BluetoothAdapter.java +199 −71 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.bluetooth; package android.bluetooth; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.os.RemoteException; import android.os.RemoteException; import android.util.Log; import android.util.Log; Loading @@ -40,32 +42,109 @@ import java.util.HashSet; public final class BluetoothAdapter { public final class BluetoothAdapter { private static final String TAG = "BluetoothAdapter"; private static final String TAG = "BluetoothAdapter"; /** @hide */ /** public static final int BLUETOOTH_STATE_OFF = 0; * Broadcast Action: The state of the local Bluetooth adapter has been /** @hide */ * changed. public static final int BLUETOOTH_STATE_TURNING_ON = 1; * <p>For example, Bluetooth has been turned on or off. /** @hide */ * <p>Contains the extra fields {@link #EXTRA_STATE} and {@link public static final int BLUETOOTH_STATE_ON = 2; * #EXTRA_PREVIOUS_STATE} containing the new and old states /** @hide */ * respectively. public static final int BLUETOOTH_STATE_TURNING_OFF = 3; * <p>Requires {@link android.Manifest.permission#BLUETOOTH} to receive. */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String ACTION_STATE_CHANGED = "android.bluetooth.intent.action.STATE_CHANGED"; /** Inquiry scan and page scan are both off. /** * Device is neither discoverable nor connectable * Used as an int extra field in {@link #ACTION_STATE_CHANGED} * @hide */ * intents to request the current power state. Possible values are: public static final int SCAN_MODE_NONE = 0; * {@link #STATE_OFF}, /** Page scan is on, inquiry scan is off. * {@link #STATE_TURNING_ON}, * Device is connectable, but not discoverable * {@link #STATE_ON}, * @hide*/ * {@link #STATE_TURNING_OFF}, public static final int SCAN_MODE_CONNECTABLE = 1; */ /** Page scan and inquiry scan are on. public static final String EXTRA_STATE = * Device is connectable and discoverable "android.bluetooth.intent.extra.STATE"; * @hide*/ /** public static final int SCAN_MODE_CONNECTABLE_DISCOVERABLE = 3; * Used as an int extra field in {@link #ACTION_STATE_CHANGED} * intents to request the previous power state. Possible values are: * {@link #STATE_OFF}, * {@link #STATE_TURNING_ON}, * {@link #STATE_ON}, * {@link #STATE_TURNING_OFF}, */ public static final String EXTRA_PREVIOUS_STATE = "android.bluetooth.intent.extra.PREVIOUS_STATE"; /** @hide */ /** public static final int RESULT_FAILURE = -1; * Indicates the local Bluetooth adapter is off. /** @hide */ */ public static final int RESULT_SUCCESS = 0; public static final int STATE_OFF = 40; /** * Indicates the local Bluetooth adapter is turning on. However local * clients should wait for {@link #STATE_ON} before attempting to * use the adapter. */ public static final int STATE_TURNING_ON = 41; /** * Indicates the local Bluetooth adapter is on, and ready for use. */ public static final int STATE_ON = 42; /** * Indicates the local Bluetooth adapter is turning off. Local clients * should immediately attempt graceful disconnection of any remote links. */ public static final int STATE_TURNING_OFF = 43; /** * Broadcast Action: Indicates the Bluetooth scan mode of the local Adapter * has changed. * <p>Contains the extra fields {@link #EXTRA_SCAN_MODE} and {@link * #EXTRA_PREVIOUS_SCAN_MODE} containing the new and old scan modes * respectively. * <p>Requires {@link android.Manifest.permission#BLUETOOTH} */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String ACTION_SCAN_MODE_CHANGED = "android.bluetooth.intent.action.SCAN_MODE_CHANGED"; /** * Used as an int extra field in {@link #ACTION_SCAN_MODE_CHANGED} * intents to request the current scan mode. Possible values are: * {@link #SCAN_MODE_NONE}, * {@link #SCAN_MODE_CONNECTABLE}, * {@link #SCAN_MODE_CONNECTABLE_DISCOVERABLE}, */ public static final String EXTRA_SCAN_MODE = "android.bluetooth.intent.extra.SCAN_MODE"; /** * Used as an int extra field in {@link #ACTION_SCAN_MODE_CHANGED} * intents to request the previous scan mode. Possible values are: * {@link #SCAN_MODE_NONE}, * {@link #SCAN_MODE_CONNECTABLE}, * {@link #SCAN_MODE_CONNECTABLE_DISCOVERABLE}, */ public static final String EXTRA_PREVIOUS_SCAN_MODE = "android.bluetooth.intent.extra.PREVIOUS_SCAN_MODE"; /** * Indicates that both inquiry scan and page scan are disabled on the local * Bluetooth adapter. Therefore this device is neither discoverable * nor connectable from remote Bluetooth devices. */ public static final int SCAN_MODE_NONE = 50; /** * Indicates that inquiry scan is disabled, but page scan is enabled on the * local Bluetooth adapter. Therefore this device is not discoverable from * remote Bluetooth devices, but is connectable from remote devices that * have previously discovered this device. */ public static final int SCAN_MODE_CONNECTABLE = 51; /** * Indicates that both inquiry scan and page scan are enabled on the local * Bluetooth adapter. Therefore this device is both discoverable and * connectable from remote Bluetooth devices. */ public static final int SCAN_MODE_CONNECTABLE_DISCOVERABLE = 53; /** The user will be prompted to enter a pin /** The user will be prompted to enter a pin * @hide */ * @hide */ Loading Loading @@ -97,6 +176,7 @@ public final class BluetoothAdapter { * such as "00:11:22:33:AA:BB". * such as "00:11:22:33:AA:BB". * <p>A {@link BluetoothDevice} will always be returned for a valid * <p>A {@link BluetoothDevice} will always be returned for a valid * hardware address, even if this adapter has never seen that device. * hardware address, even if this adapter has never seen that device. * * @param address valid Bluetooth MAC address * @param address valid Bluetooth MAC address * @throws IllegalArgumentException if address is invalid * @throws IllegalArgumentException if address is invalid */ */ Loading @@ -105,10 +185,12 @@ public final class BluetoothAdapter { } } /** /** * Is Bluetooth currently turned on. * Return true if Bluetooth is currently enabled and ready for use. * <p>Equivalent to: * <code>getBluetoothState() == STATE_ON</code> * <p>Requires {@link android.Manifest.permission#BLUETOOTH} * * * @return true if Bluetooth enabled, false otherwise. * @return true if the local adapter is turned on * @hide */ */ public boolean isEnabled() { public boolean isEnabled() { try { try { Loading @@ -118,28 +200,40 @@ public final class BluetoothAdapter { } } /** /** * Get the current state of Bluetooth. * Get the current state of the local Bluetooth adapter. * <p>Possible return values are * {@link #STATE_OFF}, * {@link #STATE_TURNING_ON}, * {@link #STATE_ON}, * {@link #STATE_TURNING_OFF}. * <p>Requires {@link android.Manifest.permission#BLUETOOTH} * * * @return One of BLUETOOTH_STATE_ or BluetoothError.ERROR. * @return current state of Bluetooth adapter * @hide */ */ public int getBluetoothState() { public int getState() { try { try { return mService.getBluetoothState(); return mService.getBluetoothState(); } catch (RemoteException e) {Log.e(TAG, "", e);} } catch (RemoteException e) {Log.e(TAG, "", e);} return BluetoothError.ERROR; return STATE_OFF; } } /** /** * Enable the Bluetooth device. * Turn on the local Bluetooth adapter. * Turn on the underlying hardware. * <p>This powers on the underlying Bluetooth hardware, and starts all * This is an asynchronous call, * Bluetooth system services. * BluetoothIntent.BLUETOOTH_STATE_CHANGED_ACTION can be used to check if * <p>This is an asynchronous call: it will return immediatley, and * and when the device is sucessfully enabled. * clients should listen for {@link #ACTION_STATE_CHANGED} * @return false if we cannot enable the Bluetooth device. True does not * to be notified of subsequent adapter state changes. If this call returns * imply the device was enabled, it only implies that so far there were no * true, then the adapter state will immediately transition from {@link * problems. * #STATE_OFF} to {@link #STATE_TURNING_ON}, and some time * @hide * later transition to either {@link #STATE_OFF} or {@link * #STATE_ON}. If this call returns false then there was an * immediate problem that will prevent the adapter from being turned on - * such as Airplane mode, or the adapter is already turned on. * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} * * @return true to indicate adapter startup has begun, or false on * immediate error */ */ public boolean enable() { public boolean enable() { try { try { Loading @@ -149,11 +243,22 @@ public final class BluetoothAdapter { } } /** /** * Disable the Bluetooth device. * Turn off the local Bluetooth adapter. * This turns off the underlying hardware. * <p>This gracefully shuts down all Bluetooth connections, stops Bluetooth * system services, and powers down the underlying Bluetooth hardware. * <p>This is an asynchronous call: it will return immediatley, and * clients should listen for {@link #ACTION_STATE_CHANGED} * to be notified of subsequent adapter state changes. If this call returns * true, then the adapter state will immediately transition from {@link * #STATE_ON} to {@link #STATE_TURNING_OFF}, and some time * later transition to either {@link #STATE_OFF} or {@link * #STATE_ON}. If this call returns false then there was an * immediate problem that will prevent the adapter from being turned off - * such as the adapter already being turned off. * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} * * * @return true if successful, false otherwise. * @return true to indicate adapter shutdown has begun, or false on * @hide * immediate error */ */ public boolean disable() { public boolean disable() { try { try { Loading @@ -162,7 +267,13 @@ public final class BluetoothAdapter { return false; return false; } } /** @hide */ /** * Returns the hardware address of the local Bluetooth adapter. * <p>For example, "00:11:22:AA:BB:CC". * <p>Requires {@link android.Manifest.permission#BLUETOOTH} * * @return Bluetooth hardware address as string */ public String getAddress() { public String getAddress() { try { try { return mService.getAddress(); return mService.getAddress(); Loading @@ -171,13 +282,11 @@ public final class BluetoothAdapter { } } /** /** * Get the friendly Bluetooth name of this device. * Get the friendly Bluetooth name of the local Bluetooth adapter. * * <p>This name is visible to remote Bluetooth devices. * This name is visible to remote Bluetooth devices. Currently it is only * <p>Requires {@link android.Manifest.permission#BLUETOOTH} * possible to retrieve the Bluetooth name when Bluetooth is enabled. * * * @return the Bluetooth name, or null if there was a problem. * @return the Bluetooth name, or null on error * @hide */ */ public String getName() { public String getName() { try { try { Loading @@ -187,14 +296,15 @@ public final class BluetoothAdapter { } } /** /** * Set the friendly Bluetooth name of this device. * Set the friendly Bluetooth name of the local Bluetoth adapter. * * <p>This name is visible to remote Bluetooth devices. * This name is visible to remote Bluetooth devices. The Bluetooth Service * <p>Valid Bluetooth names are a maximum of 248 UTF-8 characters, however * is responsible for persisting this name. * many remote devices can only display the first 40 characters, and some * may be limited to just 20. * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} * * * @param name the name to set * @param name a valid Bluetooth name * @return true, if the name was successfully set. False otherwise. * @return true if the name was set, false otherwise * @hide */ */ public boolean setName(String name) { public boolean setName(String name) { try { try { Loading @@ -204,28 +314,46 @@ public final class BluetoothAdapter { } } /** /** * Get the current scan mode. * Get the current Bluetooth scan mode of the local Bluetooth adaper. * Used to determine if the local device is connectable and/or discoverable * <p>The Bluetooth scan mode determines if the local adapter is * @return Scan mode, one of SCAN_MODE_* or an error code * connectable and/or discoverable from remote Bluetooth devices. * @hide * <p>Possible values are: * {@link #SCAN_MODE_NONE}, * {@link #SCAN_MODE_CONNECTABLE}, * {@link #SCAN_MODE_CONNECTABLE_DISCOVERABLE}. * <p>Requires {@link android.Manifest.permission#BLUETOOTH} * * @return scan mode */ */ public int getScanMode() { public int getScanMode() { try { try { return mService.getScanMode(); return mService.getScanMode(); } catch (RemoteException e) {Log.e(TAG, "", e);} } catch (RemoteException e) {Log.e(TAG, "", e);} return BluetoothError.ERROR_IPC; return SCAN_MODE_NONE; } } /** /** * Set the current scan mode. * Set the Bluetooth scan mode of the local Bluetooth adapter. * Used to make the local device connectable and/or discoverable * <p>The Bluetooth scan mode determines if the local adapter is * @param scanMode One of SCAN_MODE_* * connectable and/or discoverable from remote Bluetooth devices. * @hide * <p>For privacy reasons, it is recommended to limit the duration of time * that the local adapter remains in a discoverable scan mode. For example, * 2 minutes is a generous time to allow a remote Bluetooth device to * initiate and complete its discovery process. * <p>Valid scan mode values are: * {@link #SCAN_MODE_NONE}, * {@link #SCAN_MODE_CONNECTABLE}, * {@link #SCAN_MODE_CONNECTABLE_DISCOVERABLE}. * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} * * @param mode valid scan mode * @return true if the scan mode was set, false otherwise */ */ public void setScanMode(int scanMode) { public boolean setScanMode(int mode) { try { try { mService.setScanMode(scanMode); return mService.setScanMode(mode); } catch (RemoteException e) {Log.e(TAG, "", e);} } catch (RemoteException e) {Log.e(TAG, "", e);} return false; } } /** @hide */ /** @hide */ Loading
core/java/android/bluetooth/BluetoothDevice.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -193,9 +193,9 @@ public final class BluetoothDevice implements Parcelable { * <p>The local adapter will automatically retrieve remote names when * <p>The local adapter will automatically retrieve remote names when * performing a device scan, and will cache them. This method just returns * performing a device scan, and will cache them. This method just returns * the name for this device from the cache. * the name for this device from the cache. * <p>Requires {@link android.Manifest.permission#BLUETOOTH} * * * @return the Bluetooth name, or null if there was a problem. * @return the Bluetooth name, or null if there was a problem. * @hide */ */ public String getName() { public String getName() { try { try { Loading Loading @@ -358,6 +358,7 @@ public final class BluetoothDevice implements Parcelable { * connection. * connection. * <p>Valid RFCOMM channels are in range 1 to 30. * <p>Valid RFCOMM channels are in range 1 to 30. * <p>Requires {@link android.Manifest.permission#BLUETOOTH} * <p>Requires {@link android.Manifest.permission#BLUETOOTH} * * @param channel RFCOMM channel to connect to * @param channel RFCOMM channel to connect to * @return a RFCOMM BluetoothServerSocket ready for an outgoing connection * @return a RFCOMM BluetoothServerSocket ready for an outgoing connection * @throws IOException on error, for example Bluetooth not available, or * @throws IOException on error, for example Bluetooth not available, or Loading
core/java/android/bluetooth/BluetoothError.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -21,6 +21,8 @@ package android.bluetooth; * * * Errors are always negative. * Errors are always negative. * * * TODO: Deprecate this class. * * @hide * @hide */ */ public class BluetoothError { public class BluetoothError { Loading
core/java/android/bluetooth/BluetoothIntent.java +2 −26 Original line number Original line Diff line number Diff line Loading @@ -20,17 +20,12 @@ import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.annotation.SdkConstant.SdkConstantType; /** /** * The Android Bluetooth API is not finalized, and *will* change. Use at your * Bluetooth API constants. * own risk. * * Manages the local Bluetooth device. Scan for devices, create bondings, * power up and down the adapter. * * * TODO: Deprecate this class * @hide * @hide */ */ public interface BluetoothIntent { public interface BluetoothIntent { public static final String SCAN_MODE = "android.bluetooth.intent.SCAN_MODE"; public static final String DEVICE = public static final String DEVICE = "android.bluetooth.intent.DEVICE"; "android.bluetooth.intent.DEVICE"; public static final String NAME = public static final String NAME = Loading @@ -41,10 +36,6 @@ public interface BluetoothIntent { "android.bluetooth.intent.RSSI"; "android.bluetooth.intent.RSSI"; public static final String CLASS = public static final String CLASS = "android.bluetooth.intent.CLASS"; "android.bluetooth.intent.CLASS"; public static final String BLUETOOTH_STATE = "android.bluetooth.intent.BLUETOOTH_STATE"; public static final String BLUETOOTH_PREVIOUS_STATE = "android.bluetooth.intent.BLUETOOTH_PREVIOUS_STATE"; public static final String HEADSET_STATE = public static final String HEADSET_STATE = "android.bluetooth.intent.HEADSET_STATE"; "android.bluetooth.intent.HEADSET_STATE"; public static final String HEADSET_PREVIOUS_STATE = public static final String HEADSET_PREVIOUS_STATE = Loading Loading @@ -91,25 +82,10 @@ public interface BluetoothIntent { public static final String DEVICE_PICKER_DEVICE_PICKER = public static final String DEVICE_PICKER_DEVICE_PICKER = "android.bluetooth.intent.action.DEVICE_PICKER"; "android.bluetooth.intent.action.DEVICE_PICKER"; /** Broadcast when the local Bluetooth device state changes, for example * when Bluetooth is enabled. Will contain int extra's BLUETOOTH_STATE and * BLUETOOTH_PREVIOUS_STATE. */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String BLUETOOTH_STATE_CHANGED_ACTION = "android.bluetooth.intent.action.BLUETOOTH_STATE_CHANGED"; @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String NAME_CHANGED_ACTION = public static final String NAME_CHANGED_ACTION = "android.bluetooth.intent.action.NAME_CHANGED"; "android.bluetooth.intent.action.NAME_CHANGED"; /** * Broadcast when the scan mode changes. Always contains an int extra * named SCAN_MODE that contains the new scan mode. */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String SCAN_MODE_CHANGED_ACTION = "android.bluetooth.intent.action.SCAN_MODE_CHANGED"; @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String DISCOVERY_STARTED_ACTION = public static final String DISCOVERY_STARTED_ACTION = "android.bluetooth.intent.action.DISCOVERY_STARTED"; "android.bluetooth.intent.action.DISCOVERY_STARTED"; Loading