Home | History | Annotate | Download | only in statusbar
      1 package com.android.systemui.statusbar;
      2 
      3 import androidx.annotation.NonNull;
      4 
      5 import com.android.systemui.statusbar.notification.collection.NotificationEntry;
      6 
      7 /**
      8  * Interface for anything that may need to keep notifications managed even after
      9  * {@link NotificationListener} removes it.  The lifetime extender is in charge of performing the
     10  * callback when the notification is then safe to remove.
     11  */
     12 public interface NotificationLifetimeExtender {
     13 
     14     /**
     15      * Set the handler to callback to when the notification is safe to remove.
     16      *
     17      * @param callback the handler to callback
     18      */
     19     void setCallback(@NonNull NotificationSafeToRemoveCallback callback);
     20 
     21     /**
     22      * Determines whether or not the extender needs the notification kept after removal.
     23      *
     24      * @param entry the entry containing the notification to check
     25      * @return true if the notification lifetime should be extended
     26      */
     27     boolean shouldExtendLifetime(@NonNull NotificationEntry entry);
     28 
     29     /**
     30      * Sets whether or not the lifetime should be managed by the extender.  In practice, if
     31      * shouldManage is true, this is where the extender starts managing the entry internally and is
     32      * now responsible for calling {@link NotificationSafeToRemoveCallback#onSafeToRemove(String)}
     33      * when the entry is safe to remove.  If shouldManage is false, the extender no longer needs to
     34      * worry about it (either because we will be removing it anyway or the entry is no longer
     35      * removed due to an update).
     36      *
     37      * @param entry the entry that needs an extended lifetime
     38      * @param shouldManage true if the extender should manage the entry now, false otherwise
     39      */
     40     void setShouldManageLifetime(@NonNull NotificationEntry entry, boolean shouldManage);
     41 
     42     /**
     43      * The callback for when the notification is now safe to remove (i.e. its lifetime has ended).
     44      */
     45     interface NotificationSafeToRemoveCallback {
     46         /**
     47          * Called when the lifetime extender determines it's safe to remove.
     48          *
     49          * @param key key of the entry that is now safe to remove
     50          */
     51         void onSafeToRemove(String key);
     52     }
     53 }
     54