Search in sources :

Example 66 with StatusBarNotification

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

the class NotificationManagerService method maybeAddAutobundleSummary.

// Posts a 'fake' summary for a package that has exceeded the solo-notification limit.
private void maybeAddAutobundleSummary(Adjustment adjustment) {
    if (adjustment.getSignals() != null) {
        Bundle.setDefusable(adjustment.getSignals(), true);
        if (adjustment.getSignals().getBoolean(Adjustment.NEEDS_AUTOGROUPING_KEY, false)) {
            final String newAutoBundleKey = adjustment.getSignals().getString(Adjustment.GROUP_KEY_OVERRIDE_KEY, null);
            int userId = -1;
            NotificationRecord summaryRecord = null;
            synchronized (mNotificationList) {
                NotificationRecord notificationRecord = mNotificationsByKey.get(adjustment.getKey());
                if (notificationRecord == null) {
                    // adjustment will post a summary if needed.
                    return;
                }
                final StatusBarNotification adjustedSbn = notificationRecord.sbn;
                userId = adjustedSbn.getUser().getIdentifier();
                ArrayMap<String, String> summaries = mAutobundledSummaries.get(userId);
                if (summaries == null) {
                    summaries = new ArrayMap<>();
                }
                mAutobundledSummaries.put(userId, summaries);
                if (!summaries.containsKey(adjustment.getPackage()) && newAutoBundleKey != null) {
                    // Add summary
                    final ApplicationInfo appInfo = adjustedSbn.getNotification().extras.getParcelable(Notification.EXTRA_BUILDER_APPLICATION_INFO);
                    final Bundle extras = new Bundle();
                    extras.putParcelable(Notification.EXTRA_BUILDER_APPLICATION_INFO, appInfo);
                    final Notification summaryNotification = new Notification.Builder(getContext()).setSmallIcon(adjustedSbn.getNotification().getSmallIcon()).setGroupSummary(true).setGroup(newAutoBundleKey).setFlag(Notification.FLAG_AUTOGROUP_SUMMARY, true).setFlag(Notification.FLAG_GROUP_SUMMARY, true).setColor(adjustedSbn.getNotification().color).setLocalOnly(true).build();
                    summaryNotification.extras.putAll(extras);
                    Intent appIntent = getContext().getPackageManager().getLaunchIntentForPackage(adjustment.getPackage());
                    if (appIntent != null) {
                        summaryNotification.contentIntent = PendingIntent.getActivityAsUser(getContext(), 0, appIntent, 0, null, UserHandle.of(userId));
                    }
                    final StatusBarNotification summarySbn = new StatusBarNotification(adjustedSbn.getPackageName(), adjustedSbn.getOpPkg(), Integer.MAX_VALUE, Adjustment.GROUP_KEY_OVERRIDE_KEY, adjustedSbn.getUid(), adjustedSbn.getInitialPid(), summaryNotification, adjustedSbn.getUser(), newAutoBundleKey, System.currentTimeMillis());
                    summaryRecord = new NotificationRecord(getContext(), summarySbn);
                    summaries.put(adjustment.getPackage(), summarySbn.getKey());
                }
            }
            if (summaryRecord != null) {
                mHandler.post(new EnqueueNotificationRunnable(userId, summaryRecord));
            }
        }
    }
}
Also used : StatusBarNotification(android.service.notification.StatusBarNotification) Bundle(android.os.Bundle) PersistableBundle(android.os.PersistableBundle) ApplicationInfo(android.content.pm.ApplicationInfo) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) ITransientNotification(android.app.ITransientNotification) Notification(android.app.Notification) StatusBarNotification(android.service.notification.StatusBarNotification)

Example 67 with StatusBarNotification

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

the class NotificationManagerService method handleGroupedNotificationLocked.

/**
     * Ensures that grouped notification receive their special treatment.
     *
     * <p>Cancels group children if the new notification causes a group to lose
     * its summary.</p>
     *
     * <p>Updates mSummaryByGroupKey.</p>
     */
private void handleGroupedNotificationLocked(NotificationRecord r, NotificationRecord old, int callingUid, int callingPid) {
    StatusBarNotification sbn = r.sbn;
    Notification n = sbn.getNotification();
    if (n.isGroupSummary() && !sbn.isAppGroup()) {
        // notifications without a group shouldn't be a summary, otherwise autobundling can
        // lead to bugs
        n.flags &= ~Notification.FLAG_GROUP_SUMMARY;
    }
    String group = sbn.getGroupKey();
    boolean isSummary = n.isGroupSummary();
    Notification oldN = old != null ? old.sbn.getNotification() : null;
    String oldGroup = old != null ? old.sbn.getGroupKey() : null;
    boolean oldIsSummary = old != null && oldN.isGroupSummary();
    if (oldIsSummary) {
        NotificationRecord removedSummary = mSummaryByGroupKey.remove(oldGroup);
        if (removedSummary != old) {
            String removedKey = removedSummary != null ? removedSummary.getKey() : "<null>";
            Slog.w(TAG, "Removed summary didn't match old notification: old=" + old.getKey() + ", removed=" + removedKey);
        }
    }
    if (isSummary) {
        mSummaryByGroupKey.put(group, r);
    }
    // notification was a summary and its group key changed.
    if (oldIsSummary && (!isSummary || !oldGroup.equals(group))) {
        cancelGroupChildrenLocked(old, callingUid, callingPid, null, REASON_GROUP_SUMMARY_CANCELED, false);
    }
}
Also used : StatusBarNotification(android.service.notification.StatusBarNotification) ITransientNotification(android.app.ITransientNotification) Notification(android.app.Notification) StatusBarNotification(android.service.notification.StatusBarNotification)

Example 68 with StatusBarNotification

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

the class BugreportReceiverTest method cancelExistingNotifications.

private void cancelExistingNotifications() {
    NotificationManager nm = NotificationManager.from(mContext);
    for (StatusBarNotification notification : nm.getActiveNotifications()) {
        int id = notification.getId();
        Log.i(TAG, "Canceling existing notification (id=" + id + ")");
        nm.cancel(id);
    }
}
Also used : NotificationManager(android.app.NotificationManager) StatusBarNotification(android.service.notification.StatusBarNotification)

Example 69 with StatusBarNotification

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

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 70 with StatusBarNotification

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

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)

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