--- AppRTCBluetoothManager.orig.java +++ AppRTCBluetoothManager.java @@ -7,7 +7,7 @@ * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ -package org.appspot.apprtc; +package com.zxcpoiu.incallmanager.AppRTC; import android.annotation.SuppressLint; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; @@ -19,6 +19,7 @@ import android.content.IntentFilter; import android.content.pm.PackageManager; import android.media.AudioManager; +import android.os.Build; import android.os.Handler; import android.os.Looper; import android.os.Process; @@ -26,8 +27,9 @@ import androidx.annotation.Nullable; import java.util.List; import java.util.Set; -import org.appspot.apprtc.util.AppRTCUtils; -import org.webrtc.ThreadUtils; +import com.zxcpoiu.incallmanager.AppRTC.AppRTCUtils; +import com.zxcpoiu.incallmanager.AppRTC.ThreadUtils; +import com.zxcpoiu.incallmanager.InCallManagerModule; /** * AppRTCProximitySensor manages functions related to Bluetoth devices in the * AppRTC demo. @@ -58,7 +60,7 @@ SCO_CONNECTED } private final Context apprtcContext; - private final AppRTCAudioManager apprtcAudioManager; + private final InCallManagerModule apprtcAudioManager; @Nullable private final AudioManager audioManager; private final Handler handler; @@ -183,11 +185,11 @@ } } /** Construction. */ - static AppRTCBluetoothManager create(Context context, AppRTCAudioManager audioManager) { + public static AppRTCBluetoothManager create(Context context, InCallManagerModule audioManager) { Log.d(TAG, "create" + AppRTCUtils.getThreadInfo()); return new AppRTCBluetoothManager(context, audioManager); } - protected AppRTCBluetoothManager(Context context, AppRTCAudioManager audioManager) { + protected AppRTCBluetoothManager(Context context, InCallManagerModule audioManager) { Log.d(TAG, "ctor"); ThreadUtils.checkIsOnMainThread(); apprtcContext = context; @@ -219,7 +221,8 @@ public void start() { ThreadUtils.checkIsOnMainThread(); Log.d(TAG, "start"); - if (!hasPermission(apprtcContext, android.Manifest.permission.BLUETOOTH)) { + String p = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S ? android.Manifest.permission.BLUETOOTH_CONNECT : android.Manifest.permission.BLUETOOTH; + if (!hasPermission(apprtcContext, p)) { Log.w(TAG, "Process (pid=" + Process.myPid() + ") lacks BLUETOOTH permission"); return; }