Home | History | Annotate | Download | only in statusbar
      1 /*
      2  * Copyright (C) 2017 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License
     15  */
     16 package com.android.systemui.statusbar;
     17 
     18 import android.content.Intent;
     19 import android.os.Handler;
     20 import android.view.View;
     21 
     22 /**
     23  * An abstraction of something that presents notifications, e.g. StatusBar. Contains methods
     24  * for both querying the state of the system (some modularised piece of functionality may
     25  * want to act differently based on e.g. whether the presenter is visible to the user or not) and
     26  * for affecting the state of the system (e.g. starting an intent, given that the presenter may
     27  * want to perform some action before doing so).
     28  */
     29 public interface NotificationPresenter extends NotificationData.Environment,
     30         NotificationRemoteInputManager.Callback,
     31         ExpandableNotificationRow.OnExpandClickListener,
     32         ActivatableNotificationView.OnActivatedListener,
     33         NotificationEntryManager.Callback {
     34     /**
     35      * Returns true if the presenter is not visible. For example, it may not be necessary to do
     36      * animations if this returns true.
     37      */
     38     boolean isPresenterFullyCollapsed();
     39 
     40     /**
     41      * Returns true if the presenter is locked. For example, if the keyguard is active.
     42      */
     43     boolean isPresenterLocked();
     44 
     45     /**
     46      * Runs the given intent. The presenter may want to run some animations or close itself when
     47      * this happens.
     48      */
     49     void startNotificationGutsIntent(Intent intent, int appUid, ExpandableNotificationRow row);
     50 
     51     /**
     52      * Returns the Handler for NotificationPresenter.
     53      */
     54     Handler getHandler();
     55 
     56     /**
     57      * Refresh or remove lockscreen artwork from media metadata or the lockscreen wallpaper.
     58      */
     59     void updateMediaMetaData(boolean metaDataChanged, boolean allowEnterAnimation);
     60 
     61     /**
     62      * Called when the locked status of the device is changed for a work profile.
     63      */
     64     void onWorkChallengeChanged();
     65 
     66     /**
     67      * Called when the current user changes.
     68      * @param newUserId new user id
     69      */
     70     void onUserSwitched(int newUserId);
     71 
     72     /**
     73      * Gets the NotificationLockscreenUserManager for this Presenter.
     74      */
     75     NotificationLockscreenUserManager getNotificationLockscreenUserManager();
     76 
     77     /**
     78      * Wakes the device up if dozing.
     79      *
     80      * @param time the time when the request to wake up was issued
     81      * @param where which view caused this wake up request
     82      */
     83     void wakeUpIfDozing(long time, View where);
     84 
     85     /**
     86      * True if the device currently requires a PIN, pattern, or password to unlock.
     87      *
     88      * @param userId user id to query about
     89      * @return true iff the device is locked
     90      */
     91     boolean isDeviceLocked(int userId);
     92 
     93     /**
     94      * @return true iff the device is in vr mode
     95      */
     96     boolean isDeviceInVrMode();
     97 
     98     /**
     99      * Updates the visual representation of the notifications.
    100      */
    101     void updateNotificationViews();
    102 
    103     /**
    104      * Returns the maximum number of notifications to show while locked.
    105      *
    106      * @param recompute whether something has changed that means we should recompute this value
    107      * @return the maximum number of notifications to show while locked
    108      */
    109     int getMaxNotificationsWhileLocked(boolean recompute);
    110 
    111     /**
    112      * Called when the row states are updated by NotificationViewHierarchyManager.
    113      */
    114     void onUpdateRowStates();
    115 }
    116