summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2019-11-22 22:54:37 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2019-11-22 22:54:37 +0000
commitbad5a30d4f1c921726b3213b1eb19d45c7c938cf (patch)
treecf912e0c53c95675a976d387018d5bb6266aeae5
parentd363bc08e90c833241af8939a47d795a49e6f329 (diff)
parenta052447ad6f6e412dd0f1a6baeddb422c47d9625 (diff)
Merge "Resolve API dependencies on BluetoothPan"
-rw-r--r--api/system-current.txt16
-rw-r--r--core/java/android/bluetooth/BluetoothPan.java43
-rw-r--r--core/java/android/bluetooth/BluetoothProfile.java6
3 files changed, 58 insertions, 7 deletions
diff --git a/api/system-current.txt b/api/system-current.txt
index b46090abc2e4..921b981de33e 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -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
}
diff --git a/core/java/android/bluetooth/BluetoothPan.java b/core/java/android/bluetooth/BluetoothPan.java
index cfb363a0834c..4e9762737c07 100644
--- a/core/java/android/bluetooth/BluetoothPan.java
+++ b/core/java/android/bluetooth/BluetoothPan.java
@@ -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();
diff --git a/core/java/android/bluetooth/BluetoothProfile.java b/core/java/android/bluetooth/BluetoothProfile.java
index f5aa01458481..f1ac76527487 100644
--- a/core/java/android/bluetooth/BluetoothProfile.java
+++ b/core/java/android/bluetooth/BluetoothProfile.java
@@ -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;
/**