Search in sources :

Example 41 with StatusBarNotification

use of android.service.notification.StatusBarNotification in project platform_frameworks_base by android.

the class NotificationManagerService method dumpImpl.

void dumpImpl(PrintWriter pw, DumpFilter filter) {
    pw.print("Current Notification Manager state");
    if (filter.filtered) {
        pw.print(" (filtered to ");
        pw.print(filter);
        pw.print(")");
    }
    pw.println(':');
    int N;
    final boolean zenOnly = filter.filtered && filter.zen;
    if (!zenOnly) {
        synchronized (mToastQueue) {
            N = mToastQueue.size();
            if (N > 0) {
                pw.println("  Toast Queue:");
                for (int i = 0; i < N; i++) {
                    mToastQueue.get(i).dump(pw, "    ", filter);
                }
                pw.println("  ");
            }
        }
    }
    synchronized (mNotificationList) {
        if (!zenOnly) {
            N = mNotificationList.size();
            if (N > 0) {
                pw.println("  Notification List:");
                for (int i = 0; i < N; i++) {
                    final NotificationRecord nr = mNotificationList.get(i);
                    if (filter.filtered && !filter.matches(nr.sbn))
                        continue;
                    nr.dump(pw, "    ", getContext(), filter.redact);
                }
                pw.println("  ");
            }
            if (!filter.filtered) {
                N = mLights.size();
                if (N > 0) {
                    pw.println("  Lights List:");
                    for (int i = 0; i < N; i++) {
                        if (i == N - 1) {
                            pw.print("  > ");
                        } else {
                            pw.print("    ");
                        }
                        pw.println(mLights.get(i));
                    }
                    pw.println("  ");
                }
                pw.println("  mUseAttentionLight=" + mUseAttentionLight);
                pw.println("  mNotificationPulseEnabled=" + mNotificationPulseEnabled);
                pw.println("  mSoundNotificationKey=" + mSoundNotificationKey);
                pw.println("  mVibrateNotificationKey=" + mVibrateNotificationKey);
                pw.println("  mDisableNotificationEffects=" + mDisableNotificationEffects);
                pw.println("  mCallState=" + callStateToString(mCallState));
                pw.println("  mSystemReady=" + mSystemReady);
                pw.println("  mMaxPackageEnqueueRate=" + mMaxPackageEnqueueRate);
            }
            pw.println("  mArchive=" + mArchive.toString());
            Iterator<StatusBarNotification> iter = mArchive.descendingIterator();
            int i = 0;
            while (iter.hasNext()) {
                final StatusBarNotification sbn = iter.next();
                if (filter != null && !filter.matches(sbn))
                    continue;
                pw.println("    " + sbn);
                if (++i >= 5) {
                    if (iter.hasNext())
                        pw.println("    ...");
                    break;
                }
            }
        }
        if (!zenOnly) {
            pw.println("\n  Usage Stats:");
            mUsageStats.dump(pw, "    ", filter);
        }
        if (!filter.filtered || zenOnly) {
            pw.println("\n  Zen Mode:");
            pw.print("    mInterruptionFilter=");
            pw.println(mInterruptionFilter);
            mZenModeHelper.dump(pw, "    ");
            pw.println("\n  Zen Log:");
            ZenLog.dump(pw, "    ");
        }
        if (!zenOnly) {
            pw.println("\n  Ranking Config:");
            mRankingHelper.dump(pw, "    ", filter);
            pw.println("\n  Notification listeners:");
            mListeners.dump(pw, filter);
            pw.print("    mListenerHints: ");
            pw.println(mListenerHints);
            pw.print("    mListenersDisablingEffects: (");
            N = mListenersDisablingEffects.size();
            for (int i = 0; i < N; i++) {
                final int hint = mListenersDisablingEffects.keyAt(i);
                if (i > 0)
                    pw.print(';');
                pw.print("hint[" + hint + "]:");
                final ArraySet<ManagedServiceInfo> listeners = mListenersDisablingEffects.valueAt(i);
                final int listenerSize = listeners.size();
                for (int j = 0; j < listenerSize; j++) {
                    if (i > 0)
                        pw.print(',');
                    final ManagedServiceInfo listener = listeners.valueAt(i);
                    pw.print(listener.component);
                }
            }
            pw.println(')');
            pw.println("\n  mRankerServicePackageName: " + mRankerServicePackageName);
            pw.println("\n  Notification ranker services:");
            mRankerServices.dump(pw, filter);
        }
        pw.println("\n  Policy access:");
        pw.print("    mPolicyAccess: ");
        pw.println(mPolicyAccess);
        pw.println("\n  Condition providers:");
        mConditionProviders.dump(pw, filter);
        pw.println("\n  Group summaries:");
        for (Entry<String, NotificationRecord> entry : mSummaryByGroupKey.entrySet()) {
            NotificationRecord r = entry.getValue();
            pw.println("    " + entry.getKey() + " -> " + r.getKey());
            if (mNotificationsByKey.get(r.getKey()) != r) {
                pw.println("!!!!!!LEAK: Record not found in mNotificationsByKey.");
                r.dump(pw, "      ", getContext(), filter.redact);
            }
        }
    }
}
Also used : ManagedServiceInfo(com.android.server.notification.ManagedServices.ManagedServiceInfo) StatusBarNotification(android.service.notification.StatusBarNotification)

Example 42 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 43 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 44 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 45 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)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