Loading jni/com_android_bluetooth_btservice_AdapterService.cpp +25 −3 Original line number Diff line number Diff line Loading @@ -680,7 +680,8 @@ static void classInitNative(JNIEnv* env, jclass clazz) { } static bool initNative(JNIEnv* env, jobject obj, jboolean isGuest, jboolean isNiapMode, int configCompareResult) { jboolean isNiapMode, int configCompareResult, jobjectArray initFlags) { ALOGV("%s", __func__); android_bluetooth_UidTraffic.clazz = Loading @@ -694,9 +695,30 @@ static bool initNative(JNIEnv* env, jobject obj, jboolean isGuest, return JNI_FALSE; } int flagCount = env->GetArrayLength(initFlags); jstring* flagObjs = new jstring[flagCount]; const char** flags = nullptr; if (flagCount > 0) { flags = new const char*[flagCount + 1]; flags[flagCount] = nullptr; } for (int i = 0; i < flagCount; i++) { flagObjs[i] = (jstring)env->GetObjectArrayElement(initFlags, i); flags[i] = env->GetStringUTFChars(flagObjs[i], NULL); } int ret = sBluetoothInterface->init( &sBluetoothCallbacks, isGuest == JNI_TRUE ? 1 : 0, isNiapMode == JNI_TRUE ? 1 : 0, configCompareResult); isNiapMode == JNI_TRUE ? 1 : 0, configCompareResult, flags); for (int i = 0; i < flagCount; i++) { env->ReleaseStringUTFChars(flagObjs[i], flags[i]); } delete[] flags; delete[] flagObjs; if (ret != BT_STATUS_SUCCESS) { ALOGE("Error while setting the callbacks: %d\n", ret); sBluetoothInterface = NULL; Loading Loading @@ -1312,7 +1334,7 @@ static int getMetricIdNative(JNIEnv* env, jobject obj, jbyteArray address) { static JNINativeMethod sMethods[] = { /* name, signature, funcPtr */ {"classInitNative", "()V", (void*)classInitNative}, {"initNative", "(ZZI)Z", (void*)initNative}, {"initNative", "(ZZI[Ljava/lang/String;)Z", (void*)initNative}, {"cleanupNative", "()V", (void*)cleanupNative}, {"enableNative", "()Z", (void*)enableNative}, {"disableNative", "()Z", (void*)disableNative}, Loading src/com/android/bluetooth/btservice/AdapterService.java +13 −3 Original line number Diff line number Diff line Loading @@ -69,6 +69,7 @@ import android.os.SystemClock; import android.os.SystemProperties; import android.os.UserHandle; import android.os.UserManager; import android.provider.DeviceConfig; import android.provider.Settings; import android.text.TextUtils; import android.util.Base64; Loading Loading @@ -439,7 +440,7 @@ public class AdapterService extends Service { mBluetoothKeystoreService = new BluetoothKeystoreService(isNiapMode()); mBluetoothKeystoreService.start(); int configCompareResult = mBluetoothKeystoreService.getCompareResult(); initNative(isGuest(), isNiapMode(), configCompareResult); initNative(isGuest(), isNiapMode(), configCompareResult, getInitFlags()); mNativeAvailable = true; mCallbacks = new RemoteCallbackList<IBluetoothCallback>(); mAppOps = getSystemService(AppOpsManager.class); Loading Loading @@ -3009,6 +3010,15 @@ public class AdapterService extends Service { return Settings.Global.getInt(getContentResolver(), "niap_mode", 0) == 1; } private static final String GD_CORE_FLAG = "INIT_gd_core"; private String[] getInitFlags() { ArrayList<String> initFlags = new ArrayList<>(); if (DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_BLUETOOTH, GD_CORE_FLAG, false)) { initFlags.add(GD_CORE_FLAG); } return initFlags.toArray(new String[0]); } /** * Obfuscate Bluetooth MAC address into a PII free ID string * Loading Loading @@ -3038,8 +3048,8 @@ public class AdapterService extends Service { static native void classInitNative(); native boolean initNative(boolean startRestricted, boolean isNiapMode, int configCompareResult); native boolean initNative(boolean startRestricted, boolean isNiapMode, int configCompareResult, String[] initFlags); native void cleanupNative(); Loading tests/unit/src/com/android/bluetooth/btservice/AdapterServiceTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -107,7 +107,7 @@ public class AdapterServiceTest { Assert.assertNotNull(Looper.myLooper()); AdapterService adapterService = new AdapterService(); adapterService.initNative(false /* is_restricted */, false /* is_niap_mode */, 0 /* config_compare_result */); 0 /* config_compare_result */, new String[0]); adapterService.cleanupNative(); HashMap<String, HashMap<String, String>> adapterConfig = TestUtils.readAdapterConfig(); Assert.assertNotNull(adapterConfig); Loading tests/unit/src/com/android/bluetooth/btservice/ProfileServiceTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -97,7 +97,7 @@ public class ProfileServiceTest { mProfiles = Config.getSupportedProfiles(); mMockAdapterService.initNative(false /* is_restricted */, false /* is_niap_mode */, 0 /* config_compare_result */); 0 /* config_compare_result */, new String[0]); TestUtils.setAdapterService(mMockAdapterService); Loading Loading
jni/com_android_bluetooth_btservice_AdapterService.cpp +25 −3 Original line number Diff line number Diff line Loading @@ -680,7 +680,8 @@ static void classInitNative(JNIEnv* env, jclass clazz) { } static bool initNative(JNIEnv* env, jobject obj, jboolean isGuest, jboolean isNiapMode, int configCompareResult) { jboolean isNiapMode, int configCompareResult, jobjectArray initFlags) { ALOGV("%s", __func__); android_bluetooth_UidTraffic.clazz = Loading @@ -694,9 +695,30 @@ static bool initNative(JNIEnv* env, jobject obj, jboolean isGuest, return JNI_FALSE; } int flagCount = env->GetArrayLength(initFlags); jstring* flagObjs = new jstring[flagCount]; const char** flags = nullptr; if (flagCount > 0) { flags = new const char*[flagCount + 1]; flags[flagCount] = nullptr; } for (int i = 0; i < flagCount; i++) { flagObjs[i] = (jstring)env->GetObjectArrayElement(initFlags, i); flags[i] = env->GetStringUTFChars(flagObjs[i], NULL); } int ret = sBluetoothInterface->init( &sBluetoothCallbacks, isGuest == JNI_TRUE ? 1 : 0, isNiapMode == JNI_TRUE ? 1 : 0, configCompareResult); isNiapMode == JNI_TRUE ? 1 : 0, configCompareResult, flags); for (int i = 0; i < flagCount; i++) { env->ReleaseStringUTFChars(flagObjs[i], flags[i]); } delete[] flags; delete[] flagObjs; if (ret != BT_STATUS_SUCCESS) { ALOGE("Error while setting the callbacks: %d\n", ret); sBluetoothInterface = NULL; Loading Loading @@ -1312,7 +1334,7 @@ static int getMetricIdNative(JNIEnv* env, jobject obj, jbyteArray address) { static JNINativeMethod sMethods[] = { /* name, signature, funcPtr */ {"classInitNative", "()V", (void*)classInitNative}, {"initNative", "(ZZI)Z", (void*)initNative}, {"initNative", "(ZZI[Ljava/lang/String;)Z", (void*)initNative}, {"cleanupNative", "()V", (void*)cleanupNative}, {"enableNative", "()Z", (void*)enableNative}, {"disableNative", "()Z", (void*)disableNative}, Loading
src/com/android/bluetooth/btservice/AdapterService.java +13 −3 Original line number Diff line number Diff line Loading @@ -69,6 +69,7 @@ import android.os.SystemClock; import android.os.SystemProperties; import android.os.UserHandle; import android.os.UserManager; import android.provider.DeviceConfig; import android.provider.Settings; import android.text.TextUtils; import android.util.Base64; Loading Loading @@ -439,7 +440,7 @@ public class AdapterService extends Service { mBluetoothKeystoreService = new BluetoothKeystoreService(isNiapMode()); mBluetoothKeystoreService.start(); int configCompareResult = mBluetoothKeystoreService.getCompareResult(); initNative(isGuest(), isNiapMode(), configCompareResult); initNative(isGuest(), isNiapMode(), configCompareResult, getInitFlags()); mNativeAvailable = true; mCallbacks = new RemoteCallbackList<IBluetoothCallback>(); mAppOps = getSystemService(AppOpsManager.class); Loading Loading @@ -3009,6 +3010,15 @@ public class AdapterService extends Service { return Settings.Global.getInt(getContentResolver(), "niap_mode", 0) == 1; } private static final String GD_CORE_FLAG = "INIT_gd_core"; private String[] getInitFlags() { ArrayList<String> initFlags = new ArrayList<>(); if (DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_BLUETOOTH, GD_CORE_FLAG, false)) { initFlags.add(GD_CORE_FLAG); } return initFlags.toArray(new String[0]); } /** * Obfuscate Bluetooth MAC address into a PII free ID string * Loading Loading @@ -3038,8 +3048,8 @@ public class AdapterService extends Service { static native void classInitNative(); native boolean initNative(boolean startRestricted, boolean isNiapMode, int configCompareResult); native boolean initNative(boolean startRestricted, boolean isNiapMode, int configCompareResult, String[] initFlags); native void cleanupNative(); Loading
tests/unit/src/com/android/bluetooth/btservice/AdapterServiceTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -107,7 +107,7 @@ public class AdapterServiceTest { Assert.assertNotNull(Looper.myLooper()); AdapterService adapterService = new AdapterService(); adapterService.initNative(false /* is_restricted */, false /* is_niap_mode */, 0 /* config_compare_result */); 0 /* config_compare_result */, new String[0]); adapterService.cleanupNative(); HashMap<String, HashMap<String, String>> adapterConfig = TestUtils.readAdapterConfig(); Assert.assertNotNull(adapterConfig); Loading
tests/unit/src/com/android/bluetooth/btservice/ProfileServiceTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -97,7 +97,7 @@ public class ProfileServiceTest { mProfiles = Config.getSupportedProfiles(); mMockAdapterService.initNative(false /* is_restricted */, false /* is_niap_mode */, 0 /* config_compare_result */); 0 /* config_compare_result */, new String[0]); TestUtils.setAdapterService(mMockAdapterService); Loading