1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 5 * except in compliance with the License. You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software distributed under the 10 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 11 * KIND, either express or implied. See the License for the specific language governing 12 * permissions and limitations under the License. 13 */ 14 15 package com.android.systemui.statusbar; 16 17 import android.content.pm.UserInfo; 18 import android.util.SparseArray; 19 20 import com.android.systemui.statusbar.notification.collection.NotificationEntry; 21 22 public interface NotificationLockscreenUserManager { 23 String PERMISSION_SELF = "com.android.systemui.permission.SELF"; 24 String NOTIFICATION_UNLOCKED_BY_WORK_CHALLENGE_ACTION 25 = "com.android.systemui.statusbar.work_challenge_unlocked_notification_action"; 26 27 /** 28 * @param userId user Id 29 * @return true if we re on a secure lock screen 30 */ isLockscreenPublicMode(int userId)31 boolean isLockscreenPublicMode(int userId); 32 33 /** 34 * Does a user require a separate work challenge? If so, the unlock mechanism is decoupled from 35 * the current user and has to be solved separately. 36 */ needsSeparateWorkChallenge(int userId)37 default boolean needsSeparateWorkChallenge(int userId) { 38 return false; 39 } 40 setUpWithPresenter(NotificationPresenter presenter)41 void setUpWithPresenter(NotificationPresenter presenter); 42 getCurrentUserId()43 int getCurrentUserId(); 44 isCurrentProfile(int userId)45 boolean isCurrentProfile(int userId); 46 47 /** 48 * 49 * @param userId user Id 50 * @return true if user profile is running. 51 */ isProfileAvailable(int userId)52 boolean isProfileAvailable(int userId); 53 54 /** Adds a listener to be notified when the current user changes. */ addUserChangedListener(UserChangedListener listener)55 void addUserChangedListener(UserChangedListener listener); 56 57 /** 58 * Removes a listener previously registered with 59 * {@link #addUserChangedListener(UserChangedListener)} 60 */ removeUserChangedListener(UserChangedListener listener)61 void removeUserChangedListener(UserChangedListener listener); 62 getCurrentProfiles()63 SparseArray<UserInfo> getCurrentProfiles(); 64 shouldShowLockscreenNotifications()65 boolean shouldShowLockscreenNotifications(); 66 isAnyProfilePublicMode()67 boolean isAnyProfilePublicMode(); 68 updatePublicMode()69 void updatePublicMode(); 70 needsRedaction(NotificationEntry entry)71 boolean needsRedaction(NotificationEntry entry); 72 73 /** 74 * Has the given user chosen to allow their private (full) notifications to be shown even 75 * when the lockscreen is in "public" (secure & locked) mode? 76 */ userAllowsPrivateNotificationsInPublic(int currentUserId)77 boolean userAllowsPrivateNotificationsInPublic(int currentUserId); 78 79 /** 80 * Has the given user chosen to allow notifications to be shown even when the lockscreen is in 81 * "public" (secure & locked) mode? 82 */ userAllowsNotificationsInPublic(int userId)83 boolean userAllowsNotificationsInPublic(int userId); 84 85 /** 86 * Adds a {@link NotificationStateChangedListener} to be notified of any state changes that 87 * would affect presentation of notifications. 88 */ addNotificationStateChangedListener(NotificationStateChangedListener listener)89 void addNotificationStateChangedListener(NotificationStateChangedListener listener); 90 91 /** 92 * Removes a {@link NotificationStateChangedListener} that was previously registered with 93 * {@link #addNotificationStateChangedListener(NotificationStateChangedListener)}. 94 */ removeNotificationStateChangedListener(NotificationStateChangedListener listener)95 void removeNotificationStateChangedListener(NotificationStateChangedListener listener); 96 97 /** Notified when the current user changes. */ 98 interface UserChangedListener { onUserChanged(int userId)99 default void onUserChanged(int userId) {} onCurrentProfilesChanged(SparseArray<UserInfo> currentProfiles)100 default void onCurrentProfilesChanged(SparseArray<UserInfo> currentProfiles) {} onUserRemoved(int userId)101 default void onUserRemoved(int userId) {} 102 } 103 104 /** 105 * Notified when any state pertaining to Notifications has changed; any methods pertaining to 106 * notifications should be re-queried. 107 */ 108 interface NotificationStateChangedListener { onNotificationStateChanged()109 void onNotificationStateChanged(); 110 } 111 } 112