Search in sources :

Example 76 with Entry

use of com.android.systemui.statusbar.NotificationData.Entry in project android_frameworks_base by crdroidandroid.

the class BaseStatusBar method updateNotification.

public void updateNotification(StatusBarNotification notification, RankingMap ranking) {
    if (DEBUG)
        Log.d(TAG, "updateNotification(" + notification + ")");
    final String key = notification.getKey();
    Entry entry = mNotificationData.get(key);
    if (entry == null) {
        return;
    } else {
        mHeadsUpEntriesToRemoveOnSwitch.remove(entry);
        mRemoteInputEntriesToRemoveOnCollapse.remove(entry);
    }
    Notification n = notification.getNotification();
    mNotificationData.updateRanking(ranking);
    boolean applyInPlace;
    try {
        applyInPlace = entry.cacheContentViews(mContext, notification.getNotification());
    } catch (RuntimeException e) {
        Log.e(TAG, "Unable to get notification remote views", e);
        applyInPlace = false;
    }
    boolean shouldPeek = shouldPeek(entry, notification);
    boolean alertAgain = alertAgain(entry, n);
    if (DEBUG) {
        Log.d(TAG, "applyInPlace=" + applyInPlace + " shouldPeek=" + shouldPeek + " alertAgain=" + alertAgain);
    }
    boolean updateTicker = n.tickerText != null && !TextUtils.equals(n.tickerText, entry.notification.getNotification().tickerText);
    final StatusBarNotification oldNotification = entry.notification;
    entry.notification = notification;
    mGroupManager.onEntryUpdated(entry, oldNotification);
    boolean updateSuccessful = false;
    if (applyInPlace) {
        if (DEBUG)
            Log.d(TAG, "reusing notification for key: " + key);
        try {
            if (entry.icon != null) {
                // Update the icon
                final StatusBarIcon ic = new StatusBarIcon(notification.getUser(), notification.getPackageName(), n.getSmallIcon(), n.iconLevel, n.number, StatusBarIconView.contentDescForNotification(mContext, n));
                entry.icon.setNotification(n);
                if (!entry.icon.set(ic)) {
                    handleNotificationError(notification, "Couldn't update icon: " + ic);
                    return;
                }
            }
            updateNotificationViews(entry, notification);
            updateSuccessful = true;
        } catch (RuntimeException e) {
            // It failed to apply cleanly.
            Log.w(TAG, "Couldn't reapply views for package " + notification.getPackageName(), e);
        }
    }
    if (!updateSuccessful) {
        if (DEBUG)
            Log.d(TAG, "not reusing notification for key: " + key);
        final StatusBarIcon ic = new StatusBarIcon(notification.getUser(), notification.getPackageName(), n.getSmallIcon(), n.iconLevel, n.number, StatusBarIconView.contentDescForNotification(mContext, n));
        entry.icon.setNotification(n);
        entry.icon.set(ic);
        if (!inflateViews(entry, mStackScroller)) {
            handleNotificationError(notification, "Couldn't update remote views for: " + notification);
        }
    }
    updateHeadsUp(key, entry, shouldPeek, alertAgain);
    updateNotifications();
    if (!notification.isClearable()) {
        // The user may have performed a dismiss action on the notification, since it's
        // not clearable we should snap it back.
        mStackScroller.snapViewIfNeeded(entry.row);
    }
    // Is this for you?
    boolean isForCurrentUser = isNotificationForCurrentProfiles(notification);
    Log.d(TAG, "notification is " + (isForCurrentUser ? "" : "not ") + "for you");
    // Restart the ticker if it's still running
    if (updateTicker && isForCurrentUser) {
        haltTicker();
        tick(notification, false, false, null);
    }
    setAreThereNotifications();
}
Also used : Entry(com.android.systemui.statusbar.NotificationData.Entry) StatusBarNotification(android.service.notification.StatusBarNotification) StatusBarIcon(com.android.internal.statusbar.StatusBarIcon) Notification(android.app.Notification) StatusBarNotification(android.service.notification.StatusBarNotification)

Example 77 with Entry

use of com.android.systemui.statusbar.NotificationData.Entry in project android_frameworks_base by crdroidandroid.

the class BaseStatusBar method createNotificationViews.

protected NotificationData.Entry createNotificationViews(StatusBarNotification sbn) {
    if (DEBUG) {
        Log.d(TAG, "createNotificationViews(notification=" + sbn);
    }
    final StatusBarIconView iconView = createIcon(sbn);
    if (iconView == null) {
        return null;
    }
    // Construct the expanded view.
    NotificationData.Entry entry = new NotificationData.Entry(sbn, iconView);
    if (!inflateViews(entry, mStackScroller)) {
        handleNotificationError(sbn, "Couldn't expand RemoteViews for: " + sbn);
        return null;
    }
    return entry;
}
Also used : Entry(com.android.systemui.statusbar.NotificationData.Entry) Entry(com.android.systemui.statusbar.NotificationData.Entry)

