Search in sources :

Example 51 with StatusBarNotification

use of android.service.notification.StatusBarNotification in project android_frameworks_base by AOSPA.

the class NotificationData method updateRankingAndSort.

private void updateRankingAndSort(RankingMap ranking) {
    if (ranking != null) {
        mRankingMap = ranking;
        synchronized (mEntries) {
            final int N = mEntries.size();
            for (int i = 0; i < N; i++) {
                Entry entry = mEntries.valueAt(i);
                final StatusBarNotification oldSbn = entry.notification.clone();
                final String overrideGroupKey = getOverrideGroupKey(entry.key);
                if (!Objects.equals(oldSbn.getOverrideGroupKey(), overrideGroupKey)) {
                    entry.notification.setOverrideGroupKey(overrideGroupKey);
                    mGroupManager.onEntryUpdated(entry, oldSbn);
                }
            }
        }
    }
    filterAndSort();
}
Also used : StatusBarNotification(android.service.notification.StatusBarNotification)

Example 52 with StatusBarNotification

use of android.service.notification.StatusBarNotification in project android_frameworks_base by crdroidandroid.

the class NotificationData method dumpEntry.

private void dumpEntry(PrintWriter pw, String indent, int i, Entry e) {
    mRankingMap.getRanking(e.key, mTmpRanking);
    pw.print(indent);
    pw.println("  [" + i + "] key=" + e.key + " icon=" + e.icon);
    StatusBarNotification n = e.notification;
    pw.print(indent);
    pw.println("      pkg=" + n.getPackageName() + " id=" + n.getId() + " importance=" + mTmpRanking.getImportance());
    pw.print(indent);
    pw.println("      notification=" + n.getNotification());
    pw.print(indent);
    pw.println("      tickerText=\"" + n.getNotification().tickerText + "\"");
}
Also used : StatusBarNotification(android.service.notification.StatusBarNotification)

Example 53 with StatusBarNotification

use of android.service.notification.StatusBarNotification in project android_frameworks_base by crdroidandroid.

the class NotificationData method filterAndSort.

// TODO: This should not be public. Instead the Environment should notify this class when
// anything changed, and this class should call back the UI so it updates itself.
public void filterAndSort() {
    mSortedAndFiltered.clear();
    synchronized (mEntries) {
        final int N = mEntries.size();
        for (int i = 0; i < N; i++) {
            Entry entry = mEntries.valueAt(i);
            StatusBarNotification sbn = entry.notification;
            if (shouldFilterOut(sbn)) {
                continue;
            }
            mSortedAndFiltered.add(entry);
        }
    }
    Collections.sort(mSortedAndFiltered, mRankingComparator);
}
Also used : StatusBarNotification(android.service.notification.StatusBarNotification)

Example 54 with StatusBarNotification

use of android.service.notification.StatusBarNotification in project android_frameworks_base by crdroidandroid.

the class NotificationGroupManager method onEntryAdded.

public void onEntryAdded(final NotificationData.Entry added) {
    final StatusBarNotification sbn = added.notification;
    boolean isGroupChild = isGroupChild(sbn);
    String groupKey = getGroupKey(sbn);
    NotificationGroup group = mGroupMap.get(groupKey);
    if (group == null) {
        group = new NotificationGroup();
        mGroupMap.put(groupKey, group);
    }
    if (isGroupChild) {
        group.children.add(added);
        updateSuppression(group);
    } else {
        group.summary = added;
        group.expanded = added.row.areChildrenExpanded();
        updateSuppression(group);
        if (!group.children.isEmpty()) {
            HashSet<NotificationData.Entry> childrenCopy = (HashSet<NotificationData.Entry>) group.children.clone();
            for (NotificationData.Entry child : childrenCopy) {
                onEntryBecomingChild(child);
            }
            mListener.onGroupCreatedFromChildren(group);
        }
    }
}
Also used : StatusBarNotification(android.service.notification.StatusBarNotification) HashSet(java.util.HashSet) NotificationData(com.android.systemui.statusbar.NotificationData)

Example 55 with StatusBarNotification

use of android.service.notification.StatusBarNotification in project android_frameworks_base by crdroidandroid.

the class NotificationManagerService method enqueueNotificationInternal.

