From ed1d5e56c0f2751ba52cc95eb8aa9190ca608c05 Mon Sep 17 00:00:00 2001 From: Blaine Jester Date: Mon, 15 Jan 2024 13:18:34 -0800 Subject: [PATCH] Add onStopped hook --- .../org/learningequality/Kolibri/BackgroundWorker.java | 7 +++++++ .../org/learningequality/Kolibri/ForegroundWorker.java | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/python-for-android/dists/kolibri/src/main/java/org/learningequality/Kolibri/BackgroundWorker.java b/python-for-android/dists/kolibri/src/main/java/org/learningequality/Kolibri/BackgroundWorker.java index 677b5700..8be15c4d 100644 --- a/python-for-android/dists/kolibri/src/main/java/org/learningequality/Kolibri/BackgroundWorker.java +++ b/python-for-android/dists/kolibri/src/main/java/org/learningequality/Kolibri/BackgroundWorker.java @@ -36,4 +36,11 @@ public Result doWork() { final String arg = getArgument(); return workerImpl.execute(id, arg) ? Result.success() : Result.failure(); } + + @Override + public void onStopped() { + Log.d(TAG, "Stopping foreground remote task " + getId()); + super.onStopped(); + hideNotification(); + } } diff --git a/python-for-android/dists/kolibri/src/main/java/org/learningequality/Kolibri/ForegroundWorker.java b/python-for-android/dists/kolibri/src/main/java/org/learningequality/Kolibri/ForegroundWorker.java index 95db6d6e..dc5d5a76 100644 --- a/python-for-android/dists/kolibri/src/main/java/org/learningequality/Kolibri/ForegroundWorker.java +++ b/python-for-android/dists/kolibri/src/main/java/org/learningequality/Kolibri/ForegroundWorker.java @@ -73,6 +73,13 @@ public ListenableFuture startRemoteWork() { return future; } + @Override + public void onStopped() { + Log.d(TAG, "Stopping foreground remote task " + getId()); + super.onStopped(); + hideNotification(); + } + public ForegroundInfo getForegroundInfo() { NotificationRef ref = getNotificationRef(); // If we are running in the service, use the service notification ref