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

Commit 08462caf authored by Nate Myren's avatar Nate Myren
Browse files

Create a redacted single line view

Currently, a mixed public/private notification bundle looks bad, due to
the public notification using its contracted view, despite only having
space for a single line. This change creates a redacted single line view
for these public views.

Flag: android.app.redact_sensitive_content_notifications_on_lockscreen
Test: atest NotificationRowContentBinderImplTest
Fixes: 352020702

Change-Id: Ic3f966f856258a997b3c7d39a53058bf6e45c2a1
parent a9b60624
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
<!--
  ~ Copyright (C) 2019 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="32dp"
    android:height="32dp"
    android:viewportWidth="24"
    android:viewportHeight="24">
    <path
        android:fillColor="?android:attr/colorAccent"
        android:pathData="M12,15m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0"/>
    <path
        android:fillColor="?android:attr/colorAccent"
        android:pathData="M18,8h-1.5V5.5C16.5,3.01 14.49,1 12,1S7.5,3.01 7.5,5.5V8H6c-1.1,0 -2,0.9 -2,2v10c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2V10C20,8.9 19.1,8 18,8zM9.5,5.5C9.5,4.12 10.62,3 12,3c1.38,0 2.5,1.12 2.5,2.5V8h-5V5.5zM18,20H6V10h1.5h9H18V20z"/>
</vector>
+5 −0
Original line number Diff line number Diff line
@@ -3709,6 +3709,11 @@ Action + ESC for this.</string>
    <!-- Education toast text for All Apps [CHAR_LIMIT=100] -->
    <string name="all_apps_edu_toast_content">To view all your apps, press the action key on your keyboard</string>

    <!-- Title of the one line view of a redacted notification -->
    <string name="redacted_notification_single_line_title">Redacted</string>
    <!-- Main text of the one line view of a redacted notification -->
    <string name="redacted_notification_single_line_text">Unlock to view</string>

    <!-- Education notification title for Back [CHAR_LIMIT=100] -->
    <string name="back_edu_notification_title">Use your touchpad to go back</string>
    <!-- Education notification text for Back [CHAR_LIMIT=100] -->
+2 −2
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@
package com.android.systemui.statusbar;

import static android.app.Flags.keyguardPrivateNotifications;
import static android.app.Flags.redactSensitiveContentNotificationsOnLockscreen;
import static android.app.StatusBarManager.ACTION_KEYGUARD_PRIVATE_NOTIFICATIONS_CHANGED;
import static android.app.StatusBarManager.EXTRA_KM_PRIVATE_NOTIFS_ALLOWED;
import static android.app.admin.DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED;
@@ -72,6 +71,7 @@ import com.android.systemui.settings.UserTracker;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection;
import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider;
import com.android.systemui.statusbar.notification.row.shared.LockscreenOtpRedaction;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.util.ListenerSet;
@@ -655,7 +655,7 @@ public class NotificationLockscreenUserManagerImpl implements
                !userAllowsPrivateNotificationsInPublic(mCurrentUserId);
        boolean isNotifForManagedProfile = mCurrentManagedProfiles.contains(userId);
        boolean isNotifUserRedacted = !userAllowsPrivateNotificationsInPublic(userId);
        boolean isNotifSensitive = redactSensitiveContentNotificationsOnLockscreen()
        boolean isNotifSensitive = LockscreenOtpRedaction.isEnabled()
                && ent.getRanking() != null && ent.getRanking().hasSensitiveContent();

        // redact notifications if the current user is redacting notifications or the notification
+14 −3
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static com.android.server.notification.Flags.screenshareNotificationHidin
import static com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.FLAG_CONTENT_VIEW_CONTRACTED;
import static com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.FLAG_CONTENT_VIEW_EXPANDED;
import static com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.FLAG_CONTENT_VIEW_PUBLIC;
import static com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.FLAG_CONTENT_VIEW_PUBLIC_SINGLE_LINE;
import static com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.FLAG_CONTENT_VIEW_SINGLE_LINE;
import static com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.FLAG_GROUP_SUMMARY_HEADER;
import static com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.FLAG_LOW_PRIORITY_GROUP_SUMMARY_HEADER;
@@ -54,6 +55,7 @@ import com.android.systemui.statusbar.notification.row.RowInflaterTask;
import com.android.systemui.statusbar.notification.row.dagger.ExpandableNotificationRowComponent;
import com.android.systemui.statusbar.notification.row.shared.AsyncGroupHeaderViewInflation;
import com.android.systemui.statusbar.notification.row.shared.AsyncHybridViewInflation;
import com.android.systemui.statusbar.notification.row.shared.LockscreenOtpRedaction;
import com.android.systemui.statusbar.notification.stack.NotificationListContainer;

import javax.inject.Inject;
@@ -253,10 +255,11 @@ public class NotificationRowBinderImpl implements NotificationRowBinder {
        params.requireContentViews(FLAG_CONTENT_VIEW_EXPANDED);
        params.setUseIncreasedCollapsedHeight(useIncreasedCollapsedHeight);
        params.setUseMinimized(isMinimized);

        if (screenshareNotificationHiding()
        boolean needsRedaction = screenshareNotificationHiding()
                ? inflaterParams.getNeedsRedaction()
                : mNotificationLockscreenUserManager.needsRedaction(entry)) {
                : mNotificationLockscreenUserManager.needsRedaction(entry);

        if (needsRedaction) {
            params.requireContentViews(FLAG_CONTENT_VIEW_PUBLIC);
        } else {
            params.markContentViewsFreeable(FLAG_CONTENT_VIEW_PUBLIC);
@@ -272,6 +275,14 @@ public class NotificationRowBinderImpl implements NotificationRowBinder {
            }
        }

        if (LockscreenOtpRedaction.isEnabled()) {
            if (inflaterParams.isChildInGroup() && needsRedaction) {
                params.requireContentViews(FLAG_CONTENT_VIEW_PUBLIC_SINGLE_LINE);
            } else {
                params.markContentViewsFreeable(FLAG_CONTENT_VIEW_PUBLIC_SINGLE_LINE);
            }
        }

        if (AsyncGroupHeaderViewInflation.isEnabled()) {
            if (inflaterParams.isGroupSummary()) {
                params.requireContentViews(FLAG_GROUP_SUMMARY_HEADER);
+4 −0
Original line number Diff line number Diff line
@@ -102,6 +102,7 @@ import com.android.systemui.statusbar.notification.logging.NotificationCounters;
import com.android.systemui.statusbar.notification.people.PeopleNotificationIdentifier;
import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.InflationFlag;
import com.android.systemui.statusbar.notification.row.shared.AsyncGroupHeaderViewInflation;
import com.android.systemui.statusbar.notification.row.shared.LockscreenOtpRedaction;
import com.android.systemui.statusbar.notification.row.wrapper.NotificationCompactMessagingTemplateViewWrapper;
import com.android.systemui.statusbar.notification.row.wrapper.NotificationViewWrapper;
import com.android.systemui.statusbar.notification.shared.NotificationContentAlphaOptimization;
@@ -997,6 +998,9 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        }
        mNotificationParent = isChildInGroup ? parent : null;
        mPrivateLayout.setIsChildInGroup(isChildInGroup);
        if (LockscreenOtpRedaction.isEnabled()) {
            mPublicLayout.setIsChildInGroup(isChildInGroup);
        }

        updateBackgroundForGroupState();
        updateClickAndFocus();
Loading