use of android.service.notification.StatusBarNotification in project platform_frameworks_base by android.
the class BaseStatusBar method inflateViews.
protected boolean inflateViews(Entry entry, ViewGroup parent) {
PackageManager pmUser = getPackageManagerForUser(mContext, entry.notification.getUser().getIdentifier());
final StatusBarNotification sbn = entry.notification;
try {
entry.cacheContentViews(mContext, null);
} catch (RuntimeException e) {
Log.e(TAG, "Unable to get notification remote views", e);
return false;
}
final RemoteViews contentView = entry.cachedContentView;
final RemoteViews bigContentView = entry.cachedBigContentView;
final RemoteViews headsUpContentView = entry.cachedHeadsUpContentView;
final RemoteViews publicContentView = entry.cachedPublicContentView;
if (contentView == null) {
Log.v(TAG, "no contentView for: " + sbn.getNotification());
return false;
}
if (DEBUG) {
Log.v(TAG, "publicContentView: " + publicContentView);
}
ExpandableNotificationRow row;
// Stash away previous user expansion state so we can restore it at
// the end.
boolean hasUserChangedExpansion = false;
boolean userExpanded = false;
boolean userLocked = false;
if (entry.row != null) {
row = entry.row;
hasUserChangedExpansion = row.hasUserChangedExpansion();
userExpanded = row.isUserExpanded();
userLocked = row.isUserLocked();
entry.reset();
if (hasUserChangedExpansion) {
row.setUserExpanded(userExpanded);
}
} else {
// create the row view
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
row = (ExpandableNotificationRow) inflater.inflate(R.layout.status_bar_notification_row, parent, false);
row.setExpansionLogger(this, entry.notification.getKey());
row.setGroupManager(mGroupManager);
row.setHeadsUpManager(mHeadsUpManager);
row.setRemoteInputController(mRemoteInputController);
row.setOnExpandClickListener(this);
// Get the app name.
// Note that Notification.Builder#bindHeaderAppName has similar logic
// but since this field is used in the guts, it must be accurate.
// Therefore we will only show the application label, or, failing that, the
// package name. No substitutions.
final String pkg = sbn.getPackageName();
String appname = pkg;
try {
final ApplicationInfo info = pmUser.getApplicationInfo(pkg, PackageManager.GET_UNINSTALLED_PACKAGES | PackageManager.GET_DISABLED_COMPONENTS);
if (info != null) {
appname = String.valueOf(pmUser.getApplicationLabel(info));
}
} catch (NameNotFoundException e) {
// Do nothing
}
row.setAppName(appname);
}
workAroundBadLayerDrawableOpacity(row);
bindDismissListener(row);
// NB: the large icon is now handled entirely by the template
// bind the click event to the content area
NotificationContentView contentContainer = row.getPrivateLayout();
NotificationContentView contentContainerPublic = row.getPublicLayout();
row.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
if (ENABLE_REMOTE_INPUT) {
row.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
}
mNotificationClicker.register(row, sbn);
// set up the adaptive layout
View contentViewLocal = null;
View bigContentViewLocal = null;
View headsUpContentViewLocal = null;
View publicViewLocal = null;
try {
contentViewLocal = contentView.apply(sbn.getPackageContext(mContext), contentContainer, mOnClickHandler);
if (bigContentView != null) {
bigContentViewLocal = bigContentView.apply(sbn.getPackageContext(mContext), contentContainer, mOnClickHandler);
}
if (headsUpContentView != null) {
headsUpContentViewLocal = headsUpContentView.apply(sbn.getPackageContext(mContext), contentContainer, mOnClickHandler);
}
if (publicContentView != null) {
publicViewLocal = publicContentView.apply(sbn.getPackageContext(mContext), contentContainerPublic, mOnClickHandler);
}
if (contentViewLocal != null) {
contentViewLocal.setIsRootNamespace(true);
contentContainer.setContractedChild(contentViewLocal);
}
if (bigContentViewLocal != null) {
bigContentViewLocal.setIsRootNamespace(true);
contentContainer.setExpandedChild(bigContentViewLocal);
}
if (headsUpContentViewLocal != null) {
headsUpContentViewLocal.setIsRootNamespace(true);
contentContainer.setHeadsUpChild(headsUpContentViewLocal);
}
if (publicViewLocal != null) {
publicViewLocal.setIsRootNamespace(true);
contentContainerPublic.setContractedChild(publicViewLocal);
}
} catch (RuntimeException e) {
final String ident = sbn.getPackageName() + "/0x" + Integer.toHexString(sbn.getId());
Log.e(TAG, "couldn't inflate view for notification " + ident, e);
return false;
}
// Extract target SDK version.
try {
ApplicationInfo info = pmUser.getApplicationInfo(sbn.getPackageName(), 0);
entry.targetSdk = info.targetSdkVersion;
} catch (NameNotFoundException ex) {
Log.e(TAG, "Failed looking up ApplicationInfo for " + sbn.getPackageName(), ex);
}
entry.autoRedacted = entry.notification.getNotification().publicVersion == null;
if (MULTIUSER_DEBUG) {
TextView debug = (TextView) row.findViewById(R.id.debug_info);
if (debug != null) {
debug.setVisibility(View.VISIBLE);
debug.setText("CU " + mCurrentUserId + " NU " + entry.notification.getUserId());
}
}
entry.row = row;
entry.row.setOnActivatedListener(this);
entry.row.setExpandable(bigContentViewLocal != null);
applyColorsAndBackgrounds(sbn, entry);
// Restore previous flags.
if (hasUserChangedExpansion) {
// Note: setUserExpanded() conveniently ignores calls with
// userExpanded=true if !isExpandable().
row.setUserExpanded(userExpanded);
}
row.setUserLocked(userLocked);
row.onNotificationUpdated(entry);
return true;
}
use of android.service.notification.StatusBarNotification in project platform_frameworks_base by android.
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 android.service.notification.StatusBarNotification in project platform_frameworks_base by android.
the class NotificationData method dumpEntry.
private void dumpEntry(PrintWriter pw, String indent, int i, Entry e) {
mRankingMap.getRanking(e.key, mTmpRanking);
pw.print(indent);
pw.println(" [" + i + "] key=" + e.key + " icon=" + e.icon);
StatusBarNotification n = e.notification;
pw.print(indent);
pw.println(" pkg=" + n.getPackageName() + " id=" + n.getId() + " importance=" + mTmpRanking.getImportance());
pw.print(indent);
pw.println(" notification=" + n.getNotification());
pw.print(indent);
pw.println(" tickerText=\"" + n.getNotification().tickerText + "\"");
}
use of android.service.notification.StatusBarNotification in project platform_frameworks_base by android.
the class NotificationData method updateRankingAndSort.
private void updateRankingAndSort(RankingMap ranking) {
if (ranking != null) {
mRankingMap = ranking;
synchronized (mEntries) {
final int N = mEntries.size();
for (int i = 0; i < N; i++) {
Entry entry = mEntries.valueAt(i);
final StatusBarNotification oldSbn = entry.notification.clone();
final String overrideGroupKey = getOverrideGroupKey(entry.key);
if (!Objects.equals(oldSbn.getOverrideGroupKey(), overrideGroupKey)) {
entry.notification.setOverrideGroupKey(overrideGroupKey);
mGroupManager.onEntryUpdated(entry, oldSbn);
}
}
}
}
filterAndSort();
}
use of android.service.notification.StatusBarNotification in project platform_frameworks_base by android.
the class NotificationData method filterAndSort.
// TODO: This should not be public. Instead the Environment should notify this class when
// anything changed, and this class should call back the UI so it updates itself.
public void filterAndSort() {
mSortedAndFiltered.clear();
synchronized (mEntries) {
final int N = mEntries.size();
for (int i = 0; i < N; i++) {
Entry entry = mEntries.valueAt(i);
StatusBarNotification sbn = entry.notification;
if (shouldFilterOut(sbn)) {
continue;
}
mSortedAndFiltered.add(entry);
}
}
Collections.sort(mSortedAndFiltered, mRankingComparator);
}
Aggregations