Skip to content

Commit

Permalink
Force Heads up in all applications [1/2]
Browse files Browse the repository at this point in the history
also make heads up blacklist,whitelist,dnd multiuser friendly
  • Loading branch information
Beanstown authored and temasek committed Apr 8, 2016
1 parent 1e8bb32 commit 809732a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions core/java/android/provider/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -4865,6 +4865,12 @@ public boolean validate(String value) {
*/
public static final String HEADS_UP_SNOOZE_LENGTH_MS = "heads_up_snooze_length_ms";

/**
* Force heads up in all applications
* @hide
*/
public static final String HEADS_UP_FORCE_ALL = "heads_up_force_all";

/**
* Settings to backup. This is here so that it's in the same place as the settings
* keys and easy to update.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ public abstract class BaseStatusBar extends SystemUI implements

// for heads up notifications
protected HeadsUpManager mHeadsUpManager;
protected boolean mForceAllHeads;

protected int mCurrentUserId = 0;
final protected SparseArray<UserInfo> mCurrentProfiles = new SparseArray<UserInfo>();
Expand Down Expand Up @@ -365,6 +366,8 @@ public void observe() {
CMSettings.System.HEADS_UP_BLACKLIST_VALUES), false, this);
resolver.registerContentObserver(CMSettings.System.getUriFor(
CMSettings.System.HEADS_UP_WHITELIST_VALUES), false, this);
resolver.registerContentObserver(Settings.System.getUriFor(
Settings.System.HEADS_UP_FORCE_ALL), false, this, UserHandle.USER_ALL);
update();
}

Expand All @@ -382,6 +385,8 @@ private void update() {
CMSettings.System.HEADS_UP_BLACKLIST_VALUES);
final String whiteString = CMSettings.System.getString(resolver,
CMSettings.System.HEADS_UP_WHITELIST_VALUES);
mForceAllHeads = Settings.System.getIntForUser(resolver,
Settings.System.HEADS_UP_FORCE_ALL, 0, UserHandle.USER_CURRENT) == 1;
splitAndAddToArrayList(mDndList, dndString, "\\|");
splitAndAddToArrayList(mBlacklist, blackString, "\\|");
splitAndAddToArrayList(mWhitelist, whiteString, "\\|");
Expand Down Expand Up @@ -2480,7 +2485,7 @@ protected boolean shouldInterrupt(Entry entry, StatusBarNotification sbn) {

Notification notification = sbn.getNotification();
// some predicates to make the boolean logic legible
boolean whiteListed = isPackageWhitelisted(sbn.getPackageName());
boolean whiteListed = mForceAllHeads || isPackageWhitelisted(sbn.getPackageName());
boolean isNoisy = (notification.defaults & Notification.DEFAULT_SOUND) != 0
|| (notification.defaults & Notification.DEFAULT_VIBRATE) != 0
|| notification.sound != null
Expand Down

0 comments on commit 809732a

Please sign in to comment.