Commit e1ca5ccc authored by Ajay Panicker's avatar Ajay Panicker
Browse files

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
parent fd7a794f
......@@ -791,13 +791,13 @@ 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) ? JNI_TRUE : JNI_FALSE;
return result;
}
......@@ -1219,7 +1219,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},
......
......@@ -1811,7 +1811,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();
......
......@@ -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;
......@@ -258,9 +259,9 @@ final class AdapterState extends StateMachine {
removeMessages(START_TIMEOUT);
//Enable
boolean ret = adapterService.enableNative();
if (!ret) {
Log.e(TAG, "Error while turning Bluetooth On");
boolean isGuest = UserManager.get(mAdapterService).isGuestUser();
if (!adapterService.enableNative(isGuest)) {
Log.e(TAG, "Error while turning Bluetooth on");
notifyAdapterStateChange(BluetoothAdapter.STATE_OFF);
transitionTo(mOffState);
} else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment