From 9eada687ef863d3003607c9a9f19eefc982ea812 Mon Sep 17 00:00:00 2001 From: Courville Software Date: Sat, 14 Dec 2024 11:47:24 +0100 Subject: [PATCH] startForeground is no more: update comments --- .../video/VideoStoreImportService.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/com/archos/mediaprovider/video/VideoStoreImportService.java b/src/com/archos/mediaprovider/video/VideoStoreImportService.java index 7068d000..f4dc10d5 100644 --- a/src/com/archos/mediaprovider/video/VideoStoreImportService.java +++ b/src/com/archos/mediaprovider/video/VideoStoreImportService.java @@ -132,7 +132,7 @@ public static boolean startIfHandles(Context context, Intent broadcast) { if(broadcast.getExtras()!=null) serviceIntent.putExtras(broadcast.getExtras()); //in case we have an extra... such as "recordLogExtra" if (AppState.isForeGround()) { - log.debug("startIfHandles: apps is foreground startForegroundService and pass intent to self"); + log.debug("startIfHandles: apps is foreground startService and pass intent to self"); ArchosUtils.addBreadcrumb(SentryLevel.INFO, "VideoStoreImportService.startIfHandles", "apps is foreground mContext.startService and pass intent to self"); context.startService(serviceIntent); } @@ -237,15 +237,16 @@ public int onStartCommand(Intent intent, int flags, int startId) { // intents are delivered here. log.debug("onStartCommand:" + intent + " flags:" + flags + " startId:" + startId + ((intent != null) ? ", getAction " + intent.getAction() : " getAction null")); - ArchosUtils.addBreadcrumb(SentryLevel.INFO, "VideoStoreImportService.onStartCommand", "created notification + startForeground " + NOTIFICATION_ID + " notification null? " + (n == null)); - log.debug("onStartCommand: created notification + startForeground " + NOTIFICATION_ID + " notification null? " + (n == null)); - if (!AppState.isForeGround()) { + ArchosUtils.addBreadcrumb(SentryLevel.INFO, "VideoStoreImportService.onStartCommand", "aoo in background stopself, isForeground=" + AppState.isForeGround()); cleanup(); stopSelf(); return START_NOT_STICKY; } + ArchosUtils.addBreadcrumb(SentryLevel.INFO, "VideoStoreImportService.onStartCommand", "created notification + startService " + NOTIFICATION_ID + " notification null? " + (n == null) + " isForeground=" + AppState.isForeGround()); + log.debug("onStartCommand: created notification + startService " + NOTIFICATION_ID + " notification null? " + (n == null) + " isForeground=" + AppState.isForeGround()); + if (intent == null || intent.getAction() == null) { // do a full import here to make sure that we have initial data log.debug("onStartCommand: intent == null || intent.getAction() == null do MESSAGE_IMPORT_FULL"); @@ -331,12 +332,12 @@ public static void startService(Context context) { mContext = context; Intent intent = new Intent(context, VideoStoreImportService.class); if (AppState.isForeGround()) { - ArchosUtils.addBreadcrumb(SentryLevel.INFO, "VideoStoreImportService.startService", "app in foreground calling ContextCompat.startForegroundService"); - log.debug("startService: app in foreground calling ContextCompat.startForegroundService"); + ArchosUtils.addBreadcrumb(SentryLevel.INFO, "VideoStoreImportService.startService", "app in foreground calling startService"); + log.debug("startService: app in foreground calling startService"); context.startService(intent); // triggers an initial video import on local storage because files might have been created meanwhile } else { - ArchosUtils.addBreadcrumb(SentryLevel.INFO, "VideoStoreImportService.startService", "app in background NOT calling ContextCompat.startForegroundService"); - log.debug("startService: app in background NOT calling ContextCompat.startForegroundService"); + ArchosUtils.addBreadcrumb(SentryLevel.INFO, "VideoStoreImportService.startService", "app in background NOT calling startService"); + log.debug("startService: app in background NOT calling startService"); } } @@ -624,11 +625,11 @@ public void onChange(boolean selfChange) { intent.setAction(ArchosMediaIntent.ACTION_VIDEO_SCANNER_IMPORT_INCR); if (AppState.isForeGround()) { ArchosUtils.addBreadcrumb(SentryLevel.INFO, "VideoStoreImportService.onChange", "app in foreground calling mContext.startService"); - log.debug("onChange: app in foreground calling ContextCompat.startForegroundService"); + log.debug("onChange: app in foreground calling startService"); mContext.startService(intent); } else { ArchosUtils.addBreadcrumb(SentryLevel.INFO, "VideoStoreImportService.onChange", "app in background NOT calling mContext.startService"); - log.debug("onChange: app in background NOT calling mContext.startService"); + log.debug("onChange: app in background NOT calling startService"); } } }