Search in sources :

Example 66 with Entry

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

the class BaseStatusBar method updatePreferences.

public static void updatePreferences() {
    if (mNotificationData == null)
        return;
    for (Entry entry : mNotificationData.getActiveNotifications()) {
        NotificationBackgroundView mBackgroundNormal = (NotificationBackgroundView) getObjectField(entry.row, "mBackgroundNormal");
        NotificationBackgroundView mBackgroundDimmed = (NotificationBackgroundView) getObjectField(entry.row, "mBackgroundDimmed");
        mBackgroundNormal.postInvalidate();
        mBackgroundDimmed.postInvalidate();
    }
}
Also used : Entry(com.android.systemui.statusbar.NotificationData.Entry)

Example 67 with Entry

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

the class PhoneStatusBar method performRemoveNotification.

@Override
protected void performRemoveNotification(StatusBarNotification n) {
    Entry entry = mNotificationData.get(n.getKey());
    if (mRemoteInputController.isRemoteInputActive(entry)) {
        mRemoteInputController.removeRemoteInput(entry, null);
    }
    super.performRemoveNotification(n);
}
Also used : Entry(com.android.systemui.statusbar.NotificationData.Entry)

Example 68 with Entry

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

the class PhoneStatusBar method findAndUpdateMediaNotifications.

public void findAndUpdateMediaNotifications() {
    boolean metaDataChanged = false;
    synchronized (mNotificationData) {
        ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications();
        final int N = activeNotifications.size();
        // Promote the media notification with a controller in 'playing' state, if any.
        Entry mediaNotification = null;
        MediaController controller = null;
        for (int i = 0; i < N; i++) {
            final Entry entry = activeNotifications.get(i);
            if (isMediaNotification(entry)) {
                final MediaSession.Token token = entry.notification.getNotification().extras.getParcelable(Notification.EXTRA_MEDIA_SESSION);
                if (token != null) {
                    MediaController aController = new MediaController(mContext, token);
                    if (PlaybackState.STATE_PLAYING == getMediaControllerPlaybackState(aController)) {
                        if (DEBUG_MEDIA) {
                            Log.v(TAG, "DEBUG_MEDIA: found mediastyle controller matching " + entry.notification.getKey());
                        }
                        mediaNotification = entry;
                        controller = aController;
                        break;
                    }
                }
            }
        }
        if (mediaNotification == null) {
            if (mMediaSessionManager != null) {
                final List<MediaController> sessions = mMediaSessionManager.getActiveSessionsForUser(null, UserHandle.USER_ALL);
                for (MediaController aController : sessions) {
                    if (PlaybackState.STATE_PLAYING == getMediaControllerPlaybackState(aController)) {
                        // now to see if we have one like this
                        final String pkg = aController.getPackageName();
                        for (int i = 0; i < N; i++) {
                            final Entry entry = activeNotifications.get(i);
                            if (entry.notification.getPackageName().equals(pkg)) {
                                if (DEBUG_MEDIA) {
                                    Log.v(TAG, "DEBUG_MEDIA: found controller matching " + entry.notification.getKey());
                                }
                                controller = aController;
                                mediaNotification = entry;
                                break;
                            }
                        }
                    }
                }
            }
        }
        if (controller != null && !sameSessions(mMediaController, controller)) {
            // We have a new media session
            clearCurrentMediaNotification();
            mMediaController = controller;
            mMediaController.registerCallback(mMediaListener);
            mMediaMetadata = mMediaController.getMetadata();
            if (DEBUG_MEDIA) {
                Log.v(TAG, "DEBUG_MEDIA: insert listener, receive metadata: " + mMediaMetadata);
            }
            if (mediaNotification != null && mediaNotification.row != null && mediaNotification.row instanceof MediaExpandableNotificationRow) {
                ((MediaExpandableNotificationRow) mediaNotification.row).setMediaController(controller);
            }
            if (mediaNotification != null) {
                mMediaNotificationKey = mediaNotification.notification.getKey();
                if (DEBUG_MEDIA) {
                    Log.v(TAG, "DEBUG_MEDIA: Found new media notification: key=" + mMediaNotificationKey + " controller=" + mMediaController);
                }
            }
            metaDataChanged = true;
        }
    }
    if (metaDataChanged) {
        updateNotifications();
    }
    updateMediaMetaData(metaDataChanged, true);
}
Also used : Entry(com.android.systemui.statusbar.NotificationData.Entry) MediaController(android.media.session.MediaController) MediaSession(android.media.session.MediaSession) StatusBarManager.windowStateToString(android.app.StatusBarManager.windowStateToString) SpannableString(android.text.SpannableString) Point(android.graphics.Point) MediaExpandableNotificationRow(com.android.systemui.statusbar.MediaExpandableNotificationRow)

Example 69 with Entry

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

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

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

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