Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,23 @@
android:exported="false"
android:label="@string/title_activity_about" />

<service android:name=".local.subscription.services.SubscriptionsImportService" />
<service android:name=".local.subscription.services.SubscriptionsExportService" />
<service android:name=".local.feed.service.FeedLoadService"
<service
android:name=".local.subscription.services.SubscriptionsImportService"
android:foregroundServiceType="dataSync" />

<service
android:name=".local.subscription.services.SubscriptionsExportService"
android:foregroundServiceType="dataSync" />

<service
android:name=".local.feed.service.FeedLoadService"
android:foregroundServiceType="dataSync" />

<service
android:name="androidx.work.impl.foreground.SystemForegroundService"
android:foregroundServiceType="dataSync"
tools:node="merge" />

<activity
android:name=".PanicResponderActivity"
android:exported="true"
Expand Down Expand Up @@ -425,6 +437,7 @@
</activity>
<service
android:name=".RouterActivity$FetcherService"
android:foregroundServiceType="dataSync"
android:exported="false" />

<!-- opting out of sending metrics to Google in Android System WebView -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.schabi.newpipe.local.feed.notifications

import android.content.Context
import android.content.pm.ServiceInfo
import android.util.Log
import androidx.core.app.NotificationCompat
import androidx.work.Constraints
Expand Down Expand Up @@ -83,7 +84,9 @@ class NotificationWorker(
.setPriority(NotificationCompat.PRIORITY_LOW)
.setContentTitle(applicationContext.getString(R.string.feed_notification_loading))
.build()
setForegroundAsync(ForegroundInfo(FeedLoadService.NOTIFICATION_ID, notification))
@Suppress("NewApi") // ServiceInfo constant is inlined
val serviceType = ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC
setForegroundAsync(ForegroundInfo(FeedLoadService.NOTIFICATION_ID, notification, serviceType))
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,19 +167,15 @@ public boolean shouldUpdateBufferingSlot() {
&& notificationBuilder.mActions.get(2).actionIntent != null);
}


@SuppressLint("NewApi") // ServiceInfo constant is inlined
Comment thread
Isira-Seneviratne marked this conversation as resolved.
Outdated
public void createNotificationAndStartForeground() {
if (notificationBuilder == null) {
notificationBuilder = createNotification();
}
updateNotification();

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
player.getService().startForeground(NOTIFICATION_ID, notificationBuilder.build(),
ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK);
} else {
player.getService().startForeground(NOTIFICATION_ID, notificationBuilder.build());
}
ServiceCompat.startForeground(player.getService(), NOTIFICATION_ID,
notificationBuilder.build(), ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK);
}

public void cancelNotificationAndStopForeground() {
Expand Down