Skip to content

Commit

Permalink
explain a problem with ContextObserver
Browse files Browse the repository at this point in the history
  • Loading branch information
CampelloManuel committed Sep 11, 2024
1 parent 507f9fd commit 00a0775
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -663,12 +663,26 @@ private static List<com.nononsenseapps.notepad.database.Notification> getSubList

private static class ContextObserver extends ContentObserver {

// TODO can we please delete this class ?
// TODO can we please delete this class ? It causes problems & does nothing useful

private final Context context;

public ContextObserver(final Context context, Handler h) {

// TODO Issue #543 is caused by this function
// If you call the constructor like this, a java.lang.SecurityException will block
// its execution, because the ContextObserver is being called by the OS,
// not by our app, as explained in https://stackoverflow.com/a/36694250/6307322
// So this function doesn't have the permission to run, but the notifications still
// appear, because this ContextObserver class is redundand and the notifications
// were actually already shown somewhere else in the codebase.
// SOLUTION: delete ContextObserver once & for all!
super(h);

// If we make our own Handler, as shown here,
// the notifications reappear every time the user dismisses them!
// super(new Handler(Looper.getMainLooper()));

this.context = context.getApplicationContext();
}

Expand Down

0 comments on commit 00a0775

Please sign in to comment.