|
25 | 25 | import android.app.Notification; |
26 | 26 | import android.app.PendingIntent; |
27 | 27 | import android.app.TaskStackBuilder; |
| 28 | +import android.app.admin.DevicePolicyManager; |
28 | 29 | import android.content.BroadcastReceiver; |
29 | 30 | import android.content.ComponentName; |
30 | 31 | import android.content.Context; |
@@ -159,6 +160,7 @@ public abstract class BaseStatusBar extends SystemUI implements |
159 | 160 | protected boolean mHeadsUpTicker = false; |
160 | 161 | protected boolean mDisableNotificationAlerts = false; |
161 | 162 |
|
| 163 | + protected DevicePolicyManager mDevicePolicyManager; |
162 | 164 | protected IDreamManager mDreamManager; |
163 | 165 | PowerManager mPowerManager; |
164 | 166 | protected int mRowMinHeight; |
@@ -299,6 +301,11 @@ public void onReceive(Context context, Intent intent) { |
299 | 301 | userSwitched(mCurrentUserId); |
300 | 302 | } else if (Intent.ACTION_USER_ADDED.equals(action)) { |
301 | 303 | updateCurrentProfilesCache(); |
| 304 | + } else if (DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED.equals( |
| 305 | + action)) { |
| 306 | + mUsersAllowingPrivateNotifications.clear(); |
| 307 | + updateLockscreenNotificationSetting(); |
| 308 | + updateNotifications(); |
302 | 309 | } |
303 | 310 | } |
304 | 311 | }; |
@@ -379,6 +386,8 @@ public void start() { |
379 | 386 | mWindowManager = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE); |
380 | 387 | mWindowManagerService = WindowManagerGlobal.getWindowManagerService(); |
381 | 388 | mDisplay = mWindowManager.getDefaultDisplay(); |
| 389 | + mDevicePolicyManager = (DevicePolicyManager)mContext.getSystemService( |
| 390 | + Context.DEVICE_POLICY_SERVICE); |
382 | 391 |
|
383 | 392 | mNotificationData = new NotificationData(this); |
384 | 393 |
|
@@ -478,6 +487,7 @@ public void start() { |
478 | 487 | IntentFilter filter = new IntentFilter(); |
479 | 488 | filter.addAction(Intent.ACTION_USER_SWITCHED); |
480 | 489 | filter.addAction(Intent.ACTION_USER_ADDED); |
| 490 | + filter.addAction(DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED); |
481 | 491 | mContext.registerReceiver(mBroadcastReceiver, filter); |
482 | 492 |
|
483 | 493 | updateCurrentProfilesCache(); |
@@ -865,7 +875,11 @@ public boolean userAllowsPrivateNotificationsInPublic(int userHandle) { |
865 | 875 | final boolean allowed = 0 != Settings.Secure.getIntForUser( |
866 | 876 | mContext.getContentResolver(), |
867 | 877 | 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); |
869 | 883 | return allowed; |
870 | 884 | } |
871 | 885 |
|
@@ -1455,7 +1469,11 @@ private void updateLockscreenNotificationSetting() { |
1455 | 1469 | Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, |
1456 | 1470 | 1, |
1457 | 1471 | 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); |
1459 | 1477 | } |
1460 | 1478 |
|
1461 | 1479 | protected abstract void haltTicker(); |
|
0 commit comments