From dfee7931974dbbb519ba2006da4982361e56652d Mon Sep 17 00:00:00 2001 From: Blaine Jester Date: Tue, 16 Jan 2024 08:16:44 -0800 Subject: [PATCH] Fix lingering notifications spam --- .../src/main/java/org/kivy/android/PythonWorker.java | 3 +-- .../java/org/learningequality/Kolibri/BackgroundWorker.java | 6 ++++-- .../java/org/learningequality/Kolibri/ForegroundWorker.java | 4 ++++ .../java/org/learningequality/Kolibri/WorkerService.java | 3 --- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/python-for-android/dists/kolibri/src/main/java/org/kivy/android/PythonWorker.java b/python-for-android/dists/kolibri/src/main/java/org/kivy/android/PythonWorker.java index d62ecaf3..9ea02666 100644 --- a/python-for-android/dists/kolibri/src/main/java/org/kivy/android/PythonWorker.java +++ b/python-for-android/dists/kolibri/src/main/java/org/kivy/android/PythonWorker.java @@ -22,8 +22,7 @@ public class PythonWorker { private final String pythonPath; public PythonWorker(@NonNull Context context, String pythonName, String workerEntrypoint) { -// PythonLoader.doLoad(context); - PythonUtil.loadLibraries(new File(context.getApplicationInfo().nativeLibraryDir)); + PythonLoader.doLoad(context); this.pythonName = pythonName; this.workerEntrypoint = workerEntrypoint; 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 8be15c4d..ffc2897d 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 @@ -34,12 +34,14 @@ public Result doWork() { Log.d(TAG, "Running background task " + getId()); final String id = getId().toString(); final String arg = getArgument(); - return workerImpl.execute(id, arg) ? Result.success() : Result.failure(); + Result r = workerImpl.execute(id, arg) ? Result.success() : Result.failure(); + hideNotification(); + return r; } @Override public void onStopped() { - Log.d(TAG, "Stopping foreground remote task " + getId()); + Log.d(TAG, "Stopping background 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 060ccf62..a7c2c3f5 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 @@ -68,6 +68,10 @@ public ListenableFuture startRemoteWork() { threadFuture.cancel(true); } } + + if (future.isDone()) { + hideNotification(); + } } }, getTaskExecutor().getMainThreadExecutor()); return future; diff --git a/python-for-android/dists/kolibri/src/main/java/org/learningequality/Kolibri/WorkerService.java b/python-for-android/dists/kolibri/src/main/java/org/learningequality/Kolibri/WorkerService.java index 4654c91e..68a4bb5a 100644 --- a/python-for-android/dists/kolibri/src/main/java/org/learningequality/Kolibri/WorkerService.java +++ b/python-for-android/dists/kolibri/src/main/java/org/learningequality/Kolibri/WorkerService.java @@ -22,9 +22,6 @@ public class WorkerService extends RemoteWorkerService implements Notifier { public void onCreate() { Log.d(TAG, "Initializing foreground worker service"); super.onCreate(); - // We could potentially remove this and leave the notification up to long-running workers - // bound to the service - sendNotification(); mService = this; }