AOD: Implement redacted notificatinos
Test: Turn on "show sensitive notifications on lockscreen", receive notification, observe AOD
Bug: 36610748
Change-Id: I981ef4cea7cefc76dcd55ebad9d05c758927dabb
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationInflater.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationInflater.java
index 73eecbb..2e34f24 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationInflater.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationInflater.java
@@ -21,6 +21,8 @@
import android.service.notification.StatusBarNotification;
import android.util.Log;
import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewParent;
import android.widget.RemoteViews;
import com.android.internal.annotations.VisibleForTesting;
@@ -49,6 +51,7 @@
private RemoteViews.OnClickHandler mRemoteViewClickHandler;
private boolean mIsChildInGroup;
private InflationExceptionHandler mInflateExceptionHandler;
+ private boolean mRedactAmbient;
public NotificationInflater(ExpandableNotificationRow row) {
mRow = row;
@@ -92,6 +95,21 @@
mRemoteViewClickHandler = remoteViewClickHandler;
}
+ public void setRedactAmbient(boolean redactAmbient) {
+ if (mRedactAmbient != redactAmbient) {
+ mRedactAmbient = redactAmbient;
+ if (mRow.getEntry() == null) {
+ return;
+ }
+ try {
+ inflateNotificationViews(FLAG_REINFLATE_AMBIENT_VIEW);
+ } catch (InflationException e) {
+ mInflateExceptionHandler.handleInflationException(
+ mRow.getStatusBarNotification(), e);
+ }
+ }
+ }
+
public void inflateNotificationViews() throws InflationException {
inflateNotificationViews(FLAG_REINFLATE_ALL);
}
@@ -123,6 +141,8 @@
Notification.Builder builder, Context packageContext) {
NotificationData.Entry entry = mRow.getEntry();
NotificationContentView privateLayout = mRow.getPrivateLayout();
+ NotificationContentView publicLayout = mRow.getPublicLayout();
+
boolean isLowPriority = mIsLowPriority && !mIsChildInGroup;
if ((reInflateFlags & FLAG_REINFLATE_CONTENT_VIEW) != 0) {
final RemoteViews newContentView = createContentView(builder,
@@ -190,7 +210,6 @@
}
if ((reInflateFlags & FLAG_REINFLATE_PUBLIC_VIEW) != 0) {
- NotificationContentView publicLayout = mRow.getPublicLayout();
final RemoteViews newPublicNotification
= builder.makePublicContentView();
if (!compareRemoteViews(newPublicNotification, entry.cachedPublicContentView)) {
@@ -209,18 +228,24 @@
}
if ((reInflateFlags & FLAG_REINFLATE_AMBIENT_VIEW) != 0) {
- final RemoteViews newAmbientNotification
- = builder.makeAmbientNotification();
- if (!compareRemoteViews(newAmbientNotification, entry.cachedAmbientContentView)) {
+ final RemoteViews newAmbientNotification = mRedactAmbient
+ ? builder.makePublicAmbientNotification()
+ : builder.makeAmbientNotification();
+ NotificationContentView newParent = mRedactAmbient ? publicLayout : privateLayout;
+ NotificationContentView otherParent = !mRedactAmbient ? publicLayout : privateLayout;
+
+ if (newParent.getAmbientChild() == null ||
+ !compareRemoteViews(newAmbientNotification, entry.cachedAmbientContentView)) {
View ambientContentView = newAmbientNotification.apply(
packageContext,
- privateLayout,
+ newParent,
mRemoteViewClickHandler);
ambientContentView.setIsRootNamespace(true);
- privateLayout.setAmbientChild(ambientContentView);
+ newParent.setAmbientChild(ambientContentView);
+ otherParent.setAmbientChild(null);
} else {
newAmbientNotification.reapply(packageContext,
- privateLayout.getAmbientChild(),
+ newParent.getAmbientChild(),
mRemoteViewClickHandler);
}
entry.cachedAmbientContentView = newAmbientNotification;