Search in sources :

Example 46 with StatusBarIcon

use of com.android.internal.statusbar.StatusBarIcon in project android_frameworks_base by ResurrectionRemix.

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 47 with StatusBarIcon

use of com.android.internal.statusbar.StatusBarIcon in project android_frameworks_base by ResurrectionRemix.

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 48 with StatusBarIcon

use of com.android.internal.statusbar.StatusBarIcon in project android_frameworks_base by ResurrectionRemix.

the class TileServices method updateStatusIcon.

@Override
public void updateStatusIcon(IBinder token, Icon icon, String contentDescription) {
    CustomTile customTile = getTileForToken(token);
    if (customTile != null) {
        verifyCaller(customTile);
        try {
            ComponentName componentName = customTile.getComponent();
            String packageName = componentName.getPackageName();
            UserHandle userHandle = getCallingUserHandle();
            PackageInfo info = mContext.getPackageManager().getPackageInfoAsUser(packageName, 0, userHandle.getIdentifier());
            if (info.applicationInfo.isSystemApp()) {
                final StatusBarIcon statusIcon = icon != null ? new StatusBarIcon(userHandle, packageName, icon, 0, 0, contentDescription) : null;
                mMainHandler.post(new Runnable() {

                    @Override
                    public void run() {
                        StatusBarIconController iconController = mHost.getIconController();
                        iconController.setIcon(componentName.getClassName(), statusIcon);
                        iconController.setExternalIcon(componentName.getClassName());
                    }
                });
            }
        } catch (PackageManager.NameNotFoundException e) {
        }
    }
}
Also used : PackageManager(android.content.pm.PackageManager) PackageInfo(android.content.pm.PackageInfo) UserHandle(android.os.UserHandle) ComponentName(android.content.ComponentName) StatusBarIcon(com.android.internal.statusbar.StatusBarIcon) StatusBarIconController(com.android.systemui.statusbar.phone.StatusBarIconController)

Example 49 with StatusBarIcon

use of com.android.internal.statusbar.StatusBarIcon in project android_frameworks_base by DirtyUnicorns.

the class TileServices method updateStatusIcon.

@Override
public void updateStatusIcon(IBinder token, Icon icon, String contentDescription) {
    CustomTile customTile = getTileForToken(token);
    if (customTile != null) {
        verifyCaller(customTile);
        try {
            ComponentName componentName = customTile.getComponent();
            String packageName = componentName.getPackageName();
            UserHandle userHandle = getCallingUserHandle();
            PackageInfo info = mContext.getPackageManager().getPackageInfoAsUser(packageName, 0, userHandle.getIdentifier());
            if (info.applicationInfo.isSystemApp()) {
                final StatusBarIcon statusIcon = icon != null ? new StatusBarIcon(userHandle, packageName, icon, 0, 0, contentDescription) : null;
                mMainHandler.post(new Runnable() {

                    @Override
                    public void run() {
                        StatusBarIconController iconController = mHost.getIconController();
                        iconController.setIcon(componentName.getClassName(), statusIcon);
                        iconController.setExternalIcon(componentName.getClassName());
                    }
                });
            }
        } catch (PackageManager.NameNotFoundException e) {
        }
    }
}
Also used : PackageManager(android.content.pm.PackageManager) PackageInfo(android.content.pm.PackageInfo) UserHandle(android.os.UserHandle) ComponentName(android.content.ComponentName) StatusBarIcon(com.android.internal.statusbar.StatusBarIcon) StatusBarIconController(com.android.systemui.statusbar.phone.StatusBarIconController)

Example 50 with StatusBarIcon

use of com.android.internal.statusbar.StatusBarIcon in project android_frameworks_base by DirtyUnicorns.

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 updateTicker = n.tickerText != null && !TextUtils.equals(n.tickerText, entry.notification.getNotification().tickerText);
    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);
    }
    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)

Aggregations

StatusBarIcon (com.android.internal.statusbar.StatusBarIcon)56 StatusBarNotification (android.service.notification.StatusBarNotification)16 Notification (android.app.Notification)13 RemoteException (android.os.RemoteException)13 ComponentName (android.content.ComponentName)10 Drawable (android.graphics.drawable.Drawable)8 StatusBarIconView (com.android.systemui.statusbar.StatusBarIconView)8 IBinder (android.os.IBinder)7 ArrayList (java.util.ArrayList)7 IntentFilter (android.content.IntentFilter)6 Rect (android.graphics.Rect)6 PackageInfo (android.content.pm.PackageInfo)5 PackageManager (android.content.pm.PackageManager)5 Configuration (android.content.res.Configuration)5 Icon (android.graphics.drawable.Icon)5 UserHandle (android.os.UserHandle)5 IVrManager (android.service.vr.IVrManager)5 LinearLayout (android.widget.LinearLayout)5 LockPatternUtils (com.android.internal.widget.LockPatternUtils)5 Entry (com.android.systemui.statusbar.NotificationData.Entry)5