@Override public void setServiceForeground(ComponentName className, IBinder token, int id, Notification notification, boolean removeNotification, int userId) { ServiceRecord r = (ServiceRecord) token; if (r != null) { if (id != 0) { if (notification == null) { throw new IllegalArgumentException("null notification"); } if (r.foregroundId != id) { if (r.foregroundId != 0) { cancelNotification(userId, r.foregroundId, r.serviceInfo.packageName); } r.foregroundId = id; } r.foregroundNoti = notification; postNotification(userId, id, r.serviceInfo.packageName, notification); } else { if (removeNotification) { cancelNotification(userId, r.foregroundId, r.serviceInfo.packageName); r.foregroundId = 0; r.foregroundNoti = null; } } } }
@Override public void setServiceForeground(ComponentName className, IBinder token, int id, Notification notification, boolean removeNotification, int userId) { ServiceRecord r = (ServiceRecord) token; if (r != null) { if (id != 0) { if (notification == null) { throw new IllegalArgumentException("null notification"); } if (r.foregroundId != id) { if (r.foregroundId != 0) { cancelNotification(userId, r.foregroundId, r.serviceInfo.packageName); } r.foregroundId = id; } r.foregroundNoti = notification; postNotification(userId, id, r.serviceInfo.packageName, notification); } else { if (removeNotification) { cancelNotification(userId, r.foregroundId, r.serviceInfo.packageName); r.foregroundId = 0; r.foregroundNoti = null; } } } }
@Override public void setServiceForeground(ComponentName className, IBinder token, int id, Notification notification, boolean removeNotification, int userId) { ServiceRecord r = (ServiceRecord) token; if (r != null) { if (id != 0) { if (notification == null) { throw new IllegalArgumentException("null notification"); } if (r.foregroundId != id) { if (r.foregroundId != 0) { cancelNotification(userId, r.foregroundId, r.serviceInfo.packageName); } r.foregroundId = id; } r.foregroundNoti = notification; postNotification(userId, id, r.serviceInfo.packageName, notification); } else { if (removeNotification) { cancelNotification(userId, r.foregroundId, r.serviceInfo.packageName); r.foregroundId = 0; r.foregroundNoti = null; } } } }