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.annotation.IntDef; 18 import android.content.pm.UserInfo; 19 import android.util.SparseArray; 20 21 import com.android.systemui.statusbar.notification.collection.NotificationEntry; 22 23 import java.lang.annotation.Retention; 24 import java.lang.annotation.RetentionPolicy; 25 26 public interface NotificationLockscreenUserManager { 27 String PERMISSION_SELF = "com.android.systemui.permission.SELF"; 28 String NOTIFICATION_UNLOCKED_BY_WORK_CHALLENGE_ACTION 29 = "com.android.systemui.statusbar.work_challenge_unlocked_notification_action"; 30 31 @Retention(RetentionPolicy.SOURCE) 32 @IntDef(flag = true, 33 prefix = {"REDACTION_TYPE_"}, 34 value = { 35 REDACTION_TYPE_NONE, 36 REDACTION_TYPE_PUBLIC, 37 REDACTION_TYPE_OTP}) 38 @interface RedactionType {} 39 40 /** 41 * Indicates that a notification requires no redaction 42 */ 43 int REDACTION_TYPE_NONE = 0; 44 45 /** 46 * Indicates that a notification should have all content redacted, showing the public view. 47 * Overrides all other redaction types. 48 */ 49 int REDACTION_TYPE_PUBLIC = 1; 50 51 /** 52 * Indicates that a notification should have its main content redacted, due to detected 53 * sensitive content, such as a One-Time Password 54 */ 55 int REDACTION_TYPE_OTP = 1 << 1; 56 57 /** 58 * @param userId user Id 59 * @return true if we're on a secure lock screen 60 */ isLockscreenPublicMode(int userId)61 boolean isLockscreenPublicMode(int userId); 62 63 /** 64 * Does a user require a separate work challenge? If so, the unlock mechanism is decoupled from 65 * the current user and has to be solved separately. 66 */ needsSeparateWorkChallenge(int userId)67 default boolean needsSeparateWorkChallenge(int userId) { 68 return false; 69 } 70 setUpWithPresenter(NotificationPresenter presenter)71 void setUpWithPresenter(NotificationPresenter presenter); 72 getCurrentUserId()73 int getCurrentUserId(); 74 isCurrentProfile(int userId)75 boolean isCurrentProfile(int userId); 76 77 /** 78 * 79 * @param userId user Id 80 * @return true if user profile is running. 81 */ isProfileAvailable(int userId)82 boolean isProfileAvailable(int userId); 83 84 /** Adds a listener to be notified when the current user changes. */ addUserChangedListener(UserChangedListener listener)85 void addUserChangedListener(UserChangedListener listener); 86 87 /** 88 * Removes a listener previously registered with 89 * {@link #addUserChangedListener(UserChangedListener)} 90 */ removeUserChangedListener(UserChangedListener listener)91 void removeUserChangedListener(UserChangedListener listener); 92 getCurrentProfiles()93 SparseArray<UserInfo> getCurrentProfiles(); 94 shouldShowLockscreenNotifications()95 boolean shouldShowLockscreenNotifications(); 96 isAnyProfilePublicMode()97 boolean isAnyProfilePublicMode(); 98 updatePublicMode()99 void updatePublicMode(); 100 101 /** 102 * Determine what type of redaction is needed, if any. Returns REDACTION_TYPE_NONE if no 103 * redaction type is needed, REDACTION_TYPE_PUBLIC if private notifications are blocked, and 104 * REDACTION_TYPE_SENSITIVE_CONTENT if sensitive content is detected, and REDACTION_TYPE_PUBLIC 105 * doesn't apply. 106 */ getRedactionType(NotificationEntry entry)107 @RedactionType int getRedactionType(NotificationEntry entry); 108 109 /** 110 * Has the given user chosen to allow their private (full) notifications to be shown even 111 * when the lockscreen is in "public" (secure & locked) mode? 112 */ userAllowsPrivateNotificationsInPublic(int currentUserId)113 boolean userAllowsPrivateNotificationsInPublic(int currentUserId); 114 115 /** 116 * Has the given user chosen to allow notifications to be shown even when the lockscreen is in 117 * "public" (secure & locked) mode? 118 */ userAllowsNotificationsInPublic(int userId)119 boolean userAllowsNotificationsInPublic(int userId); 120 121 /** 122 * Adds a {@link NotificationStateChangedListener} to be notified of any state changes that 123 * would affect presentation of notifications. 124 */ addNotificationStateChangedListener(NotificationStateChangedListener listener)125 void addNotificationStateChangedListener(NotificationStateChangedListener listener); 126 127 /** 128 * Removes a {@link NotificationStateChangedListener} that was previously registered with 129 * {@link #addNotificationStateChangedListener(NotificationStateChangedListener)}. 130 */ removeNotificationStateChangedListener(NotificationStateChangedListener listener)131 void removeNotificationStateChangedListener(NotificationStateChangedListener listener); 132 133 /** Notified when the current user changes. */ 134 interface UserChangedListener { onUserChanged(int userId)135 default void onUserChanged(int userId) {} onCurrentProfilesChanged(SparseArray<UserInfo> currentProfiles)136 default void onCurrentProfilesChanged(SparseArray<UserInfo> currentProfiles) {} onUserRemoved(int userId)137 default void onUserRemoved(int userId) {} 138 } 139 140 /** 141 * Notified when any state pertaining to Notifications has changed; any methods pertaining to 142 * notifications should be re-queried. 143 */ 144 interface NotificationStateChangedListener { onNotificationStateChanged()145 void onNotificationStateChanged(); 146 } 147 } 148