Commit 73e27544 authored by Geoffrey Métais's avatar Geoffrey Métais

Force mediaparsingservice foreground on start

For Oreo+ devices
parent f3b541c4
......@@ -110,13 +110,13 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
exitCommand();
return START_NOT_STICKY;
}
synchronized (MediaParsingService.this) {
// Set 1s delay before displaying scan icon
// Except for Android 8+ which expects startForeground immediately
if (mLastNotificationTime <= 0L)
if (mLastNotificationTime == 0L && AndroidUtil.isOOrLater) forceForeground();
if (mLastNotificationTime <= 0L) {
synchronized (MediaParsingService.this) {
// Set 1s delay before displaying scan icon
// Except for Android 8+ which expects startForeground immediately
mLastNotificationTime = AndroidUtil.isOOrLater ? 0L : System.currentTimeMillis();
if (AndroidUtil.isOOrLater)
showNotification();
}
}
switch (intent.getAction()) {
case Constants.ACTION_INIT:
......@@ -142,6 +142,11 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
return START_NOT_STICKY;
}
private void forceForeground() {
final Notification notification = NotificationHelper.createScanNotification(this, getString(R.string.loading_medialibrary), false, mScanPaused);
startForeground(43, notification);
}
private void discoverStorage(final String path) {
if (BuildConfig.DEBUG) Log.d(TAG, "discoverStorage: "+path);
if (TextUtils.isEmpty(path)) {
......
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