Loading android/app/AndroidManifest.xml +2 −1 Original line number Diff line number Diff line Loading @@ -80,7 +80,8 @@ android:supportsRtl="true" android:usesCleartextTraffic="false" android:directBootAware="true" android:defaultToDeviceProtectedStorage="true"> android:defaultToDeviceProtectedStorage="true" android:requestLegacyExternalStorage="true"> <uses-library android:name="javax.obex" /> <provider android:name=".opp.BluetoothOppProvider" android:authorities="com.android.bluetooth.opp" Loading android/app/PREUPLOAD.cfg +1 −0 Original line number Diff line number Diff line Loading @@ -9,3 +9,4 @@ checkstyle_hook = ${REPO_ROOT}/prebuilts/checkstyle/checkstyle.py --sha ${PREUPL -fw src/com/android/bluetooth/ lib/mapapi/com/android/bluetooth/mapapi/ tests/src/com/android/bluetooth/ aosp_first = ${REPO_ROOT}/frameworks/base/tools/aosp/aosp_sha.sh ${PREUPLOAD_COMMIT} ${PREUPLOAD_FILES} android/app/jni/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -43,4 +43,7 @@ cc_library_shared { "-Wextra", "-Wno-unused-parameter", ], sanitize: { scs: true, }, } android/app/jni/com_android_bluetooth.h +59 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,65 @@ public: return true; } // stolen from art/runtime/jni/check_jni.cc bool isValidUtf(const char* bytes) const { while (*bytes != '\0') { const uint8_t* utf8 = reinterpret_cast<const uint8_t*>(bytes++); // Switch on the high four bits. switch (*utf8 >> 4) { case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07: // Bit pattern 0xxx. No need for any extra bytes. break; case 0x08: case 0x09: case 0x0a: case 0x0b: // Bit patterns 10xx, which are illegal start bytes. return false; case 0x0f: // Bit pattern 1111, which might be the start of a 4 byte sequence. if ((*utf8 & 0x08) == 0) { // Bit pattern 1111 0xxx, which is the start of a 4 byte sequence. // We consume one continuation byte here, and fall through to // consume two more. utf8 = reinterpret_cast<const uint8_t*>(bytes++); if ((*utf8 & 0xc0) != 0x80) { return false; } } else { return false; } // Fall through to the cases below to consume two more continuation // bytes. FALLTHROUGH_INTENDED; case 0x0e: // Bit pattern 1110, so there are two additional bytes. utf8 = reinterpret_cast<const uint8_t*>(bytes++); if ((*utf8 & 0xc0) != 0x80) { return false; } // Fall through to consume one more continuation byte. FALLTHROUGH_INTENDED; case 0x0c: case 0x0d: // Bit pattern 110x, so there is one additional byte. utf8 = reinterpret_cast<const uint8_t*>(bytes++); if ((*utf8 & 0xc0) != 0x80) { return false; } break; } } return true; } JNIEnv *operator-> () const { return mCallbackEnv; } 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 Loading
android/app/AndroidManifest.xml +2 −1 Original line number Diff line number Diff line Loading @@ -80,7 +80,8 @@ android:supportsRtl="true" android:usesCleartextTraffic="false" android:directBootAware="true" android:defaultToDeviceProtectedStorage="true"> android:defaultToDeviceProtectedStorage="true" android:requestLegacyExternalStorage="true"> <uses-library android:name="javax.obex" /> <provider android:name=".opp.BluetoothOppProvider" android:authorities="com.android.bluetooth.opp" Loading
android/app/PREUPLOAD.cfg +1 −0 Original line number Diff line number Diff line Loading @@ -9,3 +9,4 @@ checkstyle_hook = ${REPO_ROOT}/prebuilts/checkstyle/checkstyle.py --sha ${PREUPL -fw src/com/android/bluetooth/ lib/mapapi/com/android/bluetooth/mapapi/ tests/src/com/android/bluetooth/ aosp_first = ${REPO_ROOT}/frameworks/base/tools/aosp/aosp_sha.sh ${PREUPLOAD_COMMIT} ${PREUPLOAD_FILES}
android/app/jni/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -43,4 +43,7 @@ cc_library_shared { "-Wextra", "-Wno-unused-parameter", ], sanitize: { scs: true, }, }
android/app/jni/com_android_bluetooth.h +59 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,65 @@ public: return true; } // stolen from art/runtime/jni/check_jni.cc bool isValidUtf(const char* bytes) const { while (*bytes != '\0') { const uint8_t* utf8 = reinterpret_cast<const uint8_t*>(bytes++); // Switch on the high four bits. switch (*utf8 >> 4) { case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07: // Bit pattern 0xxx. No need for any extra bytes. break; case 0x08: case 0x09: case 0x0a: case 0x0b: // Bit patterns 10xx, which are illegal start bytes. return false; case 0x0f: // Bit pattern 1111, which might be the start of a 4 byte sequence. if ((*utf8 & 0x08) == 0) { // Bit pattern 1111 0xxx, which is the start of a 4 byte sequence. // We consume one continuation byte here, and fall through to // consume two more. utf8 = reinterpret_cast<const uint8_t*>(bytes++); if ((*utf8 & 0xc0) != 0x80) { return false; } } else { return false; } // Fall through to the cases below to consume two more continuation // bytes. FALLTHROUGH_INTENDED; case 0x0e: // Bit pattern 1110, so there are two additional bytes. utf8 = reinterpret_cast<const uint8_t*>(bytes++); if ((*utf8 & 0xc0) != 0x80) { return false; } // Fall through to consume one more continuation byte. FALLTHROUGH_INTENDED; case 0x0c: case 0x0d: // Bit pattern 110x, so there is one additional byte. utf8 = reinterpret_cast<const uint8_t*>(bytes++); if ((*utf8 & 0xc0) != 0x80) { return false; } break; } } return true; } JNIEnv *operator-> () const { return mCallbackEnv; } 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