Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f5b850e6 authored by Sudheer Shanka's avatar Sudheer Shanka
Browse files

Update notification title when admin disallows unredacted ones.

Currently, we use "Contents hidden" message in either case where user
wants to hide sensitive content or admin disallows  unredacted
notifications. Updated to use a different message when the
admin disallows it.
Change-Id: Idc73968ff7894e96d8f9b5be4621cc02f682e0aa
parent 7d8501d0
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -559,6 +559,9 @@
    <!-- Text shown in place of notification contents when the notification is hidden on a secure lockscreen -->
    <string name="notification_hidden_text">Contents hidden</string>

    <!-- Text shown in place of notification contents when the notification is hidden by policy on a secure lockscreen -->
    <string name="notification_hidden_by_policy_text">Contents hidden by policy</string>

    <!-- Displayed to the user to tell them that they have started up the phone in "safe mode" -->
    <string name="safeMode">Safe mode</string>

+1 −0
Original line number Diff line number Diff line
@@ -2401,6 +2401,7 @@

  <java-symbol type="string" name="notification_children_count_bracketed" />
  <java-symbol type="string" name="notification_hidden_text" />
  <java-symbol type="string" name="notification_hidden_by_policy_text" />
  <java-symbol type="id" name="app_name_text" />
  <java-symbol type="id" name="number_of_children" />
  <java-symbol type="id" name="header_sub_text" />
+25 −4
Original line number Diff line number Diff line
@@ -1225,10 +1225,7 @@ public abstract class BaseStatusBar extends SystemUI implements
            final boolean allowedByUser = 0 != Settings.Secure.getIntForUser(
                    mContext.getContentResolver(),
                    Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0, userHandle);
            final int dpmFlags = mDevicePolicyManager.getKeyguardDisabledFeatures(null /* admin */,
                    userHandle);
            final boolean allowedByDpm = (dpmFlags
                    & DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS) == 0;
            final boolean allowedByDpm = adminAllowsUnredactedNotifications(userHandle);
            final boolean allowed = allowedByUser && allowedByDpm;
            mUsersAllowingPrivateNotifications.append(userHandle, allowed);
            return allowed;
@@ -1237,6 +1234,15 @@ public abstract class BaseStatusBar extends SystemUI implements
        return mUsersAllowingPrivateNotifications.get(userHandle);
    }

    private boolean adminAllowsUnredactedNotifications(int userHandle) {
        if (userHandle == UserHandle.USER_ALL) {
            return true;
        }
        final int dpmFlags = mDevicePolicyManager.getKeyguardDisabledFeatures(null /* admin */,
                    userHandle);
        return (dpmFlags & DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS) == 0;
    }

    /**
     * Returns true if we're on a secure lockscreen and the user wants to hide "sensitive"
     * notification data. If so, private notifications should show their (possibly
@@ -2047,6 +2053,21 @@ public abstract class BaseStatusBar extends SystemUI implements
        entry.row.resetHeight();
    }

    protected void updatePublicContentView(Entry entry,
            StatusBarNotification sbn) {
        final RemoteViews publicContentView = entry.cachedPublicContentView;
        if (publicContentView != null && entry.getPublicContentView() != null) {
            final boolean disabledByPolicy =
                    !adminAllowsUnredactedNotifications(entry.notification.getUserId());
            publicContentView.setTextViewText(android.R.id.title,
                    mContext.getString(disabledByPolicy
                            ? com.android.internal.R.string.notification_hidden_by_policy_text
                            : com.android.internal.R.string.notification_hidden_text));
            publicContentView.reapply(sbn.getPackageContext(mContext),
                    entry.getPublicContentView(), mOnClickHandler);
        }
    }

    protected void notifyHeadsUpScreenOff() {
        maybeEscalateHeadsUp();
    }
+3 −0
Original line number Diff line number Diff line
@@ -1373,6 +1373,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
            boolean sensitivePackage = packageHasVisibilityOverride(ent.notification.getKey());
            boolean sensitive = (sensitiveNote && hideSensitive) || sensitivePackage;
            boolean showingPublic = sensitive && isLockscreenPublicMode();
            if (showingPublic) {
                updatePublicContentView(ent, ent.notification);
            }
            ent.row.setSensitive(sensitive);
            if (ent.autoRedacted && ent.legacy) {
                // TODO: Also fade this? Or, maybe easier (and better), provide a dark redacted form