Skip to content

Commit bd3409c

Browse files
committed
Respect DPM flags for lockscreen notifications
Disables unredacted or all notifications based on device policy. Bug: 15934116 Change-Id: Ia012e44da8fbf73c24e26950abb1df76af7001a9
1 parent 14690b0 commit bd3409c

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import android.app.Notification;
2626
import android.app.PendingIntent;
2727
import android.app.TaskStackBuilder;
28+
import android.app.admin.DevicePolicyManager;
2829
import android.content.BroadcastReceiver;
2930
import android.content.ComponentName;
3031
import android.content.Context;
@@ -159,6 +160,7 @@ public abstract class BaseStatusBar extends SystemUI implements
159160
protected boolean mHeadsUpTicker = false;
160161
protected boolean mDisableNotificationAlerts = false;
161162

163+
protected DevicePolicyManager mDevicePolicyManager;
162164
protected IDreamManager mDreamManager;
163165
PowerManager mPowerManager;
164166
protected int mRowMinHeight;
@@ -299,6 +301,11 @@ public void onReceive(Context context, Intent intent) {
299301
userSwitched(mCurrentUserId);
300302
} else if (Intent.ACTION_USER_ADDED.equals(action)) {
301303
updateCurrentProfilesCache();
304+
} else if (DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED.equals(
305+
action)) {
306+
mUsersAllowingPrivateNotifications.clear();
307+
updateLockscreenNotificationSetting();
308+
updateNotifications();
302309
}
303310
}
304311
};
@@ -379,6 +386,8 @@ public void start() {
379386
mWindowManager = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
380387
mWindowManagerService = WindowManagerGlobal.getWindowManagerService();
381388
mDisplay = mWindowManager.getDefaultDisplay();
389+
mDevicePolicyManager = (DevicePolicyManager)mContext.getSystemService(
390+
Context.DEVICE_POLICY_SERVICE);
382391

383392
mNotificationData = new NotificationData(this);
384393

@@ -478,6 +487,7 @@ public void start() {
478487
IntentFilter filter = new IntentFilter();
479488
filter.addAction(Intent.ACTION_USER_SWITCHED);
480489
filter.addAction(Intent.ACTION_USER_ADDED);
490+
filter.addAction(DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED);
481491
mContext.registerReceiver(mBroadcastReceiver, filter);
482492

483493
updateCurrentProfilesCache();
@@ -865,7 +875,11 @@ public boolean userAllowsPrivateNotificationsInPublic(int userHandle) {
865875
final boolean allowed = 0 != Settings.Secure.getIntForUser(
866876
mContext.getContentResolver(),
867877
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0, userHandle);
868-
mUsersAllowingPrivateNotifications.append(userHandle, allowed);
878+
final int dpmFlags = mDevicePolicyManager.getKeyguardDisabledFeatures(null /* admin */,
879+
userHandle);
880+
final boolean allowedByDpm = (dpmFlags
881+
& DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS) == 0;
882+
mUsersAllowingPrivateNotifications.append(userHandle, allowed && allowedByDpm);
869883
return allowed;
870884
}
871885

@@ -1455,7 +1469,11 @@ private void updateLockscreenNotificationSetting() {
14551469
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS,
14561470
1,
14571471
mCurrentUserId) != 0;
1458-
setShowLockscreenNotifications(show);
1472+
final int dpmFlags = mDevicePolicyManager.getKeyguardDisabledFeatures(
1473+
null /* admin */, mCurrentUserId);
1474+
final boolean allowedByDpm = (dpmFlags
1475+
& DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS) == 0;
1476+
setShowLockscreenNotifications(show && allowedByDpm);
14591477
}
14601478

14611479
protected abstract void haltTicker();

0 commit comments

Comments
 (0)