void enqueueNotificationInternal(final String pkg, final String opPkg, final int callingUid, final int callingPid, final String tag, final int id, final Notification notification, int[] idOut, int incomingUserId) {
    if (DBG) {
        Slog.v(TAG, "enqueueNotificationInternal: pkg=" + pkg + " id=" + id + " notification=" + notification);
    }
    checkCallerIsSystemOrSameApp(pkg);
    final boolean isSystemNotification = isUidSystem(callingUid) || ("android".equals(pkg));
    final boolean isNotificationFromListener = mListeners.isListenerPackage(pkg);
    final int userId = ActivityManager.handleIncomingUser(callingPid, callingUid, incomingUserId, true, false, "enqueueNotification", pkg);
    final UserHandle user = new UserHandle(userId);
    // Fix the notification as best we can.
    try {
        final ApplicationInfo ai = getContext().getPackageManager().getApplicationInfoAsUser(pkg, PackageManager.MATCH_DEBUG_TRIAGED_MISSING, (userId == UserHandle.USER_ALL) ? UserHandle.USER_SYSTEM : userId);
        Notification.addFieldsFromContext(ai, userId, notification);
    } catch (NameNotFoundException e) {
        Slog.e(TAG, "Cannot create a context for sending app", e);
        return;
    }
    mUsageStats.registerEnqueuedByApp(pkg);
    if (pkg == null || notification == null) {
        throw new IllegalArgumentException("null not allowed: pkg=" + pkg + " id=" + id + " notification=" + notification);
    }
    final StatusBarNotification n = new StatusBarNotification(pkg, opPkg, id, tag, callingUid, callingPid, 0, notification, user);
    // package or a registered listener can enqueue.  Prevents DOS attacks and deals with leaks.
    if (!isSystemNotification && !isNotificationFromListener) {
        synchronized (mNotificationList) {
            if (mNotificationsByKey.get(n.getKey()) != null) {
                // this is an update, rate limit updates only
                final float appEnqueueRate = mUsageStats.getAppEnqueueRate(pkg);
                if (appEnqueueRate > mMaxPackageEnqueueRate) {
                    mUsageStats.registerOverRateQuota(pkg);
                    final long now = SystemClock.elapsedRealtime();
                    if ((now - mLastOverRateLogTime) > MIN_PACKAGE_OVERRATE_LOG_INTERVAL) {
                        Slog.e(TAG, "Package enqueue rate is " + appEnqueueRate + ". Shedding events. package=" + pkg);
                        mLastOverRateLogTime = now;
                    }
                    return;
                }
            }
            int count = 0;
            final int N = mNotificationList.size();
            for (int i = 0; i < N; i++) {
                final NotificationRecord r = mNotificationList.get(i);
                if (r.sbn.getPackageName().equals(pkg) && r.sbn.getUserId() == userId) {
                    if (r.sbn.getId() == id && TextUtils.equals(r.sbn.getTag(), tag)) {
                        // Allow updating existing notification
                        break;
                    }
                    count++;
                    if (count >= MAX_PACKAGE_NOTIFICATIONS) {
                        mUsageStats.registerOverCountQuota(pkg);
                        Slog.e(TAG, "Package has already posted " + count + " notifications.  Not showing more.  package=" + pkg);
                        return;
                    }
                }
            }
        }
    }
    // Whitelist pending intents.
    if (notification.allPendingIntents != null) {
        final int intentCount = notification.allPendingIntents.size();
        if (intentCount > 0) {
            final ActivityManagerInternal am = LocalServices.getService(ActivityManagerInternal.class);
            final long duration = LocalServices.getService(DeviceIdleController.LocalService.class).getNotificationWhitelistDuration();
            for (int i = 0; i < intentCount; i++) {
                PendingIntent pendingIntent = notification.allPendingIntents.valueAt(i);
                if (pendingIntent != null) {
                    am.setPendingIntentWhitelistDuration(pendingIntent.getTarget(), duration);
                }
            }
        }
    }
    // Sanitize inputs
    notification.priority = clamp(notification.priority, Notification.PRIORITY_MIN, Notification.PRIORITY_MAX);
    // setup local book-keeping
    final NotificationRecord r = new NotificationRecord(getContext(), n);
    mHandler.post(new EnqueueNotificationRunnable(userId, r));
    idOut[0] = id;
}
Also used : NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) ActivityManagerInternal(android.app.ActivityManagerInternal) ApplicationInfo(android.content.pm.ApplicationInfo) StatusBarNotification(android.service.notification.StatusBarNotification) UserHandle(android.os.UserHandle) PendingIntent(android.app.PendingIntent)

Aggregations

StatusBarNotification (android.service.notification.StatusBarNotification)144 Notification (android.app.Notification)61 View (android.view.View)24 PendingIntent (android.app.PendingIntent)23 TextView (android.widget.TextView)23 ApplicationInfo (android.content.pm.ApplicationInfo)21 ImageView (android.widget.ImageView)21 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)17 StatusBarIcon (com.android.internal.statusbar.StatusBarIcon)16 ITransientNotification (android.app.ITransientNotification)15 NotificationData (com.android.systemui.statusbar.NotificationData)14 Point (android.graphics.Point)13 RemoteViews (android.widget.RemoteViews)12 Entry (com.android.systemui.statusbar.NotificationData.Entry)12 PackageManager (android.content.pm.PackageManager)11 UserHandle (android.os.UserHandle)10 NavigationBarView (com.android.systemui.statusbar.phone.NavigationBarView)10 RemoteInputView (com.android.systemui.statusbar.policy.RemoteInputView)10 Drawable (android.graphics.drawable.Drawable)9 NotificationPanelView (com.android.systemui.statusbar.phone.NotificationPanelView)9