Merge "Remove unneeded sysui notifications" into pi-dev
am: bd65574db6
Change-Id: I48a017b4397292bfa4009af72a7200932f930e62
This commit is contained in:
@@ -747,8 +747,6 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mUpdateCallback);
|
||||
putComponent(DozeHost.class, mDozeServiceHost);
|
||||
|
||||
notifyUserAboutHiddenNotifications();
|
||||
|
||||
mScreenPinningRequest = new ScreenPinningRequest(mContext);
|
||||
mFalsingManager = FalsingManager.getInstance(mContext);
|
||||
|
||||
@@ -5145,55 +5143,6 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
|
||||
protected NotificationListener mNotificationListener;
|
||||
|
||||
protected void notifyUserAboutHiddenNotifications() {
|
||||
if (0 != Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.SHOW_NOTE_ABOUT_NOTIFICATION_HIDING, 1)) {
|
||||
Log.d(TAG, "user hasn't seen notification about hidden notifications");
|
||||
if (!mLockPatternUtils.isSecure(KeyguardUpdateMonitor.getCurrentUser())) {
|
||||
Log.d(TAG, "insecure lockscreen, skipping notification");
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.SHOW_NOTE_ABOUT_NOTIFICATION_HIDING, 0);
|
||||
return;
|
||||
}
|
||||
Log.d(TAG, "disabling lockscreen notifications and alerting the user");
|
||||
// disable lockscreen notifications until user acts on the banner.
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0);
|
||||
|
||||
final String packageName = mContext.getPackageName();
|
||||
PendingIntent cancelIntent = PendingIntent.getBroadcast(mContext, 0,
|
||||
new Intent(BANNER_ACTION_CANCEL).setPackage(packageName),
|
||||
PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
PendingIntent setupIntent = PendingIntent.getBroadcast(mContext, 0,
|
||||
new Intent(BANNER_ACTION_SETUP).setPackage(packageName),
|
||||
PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
|
||||
final int colorRes = com.android.internal.R.color.system_notification_accent_color;
|
||||
Notification.Builder note =
|
||||
new Notification.Builder(mContext, NotificationChannels.GENERAL)
|
||||
.setSmallIcon(R.drawable.ic_android)
|
||||
.setContentTitle(mContext.getString(
|
||||
R.string.hidden_notifications_title))
|
||||
.setContentText(mContext.getString(R.string.hidden_notifications_text))
|
||||
.setOngoing(true)
|
||||
.setColor(mContext.getColor(colorRes))
|
||||
.setContentIntent(setupIntent)
|
||||
.addAction(R.drawable.ic_close,
|
||||
mContext.getString(R.string.hidden_notifications_cancel),
|
||||
cancelIntent)
|
||||
.addAction(R.drawable.ic_settings,
|
||||
mContext.getString(R.string.hidden_notifications_setup),
|
||||
setupIntent);
|
||||
overrideNotificationAppName(mContext, note);
|
||||
|
||||
NotificationManager noMan =
|
||||
(NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
noMan.notify(SystemMessage.NOTE_HIDDEN_NOTIFICATIONS, note.build());
|
||||
}
|
||||
}
|
||||
|
||||
@Override // NotificationData.Environment
|
||||
public boolean isNotificationForCurrentProfiles(StatusBarNotification n) {
|
||||
final int notificationUserId = n.getUserId();
|
||||
|
||||
@@ -83,13 +83,8 @@ public class UserSwitcherController {
|
||||
private static final boolean DEBUG = false;
|
||||
private static final String SIMPLE_USER_SWITCHER_GLOBAL_SETTING =
|
||||
"lockscreenSimpleUserSwitcher";
|
||||
private static final String ACTION_REMOVE_GUEST = "com.android.systemui.REMOVE_GUEST";
|
||||
private static final String ACTION_LOGOUT_USER = "com.android.systemui.LOGOUT_USER";
|
||||
private static final int PAUSE_REFRESH_USERS_TIMEOUT_MS = 3000;
|
||||
|
||||
private static final String TAG_REMOVE_GUEST = "remove_guest";
|
||||
private static final String TAG_LOGOUT_USER = "logout_user";
|
||||
|
||||
private static final String PERMISSION_SELF = "com.android.systemui.permission.SELF";
|
||||
|
||||
protected final Context mContext;
|
||||
@@ -134,8 +129,6 @@ public class UserSwitcherController {
|
||||
mSecondaryUserServiceIntent = new Intent(context, SystemUISecondaryUserService.class);
|
||||
|
||||
filter = new IntentFilter();
|
||||
filter.addAction(ACTION_REMOVE_GUEST);
|
||||
filter.addAction(ACTION_LOGOUT_USER);
|
||||
mContext.registerReceiverAsUser(mReceiver, UserHandle.SYSTEM, filter,
|
||||
PERMISSION_SELF, null /* scheduler */);
|
||||
|
||||
@@ -471,11 +464,6 @@ public class UserSwitcherController {
|
||||
if (mCallState == state) return;
|
||||
if (DEBUG) Log.v(TAG, "Call state changed: " + state);
|
||||
mCallState = state;
|
||||
int currentUserId = ActivityManager.getCurrentUser();
|
||||
UserInfo userInfo = mUserManager.getUserInfo(currentUserId);
|
||||
if (userInfo != null && userInfo.isGuest()) {
|
||||
showGuestNotification(currentUserId);
|
||||
}
|
||||
refreshUsers(UserHandle.USER_NULL);
|
||||
}
|
||||
};
|
||||
@@ -491,16 +479,7 @@ public class UserSwitcherController {
|
||||
boolean unpauseRefreshUsers = false;
|
||||
int forcePictureLoadForId = UserHandle.USER_NULL;
|
||||
|
||||
if (ACTION_REMOVE_GUEST.equals(intent.getAction())) {
|
||||
int currentUser = ActivityManager.getCurrentUser();
|
||||
UserInfo userInfo = mUserManager.getUserInfo(currentUser);
|
||||
if (userInfo != null && userInfo.isGuest()) {
|
||||
showExitGuestDialog(currentUser);
|
||||
}
|
||||
return;
|
||||
} else if (ACTION_LOGOUT_USER.equals(intent.getAction())) {
|
||||
logoutCurrentUser();
|
||||
} else if (Intent.ACTION_USER_SWITCHED.equals(intent.getAction())) {
|
||||
if (Intent.ACTION_USER_SWITCHED.equals(intent.getAction())) {
|
||||
if (mExitGuestDialog != null && mExitGuestDialog.isShowing()) {
|
||||
mExitGuestDialog.cancel();
|
||||
mExitGuestDialog = null;
|
||||
@@ -540,14 +519,6 @@ public class UserSwitcherController {
|
||||
UserHandle.of(userInfo.id));
|
||||
mSecondaryUser = userInfo.id;
|
||||
}
|
||||
|
||||
if (UserManager.isSplitSystemUser() && userInfo != null && !userInfo.isGuest()
|
||||
&& userInfo.id != UserHandle.USER_SYSTEM) {
|
||||
showLogoutNotification(currentId);
|
||||
}
|
||||
if (userInfo != null && userInfo.isGuest()) {
|
||||
showGuestNotification(currentId);
|
||||
}
|
||||
unpauseRefreshUsers = true;
|
||||
} else if (Intent.ACTION_USER_INFO_CHANGED.equals(intent.getAction())) {
|
||||
forcePictureLoadForId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE,
|
||||
@@ -564,52 +535,8 @@ public class UserSwitcherController {
|
||||
mUnpauseRefreshUsers.run();
|
||||
}
|
||||
}
|
||||
|
||||
private void showLogoutNotification(int userId) {
|
||||
PendingIntent logoutPI = PendingIntent.getBroadcastAsUser(mContext,
|
||||
0, new Intent(ACTION_LOGOUT_USER), 0, UserHandle.SYSTEM);
|
||||
Notification.Builder builder =
|
||||
new Notification.Builder(mContext, NotificationChannels.GENERAL)
|
||||
.setVisibility(Notification.VISIBILITY_SECRET)
|
||||
.setSmallIcon(R.drawable.ic_person)
|
||||
.setContentTitle(mContext.getString(
|
||||
R.string.user_logout_notification_title))
|
||||
.setContentText(mContext.getString(
|
||||
R.string.user_logout_notification_text))
|
||||
.setContentIntent(logoutPI)
|
||||
.setOngoing(true)
|
||||
.setShowWhen(false)
|
||||
.addAction(R.drawable.ic_delete,
|
||||
mContext.getString(R.string.user_logout_notification_action),
|
||||
logoutPI);
|
||||
SystemUI.overrideNotificationAppName(mContext, builder);
|
||||
NotificationManager.from(mContext).notifyAsUser(TAG_LOGOUT_USER,
|
||||
SystemMessage.NOTE_LOGOUT_USER, builder.build(), new UserHandle(userId));
|
||||
}
|
||||
};
|
||||
|
||||
private void showGuestNotification(int guestUserId) {
|
||||
boolean canSwitchUsers = mUserManager.canSwitchUsers();
|
||||
// Disable 'Remove guest' action if cannot switch users right now
|
||||
PendingIntent removeGuestPI = canSwitchUsers ? PendingIntent.getBroadcastAsUser(mContext,
|
||||
0, new Intent(ACTION_REMOVE_GUEST), 0, UserHandle.SYSTEM) : null;
|
||||
|
||||
Notification.Builder builder =
|
||||
new Notification.Builder(mContext, NotificationChannels.GENERAL)
|
||||
.setVisibility(Notification.VISIBILITY_SECRET)
|
||||
.setSmallIcon(R.drawable.ic_person)
|
||||
.setContentTitle(mContext.getString(R.string.guest_notification_title))
|
||||
.setContentText(mContext.getString(R.string.guest_notification_text))
|
||||
.setContentIntent(removeGuestPI)
|
||||
.setShowWhen(false)
|
||||
.addAction(R.drawable.ic_delete,
|
||||
mContext.getString(R.string.guest_notification_remove_action),
|
||||
removeGuestPI);
|
||||
SystemUI.overrideNotificationAppName(mContext, builder);
|
||||
NotificationManager.from(mContext).notifyAsUser(TAG_REMOVE_GUEST,
|
||||
SystemMessage.NOTE_REMOVE_GUEST, builder.build(), new UserHandle(guestUserId));
|
||||
}
|
||||
|
||||
private final Runnable mUnpauseRefreshUsers = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
Reference in New Issue
Block a user