Skip to content

Commit

Permalink
Fix lingering notifications spam
Browse files Browse the repository at this point in the history
  • Loading branch information
bjester committed Jan 16, 2024
1 parent 4ce4a69 commit dfee793
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ public ListenableFuture<Result> startRemoteWork() {
threadFuture.cancel(true);
}
}

if (future.isDone()) {
hideNotification();
}
}
}, getTaskExecutor().getMainThreadExecutor());
return future;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit dfee793

Please sign in to comment.