summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAjay Panicker <apanicke@google.com>2016-03-17 17:12:08 -0700
committerThe Android Automerger <android-build@google.com>2016-05-27 11:31:36 -0700
commit122feb9a0b04290f55183ff2f0384c6c53756bd8 (patch)
tree1f9d7dee2e31ba8ab9e3b4bd3a2478344cf2116d
parenta283d524475da1b9ce9013eb2c8709bc7bd9dcfc (diff)
downloadandroid_packages_apps_Bluetooth-122feb9a0b04290f55183ff2f0384c6c53756bd8.tar.gz
android_packages_apps_Bluetooth-122feb9a0b04290f55183ff2f0384c6c53756bd8.tar.bz2
android_packages_apps_Bluetooth-122feb9a0b04290f55183ff2f0384c6c53756bd8.zip
Add guest mode functionality (3/3)
Add a flag to enable() to start Bluetooth in restricted mode. In restricted mode, all devices that are paired during restricted mode are deleted upon leaving restricted mode. Right now restricted mode is only entered while a guest user is active. Bug: 27410683 Change-Id: If4a8855faf362d7f6de509d7ddc7197d1ac75cee
-rwxr-xr-xjni/com_android_bluetooth_btservice_AdapterService.cpp7
-rw-r--r--src/com/android/bluetooth/btservice/AdapterService.java2
-rw-r--r--src/com/android/bluetooth/btservice/AdapterState.java4
3 files changed, 7 insertions, 6 deletions
diff --git a/jni/com_android_bluetooth_btservice_AdapterService.cpp b/jni/com_android_bluetooth_btservice_AdapterService.cpp
index b8e9a97b3..ad5288eff 100755
--- a/jni/com_android_bluetooth_btservice_AdapterService.cpp
+++ b/jni/com_android_bluetooth_btservice_AdapterService.cpp
@@ -702,13 +702,12 @@ static bool cleanupNative(JNIEnv *env, jobject obj) {
return JNI_TRUE;
}
-static jboolean enableNative(JNIEnv* env, jobject obj) {
+static jboolean enableNative(JNIEnv* env, jobject obj, jboolean isGuest) {
ALOGV("%s:",__FUNCTION__);
jboolean result = JNI_FALSE;
if (!sBluetoothInterface) return result;
-
- int ret = sBluetoothInterface->enable();
+ int ret = sBluetoothInterface->enable(isGuest == JNI_TRUE ? 1 : 0);
result = (ret == BT_STATUS_SUCCESS || ret == BT_STATUS_DONE) ? JNI_TRUE : JNI_FALSE;
return result;
}
@@ -1156,7 +1155,7 @@ static JNINativeMethod sMethods[] = {
{"classInitNative", "()V", (void *) classInitNative},
{"initNative", "()Z", (void *) initNative},
{"cleanupNative", "()V", (void*) cleanupNative},
- {"enableNative", "()Z", (void*) enableNative},
+ {"enableNative", "(Z)Z", (void*) enableNative},
{"disableNative", "()Z", (void*) disableNative},
{"setAdapterPropertyNative", "(I[B)Z", (void*) setAdapterPropertyNative},
{"getAdapterPropertiesNative", "()Z", (void*) getAdapterPropertiesNative},
diff --git a/src/com/android/bluetooth/btservice/AdapterService.java b/src/com/android/bluetooth/btservice/AdapterService.java
index 1fbd231af..3b96b7f95 100644
--- a/src/com/android/bluetooth/btservice/AdapterService.java
+++ b/src/com/android/bluetooth/btservice/AdapterService.java
@@ -2154,7 +2154,7 @@ public class AdapterService extends Service {
private native static void classInitNative();
private native boolean initNative();
private native void cleanupNative();
- /*package*/ native boolean enableNative();
+ /*package*/ native boolean enableNative(boolean startRestricted);
/*package*/ native boolean disableNative();
/*package*/ native boolean setAdapterPropertyNative(int type, byte[] val);
/*package*/ native boolean getAdapterPropertiesNative();
diff --git a/src/com/android/bluetooth/btservice/AdapterState.java b/src/com/android/bluetooth/btservice/AdapterState.java
index 555e175e8..b47d3242b 100644
--- a/src/com/android/bluetooth/btservice/AdapterState.java
+++ b/src/com/android/bluetooth/btservice/AdapterState.java
@@ -20,6 +20,7 @@ import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.Intent;
import android.os.Message;
+import android.os.UserManager;
import android.util.Log;
import com.android.internal.util.State;
@@ -360,7 +361,8 @@ final class AdapterState extends StateMachine {
removeMessages(BLE_START_TIMEOUT);
//Enable
- if (!adapterService.enableNative()) {
+ boolean isGuest = UserManager.get(mAdapterService).isGuestUser();
+ if (!adapterService.enableNative(isGuest)) {
errorLog("Error while turning Bluetooth on");
notifyAdapterStateChange(BluetoothAdapter.STATE_OFF);
transitionTo(mOffState);