Loading android/app/jni/com_android_bluetooth_a2dp.cpp +43 −22 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include "utils/Log.h" #include <string.h> #include <shared_mutex> namespace android { static jmethodID method_onConnectionStateChanged; Loading @@ -44,14 +45,19 @@ static struct { jmethodID getCodecSpecific4; } android_bluetooth_BluetoothCodecConfig; static const btav_source_interface_t* sBluetoothA2dpInterface = NULL; static jobject mCallbacksObj = NULL; static const btav_source_interface_t* sBluetoothA2dpInterface = nullptr; static std::shared_timed_mutex interface_mutex; static jobject mCallbacksObj = nullptr; static std::shared_timed_mutex callbacks_mutex; static void bta2dp_connection_state_callback(btav_connection_state_t state, RawAddress* bd_addr) { ALOGI("%s", __func__); std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex); CallbackEnv sCallbackEnv(__func__); if (!sCallbackEnv.valid()) return; if (!sCallbackEnv.valid() || mCallbacksObj == nullptr) return; ScopedLocalRef<jbyteArray> addr( sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress))); Loading @@ -69,8 +75,10 @@ static void bta2dp_connection_state_callback(btav_connection_state_t state, static void bta2dp_audio_state_callback(btav_audio_state_t state, RawAddress* bd_addr) { ALOGI("%s", __func__); std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex); CallbackEnv sCallbackEnv(__func__); if (!sCallbackEnv.valid()) return; if (!sCallbackEnv.valid() || mCallbacksObj == nullptr) return; ScopedLocalRef<jbyteArray> addr( sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress))); Loading @@ -90,8 +98,10 @@ static void bta2dp_audio_config_callback( std::vector<btav_a2dp_codec_config_t> codecs_local_capabilities, std::vector<btav_a2dp_codec_config_t> codecs_selectable_capabilities) { ALOGI("%s", __func__); std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex); CallbackEnv sCallbackEnv(__func__); if (!sCallbackEnv.valid()) return; if (!sCallbackEnv.valid() || mCallbacksObj == nullptr) return; jobject codecConfigObj = sCallbackEnv->NewObject( android_bluetooth_BluetoothCodecConfig.clazz, Loading @@ -106,7 +116,7 @@ static void bta2dp_audio_config_callback( jsize i = 0; jobjectArray local_capabilities_array = sCallbackEnv->NewObjectArray( (jsize)codecs_local_capabilities.size(), android_bluetooth_BluetoothCodecConfig.clazz, NULL); android_bluetooth_BluetoothCodecConfig.clazz, nullptr); for (auto const& cap : codecs_local_capabilities) { jobject capObj = sCallbackEnv->NewObject( android_bluetooth_BluetoothCodecConfig.clazz, Loading @@ -122,7 +132,7 @@ static void bta2dp_audio_config_callback( i = 0; jobjectArray selectable_capabilities_array = sCallbackEnv->NewObjectArray( (jsize)codecs_selectable_capabilities.size(), android_bluetooth_BluetoothCodecConfig.clazz, NULL); android_bluetooth_BluetoothCodecConfig.clazz, nullptr); for (auto const& cap : codecs_selectable_capabilities) { jobject capObj = sCallbackEnv->NewObject( android_bluetooth_BluetoothCodecConfig.clazz, Loading Loading @@ -237,25 +247,28 @@ static std::vector<btav_a2dp_codec_config_t> prepareCodecPreferences( static void initNative(JNIEnv* env, jobject object, jobjectArray codecConfigArray) { std::unique_lock<std::shared_timed_mutex> interface_lock(interface_mutex); std::unique_lock<std::shared_timed_mutex> callbacks_lock(callbacks_mutex); const bt_interface_t* btInf = getBluetoothInterface(); if (btInf == NULL) { if (btInf == nullptr) { ALOGE("Bluetooth module is not loaded"); return; } if (sBluetoothA2dpInterface != NULL) { if (sBluetoothA2dpInterface != nullptr) { ALOGW("Cleaning up A2DP Interface before initializing..."); sBluetoothA2dpInterface->cleanup(); sBluetoothA2dpInterface = NULL; sBluetoothA2dpInterface = nullptr; } if (mCallbacksObj != NULL) { if (mCallbacksObj != nullptr) { ALOGW("Cleaning up A2DP callback object"); env->DeleteGlobalRef(mCallbacksObj); mCallbacksObj = NULL; mCallbacksObj = nullptr; } if ((mCallbacksObj = env->NewGlobalRef(object)) == NULL) { if ((mCallbacksObj = env->NewGlobalRef(object)) == nullptr) { ALOGE("Failed to allocate Global Ref for A2DP Callbacks"); return; } Loading @@ -270,7 +283,7 @@ static void initNative(JNIEnv* env, jobject object, sBluetoothA2dpInterface = (btav_source_interface_t*)btInf->get_profile_interface( BT_PROFILE_ADVANCED_AUDIO_ID); if (sBluetoothA2dpInterface == NULL) { if (sBluetoothA2dpInterface == nullptr) { ALOGE("Failed to get Bluetooth A2DP Interface"); return; } Loading @@ -282,38 +295,42 @@ static void initNative(JNIEnv* env, jobject object, sBluetoothA2dpInterface->init(&sBluetoothA2dpCallbacks, codec_priorities); if (status != BT_STATUS_SUCCESS) { ALOGE("Failed to initialize Bluetooth A2DP, status: %d", status); sBluetoothA2dpInterface = NULL; sBluetoothA2dpInterface = nullptr; return; } } static void cleanupNative(JNIEnv* env, jobject object) { std::unique_lock<std::shared_timed_mutex> interface_lock(interface_mutex); std::unique_lock<std::shared_timed_mutex> callbacks_lock(callbacks_mutex); const bt_interface_t* btInf = getBluetoothInterface(); if (btInf == NULL) { if (btInf == nullptr) { ALOGE("Bluetooth module is not loaded"); return; } if (sBluetoothA2dpInterface != NULL) { if (sBluetoothA2dpInterface != nullptr) { sBluetoothA2dpInterface->cleanup(); sBluetoothA2dpInterface = NULL; sBluetoothA2dpInterface = nullptr; } env->DeleteGlobalRef(android_bluetooth_BluetoothCodecConfig.clazz); android_bluetooth_BluetoothCodecConfig.clazz = nullptr; if (mCallbacksObj != NULL) { if (mCallbacksObj != nullptr) { env->DeleteGlobalRef(mCallbacksObj); mCallbacksObj = NULL; mCallbacksObj = nullptr; } } static jboolean connectA2dpNative(JNIEnv* env, jobject object, jbyteArray address) { ALOGI("%s: sBluetoothA2dpInterface: %p", __func__, sBluetoothA2dpInterface); std::shared_lock<std::shared_timed_mutex> lock(interface_mutex); if (!sBluetoothA2dpInterface) return JNI_FALSE; jbyte* addr = env->GetByteArrayElements(address, NULL); jbyte* addr = env->GetByteArrayElements(address, nullptr); if (!addr) { jniThrowIOException(env, EINVAL); return JNI_FALSE; Loading @@ -329,9 +346,11 @@ static jboolean connectA2dpNative(JNIEnv* env, jobject object, static jboolean disconnectA2dpNative(JNIEnv* env, jobject object, jbyteArray address) { ALOGI("%s: sBluetoothA2dpInterface: %p", __func__, sBluetoothA2dpInterface); std::shared_lock<std::shared_timed_mutex> lock(interface_mutex); if (!sBluetoothA2dpInterface) return JNI_FALSE; jbyte* addr = env->GetByteArrayElements(address, NULL); jbyte* addr = env->GetByteArrayElements(address, nullptr); if (!addr) { jniThrowIOException(env, EINVAL); return JNI_FALSE; Loading @@ -347,6 +366,8 @@ static jboolean disconnectA2dpNative(JNIEnv* env, jobject object, static jboolean setCodecConfigPreferenceNative(JNIEnv* env, jobject object, jobjectArray codecConfigArray) { ALOGI("%s: sBluetoothA2dpInterface: %p", __func__, sBluetoothA2dpInterface); std::shared_lock<std::shared_timed_mutex> lock(interface_mutex); if (!sBluetoothA2dpInterface) return JNI_FALSE; std::vector<btav_a2dp_codec_config_t> codec_preferences = Loading android/app/src/com/android/bluetooth/Utils.java +11 −22 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.bluetooth; import android.app.ActivityManager; import android.app.ActivityThread; import android.app.AppOpsManager; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; Loading Loading @@ -221,8 +220,12 @@ public final class Utils { } } static int sSystemUiUid = UserHandle.USER_NULL; public static void setSystemUiUid(int uid) { Utils.sSystemUiUid = uid; } public static boolean checkCaller() { boolean ok; // Get the caller's user id then clear the calling identity // which will be restored in the finally clause. int callingUser = UserHandle.getCallingUserId(); Loading @@ -232,28 +235,20 @@ public final class Utils { try { // With calling identity cleared the current user is the foreground user. int foregroundUser = ActivityManager.getCurrentUser(); ok = (foregroundUser == callingUser); if (!ok) { // Always allow SystemUI/System access. final int systemUiUid = ActivityThread.getPackageManager() .getPackageUid("com.android.systemui", PackageManager.MATCH_SYSTEM_ONLY, UserHandle.USER_SYSTEM); ok = (systemUiUid == callingUid) || (Process.SYSTEM_UID == callingUid); } return (foregroundUser == callingUser) || (sSystemUiUid == callingUid) || (Process.SYSTEM_UID == callingUid); } catch (Exception ex) { Log.e(TAG, "checkIfCallerIsSelfOrForegroundUser: Exception ex=" + ex); ok = false; return false; } finally { Binder.restoreCallingIdentity(ident); } return ok; } public static boolean checkCallerAllowManagedProfiles(Context mContext) { if (mContext == null) { return checkCaller(); } boolean ok; // Get the caller's user id and if it's a managed profile, get it's parents // id, then clear the calling identity // which will be restored in the finally clause. Loading @@ -266,21 +261,15 @@ public final class Utils { int parentUser = (ui != null) ? ui.id : UserHandle.USER_NULL; // With calling identity cleared the current user is the foreground user. int foregroundUser = ActivityManager.getCurrentUser(); ok = (foregroundUser == callingUser) || (foregroundUser == parentUser); if (!ok) { // Always allow SystemUI/System access. final int systemUiUid = ActivityThread.getPackageManager() .getPackageUid("com.android.systemui", PackageManager.MATCH_SYSTEM_ONLY, UserHandle.USER_SYSTEM); ok = (systemUiUid == callingUid) || (Process.SYSTEM_UID == callingUid); } return (foregroundUser == callingUser) || (foregroundUser == parentUser) || (sSystemUiUid == callingUid) || (Process.SYSTEM_UID == callingUid); } catch (Exception ex) { Log.e(TAG, "checkCallerAllowManagedProfiles: Exception ex=" + ex); ok = false; return false; } finally { Binder.restoreCallingIdentity(ident); } return ok; } /** Loading android/app/src/com/android/bluetooth/btservice/AdapterService.java +11 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.os.AsyncTask; import android.os.BatteryStats; import android.os.Binder; Loading Loading @@ -445,6 +446,16 @@ public class AdapterService extends Service { return null; } }.execute(); try { int systemUiUid = getApplicationContext().getPackageManager().getPackageUidAsUser( "com.android.systemui", PackageManager.MATCH_SYSTEM_ONLY, UserHandle.USER_SYSTEM); Utils.setSystemUiUid(systemUiUid); } catch (PackageManager.NameNotFoundException e) { // Some platforms, such as wearables do not have a system ui. Log.w(TAG, "Unable to resolve SystemUI's UID.", e); } } @Override Loading android/app/src/com/android/bluetooth/btservice/PhonePolicy.java +3 −2 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.os.Looper; import android.os.Message; import android.os.ParcelUuid; import android.os.Parcelable; import android.support.annotation.VisibleForTesting; import android.util.Log; import com.android.bluetooth.a2dp.A2dpService; Loading Loading @@ -124,8 +125,8 @@ class PhonePolicy { } }; // ONLY for testing public BroadcastReceiver getBroadcastReceiver() { @VisibleForTesting BroadcastReceiver getBroadcastReceiver() { return mReceiver; } Loading android/app/src/com/android/bluetooth/hfpclient/HeadsetClientStateMachine.java +5 −0 Original line number Diff line number Diff line Loading @@ -578,6 +578,11 @@ public class HeadsetClientStateMachine extends StateMachine { BluetoothHeadsetClientCall c = getCall(BluetoothHeadsetClientCall.CALL_STATE_DIALING, BluetoothHeadsetClientCall.CALL_STATE_ALERTING, BluetoothHeadsetClientCall.CALL_STATE_ACTIVE); if (c == null) { // If the call being terminated is currently held, switch the action to CHLD_0 c = getCall(BluetoothHeadsetClientCall.CALL_STATE_HELD); action = HeadsetClientHalConstants.CALL_ACTION_CHLD_0; } if (c != null) { if (NativeInterface.handleCallActionNative(getByteAddress(mCurrentDevice), action, 0)) { addQueuedAction(TERMINATE_CALL, action); Loading Loading
android/app/jni/com_android_bluetooth_a2dp.cpp +43 −22 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include "utils/Log.h" #include <string.h> #include <shared_mutex> namespace android { static jmethodID method_onConnectionStateChanged; Loading @@ -44,14 +45,19 @@ static struct { jmethodID getCodecSpecific4; } android_bluetooth_BluetoothCodecConfig; static const btav_source_interface_t* sBluetoothA2dpInterface = NULL; static jobject mCallbacksObj = NULL; static const btav_source_interface_t* sBluetoothA2dpInterface = nullptr; static std::shared_timed_mutex interface_mutex; static jobject mCallbacksObj = nullptr; static std::shared_timed_mutex callbacks_mutex; static void bta2dp_connection_state_callback(btav_connection_state_t state, RawAddress* bd_addr) { ALOGI("%s", __func__); std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex); CallbackEnv sCallbackEnv(__func__); if (!sCallbackEnv.valid()) return; if (!sCallbackEnv.valid() || mCallbacksObj == nullptr) return; ScopedLocalRef<jbyteArray> addr( sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress))); Loading @@ -69,8 +75,10 @@ static void bta2dp_connection_state_callback(btav_connection_state_t state, static void bta2dp_audio_state_callback(btav_audio_state_t state, RawAddress* bd_addr) { ALOGI("%s", __func__); std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex); CallbackEnv sCallbackEnv(__func__); if (!sCallbackEnv.valid()) return; if (!sCallbackEnv.valid() || mCallbacksObj == nullptr) return; ScopedLocalRef<jbyteArray> addr( sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress))); Loading @@ -90,8 +98,10 @@ static void bta2dp_audio_config_callback( std::vector<btav_a2dp_codec_config_t> codecs_local_capabilities, std::vector<btav_a2dp_codec_config_t> codecs_selectable_capabilities) { ALOGI("%s", __func__); std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex); CallbackEnv sCallbackEnv(__func__); if (!sCallbackEnv.valid()) return; if (!sCallbackEnv.valid() || mCallbacksObj == nullptr) return; jobject codecConfigObj = sCallbackEnv->NewObject( android_bluetooth_BluetoothCodecConfig.clazz, Loading @@ -106,7 +116,7 @@ static void bta2dp_audio_config_callback( jsize i = 0; jobjectArray local_capabilities_array = sCallbackEnv->NewObjectArray( (jsize)codecs_local_capabilities.size(), android_bluetooth_BluetoothCodecConfig.clazz, NULL); android_bluetooth_BluetoothCodecConfig.clazz, nullptr); for (auto const& cap : codecs_local_capabilities) { jobject capObj = sCallbackEnv->NewObject( android_bluetooth_BluetoothCodecConfig.clazz, Loading @@ -122,7 +132,7 @@ static void bta2dp_audio_config_callback( i = 0; jobjectArray selectable_capabilities_array = sCallbackEnv->NewObjectArray( (jsize)codecs_selectable_capabilities.size(), android_bluetooth_BluetoothCodecConfig.clazz, NULL); android_bluetooth_BluetoothCodecConfig.clazz, nullptr); for (auto const& cap : codecs_selectable_capabilities) { jobject capObj = sCallbackEnv->NewObject( android_bluetooth_BluetoothCodecConfig.clazz, Loading Loading @@ -237,25 +247,28 @@ static std::vector<btav_a2dp_codec_config_t> prepareCodecPreferences( static void initNative(JNIEnv* env, jobject object, jobjectArray codecConfigArray) { std::unique_lock<std::shared_timed_mutex> interface_lock(interface_mutex); std::unique_lock<std::shared_timed_mutex> callbacks_lock(callbacks_mutex); const bt_interface_t* btInf = getBluetoothInterface(); if (btInf == NULL) { if (btInf == nullptr) { ALOGE("Bluetooth module is not loaded"); return; } if (sBluetoothA2dpInterface != NULL) { if (sBluetoothA2dpInterface != nullptr) { ALOGW("Cleaning up A2DP Interface before initializing..."); sBluetoothA2dpInterface->cleanup(); sBluetoothA2dpInterface = NULL; sBluetoothA2dpInterface = nullptr; } if (mCallbacksObj != NULL) { if (mCallbacksObj != nullptr) { ALOGW("Cleaning up A2DP callback object"); env->DeleteGlobalRef(mCallbacksObj); mCallbacksObj = NULL; mCallbacksObj = nullptr; } if ((mCallbacksObj = env->NewGlobalRef(object)) == NULL) { if ((mCallbacksObj = env->NewGlobalRef(object)) == nullptr) { ALOGE("Failed to allocate Global Ref for A2DP Callbacks"); return; } Loading @@ -270,7 +283,7 @@ static void initNative(JNIEnv* env, jobject object, sBluetoothA2dpInterface = (btav_source_interface_t*)btInf->get_profile_interface( BT_PROFILE_ADVANCED_AUDIO_ID); if (sBluetoothA2dpInterface == NULL) { if (sBluetoothA2dpInterface == nullptr) { ALOGE("Failed to get Bluetooth A2DP Interface"); return; } Loading @@ -282,38 +295,42 @@ static void initNative(JNIEnv* env, jobject object, sBluetoothA2dpInterface->init(&sBluetoothA2dpCallbacks, codec_priorities); if (status != BT_STATUS_SUCCESS) { ALOGE("Failed to initialize Bluetooth A2DP, status: %d", status); sBluetoothA2dpInterface = NULL; sBluetoothA2dpInterface = nullptr; return; } } static void cleanupNative(JNIEnv* env, jobject object) { std::unique_lock<std::shared_timed_mutex> interface_lock(interface_mutex); std::unique_lock<std::shared_timed_mutex> callbacks_lock(callbacks_mutex); const bt_interface_t* btInf = getBluetoothInterface(); if (btInf == NULL) { if (btInf == nullptr) { ALOGE("Bluetooth module is not loaded"); return; } if (sBluetoothA2dpInterface != NULL) { if (sBluetoothA2dpInterface != nullptr) { sBluetoothA2dpInterface->cleanup(); sBluetoothA2dpInterface = NULL; sBluetoothA2dpInterface = nullptr; } env->DeleteGlobalRef(android_bluetooth_BluetoothCodecConfig.clazz); android_bluetooth_BluetoothCodecConfig.clazz = nullptr; if (mCallbacksObj != NULL) { if (mCallbacksObj != nullptr) { env->DeleteGlobalRef(mCallbacksObj); mCallbacksObj = NULL; mCallbacksObj = nullptr; } } static jboolean connectA2dpNative(JNIEnv* env, jobject object, jbyteArray address) { ALOGI("%s: sBluetoothA2dpInterface: %p", __func__, sBluetoothA2dpInterface); std::shared_lock<std::shared_timed_mutex> lock(interface_mutex); if (!sBluetoothA2dpInterface) return JNI_FALSE; jbyte* addr = env->GetByteArrayElements(address, NULL); jbyte* addr = env->GetByteArrayElements(address, nullptr); if (!addr) { jniThrowIOException(env, EINVAL); return JNI_FALSE; Loading @@ -329,9 +346,11 @@ static jboolean connectA2dpNative(JNIEnv* env, jobject object, static jboolean disconnectA2dpNative(JNIEnv* env, jobject object, jbyteArray address) { ALOGI("%s: sBluetoothA2dpInterface: %p", __func__, sBluetoothA2dpInterface); std::shared_lock<std::shared_timed_mutex> lock(interface_mutex); if (!sBluetoothA2dpInterface) return JNI_FALSE; jbyte* addr = env->GetByteArrayElements(address, NULL); jbyte* addr = env->GetByteArrayElements(address, nullptr); if (!addr) { jniThrowIOException(env, EINVAL); return JNI_FALSE; Loading @@ -347,6 +366,8 @@ static jboolean disconnectA2dpNative(JNIEnv* env, jobject object, static jboolean setCodecConfigPreferenceNative(JNIEnv* env, jobject object, jobjectArray codecConfigArray) { ALOGI("%s: sBluetoothA2dpInterface: %p", __func__, sBluetoothA2dpInterface); std::shared_lock<std::shared_timed_mutex> lock(interface_mutex); if (!sBluetoothA2dpInterface) return JNI_FALSE; std::vector<btav_a2dp_codec_config_t> codec_preferences = Loading
android/app/src/com/android/bluetooth/Utils.java +11 −22 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.bluetooth; import android.app.ActivityManager; import android.app.ActivityThread; import android.app.AppOpsManager; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; Loading Loading @@ -221,8 +220,12 @@ public final class Utils { } } static int sSystemUiUid = UserHandle.USER_NULL; public static void setSystemUiUid(int uid) { Utils.sSystemUiUid = uid; } public static boolean checkCaller() { boolean ok; // Get the caller's user id then clear the calling identity // which will be restored in the finally clause. int callingUser = UserHandle.getCallingUserId(); Loading @@ -232,28 +235,20 @@ public final class Utils { try { // With calling identity cleared the current user is the foreground user. int foregroundUser = ActivityManager.getCurrentUser(); ok = (foregroundUser == callingUser); if (!ok) { // Always allow SystemUI/System access. final int systemUiUid = ActivityThread.getPackageManager() .getPackageUid("com.android.systemui", PackageManager.MATCH_SYSTEM_ONLY, UserHandle.USER_SYSTEM); ok = (systemUiUid == callingUid) || (Process.SYSTEM_UID == callingUid); } return (foregroundUser == callingUser) || (sSystemUiUid == callingUid) || (Process.SYSTEM_UID == callingUid); } catch (Exception ex) { Log.e(TAG, "checkIfCallerIsSelfOrForegroundUser: Exception ex=" + ex); ok = false; return false; } finally { Binder.restoreCallingIdentity(ident); } return ok; } public static boolean checkCallerAllowManagedProfiles(Context mContext) { if (mContext == null) { return checkCaller(); } boolean ok; // Get the caller's user id and if it's a managed profile, get it's parents // id, then clear the calling identity // which will be restored in the finally clause. Loading @@ -266,21 +261,15 @@ public final class Utils { int parentUser = (ui != null) ? ui.id : UserHandle.USER_NULL; // With calling identity cleared the current user is the foreground user. int foregroundUser = ActivityManager.getCurrentUser(); ok = (foregroundUser == callingUser) || (foregroundUser == parentUser); if (!ok) { // Always allow SystemUI/System access. final int systemUiUid = ActivityThread.getPackageManager() .getPackageUid("com.android.systemui", PackageManager.MATCH_SYSTEM_ONLY, UserHandle.USER_SYSTEM); ok = (systemUiUid == callingUid) || (Process.SYSTEM_UID == callingUid); } return (foregroundUser == callingUser) || (foregroundUser == parentUser) || (sSystemUiUid == callingUid) || (Process.SYSTEM_UID == callingUid); } catch (Exception ex) { Log.e(TAG, "checkCallerAllowManagedProfiles: Exception ex=" + ex); ok = false; return false; } finally { Binder.restoreCallingIdentity(ident); } return ok; } /** Loading
android/app/src/com/android/bluetooth/btservice/AdapterService.java +11 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.os.AsyncTask; import android.os.BatteryStats; import android.os.Binder; Loading Loading @@ -445,6 +446,16 @@ public class AdapterService extends Service { return null; } }.execute(); try { int systemUiUid = getApplicationContext().getPackageManager().getPackageUidAsUser( "com.android.systemui", PackageManager.MATCH_SYSTEM_ONLY, UserHandle.USER_SYSTEM); Utils.setSystemUiUid(systemUiUid); } catch (PackageManager.NameNotFoundException e) { // Some platforms, such as wearables do not have a system ui. Log.w(TAG, "Unable to resolve SystemUI's UID.", e); } } @Override Loading
android/app/src/com/android/bluetooth/btservice/PhonePolicy.java +3 −2 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.os.Looper; import android.os.Message; import android.os.ParcelUuid; import android.os.Parcelable; import android.support.annotation.VisibleForTesting; import android.util.Log; import com.android.bluetooth.a2dp.A2dpService; Loading Loading @@ -124,8 +125,8 @@ class PhonePolicy { } }; // ONLY for testing public BroadcastReceiver getBroadcastReceiver() { @VisibleForTesting BroadcastReceiver getBroadcastReceiver() { return mReceiver; } Loading
android/app/src/com/android/bluetooth/hfpclient/HeadsetClientStateMachine.java +5 −0 Original line number Diff line number Diff line Loading @@ -578,6 +578,11 @@ public class HeadsetClientStateMachine extends StateMachine { BluetoothHeadsetClientCall c = getCall(BluetoothHeadsetClientCall.CALL_STATE_DIALING, BluetoothHeadsetClientCall.CALL_STATE_ALERTING, BluetoothHeadsetClientCall.CALL_STATE_ACTIVE); if (c == null) { // If the call being terminated is currently held, switch the action to CHLD_0 c = getCall(BluetoothHeadsetClientCall.CALL_STATE_HELD); action = HeadsetClientHalConstants.CALL_ACTION_CHLD_0; } if (c != null) { if (NativeInterface.handleCallActionNative(getByteAddress(mCurrentDevice), action, 0)) { addQueuedAction(TERMINATE_CALL, action); Loading