Merge "Resolve API dependencies on BluetoothPan"
am: bad5a30d4f
Change-Id: Ic9e920c37c6417485f5be12ac6137bb6e0626b92
This commit is contained in:
@@ -1311,7 +1311,23 @@ package android.bluetooth {
|
||||
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean setPriority(android.bluetooth.BluetoothDevice, int);
|
||||
}
|
||||
|
||||
public final class BluetoothPan implements android.bluetooth.BluetoothProfile {
|
||||
method protected void finalize();
|
||||
method @NonNull public java.util.List<android.bluetooth.BluetoothDevice> getConnectedDevices();
|
||||
method public int getConnectionState(@Nullable android.bluetooth.BluetoothDevice);
|
||||
method public boolean isTetheringOn();
|
||||
method public void setBluetoothTethering(boolean);
|
||||
field public static final String ACTION_CONNECTION_STATE_CHANGED = "android.bluetooth.pan.profile.action.CONNECTION_STATE_CHANGED";
|
||||
field public static final String EXTRA_LOCAL_ROLE = "android.bluetooth.pan.extra.LOCAL_ROLE";
|
||||
field public static final int LOCAL_NAP_ROLE = 1; // 0x1
|
||||
field public static final int LOCAL_PANU_ROLE = 2; // 0x2
|
||||
field public static final int PAN_ROLE_NONE = 0; // 0x0
|
||||
field public static final int REMOTE_NAP_ROLE = 1; // 0x1
|
||||
field public static final int REMOTE_PANU_ROLE = 2; // 0x2
|
||||
}
|
||||
|
||||
public interface BluetoothProfile {
|
||||
field public static final int PAN = 5; // 0x5
|
||||
field public static final int PRIORITY_OFF = 0; // 0x0
|
||||
field public static final int PRIORITY_ON = 100; // 0x64
|
||||
}
|
||||
|
||||
@@ -16,8 +16,13 @@
|
||||
|
||||
package android.bluetooth;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SdkConstant;
|
||||
import android.annotation.SdkConstant.SdkConstantType;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.SystemApi;
|
||||
import android.annotation.UnsupportedAppUsage;
|
||||
import android.content.Context;
|
||||
import android.os.Binder;
|
||||
@@ -25,6 +30,8 @@ import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -40,6 +47,7 @@ import java.util.List;
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public final class BluetoothPan implements BluetoothProfile {
|
||||
private static final String TAG = "BluetoothPan";
|
||||
private static final boolean DBG = true;
|
||||
@@ -67,6 +75,7 @@ public final class BluetoothPan implements BluetoothProfile {
|
||||
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission to
|
||||
* receive.
|
||||
*/
|
||||
@SuppressLint("ActionValue")
|
||||
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
|
||||
public static final String ACTION_CONNECTION_STATE_CHANGED =
|
||||
"android.bluetooth.pan.profile.action.CONNECTION_STATE_CHANGED";
|
||||
@@ -76,19 +85,32 @@ public final class BluetoothPan implements BluetoothProfile {
|
||||
* The local role of the PAN profile that the remote device is bound to.
|
||||
* It can be one of {@link #LOCAL_NAP_ROLE} or {@link #LOCAL_PANU_ROLE}.
|
||||
*/
|
||||
@SuppressLint("ActionValue")
|
||||
public static final String EXTRA_LOCAL_ROLE = "android.bluetooth.pan.extra.LOCAL_ROLE";
|
||||
|
||||
/** @hide */
|
||||
@IntDef({PAN_ROLE_NONE, LOCAL_NAP_ROLE, LOCAL_PANU_ROLE})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface LocalPanRole {}
|
||||
|
||||
public static final int PAN_ROLE_NONE = 0;
|
||||
/**
|
||||
* The local device is acting as a Network Access Point.
|
||||
*/
|
||||
public static final int LOCAL_NAP_ROLE = 1;
|
||||
public static final int REMOTE_NAP_ROLE = 1;
|
||||
|
||||
/**
|
||||
* The local device is acting as a PAN User.
|
||||
*/
|
||||
public static final int LOCAL_PANU_ROLE = 2;
|
||||
|
||||
/** @hide */
|
||||
@IntDef({PAN_ROLE_NONE, REMOTE_NAP_ROLE, REMOTE_PANU_ROLE})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface RemotePanRole {}
|
||||
|
||||
public static final int REMOTE_NAP_ROLE = 1;
|
||||
|
||||
public static final int REMOTE_PANU_ROLE = 2;
|
||||
|
||||
/**
|
||||
@@ -134,6 +156,8 @@ public final class BluetoothPan implements BluetoothProfile {
|
||||
/**
|
||||
* Create a BluetoothPan proxy object for interacting with the local
|
||||
* Bluetooth Service which handles the Pan profile
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
/*package*/ BluetoothPan(Context context, ServiceListener listener) {
|
||||
@@ -235,7 +259,7 @@ public final class BluetoothPan implements BluetoothProfile {
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<BluetoothDevice> getConnectedDevices() {
|
||||
public @NonNull List<BluetoothDevice> getConnectedDevices() {
|
||||
if (VDBG) log("getConnectedDevices()");
|
||||
final IBluetoothPan service = getService();
|
||||
if (service != null && isEnabled()) {
|
||||
@@ -252,6 +276,7 @@ public final class BluetoothPan implements BluetoothProfile {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @hide
|
||||
*/
|
||||
@Override
|
||||
public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
|
||||
@@ -273,7 +298,7 @@ public final class BluetoothPan implements BluetoothProfile {
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int getConnectionState(BluetoothDevice device) {
|
||||
public int getConnectionState(@Nullable BluetoothDevice device) {
|
||||
if (VDBG) log("getState(" + device + ")");
|
||||
final IBluetoothPan service = getService();
|
||||
if (service != null && isEnabled() && isValidDevice(device)) {
|
||||
@@ -288,7 +313,11 @@ public final class BluetoothPan implements BluetoothProfile {
|
||||
return BluetoothProfile.STATE_DISCONNECTED;
|
||||
}
|
||||
|
||||
@UnsupportedAppUsage
|
||||
/**
|
||||
* Turns on/off bluetooth tethering
|
||||
*
|
||||
* @param value is whether to enable or disable bluetooth tethering
|
||||
*/
|
||||
public void setBluetoothTethering(boolean value) {
|
||||
String pkgName = mContext.getOpPackageName();
|
||||
if (DBG) log("setBluetoothTethering(" + value + "), calling package:" + pkgName);
|
||||
@@ -302,7 +331,11 @@ public final class BluetoothPan implements BluetoothProfile {
|
||||
}
|
||||
}
|
||||
|
||||
@UnsupportedAppUsage
|
||||
/**
|
||||
* Determines whether tethering is enabled
|
||||
*
|
||||
* @return true if tethering is on, false if not or some error occurred
|
||||
*/
|
||||
public boolean isTetheringOn() {
|
||||
if (VDBG) log("isTetheringOn()");
|
||||
final IBluetoothPan service = getService();
|
||||
|
||||
@@ -20,9 +20,9 @@ package android.bluetooth;
|
||||
import android.Manifest;
|
||||
import android.annotation.IntDef;
|
||||
import android.annotation.RequiresPermission;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.SystemApi;
|
||||
import android.annotation.UnsupportedAppUsage;
|
||||
import android.os.Build;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -43,6 +43,7 @@ public interface BluetoothProfile {
|
||||
* This extra represents the current connection state of the profile of the
|
||||
* Bluetooth device.
|
||||
*/
|
||||
@SuppressLint("ActionValue")
|
||||
String EXTRA_STATE = "android.bluetooth.profile.extra.STATE";
|
||||
|
||||
/**
|
||||
@@ -51,6 +52,7 @@ public interface BluetoothProfile {
|
||||
* This extra represents the previous connection state of the profile of the
|
||||
* Bluetooth device.
|
||||
*/
|
||||
@SuppressLint("ActionValue")
|
||||
String EXTRA_PREVIOUS_STATE =
|
||||
"android.bluetooth.profile.extra.PREVIOUS_STATE";
|
||||
|
||||
@@ -106,7 +108,7 @@ public interface BluetoothProfile {
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
|
||||
@SystemApi
|
||||
int PAN = 5;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user