Example 78 with Entry

use of com.android.systemui.statusbar.NotificationData.Entry in project android_frameworks_base by crdroidandroid.

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) {
        // Cancel the ticker if it's still running
        if (mTickerEnabled != 0) {
            mTicker.removeEntry(old);
        }
        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 79 with Entry

use of com.android.systemui.statusbar.NotificationData.Entry in project android_frameworks_base by crdroidandroid.

the class PhoneStatusBar method tickTrackInfo.

private void tickTrackInfo() {
    ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications();
    int N = activeNotifications.size();
    if (PlaybackState.STATE_PLAYING == getMediaControllerPlaybackState(mMediaController) || PlaybackState.STATE_BUFFERING == getMediaControllerPlaybackState(mMediaController)) {
        final String pkg = mMediaController.getPackageName();
        for (int i = 0; i < N; i++) {
            final Entry entry = activeNotifications.get(i);
            if (entry.notification.getPackageName().equals(pkg)) {
                tick(entry.notification, true, true, mMediaMetadata);
                break;
            }
        }
    }
}
Also used : Entry(com.android.systemui.statusbar.NotificationData.Entry) StatusBarManager.windowStateToString(android.app.StatusBarManager.windowStateToString) Point(android.graphics.Point)

Example 80 with Entry

use of com.android.systemui.statusbar.NotificationData.Entry in project android_frameworks_base by crdroidandroid.

the class PhoneStatusBar method startKeyguard.

protected void startKeyguard() {
    Trace.beginSection("PhoneStatusBar#startKeyguard");
    KeyguardViewMediator keyguardViewMediator = getComponent(KeyguardViewMediator.class);
    mFingerprintUnlockController = new FingerprintUnlockController(mContext, mStatusBarWindowManager, mDozeScrimController, keyguardViewMediator, mScrimController, this);
    mStatusBarKeyguardViewManager = keyguardViewMediator.registerStatusBar(this, getBouncerContainer(), mStatusBarWindowManager, mScrimController, mFingerprintUnlockController);
    mKeyguardIndicationController.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager);
    mFingerprintUnlockController.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager);
    mIconPolicy.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager);
    mRemoteInputController.addCallback(mStatusBarKeyguardViewManager);
    mRemoteInputController.addCallback(new RemoteInputController.Callback() {

        @Override
        public void onRemoteInputSent(Entry entry) {
            if (FORCE_REMOTE_INPUT_HISTORY && mKeysKeptForRemoteInput.contains(entry.key)) {
                removeNotification(entry.key, null);
            } else if (mRemoteInputEntriesToRemoveOnCollapse.contains(entry)) {
                // We're currently holding onto this notification, but from the apps point of
                // view it is already canceled, so we'll need to cancel it on the apps behalf
                // after sending - unless the app posts an update in the mean time, so wait a
                // bit.
                mHandler.postDelayed(() -> {
                    if (mRemoteInputEntriesToRemoveOnCollapse.remove(entry)) {
                        removeNotification(entry.key, null);
                    }
                }, REMOTE_INPUT_KEPT_ENTRY_AUTO_CANCEL_DELAY);
            }
        }
    });
    mKeyguardViewMediatorCallback = keyguardViewMediator.getViewMediatorCallback();
    mLightStatusBarController.setFingerprintUnlockController(mFingerprintUnlockController);
    Trace.endSection();
}
Also used : KeyguardViewMediator(com.android.systemui.keyguard.KeyguardViewMediator) Entry(com.android.systemui.statusbar.NotificationData.Entry) RemoteInputController(com.android.systemui.statusbar.RemoteInputController)

Aggregations

Entry (com.android.systemui.statusbar.NotificationData.Entry)81 Point (android.graphics.Point)39 ArrayList (java.util.ArrayList)14 View (android.view.View)13 ImageView (android.widget.ImageView)13 TextView (android.widget.TextView)13 Notification (android.app.Notification)11 StatusBarNotification (android.service.notification.StatusBarNotification)11 ExpandableNotificationRow (com.android.systemui.statusbar.ExpandableNotificationRow)10 SignalClusterView (com.android.systemui.statusbar.SignalClusterView)9 StatusBarManager.windowStateToString (android.app.StatusBarManager.windowStateToString)8 NotificationData (com.android.systemui.statusbar.NotificationData)8 MediaExpandableNotificationRow (com.android.systemui.statusbar.MediaExpandableNotificationRow)6 KeyButtonView (com.android.systemui.statusbar.policy.KeyButtonView)6 MediaController (android.media.session.MediaController)5 MediaSession (android.media.session.MediaSession)5 StatusBarIcon (com.android.internal.statusbar.StatusBarIcon)5 BatteryMeterView (com.android.systemui.BatteryMeterView)5 KeyguardViewMediator (com.android.systemui.keyguard.KeyguardViewMediator)5 ActivatableNotificationView (com.android.systemui.statusbar.ActivatableNotificationView)5