Dialer: Fix calls
We need two more permissions and explicitly advertise that we are indeed
starting the service for calls
Change-Id: Id39e4a8074d0714372195d07d50f89d6189f0f62
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index e08dfc3..ba591d2 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -23,7 +23,11 @@
android:minSdkVersion="30"
android:targetSdkVersion="30"/>
+ <uses-feature
+ android:name="android.hardware.telephony"
+ android:required="false" />
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.CALL_PHONE"/>
@@ -85,6 +89,9 @@
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAPTURE_AUDIO_OUTPUT" />
+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE_PHONE_CALL"/>
+
<application
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
diff --git a/java/com/android/incallui/AndroidManifest.xml b/java/com/android/incallui/AndroidManifest.xml
index 2ce765f..1ee4a65 100644
--- a/java/com/android/incallui/AndroidManifest.xml
+++ b/java/com/android/incallui/AndroidManifest.xml
@@ -88,7 +88,8 @@
android:directBootAware="true"
android:exported="true"
android:name="com.android.incallui.InCallServiceImpl"
- android:permission="android.permission.BIND_INCALL_SERVICE">
+ android:permission="android.permission.BIND_INCALL_SERVICE"
+ android:foregroundServiceType="phoneCall">
<meta-data
android:name="android.telecom.IN_CALL_SERVICE_UI"
android:value="true"/>
diff --git a/java/com/android/incallui/call/TelecomAdapter.java b/java/com/android/incallui/call/TelecomAdapter.java
index bce0d47..507f64d 100644
--- a/java/com/android/incallui/call/TelecomAdapter.java
+++ b/java/com/android/incallui/call/TelecomAdapter.java
@@ -17,9 +17,11 @@
package com.android.incallui.call;
import android.app.Notification;
+import android.app.Service;
import android.bluetooth.BluetoothDevice;
import android.content.ActivityNotFoundException;
import android.content.Intent;
+import android.content.pm.ServiceInfo;
import android.os.Looper;
import android.telecom.InCallService;
@@ -176,7 +178,7 @@
public void startForegroundNotification(int id, Notification notification) {
Assert.isNotNull(
inCallService, "No inCallService available for starting foreground notification");
- inCallService.startForeground(id, notification);
+ inCallService.startForeground(id, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL);
}
/**
@@ -184,7 +186,7 @@
*/
public void stopForegroundNotification() {
if (inCallService != null) {
- inCallService.stopForeground(true /*removeNotification*/);
+ inCallService.stopForeground(Service.STOP_FOREGROUND_REMOVE);
} else {
LogUtil.e(
"TelecomAdapter.stopForegroundNotification",