Search in sources :

Example 41 with StatusBarIcon

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

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);
    }
    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);
    }
    if (DEBUG) {
        // Is this for you?
        boolean isForCurrentUser = isNotificationForCurrentProfiles(notification);
        Log.d(TAG, "notification is " + (isForCurrentUser ? "" : "not ") + "for you");
    }
    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 42 with StatusBarIcon

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

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

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

the class DemoStatusIcons method updateSlot.

private void updateSlot(String slot, String iconPkg, int iconId) {
    if (!mDemoMode)
        return;
    if (iconPkg == null) {
        iconPkg = mContext.getPackageName();
    }
    int removeIndex = -1;
    for (int i = 0; i < getChildCount(); i++) {
        StatusBarIconView v = (StatusBarIconView) getChildAt(i);
        if (slot.equals(v.getTag())) {
            if (iconId == 0) {
                removeIndex = i;
                break;
            } else {
                StatusBarIcon icon = v.getStatusBarIcon();
                icon.icon = Icon.createWithResource(icon.icon.getResPackage(), iconId);
                v.set(icon);
                v.updateDrawable();
                return;
            }
        }
    }
    if (iconId == 0) {
        if (removeIndex != -1) {
            removeViewAt(removeIndex);
        }
        return;
    }
    StatusBarIcon icon = new StatusBarIcon(iconPkg, UserHandle.SYSTEM, iconId, 0, 0, "Demo");
    StatusBarIconView v = new StatusBarIconView(getContext(), null, null);
    v.setTag(slot);
    v.set(icon);
    addView(v, 0, new LinearLayout.LayoutParams(mIconSize, mIconSize));
}
Also used : StatusBarIcon(com.android.internal.statusbar.StatusBarIcon) LinearLayout(android.widget.LinearLayout) StatusBarIconView(com.android.systemui.statusbar.StatusBarIconView)

Example 44 with StatusBarIcon

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

the class StatusBarManagerService method setIcon.

@Override
public void setIcon(String slot, String iconPackage, int iconId, int iconLevel, String contentDescription) {
    enforceStatusBar();
    synchronized (mIcons) {
        StatusBarIcon icon = new StatusBarIcon(iconPackage, UserHandle.SYSTEM, iconId, iconLevel, 0, contentDescription);
        //Slog.d(TAG, "setIcon slot=" + slot + " index=" + index + " icon=" + icon);
        mIcons.put(slot, icon);
        if (mBar != null) {
            try {
                mBar.setIcon(slot, icon);
            } catch (RemoteException ex) {
            }
        }
    }
}
Also used : StatusBarIcon(com.android.internal.statusbar.StatusBarIcon) RemoteException(android.os.RemoteException)

Example 45 with StatusBarIcon

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

the class StatusBarIconController method setIconVisibility.

public void setIconVisibility(String slot, boolean visibility) {
    int index = getSlotIndex(slot);
    StatusBarIcon icon = getIcon(index);
    if (icon == null || icon.visible == visibility) {
        return;
    }
    icon.visible = visibility;
    handleSet(index, icon);
}
Also used : StatusBarIcon(com.android.internal.statusbar.StatusBarIcon)

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