Search in sources :

Example 21 with StatusBarNotification

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

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) 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 22 with StatusBarNotification

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

the class PhoneStatusBar method removeNotification.

@Override
public void removeNotification(String key, RankingMap ranking) {
    boolean deferRemoval = false;
    if (mHeadsUpManager.isHeadsUp(key)) {
        // A cancel() in repsonse to a remote input shouldn't be delayed, as it makes the
        // sending look longer than it takes.
        // Also we should not defer the removal if reordering isn't allowed since otherwise
        // some notifications can't disappear before the panel is closed.
        boolean ignoreEarliestRemovalTime = mRemoteInputController.isSpinning(key) && !FORCE_REMOTE_INPUT_HISTORY || !mVisualStabilityManager.isReorderingAllowed();
        deferRemoval = !mHeadsUpManager.removeNotification(key, ignoreEarliestRemovalTime);
    }
    if (key.equals(mMediaNotificationKey)) {
        clearCurrentMediaNotification();
        updateMediaMetaData(true, true);
    }
    if (FORCE_REMOTE_INPUT_HISTORY && mRemoteInputController.isSpinning(key)) {
        Entry entry = mNotificationData.get(key);
        StatusBarNotification sbn = entry.notification;
        Notification.Builder b = Notification.Builder.recoverBuilder(mContext, sbn.getNotification().clone());
        CharSequence[] oldHistory = sbn.getNotification().extras.getCharSequenceArray(Notification.EXTRA_REMOTE_INPUT_HISTORY);
        CharSequence[] newHistory;
        if (oldHistory == null) {
            newHistory = new CharSequence[1];
        } else {
            newHistory = new CharSequence[oldHistory.length + 1];
            for (int i = 0; i < oldHistory.length; i++) {
                newHistory[i + 1] = oldHistory[i];
            }
        }
        newHistory[0] = String.valueOf(entry.remoteInputText);
        b.setRemoteInputHistory(newHistory);
        Notification newNotification = b.build();
        // Undo any compatibility view inflation
        newNotification.contentView = sbn.getNotification().contentView;
        newNotification.bigContentView = sbn.getNotification().bigContentView;
        newNotification.headsUpContentView = sbn.getNotification().headsUpContentView;
        StatusBarNotification newSbn = new StatusBarNotification(sbn.getPackageName(), sbn.getOpPkg(), sbn.getId(), sbn.getTag(), sbn.getUid(), sbn.getInitialPid(), 0, newNotification, sbn.getUser(), sbn.getPostTime());
        updateNotification(newSbn, null);
        mKeysKeptForRemoteInput.add(entry.key);
        return;
    }
    if (deferRemoval) {
        mLatestRankingMap = ranking;
        mHeadsUpEntriesToRemoveOnSwitch.add(mHeadsUpManager.getEntry(key));
        return;
    }
    Entry entry = mNotificationData.get(key);
    if (entry != null && mRemoteInputController.isRemoteInputActive(entry) && (entry.row != null && !entry.row.isDismissed())) {
        mLatestRankingMap = ranking;
        mRemoteInputEntriesToRemoveOnCollapse.add(entry);
        return;
    }
    if (entry != null && entry.row != null) {
        entry.row.setRemoved();
    }
    // Let's remove the children if this was a summary
    handleGroupSummaryRemoved(key, ranking);
    StatusBarNotification old = removeNotificationViews(key, ranking);
    if (SPEW)
        Log.d(TAG, "removeNotification key=" + key + " old=" + old);
    if (old != null) {
        if (CLOSE_PANEL_WHEN_EMPTIED && !hasActiveNotifications() && !mNotificationPanel.isTracking() && !mNotificationPanel.isQsExpanded()) {
            if (mState == StatusBarState.SHADE) {
                animateCollapsePanels();
            } else if (mState == StatusBarState.SHADE_LOCKED && !isCollapsing()) {
                goToKeyguard();
            }
        }
    }
    setAreThereNotifications();
}
Also used : Entry(com.android.systemui.statusbar.NotificationData.Entry) StatusBarNotification(android.service.notification.StatusBarNotification) Notification(android.app.Notification) StatusBarNotification(android.service.notification.StatusBarNotification) Point(android.graphics.Point)

Example 23 with StatusBarNotification

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

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

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

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 25 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)

Aggregations

StatusBarNotification (android.service.notification.StatusBarNotification)188 Notification (android.app.Notification)86 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 NotificationManager (android.app.NotificationManager)20 ArrayList (java.util.ArrayList)18 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)17 StatusBarIcon (com.android.internal.statusbar.StatusBarIcon)16 ITransientNotification (android.app.ITransientNotification)15 RemoteException (android.os.RemoteException)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