summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei Wang <weiwa@google.com>2015-03-19 15:09:56 -0700
committerWei Wang <weiwa@google.com>2015-03-27 14:05:37 -0700
commitd91f19354d628e48577128f670afb0f5587e15e8 (patch)
treec30f599c46cc1e4b1fafee0838d591271bc9982d
parentfbeeccc354c6fadde035ecc3188a07c8ccb778f3 (diff)
downloadframeworks_base-d91f19354d628e48577128f670afb0f5587e15e8.zip
frameworks_base-d91f19354d628e48577128f670afb0f5587e15e8.tar.gz
frameworks_base-d91f19354d628e48577128f670afb0f5587e15e8.tar.bz2
Add API for BLE_SCAN_ALWAYS_AVAILABLE feature.
Change-Id: I83e966d4db076db367ded71bfb50c39e57568156
-rw-r--r--api/system-current.txt2
-rw-r--r--core/java/android/bluetooth/BluetoothAdapter.java34
-rw-r--r--core/java/android/provider/Settings.java8
3 files changed, 44 insertions, 0 deletions
diff --git a/api/system-current.txt b/api/system-current.txt
index 6838ec1..ae94a9c 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -6033,6 +6033,7 @@ package android.bluetooth {
method public android.bluetooth.BluetoothDevice getRemoteDevice(byte[]);
method public int getScanMode();
method public int getState();
+ method public boolean isBleScanAlwaysAvailable();
method public boolean isDiscovering();
method public boolean isEnabled();
method public boolean isMultipleAdvertisementSupported();
@@ -6049,6 +6050,7 @@ package android.bluetooth {
field public static final java.lang.String ACTION_DISCOVERY_FINISHED = "android.bluetooth.adapter.action.DISCOVERY_FINISHED";
field public static final java.lang.String ACTION_DISCOVERY_STARTED = "android.bluetooth.adapter.action.DISCOVERY_STARTED";
field public static final java.lang.String ACTION_LOCAL_NAME_CHANGED = "android.bluetooth.adapter.action.LOCAL_NAME_CHANGED";
+ field public static final java.lang.String ACTION_REQUEST_BLE_SCAN_ALWAYS_AVAILABLE = "android.bluetooth.adapter.action.REQUEST_BLE_SCAN_ALWAYS_AVAILABLE";
field public static final java.lang.String ACTION_REQUEST_DISCOVERABLE = "android.bluetooth.adapter.action.REQUEST_DISCOVERABLE";
field public static final java.lang.String ACTION_REQUEST_ENABLE = "android.bluetooth.adapter.action.REQUEST_ENABLE";
field public static final java.lang.String ACTION_SCAN_MODE_CHANGED = "android.bluetooth.adapter.action.SCAN_MODE_CHANGED";
diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java
index b8f4bf8..ee055a5 100644
--- a/core/java/android/bluetooth/BluetoothAdapter.java
+++ b/core/java/android/bluetooth/BluetoothAdapter.java
@@ -18,6 +18,7 @@ package android.bluetooth;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
+import android.annotation.SystemApi;
import android.bluetooth.le.BluetoothLeAdvertiser;
import android.bluetooth.le.BluetoothLeScanner;
import android.bluetooth.le.ScanCallback;
@@ -209,6 +210,23 @@ public final class BluetoothAdapter {
"android.bluetooth.adapter.action.REQUEST_ENABLE";
/**
+ * Activity Action: Show a system activity that allows user to enable BLE scans even when
+ * Bluetooth is turned off.<p>
+ *
+ * Notification of result of this activity is posted using
+ * {@link android.app.Activity#onActivityResult}. The <code>resultCode</code> will be
+ * {@link android.app.Activity#RESULT_OK} if BLE scan always available setting is turned on or
+ * {@link android.app.Activity#RESULT_CANCELED} if the user has rejected the request or an
+ * error occurred.
+ *
+ * @hide
+ */
+ @SystemApi
+ @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
+ public static final String ACTION_REQUEST_BLE_SCAN_ALWAYS_AVAILABLE =
+ "android.bluetooth.adapter.action.REQUEST_BLE_SCAN_ALWAYS_AVAILABLE";
+
+ /**
* Broadcast Action: Indicates the Bluetooth scan mode of the local Adapter
* has changed.
* <p>Always contains the extra fields {@link #EXTRA_SCAN_MODE} and {@link
@@ -919,6 +937,22 @@ public final class BluetoothAdapter {
}
/**
+ * Returns {@code true} if BLE scan is always available, {@code false} otherwise. <p>
+ *
+ * If this returns {@code true}, application can issue {@link BluetoothLeScanner#startScan} and
+ * fetch scan results even when Bluetooth is turned off.<p>
+ *
+ * To change this setting, use {@link #ACTION_REQUEST_BLE_SCAN_ALWAYS_AVAILABLE}.
+ *
+ * @hide
+ */
+ @SystemApi
+ public boolean isBleScanAlwaysAvailable() {
+ // TODO: implement after Settings UI change.
+ return false;
+ }
+
+ /**
* Returns whether peripheral mode is supported.
*
* @hide
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 2647247..eeef2c2 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -5838,6 +5838,14 @@ public final class Settings {
"wifi_scan_always_enabled";
/**
+ * Settings to allow BLE scans to be enabled even when Bluetooth is turned off for
+ * connectivity.
+ * @hide
+ */
+ public static final String BLE_SCAN_ALWAYS_AVAILABLE =
+ "ble_scan_always_enabled";
+
+ /**
* Used to save the Wifi_ON state prior to tethering.
* This state will be checked to restore Wifi after
* the user turns off tethering.