Merge "Switching to the relevant SystemApi instead of the the @hide API"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 12481af..d9c23c5 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -45,6 +45,10 @@
     <uses-permission android:name="android.permission.MODIFY_AUDIO_ROUTING"/>
     <uses-permission android:name="android.permission.MODIFY_PHONE_STATE"/>
     <uses-permission android:name="android.permission.READ_CALL_LOG"/>
+    <!-- Required to check for direct to voicemail, to load custom ringtones for incoming calls
+        which are specified on a per contact basis, and also to determine user preferred
+        PhoneAccountHandles for outgoing calls. -->
+    <uses-permission android:name="android.permission.READ_CONTACTS"/>
     <uses-permission android:name="android.permission.READ_DEVICE_CONFIG"/>
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
     <uses-permission android:name="android.permission.READ_PROJECTION_STATE"/>
diff --git a/src/com/android/server/telecom/TelecomSystem.java b/src/com/android/server/telecom/TelecomSystem.java
index a7442a9..67e3be4 100644
--- a/src/com/android/server/telecom/TelecomSystem.java
+++ b/src/com/android/server/telecom/TelecomSystem.java
@@ -233,7 +233,7 @@
                         }
                     });
             BluetoothDeviceManager bluetoothDeviceManager = new BluetoothDeviceManager(mContext,
-                    new BluetoothManager(mContext).getAdapter());
+                    mContext.getSystemService(BluetoothManager.class).getAdapter());
             BluetoothRouteManager bluetoothRouteManager = new BluetoothRouteManager(mContext, mLock,
                     bluetoothDeviceManager, new Timeouts.Adapter());
             BluetoothStateReceiver bluetoothStateReceiver = new BluetoothStateReceiver(
diff --git a/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java b/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java
index 7f462d4..51e1d35 100644
--- a/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java
+++ b/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java
@@ -39,6 +39,7 @@
 import static org.mockito.Mockito.when;
 
 import android.app.AppOpsManager;
+import android.bluetooth.BluetoothManager;
 import android.content.BroadcastReceiver;
 import android.content.ComponentName;
 import android.content.ContentResolver;
@@ -348,6 +349,7 @@
         doNothing().when(mSpyContext).sendBroadcastAsUser(any(), any(), any());
 
         doReturn(mock(AppOpsManager.class)).when(mSpyContext).getSystemService(AppOpsManager.class);
+        doReturn(mock(BluetoothManager.class)).when(mSpyContext).getSystemService(BluetoothManager.class);
 
         mHandlerThread = new HandlerThread("TelecomHandlerThread");
         mHandlerThread.start();