summaryrefslogtreecommitdiff
path: root/java/com/android/incallui/call/TelecomAdapter.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/com/android/incallui/call/TelecomAdapter.java')
-rw-r--r--java/com/android/incallui/call/TelecomAdapter.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/java/com/android/incallui/call/TelecomAdapter.java b/java/com/android/incallui/call/TelecomAdapter.java
index 005278bff..0c0bbd473 100644
--- a/java/com/android/incallui/call/TelecomAdapter.java
+++ b/java/com/android/incallui/call/TelecomAdapter.java
@@ -16,12 +16,14 @@
package com.android.incallui.call;
+import android.app.Notification;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.os.Looper;
import android.support.annotation.MainThread;
import android.support.annotation.VisibleForTesting;
import android.telecom.InCallService;
+import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
import java.util.List;
@@ -167,4 +169,24 @@ public class TelecomAdapter implements InCallServiceListener {
}
return false;
}
+
+ /**
+ * Start a foreground notification. Calling it multiple times with the same id only updates the
+ * existing notification. Whoever called this function are responsible for calling {@link
+ * #stopForegroundNotification()} to remove the notification.
+ */
+ public void startForegroundNotification(int id, Notification notification) {
+ Assert.isNotNull(
+ mInCallService, "No inCallService available for starting foreground notification");
+ mInCallService.startForeground(id, notification);
+ }
+
+ /**
+ * Stop a started foreground notification. This does not stop {@code mInCallService} from running.
+ */
+ public void stopForegroundNotification() {
+ Assert.isNotNull(
+ mInCallService, "No inCallService available for stopping foreground notification");
+ mInCallService.stopForeground(true /*removeNotification*/);
+ }
}