Loading android/app/jni/com_android_bluetooth_btservice_AdapterService.cpp +9 −6 Original line number Diff line number Diff line Loading @@ -683,7 +683,8 @@ static void classInitNative(JNIEnv* env, jclass clazz) { } } static bool initNative(JNIEnv* env, jobject obj) { static bool initNative(JNIEnv* env, jobject obj, jboolean isGuest, jboolean isSingleUserMode) { ALOGV("%s", __func__); android_bluetooth_UidTraffic.clazz = Loading @@ -697,7 +698,9 @@ static bool initNative(JNIEnv* env, jobject obj) { return JNI_FALSE; } int ret = sBluetoothInterface->init(&sBluetoothCallbacks); int ret = sBluetoothInterface->init(&sBluetoothCallbacks, isGuest == JNI_TRUE ? 1 : 0, isSingleUserMode == JNI_TRUE ? 1 : 0); if (ret != BT_STATUS_SUCCESS) { ALOGE("Error while setting the callbacks: %d\n", ret); sBluetoothInterface = NULL; Loading Loading @@ -750,11 +753,11 @@ static bool cleanupNative(JNIEnv* env, jobject obj) { return JNI_TRUE; } static jboolean enableNative(JNIEnv* env, jobject obj, jboolean isGuest) { static jboolean enableNative(JNIEnv* env, jobject obj) { ALOGV("%s", __func__); if (!sBluetoothInterface) return JNI_FALSE; int ret = sBluetoothInterface->enable(isGuest == JNI_TRUE ? 1 : 0); int ret = sBluetoothInterface->enable(); return (ret == BT_STATUS_SUCCESS || ret == BT_STATUS_DONE) ? JNI_TRUE : JNI_FALSE; } Loading Loading @@ -1237,9 +1240,9 @@ static jbyteArray obfuscateAddressNative(JNIEnv* env, jobject obj, static JNINativeMethod sMethods[] = { /* name, signature, funcPtr */ {"classInitNative", "()V", (void*)classInitNative}, {"initNative", "()Z", (void*)initNative}, {"initNative", "(ZZ)Z", (void*)initNative}, {"cleanupNative", "()V", (void*)cleanupNative}, {"enableNative", "(Z)Z", (void*)enableNative}, {"enableNative", "()Z", (void*)enableNative}, {"disableNative", "()Z", (void*)disableNative}, {"setAdapterPropertyNative", "(I[B)Z", (void*)setAdapterPropertyNative}, {"getAdapterPropertiesNative", "()Z", (void*)getAdapterPropertiesNative}, Loading android/app/src/com/android/bluetooth/btservice/AdapterService.java +10 −9 Original line number Diff line number Diff line Loading @@ -286,7 +286,7 @@ public class AdapterService extends Service { } mRunningProfiles.add(profile); if (GattService.class.getSimpleName().equals(profile.getName())) { enableNativeWithGuestFlag(); enableNative(); } else if (mRegisteredProfiles.size() == Config.getSupportedProfiles().length && mRegisteredProfiles.size() == mRunningProfiles.size()) { mAdapterProperties.onBluetoothReady(); Loading Loading @@ -393,7 +393,7 @@ public class AdapterService extends Service { mAdapterProperties = new AdapterProperties(this); mAdapterStateMachine = AdapterState.make(this); mJniCallbacks = new JniCallbacks(this, mAdapterProperties); initNative(); initNative(isGuest(), isSingleUserMode()); mNativeAvailable = true; mCallbacks = new RemoteCallbackList<IBluetoothCallback>(); mAppOps = getSystemService(AppOpsManager.class); Loading Loading @@ -2853,11 +2853,12 @@ public class AdapterService extends Service { } }; private void enableNativeWithGuestFlag() { boolean isGuest = UserManager.get(this).isGuestUser(); if (!enableNative(isGuest)) { Log.e(TAG, "enableNative() returned false"); private boolean isGuest() { return UserManager.get(this).isGuestUser(); } private boolean isSingleUserMode() { return UserManager.get(this).hasUserRestriction(UserManager.DISALLOW_ADD_USER); } /** Loading @@ -2876,12 +2877,12 @@ public class AdapterService extends Service { static native void classInitNative(); native boolean initNative(); native boolean initNative(boolean startRestricted, boolean isSingleUserMode); native void cleanupNative(); /*package*/ native boolean enableNative(boolean startRestricted); native boolean enableNative(); /*package*/ native boolean disableNative(); Loading android/app/tests/unit/src/com/android/bluetooth/btservice/AdapterServiceTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -101,7 +101,7 @@ public class AdapterServiceTest { } Assert.assertNotNull(Looper.myLooper()); AdapterService adapterService = new AdapterService(); adapterService.initNative(); adapterService.initNative(false /* is_restricted */, false /* is_single_user_mode */); adapterService.cleanupNative(); HashMap<String, HashMap<String, String>> adapterConfig = TestUtils.readAdapterConfig(); Assert.assertNotNull(adapterConfig); Loading android/app/tests/unit/src/com/android/bluetooth/btservice/ProfileServiceTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -96,7 +96,7 @@ public class ProfileServiceTest { mProfiles = Config.getSupportedProfiles(); mMockAdapterService.initNative(); mMockAdapterService.initNative(false /* is_restricted */, false /* is_single_user_mode */); TestUtils.setAdapterService(mMockAdapterService); Loading Loading
android/app/jni/com_android_bluetooth_btservice_AdapterService.cpp +9 −6 Original line number Diff line number Diff line Loading @@ -683,7 +683,8 @@ static void classInitNative(JNIEnv* env, jclass clazz) { } } static bool initNative(JNIEnv* env, jobject obj) { static bool initNative(JNIEnv* env, jobject obj, jboolean isGuest, jboolean isSingleUserMode) { ALOGV("%s", __func__); android_bluetooth_UidTraffic.clazz = Loading @@ -697,7 +698,9 @@ static bool initNative(JNIEnv* env, jobject obj) { return JNI_FALSE; } int ret = sBluetoothInterface->init(&sBluetoothCallbacks); int ret = sBluetoothInterface->init(&sBluetoothCallbacks, isGuest == JNI_TRUE ? 1 : 0, isSingleUserMode == JNI_TRUE ? 1 : 0); if (ret != BT_STATUS_SUCCESS) { ALOGE("Error while setting the callbacks: %d\n", ret); sBluetoothInterface = NULL; Loading Loading @@ -750,11 +753,11 @@ static bool cleanupNative(JNIEnv* env, jobject obj) { return JNI_TRUE; } static jboolean enableNative(JNIEnv* env, jobject obj, jboolean isGuest) { static jboolean enableNative(JNIEnv* env, jobject obj) { ALOGV("%s", __func__); if (!sBluetoothInterface) return JNI_FALSE; int ret = sBluetoothInterface->enable(isGuest == JNI_TRUE ? 1 : 0); int ret = sBluetoothInterface->enable(); return (ret == BT_STATUS_SUCCESS || ret == BT_STATUS_DONE) ? JNI_TRUE : JNI_FALSE; } Loading Loading @@ -1237,9 +1240,9 @@ static jbyteArray obfuscateAddressNative(JNIEnv* env, jobject obj, static JNINativeMethod sMethods[] = { /* name, signature, funcPtr */ {"classInitNative", "()V", (void*)classInitNative}, {"initNative", "()Z", (void*)initNative}, {"initNative", "(ZZ)Z", (void*)initNative}, {"cleanupNative", "()V", (void*)cleanupNative}, {"enableNative", "(Z)Z", (void*)enableNative}, {"enableNative", "()Z", (void*)enableNative}, {"disableNative", "()Z", (void*)disableNative}, {"setAdapterPropertyNative", "(I[B)Z", (void*)setAdapterPropertyNative}, {"getAdapterPropertiesNative", "()Z", (void*)getAdapterPropertiesNative}, Loading
android/app/src/com/android/bluetooth/btservice/AdapterService.java +10 −9 Original line number Diff line number Diff line Loading @@ -286,7 +286,7 @@ public class AdapterService extends Service { } mRunningProfiles.add(profile); if (GattService.class.getSimpleName().equals(profile.getName())) { enableNativeWithGuestFlag(); enableNative(); } else if (mRegisteredProfiles.size() == Config.getSupportedProfiles().length && mRegisteredProfiles.size() == mRunningProfiles.size()) { mAdapterProperties.onBluetoothReady(); Loading Loading @@ -393,7 +393,7 @@ public class AdapterService extends Service { mAdapterProperties = new AdapterProperties(this); mAdapterStateMachine = AdapterState.make(this); mJniCallbacks = new JniCallbacks(this, mAdapterProperties); initNative(); initNative(isGuest(), isSingleUserMode()); mNativeAvailable = true; mCallbacks = new RemoteCallbackList<IBluetoothCallback>(); mAppOps = getSystemService(AppOpsManager.class); Loading Loading @@ -2853,11 +2853,12 @@ public class AdapterService extends Service { } }; private void enableNativeWithGuestFlag() { boolean isGuest = UserManager.get(this).isGuestUser(); if (!enableNative(isGuest)) { Log.e(TAG, "enableNative() returned false"); private boolean isGuest() { return UserManager.get(this).isGuestUser(); } private boolean isSingleUserMode() { return UserManager.get(this).hasUserRestriction(UserManager.DISALLOW_ADD_USER); } /** Loading @@ -2876,12 +2877,12 @@ public class AdapterService extends Service { static native void classInitNative(); native boolean initNative(); native boolean initNative(boolean startRestricted, boolean isSingleUserMode); native void cleanupNative(); /*package*/ native boolean enableNative(boolean startRestricted); native boolean enableNative(); /*package*/ native boolean disableNative(); Loading
android/app/tests/unit/src/com/android/bluetooth/btservice/AdapterServiceTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -101,7 +101,7 @@ public class AdapterServiceTest { } Assert.assertNotNull(Looper.myLooper()); AdapterService adapterService = new AdapterService(); adapterService.initNative(); adapterService.initNative(false /* is_restricted */, false /* is_single_user_mode */); adapterService.cleanupNative(); HashMap<String, HashMap<String, String>> adapterConfig = TestUtils.readAdapterConfig(); Assert.assertNotNull(adapterConfig); Loading
android/app/tests/unit/src/com/android/bluetooth/btservice/ProfileServiceTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -96,7 +96,7 @@ public class ProfileServiceTest { mProfiles = Config.getSupportedProfiles(); mMockAdapterService.initNative(); mMockAdapterService.initNative(false /* is_restricted */, false /* is_single_user_mode */); TestUtils.setAdapterService(mMockAdapterService); Loading