Search in sources :

Example 56 with StatusBarNotification

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

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);
            }
        }
        long now = SystemClock.elapsedRealtime();
        pw.println("\n  Last notification sound timestamps:");
        for (Map.Entry<String, Long> entry : mLastSoundTimestamps.entrySet()) {
            pw.print("    " + entry.getKey() + " -> ");
            TimeUtils.formatDuration(entry.getValue(), now, pw);
            pw.println(" ago");
        }
    }
}
Also used : ManagedServiceInfo(com.android.server.notification.ManagedServices.ManagedServiceInfo) StatusBarNotification(android.service.notification.StatusBarNotification) Map(java.util.Map) HashMap(java.util.HashMap) ArrayMap(android.util.ArrayMap)

Example 57 with StatusBarNotification

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

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

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

the class BaseStatusBar method bindGuts.

private void bindGuts(final ExpandableNotificationRow row) {
    row.inflateGuts();
    final StatusBarNotification sbn = row.getStatusBarNotification();
    PackageManager pmUser = getPackageManagerForUser(mContext, sbn.getUser().getIdentifier());
    row.setTag(sbn.getPackageName());
    final NotificationGuts guts = row.getGuts();
    guts.setClosedListener(this);
    final String pkg = sbn.getPackageName();
    String appname = pkg;
    Drawable pkgicon = null;
    int appUid = -1;
    try {
        final ApplicationInfo info = pmUser.getApplicationInfo(pkg, PackageManager.GET_UNINSTALLED_PACKAGES | PackageManager.GET_DISABLED_COMPONENTS);
        if (info != null) {
            appname = String.valueOf(pmUser.getApplicationLabel(info));
            pkgicon = pmUser.getApplicationIcon(info);
            appUid = info.uid;
        }
    } catch (NameNotFoundException e) {
        // app is gone, just show package name and generic icon
        pkgicon = pmUser.getDefaultActivityIcon();
    }
    ((ImageView) guts.findViewById(R.id.app_icon)).setImageDrawable(pkgicon);
    ((TextView) guts.findViewById(R.id.pkgname)).setText(appname);
    final TextView settingsButton = (TextView) guts.findViewById(R.id.more_settings);
    if (appUid >= 0) {
        final int appUidF = appUid;
        settingsButton.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                MetricsLogger.action(mContext, MetricsEvent.ACTION_NOTE_INFO);
                guts.resetFalsingCheck();
                startAppNotificationSettingsActivity(pkg, appUidF);
            }
        });
        settingsButton.setText(R.string.notification_more_settings);
    } else {
        settingsButton.setVisibility(View.GONE);
    }
    guts.bindImportance(pmUser, sbn, mNonBlockablePkgs, mNotificationData.getImportance(sbn.getKey()));
    final TextView doneButton = (TextView) guts.findViewById(R.id.done);
    doneButton.setText(R.string.notification_done);
    doneButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // If the user has security enabled, show challenge if the setting is changed.
            if (guts.hasImportanceChanged() && isLockscreenPublicMode() && (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED)) {
                OnDismissAction dismissAction = new OnDismissAction() {

                    @Override
                    public boolean onDismiss() {
                        saveImportanceCloseControls(sbn, row, guts, v);
                        return true;
                    }
                };
                onLockedNotificationImportanceChange(dismissAction);
            } else {
                saveImportanceCloseControls(sbn, row, guts, v);
            }
        }
    });
}
Also used : NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) Drawable(android.graphics.drawable.Drawable) ApplicationInfo(android.content.pm.ApplicationInfo) OnDismissAction(com.android.keyguard.KeyguardHostView.OnDismissAction) ImageView(android.widget.ImageView) View(android.view.View) RemoteInputView(com.android.systemui.statusbar.policy.RemoteInputView) TextView(android.widget.TextView) NavigationBarView(com.android.systemui.statusbar.phone.NavigationBarView) StatusBarNotification(android.service.notification.StatusBarNotification) PackageManager(android.content.pm.PackageManager) TextView(android.widget.TextView) ImageView(android.widget.ImageView)

Example 59 with StatusBarNotification

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

the class BaseStatusBar method createIcon.

public StatusBarIconView createIcon(StatusBarNotification sbn) {
    // Construct the icon.
    Notification n = sbn.getNotification();
    final StatusBarIconView iconView = new StatusBarIconView(mContext, sbn.getPackageName() + "/0x" + Integer.toHexString(sbn.getId()), n);
    iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    final Icon smallIcon = n.getSmallIcon();
    if (smallIcon == null) {
        handleNotificationError(sbn, "No small icon in notification from " + sbn.getPackageName());
        return null;
    }
    final StatusBarIcon ic = new StatusBarIcon(sbn.getUser(), sbn.getPackageName(), smallIcon, n.iconLevel, n.number, StatusBarIconView.contentDescForNotification(mContext, n));
    if (!iconView.set(ic)) {
        handleNotificationError(sbn, "Couldn't create icon: " + ic);
        return null;
    }
    return iconView;
}
Also used : StatusBarIcon(com.android.internal.statusbar.StatusBarIcon) Icon(android.graphics.drawable.Icon) StatusBarIcon(com.android.internal.statusbar.StatusBarIcon) Notification(android.app.Notification) StatusBarNotification(android.service.notification.StatusBarNotification)

Example 60 with StatusBarNotification

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

the class BuzzBeepBlinkTest method getNotificationRecord.

private NotificationRecord getNotificationRecord(int id, boolean insistent, boolean once, boolean noisy, boolean buzzy) {
    final Builder builder = new Builder(getContext()).setContentTitle("foo").setSmallIcon(android.R.drawable.sym_def_app_icon).setPriority(Notification.PRIORITY_HIGH).setOnlyAlertOnce(once);
    int defaults = 0;
    if (noisy) {
        defaults |= Notification.DEFAULT_SOUND;
    }
    if (buzzy) {
        defaults |= Notification.DEFAULT_VIBRATE;
    }
    builder.setDefaults(defaults);
    Notification n = builder.build();
    if (insistent) {
        n.flags |= Notification.FLAG_INSISTENT;
    }
    StatusBarNotification sbn = new StatusBarNotification(mPkg, mPkg, id, mTag, mUid, mPid, mScore, n, mUser, System.currentTimeMillis());
    return new NotificationRecord(getContext(), sbn);
}
Also used : StatusBarNotification(android.service.notification.StatusBarNotification) Builder(android.app.Notification.Builder) Notification(android.app.Notification) 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