Merge changes I001413f1,Id59a28c0 into rvc-dev am: a13956797e am: 72c20ad04a
Change-Id: I7e79c1cd8ba7f1e0e32765ed29b1cb3abdfec0bb
This commit is contained in:
@@ -88,14 +88,11 @@ import dagger.Lazy;
|
|||||||
* @see #getActiveNotificationUnfiltered(String) to check if a key exists
|
* @see #getActiveNotificationUnfiltered(String) to check if a key exists
|
||||||
* @see #getPendingNotificationsIterator() for an iterator over the pending notifications
|
* @see #getPendingNotificationsIterator() for an iterator over the pending notifications
|
||||||
* @see #getPendingOrActiveNotif(String) to find a notification exists for that key in any list
|
* @see #getPendingOrActiveNotif(String) to find a notification exists for that key in any list
|
||||||
* @see #getPendingAndActiveNotifications() to get the entire set of Notifications that we're
|
|
||||||
* aware of
|
|
||||||
* @see #getActiveNotificationsForCurrentUser() to see every notification that the current user owns
|
* @see #getActiveNotificationsForCurrentUser() to see every notification that the current user owns
|
||||||
*/
|
*/
|
||||||
public class NotificationEntryManager implements
|
public class NotificationEntryManager implements
|
||||||
CommonNotifCollection,
|
CommonNotifCollection,
|
||||||
Dumpable,
|
Dumpable,
|
||||||
InflationCallback,
|
|
||||||
VisualStabilityManager.Callback {
|
VisualStabilityManager.Callback {
|
||||||
private static final String TAG = "NotificationEntryMgr";
|
private static final String TAG = "NotificationEntryMgr";
|
||||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||||
@@ -309,12 +306,7 @@ public class NotificationEntryManager implements
|
|||||||
*
|
*
|
||||||
* WARNING: this will call back into us. Don't hold any locks.
|
* WARNING: this will call back into us. Don't hold any locks.
|
||||||
*/
|
*/
|
||||||
@Override
|
private void handleInflationException(StatusBarNotification n, Exception e) {
|
||||||
public void handleInflationException(NotificationEntry n, Exception e) {
|
|
||||||
handleInflationException(n.getSbn(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handleInflationException(StatusBarNotification n, Exception e) {
|
|
||||||
removeNotificationInternal(
|
removeNotificationInternal(
|
||||||
n.getKey(), null, null, true /* forceRemove */, false /* removedByUser */,
|
n.getKey(), null, null, true /* forceRemove */, false /* removedByUser */,
|
||||||
REASON_ERROR);
|
REASON_ERROR);
|
||||||
@@ -323,6 +315,12 @@ public class NotificationEntryManager implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final InflationCallback mInflationCallback = new InflationCallback() {
|
||||||
|
@Override
|
||||||
|
public void handleInflationException(NotificationEntry entry, Exception e) {
|
||||||
|
NotificationEntryManager.this.handleInflationException(entry.getSbn(), e);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAsyncInflationFinished(NotificationEntry entry) {
|
public void onAsyncInflationFinished(NotificationEntry entry) {
|
||||||
mPendingNotifications.remove(entry.getKey());
|
mPendingNotifications.remove(entry.getKey());
|
||||||
@@ -347,6 +345,7 @@ public class NotificationEntryManager implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private final NotificationHandler mNotifListener = new NotificationHandler() {
|
private final NotificationHandler mNotifListener = new NotificationHandler() {
|
||||||
@Override
|
@Override
|
||||||
@@ -558,6 +557,10 @@ public class NotificationEntryManager implements
|
|||||||
ranking,
|
ranking,
|
||||||
mFgsFeatureController.isForegroundServiceDismissalEnabled(),
|
mFgsFeatureController.isForegroundServiceDismissalEnabled(),
|
||||||
SystemClock.uptimeMillis());
|
SystemClock.uptimeMillis());
|
||||||
|
for (NotifCollectionListener listener : mNotifCollectionListeners) {
|
||||||
|
listener.onEntryBind(entry, notification);
|
||||||
|
}
|
||||||
|
mAllNotifications.add(entry);
|
||||||
|
|
||||||
mLeakDetector.trackInstance(entry);
|
mLeakDetector.trackInstance(entry);
|
||||||
|
|
||||||
@@ -568,8 +571,10 @@ public class NotificationEntryManager implements
|
|||||||
// Construct the expanded view.
|
// Construct the expanded view.
|
||||||
if (!mFeatureFlags.isNewNotifPipelineRenderingEnabled()) {
|
if (!mFeatureFlags.isNewNotifPipelineRenderingEnabled()) {
|
||||||
mNotificationRowBinderLazy.get()
|
mNotificationRowBinderLazy.get()
|
||||||
.inflateViews(entry, () -> performRemoveNotification(notification,
|
.inflateViews(
|
||||||
REASON_CANCEL));
|
entry,
|
||||||
|
() -> performRemoveNotification(notification, REASON_CANCEL),
|
||||||
|
mInflationCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
abortExistingInflation(key, "addNotification");
|
abortExistingInflation(key, "addNotification");
|
||||||
@@ -612,7 +617,9 @@ public class NotificationEntryManager implements
|
|||||||
updateRankingAndSort(ranking, "updateNotificationInternal");
|
updateRankingAndSort(ranking, "updateNotificationInternal");
|
||||||
StatusBarNotification oldSbn = entry.getSbn();
|
StatusBarNotification oldSbn = entry.getSbn();
|
||||||
entry.setSbn(notification);
|
entry.setSbn(notification);
|
||||||
mGroupManager.onEntryUpdated(entry, oldSbn);
|
for (NotifCollectionListener listener : mNotifCollectionListeners) {
|
||||||
|
listener.onEntryBind(entry, notification);
|
||||||
|
} mGroupManager.onEntryUpdated(entry, oldSbn);
|
||||||
|
|
||||||
mLogger.logNotifUpdated(entry.getKey());
|
mLogger.logNotifUpdated(entry.getKey());
|
||||||
for (NotificationEntryListener listener : mNotificationEntryListeners) {
|
for (NotificationEntryListener listener : mNotificationEntryListeners) {
|
||||||
@@ -624,8 +631,10 @@ public class NotificationEntryManager implements
|
|||||||
|
|
||||||
if (!mFeatureFlags.isNewNotifPipelineRenderingEnabled()) {
|
if (!mFeatureFlags.isNewNotifPipelineRenderingEnabled()) {
|
||||||
mNotificationRowBinderLazy.get()
|
mNotificationRowBinderLazy.get()
|
||||||
.inflateViews(entry, () -> performRemoveNotification(notification,
|
.inflateViews(
|
||||||
REASON_CANCEL));
|
entry,
|
||||||
|
() -> performRemoveNotification(notification, REASON_CANCEL),
|
||||||
|
mInflationCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateNotifications("updateNotificationInternal");
|
updateNotifications("updateNotificationInternal");
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ import com.android.systemui.statusbar.FeatureFlags;
|
|||||||
import com.android.systemui.statusbar.notification.collection.coalescer.CoalescedEvent;
|
import com.android.systemui.statusbar.notification.collection.coalescer.CoalescedEvent;
|
||||||
import com.android.systemui.statusbar.notification.collection.coalescer.GroupCoalescer;
|
import com.android.systemui.statusbar.notification.collection.coalescer.GroupCoalescer;
|
||||||
import com.android.systemui.statusbar.notification.collection.coalescer.GroupCoalescer.BatchableNotificationHandler;
|
import com.android.systemui.statusbar.notification.collection.coalescer.GroupCoalescer.BatchableNotificationHandler;
|
||||||
|
import com.android.systemui.statusbar.notification.collection.notifcollection.BindEntryEvent;
|
||||||
import com.android.systemui.statusbar.notification.collection.notifcollection.CleanUpEntryEvent;
|
import com.android.systemui.statusbar.notification.collection.notifcollection.CleanUpEntryEvent;
|
||||||
import com.android.systemui.statusbar.notification.collection.notifcollection.CollectionReadyForBuildListener;
|
import com.android.systemui.statusbar.notification.collection.notifcollection.CollectionReadyForBuildListener;
|
||||||
import com.android.systemui.statusbar.notification.collection.notifcollection.DismissedByUserStats;
|
import com.android.systemui.statusbar.notification.collection.notifcollection.DismissedByUserStats;
|
||||||
@@ -389,6 +390,7 @@ public class NotifCollection implements Dumpable {
|
|||||||
if (entry == null) {
|
if (entry == null) {
|
||||||
// A new notification!
|
// A new notification!
|
||||||
entry = new NotificationEntry(sbn, ranking, SystemClock.uptimeMillis());
|
entry = new NotificationEntry(sbn, ranking, SystemClock.uptimeMillis());
|
||||||
|
mEventQueue.add(new BindEntryEvent(entry, sbn));
|
||||||
mNotificationSet.put(sbn.getKey(), entry);
|
mNotificationSet.put(sbn.getKey(), entry);
|
||||||
|
|
||||||
mLogger.logNotifPosted(sbn.getKey());
|
mLogger.logNotifPosted(sbn.getKey());
|
||||||
@@ -409,6 +411,7 @@ public class NotifCollection implements Dumpable {
|
|||||||
entry.mCancellationReason = REASON_NOT_CANCELED;
|
entry.mCancellationReason = REASON_NOT_CANCELED;
|
||||||
|
|
||||||
entry.setSbn(sbn);
|
entry.setSbn(sbn);
|
||||||
|
mEventQueue.add(new BindEntryEvent(entry, sbn));
|
||||||
|
|
||||||
mLogger.logNotifUpdated(sbn.getKey());
|
mLogger.logNotifUpdated(sbn.getKey());
|
||||||
mEventQueue.add(new EntryUpdatedEvent(entry));
|
mEventQueue.add(new EntryUpdatedEvent(entry));
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ public class NotifInflaterImpl implements NotifInflater {
|
|||||||
private final NotifPipeline mNotifPipeline;
|
private final NotifPipeline mNotifPipeline;
|
||||||
|
|
||||||
private NotificationRowBinderImpl mNotificationRowBinder;
|
private NotificationRowBinderImpl mNotificationRowBinder;
|
||||||
private InflationCallback mExternalInflationCallback;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public NotifInflaterImpl(
|
public NotifInflaterImpl(
|
||||||
@@ -66,17 +65,11 @@ public class NotifInflaterImpl implements NotifInflater {
|
|||||||
*/
|
*/
|
||||||
public void setRowBinder(NotificationRowBinderImpl rowBinder) {
|
public void setRowBinder(NotificationRowBinderImpl rowBinder) {
|
||||||
mNotificationRowBinder = rowBinder;
|
mNotificationRowBinder = rowBinder;
|
||||||
mNotificationRowBinder.setInflationCallback(mInflationCallback);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setInflationCallback(InflationCallback callback) {
|
public void rebindViews(NotificationEntry entry, InflationCallback callback) {
|
||||||
mExternalInflationCallback = callback;
|
inflateViews(entry, callback);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void rebindViews(NotificationEntry entry) {
|
|
||||||
inflateViews(entry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -84,11 +77,14 @@ public class NotifInflaterImpl implements NotifInflater {
|
|||||||
* views are bound.
|
* views are bound.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void inflateViews(NotificationEntry entry) {
|
public void inflateViews(NotificationEntry entry, InflationCallback callback) {
|
||||||
try {
|
try {
|
||||||
requireBinder().inflateViews(entry, getDismissCallback(entry));
|
requireBinder().inflateViews(
|
||||||
|
entry,
|
||||||
|
getDismissCallback(entry),
|
||||||
|
wrapInflationCallback(callback));
|
||||||
} catch (InflationException e) {
|
} catch (InflationException e) {
|
||||||
// logged in mInflationCallback.handleInflationException
|
mNotifErrorManager.setInflationError(entry, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,16 +117,9 @@ public class NotifInflaterImpl implements NotifInflater {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private NotificationRowBinderImpl requireBinder() {
|
private NotificationContentInflater.InflationCallback wrapInflationCallback(
|
||||||
if (mNotificationRowBinder == null) {
|
InflationCallback callback) {
|
||||||
throw new RuntimeException("NotificationRowBinder must be attached before using "
|
return new NotificationContentInflater.InflationCallback() {
|
||||||
+ "NotifInflaterImpl.");
|
|
||||||
}
|
|
||||||
return mNotificationRowBinder;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final NotificationContentInflater.InflationCallback mInflationCallback =
|
|
||||||
new NotificationContentInflater.InflationCallback() {
|
|
||||||
@Override
|
@Override
|
||||||
public void handleInflationException(
|
public void handleInflationException(
|
||||||
NotificationEntry entry,
|
NotificationEntry entry,
|
||||||
@@ -141,9 +130,18 @@ public class NotifInflaterImpl implements NotifInflater {
|
|||||||
@Override
|
@Override
|
||||||
public void onAsyncInflationFinished(NotificationEntry entry) {
|
public void onAsyncInflationFinished(NotificationEntry entry) {
|
||||||
mNotifErrorManager.clearInflationError(entry);
|
mNotifErrorManager.clearInflationError(entry);
|
||||||
if (mExternalInflationCallback != null) {
|
if (callback != null) {
|
||||||
mExternalInflationCallback.onInflationFinished(entry);
|
callback.onInflationFinished(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private NotificationRowBinderImpl requireBinder() {
|
||||||
|
if (mNotificationRowBinder == null) {
|
||||||
|
throw new RuntimeException("NotificationRowBinder must be attached before using "
|
||||||
|
+ "NotifInflaterImpl.");
|
||||||
|
}
|
||||||
|
return mNotificationRowBinder;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -408,15 +408,6 @@ public final class NotificationEntry extends ListEntry {
|
|||||||
return wasBubble != isBubble();
|
return wasBubble != isBubble();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Resets the notification entry to be re-used.
|
|
||||||
*/
|
|
||||||
public void reset() {
|
|
||||||
if (row != null) {
|
|
||||||
row.reset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotificationSectionsManager.PriorityBucket
|
@NotificationSectionsManager.PriorityBucket
|
||||||
public int getBucket() {
|
public int getBucket() {
|
||||||
return mBucket;
|
return mBucket;
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2020 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.systemui.statusbar.notification.collection
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.pm.PackageManager
|
||||||
|
import android.service.notification.StatusBarNotification
|
||||||
|
import android.util.Log
|
||||||
|
import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection
|
||||||
|
import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener
|
||||||
|
import com.android.systemui.statusbar.phone.StatusBar
|
||||||
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
class TargetSdkResolver @Inject constructor(
|
||||||
|
private val context: Context,
|
||||||
|
private val collection: CommonNotifCollection
|
||||||
|
) {
|
||||||
|
init {
|
||||||
|
collection.addCollectionListener(object : NotifCollectionListener {
|
||||||
|
override fun onEntryBind(entry: NotificationEntry, sbn: StatusBarNotification) {
|
||||||
|
entry.targetSdk = resolveNotificationSdk(sbn)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun resolveNotificationSdk(sbn: StatusBarNotification): Int {
|
||||||
|
val pmUser = StatusBar.getPackageManagerForUser(context, sbn.user.identifier)
|
||||||
|
var targetSdk = 0
|
||||||
|
// Extract target SDK version.
|
||||||
|
try {
|
||||||
|
val info = pmUser.getApplicationInfo(sbn.packageName, 0)
|
||||||
|
targetSdk = info.targetSdkVersion
|
||||||
|
} catch (ex: PackageManager.NameNotFoundException) {
|
||||||
|
Log.e(TAG, "Failed looking up ApplicationInfo for " + sbn.packageName, ex)
|
||||||
|
}
|
||||||
|
return targetSdk
|
||||||
|
}
|
||||||
|
|
||||||
|
private val TAG = "TargetSdkResolver"
|
||||||
|
}
|
||||||
@@ -72,7 +72,6 @@ public class PreparationCoordinator implements Coordinator {
|
|||||||
) {
|
) {
|
||||||
mLogger = logger;
|
mLogger = logger;
|
||||||
mNotifInflater = notifInflater;
|
mNotifInflater = notifInflater;
|
||||||
mNotifInflater.setInflationCallback(mInflationCallback);
|
|
||||||
mNotifErrorManager = errorManager;
|
mNotifErrorManager = errorManager;
|
||||||
mNotifErrorManager.addInflationErrorListener(mInflationErrorListener);
|
mNotifErrorManager.addInflationErrorListener(mInflationErrorListener);
|
||||||
mViewBarn = viewBarn;
|
mViewBarn = viewBarn;
|
||||||
@@ -218,11 +217,11 @@ public class PreparationCoordinator implements Coordinator {
|
|||||||
|
|
||||||
private void inflateEntry(NotificationEntry entry, String reason) {
|
private void inflateEntry(NotificationEntry entry, String reason) {
|
||||||
abortInflation(entry, reason);
|
abortInflation(entry, reason);
|
||||||
mNotifInflater.inflateViews(entry);
|
mNotifInflater.inflateViews(entry, mInflationCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void rebind(NotificationEntry entry, String reason) {
|
private void rebind(NotificationEntry entry, String reason) {
|
||||||
mNotifInflater.rebindViews(entry);
|
mNotifInflater.rebindViews(entry, mInflationCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void abortInflation(NotificationEntry entry, String reason) {
|
private void abortInflation(NotificationEntry entry, String reason) {
|
||||||
|
|||||||
@@ -24,22 +24,20 @@ import com.android.systemui.statusbar.notification.collection.coordinator.Prepar
|
|||||||
* main thread. When the inflation is finished, NotifInflater will trigger its InflationCallback.
|
* main thread. When the inflation is finished, NotifInflater will trigger its InflationCallback.
|
||||||
*/
|
*/
|
||||||
public interface NotifInflater {
|
public interface NotifInflater {
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback used when inflation is finished.
|
|
||||||
*/
|
|
||||||
void setInflationCallback(InflationCallback callback);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called to rebind the entry's views.
|
* Called to rebind the entry's views.
|
||||||
|
*
|
||||||
|
* @param callback callback called after inflation finishes
|
||||||
*/
|
*/
|
||||||
void rebindViews(NotificationEntry entry);
|
void rebindViews(NotificationEntry entry, InflationCallback callback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called to inflate the views of an entry. Views are not considered inflated until all of its
|
* Called to inflate the views of an entry. Views are not considered inflated until all of its
|
||||||
* views are bound. Once all views are inflated, the InflationCallback is triggered.
|
* views are bound. Once all views are inflated, the InflationCallback is triggered.
|
||||||
|
*
|
||||||
|
* @param callback callback called after inflation finishes
|
||||||
*/
|
*/
|
||||||
void inflateViews(NotificationEntry entry);
|
void inflateViews(NotificationEntry entry, InflationCallback callback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request to stop the inflation of an entry. For example, called when a notification is
|
* Request to stop the inflation of an entry. For example, called when a notification is
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import com.android.systemui.statusbar.NotificationUiAdjustment;
|
|||||||
import com.android.systemui.statusbar.notification.InflationException;
|
import com.android.systemui.statusbar.notification.InflationException;
|
||||||
import com.android.systemui.statusbar.notification.NotificationEntryManager;
|
import com.android.systemui.statusbar.notification.NotificationEntryManager;
|
||||||
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
|
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
|
||||||
|
import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used by the {@link NotificationEntryManager}. When notifications are added or updated, the binder
|
* Used by the {@link NotificationEntryManager}. When notifications are added or updated, the binder
|
||||||
@@ -37,7 +38,8 @@ public interface NotificationRowBinder {
|
|||||||
*/
|
*/
|
||||||
void inflateViews(
|
void inflateViews(
|
||||||
NotificationEntry entry,
|
NotificationEntry entry,
|
||||||
Runnable onDismissRunnable)
|
Runnable onDismissRunnable,
|
||||||
|
NotificationRowContentBinder.InflationCallback callback)
|
||||||
throws InflationException;
|
throws InflationException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -16,13 +16,11 @@
|
|||||||
|
|
||||||
package com.android.systemui.statusbar.notification.collection.inflation;
|
package com.android.systemui.statusbar.notification.collection.inflation;
|
||||||
|
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.ApplicationInfo;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.service.notification.StatusBarNotification;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import com.android.internal.util.NotificationMessagingUtil;
|
import com.android.internal.util.NotificationMessagingUtil;
|
||||||
@@ -44,9 +42,6 @@ import com.android.systemui.statusbar.notification.row.RowContentBindStage;
|
|||||||
import com.android.systemui.statusbar.notification.row.RowInflaterTask;
|
import com.android.systemui.statusbar.notification.row.RowInflaterTask;
|
||||||
import com.android.systemui.statusbar.notification.row.dagger.ExpandableNotificationRowComponent;
|
import com.android.systemui.statusbar.notification.row.dagger.ExpandableNotificationRowComponent;
|
||||||
import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
|
import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
|
||||||
import com.android.systemui.statusbar.phone.StatusBar;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Provider;
|
import javax.inject.Provider;
|
||||||
@@ -72,7 +67,6 @@ public class NotificationRowBinderImpl implements NotificationRowBinder {
|
|||||||
|
|
||||||
private NotificationPresenter mPresenter;
|
private NotificationPresenter mPresenter;
|
||||||
private NotificationListContainer mListContainer;
|
private NotificationListContainer mListContainer;
|
||||||
private NotificationRowContentBinder.InflationCallback mInflationCallback;
|
|
||||||
private BindRowCallback mBindRowCallback;
|
private BindRowCallback mBindRowCallback;
|
||||||
private NotificationClicker mNotificationClicker;
|
private NotificationClicker mNotificationClicker;
|
||||||
|
|
||||||
@@ -113,10 +107,6 @@ public class NotificationRowBinderImpl implements NotificationRowBinder {
|
|||||||
mIconManager.attach();
|
mIconManager.attach();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInflationCallback(NotificationRowContentBinder.InflationCallback callback) {
|
|
||||||
mInflationCallback = callback;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNotificationClicker(NotificationClicker clicker) {
|
public void setNotificationClicker(NotificationClicker clicker) {
|
||||||
mNotificationClicker = clicker;
|
mNotificationClicker = clicker;
|
||||||
}
|
}
|
||||||
@@ -125,17 +115,19 @@ public class NotificationRowBinderImpl implements NotificationRowBinder {
|
|||||||
* Inflates the views for the given entry (possibly asynchronously).
|
* Inflates the views for the given entry (possibly asynchronously).
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void inflateViews(NotificationEntry entry, Runnable onDismissRunnable)
|
public void inflateViews(
|
||||||
|
NotificationEntry entry,
|
||||||
|
Runnable onDismissRunnable,
|
||||||
|
NotificationRowContentBinder.InflationCallback callback)
|
||||||
throws InflationException {
|
throws InflationException {
|
||||||
ViewGroup parent = mListContainer.getViewParentForNotification(entry);
|
ViewGroup parent = mListContainer.getViewParentForNotification(entry);
|
||||||
PackageManager pmUser = StatusBar.getPackageManagerForUser(mContext,
|
|
||||||
entry.getSbn().getUser().getIdentifier());
|
|
||||||
|
|
||||||
final StatusBarNotification sbn = entry.getSbn();
|
|
||||||
if (entry.rowExists()) {
|
if (entry.rowExists()) {
|
||||||
mIconManager.updateIcons(entry);
|
mIconManager.updateIcons(entry);
|
||||||
entry.reset();
|
ExpandableNotificationRow row = entry.getRow();
|
||||||
updateNotification(entry, pmUser, sbn, entry.getRow());
|
row.reset();
|
||||||
|
updateRow(entry, row);
|
||||||
|
inflateContentViews(entry, row, callback);
|
||||||
entry.getRowController().setOnDismissRunnable(onDismissRunnable);
|
entry.getRowController().setOnDismissRunnable(onDismissRunnable);
|
||||||
} else {
|
} else {
|
||||||
mIconManager.createIcons(entry);
|
mIconManager.createIcons(entry);
|
||||||
@@ -147,7 +139,6 @@ public class NotificationRowBinderImpl implements NotificationRowBinder {
|
|||||||
.expandableNotificationRow(row)
|
.expandableNotificationRow(row)
|
||||||
.notificationEntry(entry)
|
.notificationEntry(entry)
|
||||||
.onDismissRunnable(onDismissRunnable)
|
.onDismissRunnable(onDismissRunnable)
|
||||||
.inflationCallback(mInflationCallback)
|
|
||||||
.rowContentBindStage(mRowContentBindStage)
|
.rowContentBindStage(mRowContentBindStage)
|
||||||
.onExpandClickListener(mPresenter)
|
.onExpandClickListener(mPresenter)
|
||||||
.build();
|
.build();
|
||||||
@@ -155,26 +146,34 @@ public class NotificationRowBinderImpl implements NotificationRowBinder {
|
|||||||
component.getExpandableNotificationRowController();
|
component.getExpandableNotificationRowController();
|
||||||
rowController.init();
|
rowController.init();
|
||||||
entry.setRowController(rowController);
|
entry.setRowController(rowController);
|
||||||
bindRow(entry, pmUser, sbn, row);
|
bindRow(entry, row);
|
||||||
updateNotification(entry, pmUser, sbn, row);
|
updateRow(entry, row);
|
||||||
|
inflateContentViews(entry, row, callback);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: This method associates a row with an entry, but eventually needs to not do that
|
/**
|
||||||
private void bindRow(NotificationEntry entry, PackageManager pmUser,
|
* Bind row to various controllers and managers. This is only called when the row is first
|
||||||
StatusBarNotification sbn, ExpandableNotificationRow row) {
|
* created.
|
||||||
|
*
|
||||||
|
* TODO: This method associates a row with an entry, but eventually needs to not do that
|
||||||
|
*/
|
||||||
|
private void bindRow(NotificationEntry entry, ExpandableNotificationRow row) {
|
||||||
mListContainer.bindRow(row);
|
mListContainer.bindRow(row);
|
||||||
mNotificationRemoteInputManager.bindRow(row);
|
mNotificationRemoteInputManager.bindRow(row);
|
||||||
|
row.setOnActivatedListener(mPresenter);
|
||||||
entry.setRow(row);
|
entry.setRow(row);
|
||||||
row.setEntry(entry);
|
row.setEntry(entry);
|
||||||
mNotifBindPipeline.manageRow(entry, row);
|
mNotifBindPipeline.manageRow(entry, row);
|
||||||
mBindRowCallback.onBindRow(entry, pmUser, sbn, row);
|
mBindRowCallback.onBindRow(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the views bound to an entry when the entry's ranking changes, either in-place or by
|
* Updates the views bound to an entry when the entry's ranking changes, either in-place or by
|
||||||
* reinflating them.
|
* reinflating them.
|
||||||
|
*
|
||||||
|
* TODO: Should this method be in this class?
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onNotificationRankingUpdated(
|
public void onNotificationRankingUpdated(
|
||||||
@@ -184,11 +183,10 @@ public class NotificationRowBinderImpl implements NotificationRowBinder {
|
|||||||
NotificationUiAdjustment newAdjustment) {
|
NotificationUiAdjustment newAdjustment) {
|
||||||
if (NotificationUiAdjustment.needReinflate(oldAdjustment, newAdjustment)) {
|
if (NotificationUiAdjustment.needReinflate(oldAdjustment, newAdjustment)) {
|
||||||
if (entry.rowExists()) {
|
if (entry.rowExists()) {
|
||||||
entry.reset();
|
ExpandableNotificationRow row = entry.getRow();
|
||||||
PackageManager pmUser = StatusBar.getPackageManagerForUser(
|
row.reset();
|
||||||
mContext,
|
updateRow(entry, row);
|
||||||
entry.getSbn().getUser().getIdentifier());
|
inflateContentViews(entry, row, null /* callback */);
|
||||||
updateNotification(entry, pmUser, entry.getSbn(), entry.getRow());
|
|
||||||
} else {
|
} else {
|
||||||
// Once the RowInflaterTask is done, it will pick up the updated entry, so
|
// Once the RowInflaterTask is done, it will pick up the updated entry, so
|
||||||
// no-op here.
|
// no-op here.
|
||||||
@@ -202,59 +200,53 @@ public class NotificationRowBinderImpl implements NotificationRowBinder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateNotification(
|
/**
|
||||||
|
* Update row after the notification has updated.
|
||||||
|
*
|
||||||
|
* @param entry notification that has updated
|
||||||
|
*/
|
||||||
|
private void updateRow(
|
||||||
NotificationEntry entry,
|
NotificationEntry entry,
|
||||||
PackageManager pmUser,
|
|
||||||
StatusBarNotification sbn,
|
|
||||||
ExpandableNotificationRow row) {
|
ExpandableNotificationRow row) {
|
||||||
|
|
||||||
// Extract target SDK version.
|
|
||||||
try {
|
|
||||||
ApplicationInfo info = pmUser.getApplicationInfo(sbn.getPackageName(), 0);
|
|
||||||
entry.targetSdk = info.targetSdkVersion;
|
|
||||||
} catch (PackageManager.NameNotFoundException ex) {
|
|
||||||
Log.e(TAG, "Failed looking up ApplicationInfo for " + sbn.getPackageName(), ex);
|
|
||||||
}
|
|
||||||
row.setLegacy(entry.targetSdk >= Build.VERSION_CODES.GINGERBREAD
|
row.setLegacy(entry.targetSdk >= Build.VERSION_CODES.GINGERBREAD
|
||||||
&& entry.targetSdk < Build.VERSION_CODES.LOLLIPOP);
|
&& entry.targetSdk < Build.VERSION_CODES.LOLLIPOP);
|
||||||
|
|
||||||
// TODO: should this be happening somewhere else?
|
// bind the click event to the content area
|
||||||
mIconManager.updateIconTags(entry, entry.targetSdk);
|
requireNonNull(mNotificationClicker).register(row, entry.getSbn());
|
||||||
|
}
|
||||||
row.setOnActivatedListener(mPresenter);
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inflate the row's basic content views.
|
||||||
|
*/
|
||||||
|
private void inflateContentViews(
|
||||||
|
NotificationEntry entry,
|
||||||
|
ExpandableNotificationRow row,
|
||||||
|
NotificationRowContentBinder.InflationCallback inflationCallback) {
|
||||||
final boolean useIncreasedCollapsedHeight =
|
final boolean useIncreasedCollapsedHeight =
|
||||||
mMessagingUtil.isImportantMessaging(sbn, entry.getImportance());
|
mMessagingUtil.isImportantMessaging(entry.getSbn(), entry.getImportance());
|
||||||
final boolean isLowPriority = entry.isAmbient();
|
final boolean isLowPriority = entry.isAmbient();
|
||||||
|
|
||||||
RowContentBindParams params = mRowContentBindStage.getStageParams(entry);
|
RowContentBindParams params = mRowContentBindStage.getStageParams(entry);
|
||||||
params.setUseIncreasedCollapsedHeight(useIncreasedCollapsedHeight);
|
params.setUseIncreasedCollapsedHeight(useIncreasedCollapsedHeight);
|
||||||
params.setUseLowPriority(entry.isAmbient());
|
params.setUseLowPriority(entry.isAmbient());
|
||||||
|
|
||||||
//TODO: Replace this API with RowContentBindParams directly
|
// TODO: Replace this API with RowContentBindParams directly. Also move to a separate
|
||||||
|
// redaction controller.
|
||||||
row.setNeedsRedaction(mNotificationLockscreenUserManager.needsRedaction(entry));
|
row.setNeedsRedaction(mNotificationLockscreenUserManager.needsRedaction(entry));
|
||||||
|
|
||||||
params.rebindAllContentViews();
|
params.rebindAllContentViews();
|
||||||
mRowContentBindStage.requestRebind(entry, en -> {
|
mRowContentBindStage.requestRebind(entry, en -> {
|
||||||
row.setUsesIncreasedCollapsedHeight(useIncreasedCollapsedHeight);
|
row.setUsesIncreasedCollapsedHeight(useIncreasedCollapsedHeight);
|
||||||
row.setIsLowPriority(isLowPriority);
|
row.setIsLowPriority(isLowPriority);
|
||||||
mInflationCallback.onAsyncInflationFinished(en);
|
inflationCallback.onAsyncInflationFinished(en);
|
||||||
});
|
});
|
||||||
|
|
||||||
// bind the click event to the content area
|
|
||||||
Objects.requireNonNull(mNotificationClicker).register(row, sbn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Callback for when a row is bound to an entry. */
|
/** Callback for when a row is bound to an entry. */
|
||||||
public interface BindRowCallback {
|
public interface BindRowCallback {
|
||||||
/**
|
/**
|
||||||
* Called when a new notification and row is created.
|
* Called when a new row is created and bound to a notification.
|
||||||
*
|
|
||||||
* @param entry entry for the notification
|
|
||||||
* @param pmUser package manager for user
|
|
||||||
* @param sbn notification
|
|
||||||
* @param row row for the notification
|
|
||||||
*/
|
*/
|
||||||
void onBindRow(NotificationEntry entry, PackageManager pmUser,
|
void onBindRow(ExpandableNotificationRow row);
|
||||||
StatusBarNotification sbn, ExpandableNotificationRow row);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package com.android.systemui.statusbar.notification.collection.notifcollection;
|
package com.android.systemui.statusbar.notification.collection.notifcollection;
|
||||||
|
|
||||||
import android.service.notification.NotificationListenerService;
|
import android.service.notification.NotificationListenerService;
|
||||||
|
import android.service.notification.StatusBarNotification;
|
||||||
|
|
||||||
import com.android.systemui.statusbar.notification.collection.NotifCollection.CancellationReason;
|
import com.android.systemui.statusbar.notification.collection.NotifCollection.CancellationReason;
|
||||||
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
|
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
|
||||||
@@ -25,6 +26,15 @@ import com.android.systemui.statusbar.notification.collection.NotificationEntry;
|
|||||||
* Listener interface for {@link NotificationEntry} events.
|
* Listener interface for {@link NotificationEntry} events.
|
||||||
*/
|
*/
|
||||||
public interface NotifCollectionListener {
|
public interface NotifCollectionListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the entry is having a new status bar notification bound to it. This should
|
||||||
|
* be used to initialize any derivative state on the entry that needs to update when the
|
||||||
|
* notification is updated.
|
||||||
|
*/
|
||||||
|
default void onEntryBind(NotificationEntry entry, StatusBarNotification sbn) {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called whenever a new {@link NotificationEntry} is initialized. This should be used for
|
* Called whenever a new {@link NotificationEntry} is initialized. This should be used for
|
||||||
* initializing any decorated state tied to the notification.
|
* initializing any decorated state tied to the notification.
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package com.android.systemui.statusbar.notification.collection.notifcollection
|
package com.android.systemui.statusbar.notification.collection.notifcollection
|
||||||
|
|
||||||
import android.service.notification.NotificationListenerService.RankingMap
|
import android.service.notification.NotificationListenerService.RankingMap
|
||||||
|
import android.service.notification.StatusBarNotification
|
||||||
import com.android.systemui.statusbar.notification.collection.NotifCollection
|
import com.android.systemui.statusbar.notification.collection.NotifCollection
|
||||||
import com.android.systemui.statusbar.notification.collection.NotificationEntry
|
import com.android.systemui.statusbar.notification.collection.NotificationEntry
|
||||||
|
|
||||||
@@ -37,6 +38,15 @@ sealed class NotifEvent {
|
|||||||
abstract fun dispatchToListener(listener: NotifCollectionListener)
|
abstract fun dispatchToListener(listener: NotifCollectionListener)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data class BindEntryEvent(
|
||||||
|
val entry: NotificationEntry,
|
||||||
|
val sbn: StatusBarNotification
|
||||||
|
) : NotifEvent() {
|
||||||
|
override fun dispatchToListener(listener: NotifCollectionListener) {
|
||||||
|
listener.onEntryBind(entry, sbn)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
data class InitEntryEvent(
|
data class InitEntryEvent(
|
||||||
val entry: NotificationEntry
|
val entry: NotificationEntry
|
||||||
) : NotifEvent() {
|
) : NotifEvent() {
|
||||||
|
|||||||
@@ -172,18 +172,6 @@ class IconManager @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates tags on the icon views to match the posting app's target SDK level
|
|
||||||
*
|
|
||||||
* Note that this method MUST be called after both [createIcons] and [updateIcons].
|
|
||||||
*/
|
|
||||||
fun updateIconTags(entry: NotificationEntry, targetSdk: Int) {
|
|
||||||
setTagOnIconViews(
|
|
||||||
entry.icons,
|
|
||||||
R.id.icon_is_pre_L,
|
|
||||||
targetSdk < Build.VERSION_CODES.LOLLIPOP)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun updateIconsSafe(entry: NotificationEntry) {
|
private fun updateIconsSafe(entry: NotificationEntry) {
|
||||||
try {
|
try {
|
||||||
updateIcons(entry)
|
updateIcons(entry)
|
||||||
@@ -259,6 +247,7 @@ class IconManager @Inject constructor(
|
|||||||
iconView: StatusBarIconView
|
iconView: StatusBarIconView
|
||||||
) {
|
) {
|
||||||
iconView.setShowsConversation(showsConversation(entry, iconView, iconDescriptor))
|
iconView.setShowsConversation(showsConversation(entry, iconView, iconDescriptor))
|
||||||
|
iconView.setTag(R.id.icon_is_pre_L, entry.targetSdk < Build.VERSION_CODES.LOLLIPOP)
|
||||||
if (!iconView.set(iconDescriptor)) {
|
if (!iconView.set(iconDescriptor)) {
|
||||||
throw InflationException("Couldn't create icon $iconDescriptor")
|
throw InflationException("Couldn't create icon $iconDescriptor")
|
||||||
}
|
}
|
||||||
@@ -326,20 +315,13 @@ class IconManager @Inject constructor(
|
|||||||
val usedInSensitiveContext =
|
val usedInSensitiveContext =
|
||||||
iconView === entry.icons.shelfIcon || iconView === entry.icons.aodIcon
|
iconView === entry.icons.shelfIcon || iconView === entry.icons.aodIcon
|
||||||
val isSmallIcon = iconDescriptor.icon.equals(entry.sbn.notification.smallIcon)
|
val isSmallIcon = iconDescriptor.icon.equals(entry.sbn.notification.smallIcon)
|
||||||
return isImportantConversation(entry) && !isSmallIcon
|
return isImportantConversation(entry) && !isSmallIcon &&
|
||||||
&& (!usedInSensitiveContext || !entry.isSensitive)
|
(!usedInSensitiveContext || !entry.isSensitive)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isImportantConversation(entry: NotificationEntry): Boolean {
|
private fun isImportantConversation(entry: NotificationEntry): Boolean {
|
||||||
return entry.ranking.channel != null && entry.ranking.channel.isImportantConversation
|
return entry.ranking.channel != null && entry.ranking.channel.isImportantConversation
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setTagOnIconViews(icons: IconPack, key: Int, tag: Any) {
|
|
||||||
icons.statusBarIcon?.setTag(key, tag)
|
|
||||||
icons.shelfIcon?.setTag(key, tag)
|
|
||||||
icons.aodIcon?.setTag(key, tag)
|
|
||||||
icons.centeredIcon?.setTag(key, tag)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private const val TAG = "IconManager"
|
private const val TAG = "IconManager"
|
||||||
@@ -108,8 +108,6 @@ class NotificationsControllerImpl @Inject constructor(
|
|||||||
if (featureFlags.isNewNotifPipelineRenderingEnabled) {
|
if (featureFlags.isNewNotifPipelineRenderingEnabled) {
|
||||||
// TODO
|
// TODO
|
||||||
} else {
|
} else {
|
||||||
notificationRowBinder.setInflationCallback(entryManager)
|
|
||||||
|
|
||||||
remoteInputUriController.attach(entryManager)
|
remoteInputUriController.attach(entryManager)
|
||||||
groupAlertTransferHelper.bind(entryManager, groupManager)
|
groupAlertTransferHelper.bind(entryManager, groupManager)
|
||||||
headsUpManager.addListener(groupManager)
|
headsUpManager.addListener(groupManager)
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ public class ExpandableNotificationRowController {
|
|||||||
private final HeadsUpManager mHeadsUpManager;
|
private final HeadsUpManager mHeadsUpManager;
|
||||||
private final ExpandableNotificationRow.OnExpandClickListener mOnExpandClickListener;
|
private final ExpandableNotificationRow.OnExpandClickListener mOnExpandClickListener;
|
||||||
private final StatusBarStateController mStatusBarStateController;
|
private final StatusBarStateController mStatusBarStateController;
|
||||||
private final NotificationRowContentBinder.InflationCallback mInflationCallback;
|
|
||||||
|
|
||||||
private final ExpandableNotificationRow.ExpansionLogger mExpansionLogger =
|
private final ExpandableNotificationRow.ExpansionLogger mExpansionLogger =
|
||||||
this::logNotificationExpansion;
|
this::logNotificationExpansion;
|
||||||
@@ -82,7 +81,6 @@ public class ExpandableNotificationRowController {
|
|||||||
NotificationLogger notificationLogger, HeadsUpManager headsUpManager,
|
NotificationLogger notificationLogger, HeadsUpManager headsUpManager,
|
||||||
ExpandableNotificationRow.OnExpandClickListener onExpandClickListener,
|
ExpandableNotificationRow.OnExpandClickListener onExpandClickListener,
|
||||||
StatusBarStateController statusBarStateController,
|
StatusBarStateController statusBarStateController,
|
||||||
NotificationRowContentBinder.InflationCallback inflationCallback,
|
|
||||||
NotificationGutsManager notificationGutsManager,
|
NotificationGutsManager notificationGutsManager,
|
||||||
@Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME) boolean allowLongPress,
|
@Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME) boolean allowLongPress,
|
||||||
@DismissRunnable Runnable onDismissRunnable, FalsingManager falsingManager,
|
@DismissRunnable Runnable onDismissRunnable, FalsingManager falsingManager,
|
||||||
@@ -101,7 +99,6 @@ public class ExpandableNotificationRowController {
|
|||||||
mHeadsUpManager = headsUpManager;
|
mHeadsUpManager = headsUpManager;
|
||||||
mOnExpandClickListener = onExpandClickListener;
|
mOnExpandClickListener = onExpandClickListener;
|
||||||
mStatusBarStateController = statusBarStateController;
|
mStatusBarStateController = statusBarStateController;
|
||||||
mInflationCallback = inflationCallback;
|
|
||||||
mNotificationGutsManager = notificationGutsManager;
|
mNotificationGutsManager = notificationGutsManager;
|
||||||
mOnDismissRunnable = onDismissRunnable;
|
mOnDismissRunnable = onDismissRunnable;
|
||||||
mOnAppOpsClickListener = mNotificationGutsManager::openGuts;
|
mOnAppOpsClickListener = mNotificationGutsManager::openGuts;
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import com.android.systemui.statusbar.notification.collection.NotificationEntry;
|
|||||||
import com.android.systemui.statusbar.notification.row.ActivatableNotificationView;
|
import com.android.systemui.statusbar.notification.row.ActivatableNotificationView;
|
||||||
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
|
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
|
||||||
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRowController;
|
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRowController;
|
||||||
import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder;
|
|
||||||
import com.android.systemui.statusbar.notification.row.RowContentBindStage;
|
import com.android.systemui.statusbar.notification.row.RowContentBindStage;
|
||||||
import com.android.systemui.statusbar.phone.StatusBar;
|
import com.android.systemui.statusbar.phone.StatusBar;
|
||||||
|
|
||||||
@@ -60,8 +59,6 @@ public interface ExpandableNotificationRowComponent {
|
|||||||
@BindsInstance
|
@BindsInstance
|
||||||
Builder rowContentBindStage(RowContentBindStage rowContentBindStage);
|
Builder rowContentBindStage(RowContentBindStage rowContentBindStage);
|
||||||
@BindsInstance
|
@BindsInstance
|
||||||
Builder inflationCallback(NotificationRowContentBinder.InflationCallback inflationCallback);
|
|
||||||
@BindsInstance
|
|
||||||
Builder onExpandClickListener(ExpandableNotificationRow.OnExpandClickListener presenter);
|
Builder onExpandClickListener(ExpandableNotificationRow.OnExpandClickListener presenter);
|
||||||
ExpandableNotificationRowComponent build();
|
ExpandableNotificationRowComponent build();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import static com.android.systemui.statusbar.phone.StatusBar.SPEW;
|
|||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.app.KeyguardManager;
|
import android.app.KeyguardManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.service.notification.StatusBarNotification;
|
import android.service.notification.StatusBarNotification;
|
||||||
@@ -355,8 +354,7 @@ public class StatusBarNotificationPresenter implements NotificationPresenter,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindRow(NotificationEntry entry, PackageManager pmUser,
|
public void onBindRow(ExpandableNotificationRow row) {
|
||||||
StatusBarNotification sbn, ExpandableNotificationRow row) {
|
|
||||||
row.setAboveShelfChangedListener(mAboveShelfObserver);
|
row.setAboveShelfChangedListener(mAboveShelfObserver);
|
||||||
row.setSecureStateProvider(mKeyguardStateController::canDismissLockScreen);
|
row.setSecureStateProvider(mKeyguardStateController::canDismissLockScreen);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.android.systemui.statusbar.notification
|
|
||||||
|
|
||||||
import com.android.systemui.statusbar.FeatureFlags
|
|
||||||
import com.android.systemui.statusbar.NotificationPresenter
|
|
||||||
import com.android.systemui.statusbar.NotificationRemoteInputManager
|
|
||||||
import com.android.systemui.statusbar.notification.collection.NotificationEntry
|
|
||||||
import com.android.systemui.statusbar.notification.collection.NotificationRankingManager
|
|
||||||
import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinder
|
|
||||||
import com.android.systemui.statusbar.phone.NotificationGroupManager
|
|
||||||
import com.android.systemui.util.leak.LeakDetector
|
|
||||||
import java.util.concurrent.CountDownLatch
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enable some test capabilities for NEM without making everything public on the base class
|
|
||||||
*/
|
|
||||||
class TestableNotificationEntryManager(
|
|
||||||
logger: NotificationEntryManagerLogger,
|
|
||||||
gm: NotificationGroupManager,
|
|
||||||
rm: NotificationRankingManager,
|
|
||||||
ke: KeyguardEnvironment,
|
|
||||||
ff: FeatureFlags,
|
|
||||||
rb: dagger.Lazy<NotificationRowBinder>,
|
|
||||||
notificationRemoteInputManagerLazy: dagger.Lazy<NotificationRemoteInputManager>,
|
|
||||||
leakDetector: LeakDetector,
|
|
||||||
fgsFeatureController: ForegroundServiceDismissalFeatureController
|
|
||||||
) : NotificationEntryManager(logger, gm, rm, ke, ff, rb,
|
|
||||||
notificationRemoteInputManagerLazy, leakDetector, fgsFeatureController) {
|
|
||||||
|
|
||||||
public var countDownLatch: CountDownLatch = CountDownLatch(1)
|
|
||||||
|
|
||||||
override fun onAsyncInflationFinished(entry: NotificationEntry) {
|
|
||||||
super.onAsyncInflationFinished(entry)
|
|
||||||
countDownLatch.countDown()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setUpForTest(
|
|
||||||
presenter: NotificationPresenter?
|
|
||||||
) {
|
|
||||||
super.setUpWithPresenter(presenter)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setActiveNotificationList(activeList: List<NotificationEntry>) {
|
|
||||||
mSortedAndFiltered.clear()
|
|
||||||
mSortedAndFiltered.addAll(activeList)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -18,6 +18,7 @@ package com.android.systemui.statusbar.notification.collection.coordinator;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
@@ -62,7 +63,6 @@ public class PreparationCoordinatorTest extends SysuiTestCase {
|
|||||||
private OnBeforeFinalizeFilterListener mBeforeFilterListener;
|
private OnBeforeFinalizeFilterListener mBeforeFilterListener;
|
||||||
private NotifFilter mUninflatedFilter;
|
private NotifFilter mUninflatedFilter;
|
||||||
private NotifFilter mInflationErrorFilter;
|
private NotifFilter mInflationErrorFilter;
|
||||||
private NotifInflaterImpl.InflationCallback mCallback;
|
|
||||||
private NotifInflationErrorManager mErrorManager;
|
private NotifInflationErrorManager mErrorManager;
|
||||||
private NotificationEntry mEntry;
|
private NotificationEntry mEntry;
|
||||||
private Exception mInflationError;
|
private Exception mInflationError;
|
||||||
@@ -104,9 +104,6 @@ public class PreparationCoordinatorTest extends SysuiTestCase {
|
|||||||
mBeforeFilterListenerCaptor.capture());
|
mBeforeFilterListenerCaptor.capture());
|
||||||
mBeforeFilterListener = mBeforeFilterListenerCaptor.getValue();
|
mBeforeFilterListener = mBeforeFilterListenerCaptor.getValue();
|
||||||
|
|
||||||
verify(mNotifInflater).setInflationCallback(mCallbackCaptor.capture());
|
|
||||||
mCallback = mCallbackCaptor.getValue();
|
|
||||||
|
|
||||||
mCollectionListener.onEntryInit(mEntry);
|
mCollectionListener.onEntryInit(mEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,7 +139,7 @@ public class PreparationCoordinatorTest extends SysuiTestCase {
|
|||||||
mBeforeFilterListener.onBeforeFinalizeFilter(List.of(mEntry));
|
mBeforeFilterListener.onBeforeFinalizeFilter(List.of(mEntry));
|
||||||
|
|
||||||
// THEN we inflate it
|
// THEN we inflate it
|
||||||
verify(mNotifInflater).inflateViews(mEntry);
|
verify(mNotifInflater).inflateViews(eq(mEntry), any());
|
||||||
|
|
||||||
// THEN we filter it out until it's done inflating.
|
// THEN we filter it out until it's done inflating.
|
||||||
assertTrue(mUninflatedFilter.shouldFilterOut(mEntry, 0));
|
assertTrue(mUninflatedFilter.shouldFilterOut(mEntry, 0));
|
||||||
@@ -151,14 +148,17 @@ public class PreparationCoordinatorTest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testRebindsInflatedNotificationsOnUpdate() {
|
public void testRebindsInflatedNotificationsOnUpdate() {
|
||||||
// GIVEN an inflated notification
|
// GIVEN an inflated notification
|
||||||
mCallback.onInflationFinished(mEntry);
|
mCollectionListener.onEntryAdded(mEntry);
|
||||||
|
mBeforeFilterListener.onBeforeFinalizeFilter(List.of(mEntry));
|
||||||
|
verify(mNotifInflater).inflateViews(eq(mEntry), mCallbackCaptor.capture());
|
||||||
|
mCallbackCaptor.getValue().onInflationFinished(mEntry);
|
||||||
|
|
||||||
// WHEN notification is updated
|
// WHEN notification is updated
|
||||||
mCollectionListener.onEntryUpdated(mEntry);
|
mCollectionListener.onEntryUpdated(mEntry);
|
||||||
mBeforeFilterListener.onBeforeFinalizeFilter(List.of(mEntry));
|
mBeforeFilterListener.onBeforeFinalizeFilter(List.of(mEntry));
|
||||||
|
|
||||||
// THEN we rebind it
|
// THEN we rebind it
|
||||||
verify(mNotifInflater).rebindViews(mEntry);
|
verify(mNotifInflater).rebindViews(eq(mEntry), any());
|
||||||
|
|
||||||
// THEN we do not filter it because it's not the first inflation.
|
// THEN we do not filter it because it's not the first inflation.
|
||||||
assertFalse(mUninflatedFilter.shouldFilterOut(mEntry, 0));
|
assertFalse(mUninflatedFilter.shouldFilterOut(mEntry, 0));
|
||||||
@@ -166,8 +166,11 @@ public class PreparationCoordinatorTest extends SysuiTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDoesntFilterInflatedNotifs() {
|
public void testDoesntFilterInflatedNotifs() {
|
||||||
// WHEN a notification is inflated
|
// GIVEN an inflated notification
|
||||||
mCallback.onInflationFinished(mEntry);
|
mCollectionListener.onEntryAdded(mEntry);
|
||||||
|
mBeforeFilterListener.onBeforeFinalizeFilter(List.of(mEntry));
|
||||||
|
verify(mNotifInflater).inflateViews(eq(mEntry), mCallbackCaptor.capture());
|
||||||
|
mCallbackCaptor.getValue().onInflationFinished(mEntry);
|
||||||
|
|
||||||
// THEN it isn't filtered from shade list
|
// THEN it isn't filtered from shade list
|
||||||
assertFalse(mUninflatedFilter.shouldFilterOut(mEntry, 0));
|
assertFalse(mUninflatedFilter.shouldFilterOut(mEntry, 0));
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import static com.android.systemui.statusbar.notification.row.NotificationRowCon
|
|||||||
import static junit.framework.Assert.assertNotNull;
|
import static junit.framework.Assert.assertNotNull;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
@@ -215,9 +214,6 @@ public class NotificationEntryManagerInflationTest extends SysuiTestCase {
|
|||||||
when(mExpandableNotificationRowComponentBuilder
|
when(mExpandableNotificationRowComponentBuilder
|
||||||
.onDismissRunnable(any()))
|
.onDismissRunnable(any()))
|
||||||
.thenReturn(mExpandableNotificationRowComponentBuilder);
|
.thenReturn(mExpandableNotificationRowComponentBuilder);
|
||||||
when(mExpandableNotificationRowComponentBuilder
|
|
||||||
.inflationCallback(any()))
|
|
||||||
.thenReturn(mExpandableNotificationRowComponentBuilder);
|
|
||||||
when(mExpandableNotificationRowComponentBuilder
|
when(mExpandableNotificationRowComponentBuilder
|
||||||
.rowContentBindStage(any()))
|
.rowContentBindStage(any()))
|
||||||
.thenReturn(mExpandableNotificationRowComponentBuilder);
|
.thenReturn(mExpandableNotificationRowComponentBuilder);
|
||||||
@@ -243,7 +239,6 @@ public class NotificationEntryManagerInflationTest extends SysuiTestCase {
|
|||||||
mHeadsUpManager,
|
mHeadsUpManager,
|
||||||
mPresenter,
|
mPresenter,
|
||||||
mStatusBarStateController,
|
mStatusBarStateController,
|
||||||
mEntryManager,
|
|
||||||
mGutsManager,
|
mGutsManager,
|
||||||
true,
|
true,
|
||||||
null,
|
null,
|
||||||
@@ -275,7 +270,6 @@ public class NotificationEntryManagerInflationTest extends SysuiTestCase {
|
|||||||
mEntryManager.addNotificationEntryListener(mEntryListener);
|
mEntryManager.addNotificationEntryListener(mEntryListener);
|
||||||
|
|
||||||
mRowBinder.setUpWithPresenter(mPresenter, mListContainer, mBindCallback);
|
mRowBinder.setUpWithPresenter(mPresenter, mListContainer, mBindCallback);
|
||||||
mRowBinder.setInflationCallback(mEntryManager);
|
|
||||||
mRowBinder.setNotificationClicker(mock(NotificationClicker.class));
|
mRowBinder.setNotificationClicker(mock(NotificationClicker.class));
|
||||||
|
|
||||||
Ranking ranking = new Ranking();
|
Ranking ranking = new Ranking();
|
||||||
@@ -330,7 +324,7 @@ public class NotificationEntryManagerInflationTest extends SysuiTestCase {
|
|||||||
assertNotNull(entry.getRow().getPrivateLayout().getContractedChild());
|
assertNotNull(entry.getRow().getPrivateLayout().getContractedChild());
|
||||||
|
|
||||||
// THEN inflation callbacks are called
|
// THEN inflation callbacks are called
|
||||||
verify(mBindCallback).onBindRow(eq(entry), any(), eq(mSbn), any());
|
verify(mBindCallback).onBindRow(entry.getRow());
|
||||||
verify(mEntryListener, never()).onInflationError(any(), any());
|
verify(mEntryListener, never()).onInflationError(any(), any());
|
||||||
verify(mEntryListener).onEntryInflated(entry);
|
verify(mEntryListener).onEntryInflated(entry);
|
||||||
verify(mEntryListener).onNotificationAdded(entry);
|
verify(mEntryListener).onNotificationAdded(entry);
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ import com.android.systemui.statusbar.notification.NotificationEntryManager;
|
|||||||
import com.android.systemui.statusbar.notification.NotificationEntryManagerLogger;
|
import com.android.systemui.statusbar.notification.NotificationEntryManagerLogger;
|
||||||
import com.android.systemui.statusbar.notification.NotificationFilter;
|
import com.android.systemui.statusbar.notification.NotificationFilter;
|
||||||
import com.android.systemui.statusbar.notification.NotificationSectionsFeatureManager;
|
import com.android.systemui.statusbar.notification.NotificationSectionsFeatureManager;
|
||||||
import com.android.systemui.statusbar.notification.TestableNotificationEntryManager;
|
|
||||||
import com.android.systemui.statusbar.notification.VisualStabilityManager;
|
import com.android.systemui.statusbar.notification.VisualStabilityManager;
|
||||||
import com.android.systemui.statusbar.notification.collection.NotifCollection;
|
import com.android.systemui.statusbar.notification.collection.NotifCollection;
|
||||||
import com.android.systemui.statusbar.notification.collection.NotifPipeline;
|
import com.android.systemui.statusbar.notification.collection.NotifPipeline;
|
||||||
@@ -138,7 +137,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
|
|||||||
@Mock private NotificationLockscreenUserManager mLockscreenUserManager;
|
@Mock private NotificationLockscreenUserManager mLockscreenUserManager;
|
||||||
@Mock private FeatureFlags mFeatureFlags;
|
@Mock private FeatureFlags mFeatureFlags;
|
||||||
private UserChangedListener mUserChangedListener;
|
private UserChangedListener mUserChangedListener;
|
||||||
private TestableNotificationEntryManager mEntryManager;
|
private NotificationEntryManager mEntryManager;
|
||||||
private int mOriginalInterruptionModelSetting;
|
private int mOriginalInterruptionModelSetting;
|
||||||
private UiEventLoggerFake mUiEventLoggerFake = new UiEventLoggerFake();
|
private UiEventLoggerFake mUiEventLoggerFake = new UiEventLoggerFake();
|
||||||
|
|
||||||
@@ -167,7 +166,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
|
|||||||
|
|
||||||
ArgumentCaptor<UserChangedListener> userChangedCaptor = ArgumentCaptor
|
ArgumentCaptor<UserChangedListener> userChangedCaptor = ArgumentCaptor
|
||||||
.forClass(UserChangedListener.class);
|
.forClass(UserChangedListener.class);
|
||||||
mEntryManager = new TestableNotificationEntryManager(
|
mEntryManager = new NotificationEntryManager(
|
||||||
mock(NotificationEntryManagerLogger.class),
|
mock(NotificationEntryManagerLogger.class),
|
||||||
mock(NotificationGroupManager.class),
|
mock(NotificationGroupManager.class),
|
||||||
new NotificationRankingManager(
|
new NotificationRankingManager(
|
||||||
@@ -187,7 +186,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
|
|||||||
mock(LeakDetector.class),
|
mock(LeakDetector.class),
|
||||||
mock(ForegroundServiceDismissalFeatureController.class)
|
mock(ForegroundServiceDismissalFeatureController.class)
|
||||||
);
|
);
|
||||||
mEntryManager.setUpForTest(mock(NotificationPresenter.class));
|
mEntryManager.setUpWithPresenter(mock(NotificationPresenter.class));
|
||||||
when(mFeatureFlags.isNewNotifPipelineRenderingEnabled()).thenReturn(false);
|
when(mFeatureFlags.isNewNotifPipelineRenderingEnabled()).thenReturn(false);
|
||||||
|
|
||||||
NotificationShelf notificationShelf = mock(NotificationShelf.class);
|
NotificationShelf notificationShelf = mock(NotificationShelf.class);
|
||||||
|
|||||||
Reference in New Issue
Block a user