Commit a992a511 authored by Xing Liu's avatar Xing Liu Committed by Commit Bot

Upstream ForegroundServiceUtils.

ForegroundServiceUtils.startForeground is put to downstream when Android
Q sdk is not published. Now the default SDK is Q, so we can upstream it
now.

There will be 2 following CLs to delete the function in AppHooks.java.

TBR=dtrainor@chromium.org

Bug: 1051183
Change-Id: I1d2f43c4c102c4f60073e3c6dc882f9cce885ec6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2051171Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
Commit-Queue: Xing Liu <xingliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#740449}
parent 9bda72c3
......@@ -7,6 +7,7 @@ package org.chromium.chrome.browser.notifications;
import android.app.Notification;
import android.app.Service;
import android.content.Intent;
import android.os.Build;
import android.support.v4.app.ServiceCompat;
import android.support.v4.content.ContextCompat;
......@@ -14,7 +15,6 @@ import androidx.annotation.VisibleForTesting;
import org.chromium.base.ContextUtils;
import org.chromium.base.Log;
import org.chromium.chrome.browser.AppHooks;
/**
* Utility functions that call into Android foreground service related API, and provides
......@@ -68,8 +68,11 @@ public class ForegroundServiceUtils {
// If android fail to build the notification, do nothing.
if (notification == null) return;
// TODO(xingliu): Remove startForeground call from AppHooks when Q sdk is available.
AppHooks.get().startForeground(service, id, notification, foregroundServiceType);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
service.startForeground(id, notification, foregroundServiceType);
} else {
service.startForeground(id, notification);
}
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment