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();
}
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;
}
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) {
}
}
}
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) {
}
}
}
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();
}
Aggregations