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

Commit 72c20ad0 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge changes I001413f1,Id59a28c0 into rvc-dev am: a1395679

Change-Id: I558cc995c26664c801517f0da9c107eb6eb301cd
parents c514acfd a1395679
Loading
Loading
Loading
Loading
+44 −35
Original line number Original line Diff line number Diff line
@@ -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");
+3 −0
Original line number Original line Diff line number Diff line
@@ -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));
+28 −30
Original line number Original line Diff line number Diff line
@@ -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;
    }
}
+0 −9
Original line number Original line Diff line number Diff line
@@ -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;
+56 −0
Original line number Original line Diff line number Diff line
/*
 * 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"
}
 No newline at end of file
Loading