Loading core/java/com/android/internal/statusbar/StatusBarIcon.java +7 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,13 @@ public class StatusBarIcon implements Parcelable { this.iconLevel = iconLevel; } public StatusBarIcon(String iconPackage, int iconId, int iconLevel, int number) { this.iconPackage = iconPackage; this.iconId = iconId; this.iconLevel = iconLevel; this.number = number; } public String toString() { return "StatusBarIcon(pkg=" + this.iconPackage + " id=0x" + Integer.toHexString(this.iconId) + " level=" + this.iconLevel + " visible=" + visible Loading core/java/com/android/internal/statusbar/StatusBarNotification.java +1 −1 Original line number Diff line number Diff line Loading @@ -103,7 +103,7 @@ public class StatusBarNotification implements Parcelable { } public String toString() { return "StatusBarNotification(package=" + pkg + " tag=" + tag return "StatusBarNotification(package=" + pkg + " id=" + id + " tag=" + tag + " notification=" + notification + ")"; } Loading packages/StatusBarPhone/src/com/android/policy/statusbar/phone/NotificationData.java +13 −1 Original line number Diff line number Diff line Loading @@ -30,8 +30,9 @@ public class NotificationData { public static final class Entry { public IBinder key; public StatusBarNotification notification; public View expanded; public StatusBarIconView icon; public View expanded; // the outer expanded view public View contents; // the inflated RemoteViews } private final ArrayList<Entry> mEntries = new ArrayList<Entry>(); Loading @@ -43,6 +44,17 @@ public class NotificationData { return mEntries.get(index); } public int findEntry(IBinder key) { final int N = mEntries.size(); for (int i=0; i<N; i++) { Entry entry = mEntries.get(i); if (entry.key == key) { return i; } } return -1; } public int add(IBinder key, StatusBarNotification notification, View expanded, StatusBarIconView icon) { Entry entry = new Entry(); Loading packages/StatusBarPhone/src/com/android/policy/statusbar/phone/PhoneStatusBarService.java +161 −170 Original line number Diff line number Diff line Loading @@ -297,10 +297,6 @@ public class PhoneStatusBarService extends StatusBarService { WindowManagerImpl.getDefault().addView(view, lp); } // ================================================================================ // Always called from the UI thread. // ================================================================================ public void addIcon(String slot, int index, int viewIndex, StatusBarIcon icon) { Slog.d(TAG, "addIcon slot=" + slot + " index=" + index + " viewIndex=" + viewIndex + " icon=" + icon); Loading @@ -323,30 +319,7 @@ public class PhoneStatusBarService extends StatusBarService { } public void addNotification(IBinder key, StatusBarNotification notification) { NotificationData list; ViewGroup parent; final boolean isOngoing = notification.isOngoing(); if (isOngoing) { list = mOngoing; parent = mOngoingItems; } else { list = mLatest; parent = mLatestItems; } // Construct the expanded view. final View view = makeNotificationView(notification, parent); // Construct the icon. StatusBarIconView iconView = new StatusBarIconView(this, notification.pkg + "/" + notification.id); iconView.set(new StatusBarIcon(notification.pkg, notification.notification.icon, notification.notification.iconLevel)); // Add the expanded view. final int viewIndex = list.add(key, notification, view, iconView); parent.addView(view, viewIndex); // Add the icon. final int iconIndex = chooseIconIndex(isOngoing, viewIndex); mNotificationIcons.addView(iconView, iconIndex, new LinearLayout.LayoutParams(mIconWidth, mHeight)); addNotificationViews(key, notification); // show the ticker // TODO Loading @@ -356,24 +329,66 @@ public class PhoneStatusBarService extends StatusBarService { } public void updateNotification(IBinder key, StatusBarNotification notification) { } Slog.d(TAG, "updateNotification key=" + key + " notification=" + notification); public void removeNotification(IBinder key) { Slog.d(TAG, "removeNotification key=" + key); NotificationData.Entry entry = mOngoing.remove(key); if (entry == null) { entry = mLatest.remove(key); if (entry == null) { Slog.w(TAG, "removeNotification for nonexistent key: " + key); NotificationData oldList; int oldIndex = mOngoing.findEntry(key); if (oldIndex >= 0) { oldList = mOngoing; } else { oldIndex = mLatest.findEntry(key); if (oldIndex < 0) { Slog.w(TAG, "updateNotification for unknown key: " + key); return; } oldList = mLatest; } final NotificationData.Entry oldEntry = oldList.getEntryAt(oldIndex); final StatusBarNotification oldNotification = oldEntry.notification; final RemoteViews oldContentView = oldNotification.notification.contentView; final RemoteViews contentView = notification.notification.contentView; // Can we just reapply the RemoteViews in place? If when didn't change, the order // didn't change. if (notification.notification.when == oldNotification.notification.when && notification.isOngoing() == oldNotification.isOngoing() && oldEntry.contents != null && contentView != null && oldContentView != null && contentView.getPackage() != null && oldContentView.getPackage() != null && oldContentView.getPackage().equals(contentView.getPackage()) && oldContentView.getLayoutId() == contentView.getLayoutId()) { Slog.d(TAG, "reusing notification"); oldEntry.notification = notification; try { // Reapply the RemoteViews contentView.reapply(this, oldEntry.contents); // update the contentIntent ViewGroup clickView = (ViewGroup)oldEntry.expanded.findViewById( com.android.internal.R.id.content); final PendingIntent contentIntent = notification.notification.contentIntent; if (contentIntent != null) { clickView.setOnClickListener(new Launcher(contentIntent, notification.pkg, notification.tag, notification.id)); } } catch (RuntimeException e) { // It failed to add cleanly. Log, and remove the view from the panel. Slog.w(TAG, "couldn't reapply views for package " + contentView.getPackage(), e); removeNotificationViews(key); addNotificationViews(key, notification); } // Update the icon. oldEntry.icon.set(new StatusBarIcon(notification.pkg, notification.notification.icon, notification.notification.iconLevel, notification.notification.number)); } else { Slog.d(TAG, "not reusing notification"); removeNotificationViews(key); addNotificationViews(key, notification); } // Remove the expanded view. ((ViewGroup)entry.expanded.getParent()).removeView(entry.expanded); // Remove the icon. ((ViewGroup)entry.icon.getParent()).removeView(entry.icon); // Cancel the ticker if it's still running // Restart the ticker if it's still running // TODO // Recalculate the position of the sliding windows and the titles. Loading @@ -381,65 +396,17 @@ public class PhoneStatusBarService extends StatusBarService { updateExpandedViewPos(EXPANDED_LEAVE_ALONE); } /** * State is one or more of the DISABLE constants from StatusBarManager. */ public void disable(int state) { final int old = mDisabled; final int diff = state ^ old; mDisabled = state; if ((diff & StatusBarManager.DISABLE_EXPAND) != 0) { if ((state & StatusBarManager.DISABLE_EXPAND) != 0) { Slog.d(TAG, "DISABLE_EXPAND: yes"); animateCollapse(); } } if ((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { if ((state & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: yes"); if (mTicking) { mTicker.halt(); } else { setNotificationIconVisibility(false, com.android.internal.R.anim.fade_out); } } else { Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: no"); if (!mExpandedVisible) { setNotificationIconVisibility(true, com.android.internal.R.anim.fade_in); } } } else if ((diff & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { if (mTicking && (state & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { Slog.d(TAG, "DISABLE_NOTIFICATION_TICKER: yes"); mTicker.halt(); } } } public void removeNotification(IBinder key) { Slog.d(TAG, "removeNotification key=" + key); removeNotificationViews(key); /** * All changes to the status bar and notifications funnel through here and are batched. */ private class H extends Handler { public void handleMessage(Message m) { switch (m.what) { case MSG_ANIMATE: doAnimation(); break; case MSG_ANIMATE_REVEAL: doRevealAnimation(); break; } } } // Cancel the ticker if it's still running // TODO View.OnFocusChangeListener mFocusChangeListener = new View.OnFocusChangeListener() { public void onFocusChange(View v, boolean hasFocus) { // Because 'v' is a ViewGroup, all its children will be (un)selected // too, which allows marqueeing to work. v.setSelected(hasFocus); // Recalculate the position of the sliding windows and the titles. setAreThereNotifications(); updateExpandedViewPos(EXPANDED_LEAVE_ALONE); } }; private int chooseIconIndex(boolean isOngoing, int index) { final int ongoingSize = mOngoing.size(); Loading Loading @@ -488,88 +455,51 @@ public class PhoneStatusBarService extends StatusBarService { row.setDrawingCacheEnabled(true); /* notification.view = row; notification.contentView = child; */ return row; } /* StatusBarIcon icon = new StatusBarIcon(pkg, notification.icon, notification.iconLevel); icon.number = notification.number; */ /* void addNotificationView(StatusBarNotification notification) { if (notification.view != null) { throw new RuntimeException("Assertion failed: notification.view=" + notification.view); } LinearLayout parent = notification.data.ongoingEvent ? mOngoingItems : mLatestItems; View child = makeNotificationView(notification, parent); if (child == null) { return ; void addNotificationViews(IBinder key, StatusBarNotification notification) { NotificationData list; ViewGroup parent; final boolean isOngoing = notification.isOngoing(); if (isOngoing) { list = mOngoing; parent = mOngoingItems; } else { list = mLatest; parent = mLatestItems; } // Construct the expanded view. final View view = makeNotificationView(notification, parent); // Construct the icon. StatusBarIconView iconView = new StatusBarIconView(this, notification.pkg + "/" + notification.id); iconView.set(new StatusBarIcon(notification.pkg, notification.notification.icon, notification.notification.iconLevel, notification.notification.number)); // Add the expanded view. final int viewIndex = list.add(key, notification, view, iconView); parent.addView(view, viewIndex); // Add the icon. final int iconIndex = chooseIconIndex(isOngoing, viewIndex); mNotificationIcons.addView(iconView, iconIndex, new LinearLayout.LayoutParams(mIconWidth, mHeight)); int index = mNotificationData.getExpandedIndex(notification); parent.addView(child, index); } */ /** * Remove the old one and put the new one in its place. * @param notification the notification */ /* void updateNotificationView(StatusBarNotification notification, NotificationData oldData) { NotificationData n = notification.data; if (oldData != null && n != null && n.when == oldData.when && n.ongoingEvent == oldData.ongoingEvent && n.contentView != null && oldData.contentView != null && n.contentView.getPackage() != null && oldData.contentView.getPackage() != null && oldData.contentView.getPackage().equals(n.contentView.getPackage()) && oldData.contentView.getLayoutId() == n.contentView.getLayoutId() && notification.view != null) { mNotificationData.update(notification); try { n.contentView.reapply(this, notification.contentView); // update the contentIntent ViewGroup content = (ViewGroup)notification.view.findViewById( com.android.internal.R.id.content); PendingIntent contentIntent = n.contentIntent; if (contentIntent != null) { content.setOnClickListener(new Launcher(contentIntent, n.pkg, n.tag, n.id)); } } catch (RuntimeException e) { // It failed to add cleanly. Log, and remove the view from the panel. Slog.w(TAG, "couldn't reapply views for package " + n.contentView.getPackage(), e); removeNotificationView(notification); } } else { mNotificationData.update(notification); removeNotificationView(notification); addNotificationView(notification); } setAreThereNotifications(); void removeNotificationViews(IBinder key) { NotificationData.Entry entry = mOngoing.remove(key); if (entry == null) { entry = mLatest.remove(key); if (entry == null) { Slog.w(TAG, "removeNotification for unknown key: " + key); return; } void removeNotificationView(StatusBarNotification notification) { View v = notification.view; if (v != null) { ViewGroup parent = (ViewGroup)v.getParent(); parent.removeView(v); notification.view = null; } // Remove the expanded view. ((ViewGroup)entry.expanded.getParent()).removeView(entry.expanded); // Remove the icon. ((ViewGroup)entry.icon.getParent()).removeView(entry.icon); } */ private void setAreThereNotifications() { /* Loading @@ -593,6 +523,67 @@ public class PhoneStatusBarService extends StatusBarService { */ } /** * State is one or more of the DISABLE constants from StatusBarManager. */ public void disable(int state) { final int old = mDisabled; final int diff = state ^ old; mDisabled = state; if ((diff & StatusBarManager.DISABLE_EXPAND) != 0) { if ((state & StatusBarManager.DISABLE_EXPAND) != 0) { Slog.d(TAG, "DISABLE_EXPAND: yes"); animateCollapse(); } } if ((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { if ((state & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: yes"); if (mTicking) { mTicker.halt(); } else { setNotificationIconVisibility(false, com.android.internal.R.anim.fade_out); } } else { Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: no"); if (!mExpandedVisible) { setNotificationIconVisibility(true, com.android.internal.R.anim.fade_in); } } } else if ((diff & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { if (mTicking && (state & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { Slog.d(TAG, "DISABLE_NOTIFICATION_TICKER: yes"); mTicker.halt(); } } } /** * All changes to the status bar and notifications funnel through here and are batched. */ private class H extends Handler { public void handleMessage(Message m) { switch (m.what) { case MSG_ANIMATE: doAnimation(); break; case MSG_ANIMATE_REVEAL: doRevealAnimation(); break; } } } View.OnFocusChangeListener mFocusChangeListener = new View.OnFocusChangeListener() { public void onFocusChange(View v, boolean hasFocus) { // Because 'v' is a ViewGroup, all its children will be (un)selected // too, which allows marqueeing to work. v.setSelected(hasFocus); } }; private void makeExpandedVisible() { if (SPEW) Slog.d(TAG, "Make expanded visible: expanded visible=" + mExpandedVisible); if (mExpandedVisible) { Loading tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java +1 −3 Original line number Diff line number Diff line Loading @@ -623,9 +623,7 @@ public class NotificationTestList extends TestActivity private PendingIntent makeIntent() { Intent intent = new Intent(Intent.ACTION_MAIN); intent.setComponent(new android.content.ComponentName( "com.android.contacts", "com.android.contacts.ContactsActivity")); intent.addCategory(Intent.CATEGORY_HOME); return PendingIntent.getActivity(this, 0, intent, 0); } Loading Loading
core/java/com/android/internal/statusbar/StatusBarIcon.java +7 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,13 @@ public class StatusBarIcon implements Parcelable { this.iconLevel = iconLevel; } public StatusBarIcon(String iconPackage, int iconId, int iconLevel, int number) { this.iconPackage = iconPackage; this.iconId = iconId; this.iconLevel = iconLevel; this.number = number; } public String toString() { return "StatusBarIcon(pkg=" + this.iconPackage + " id=0x" + Integer.toHexString(this.iconId) + " level=" + this.iconLevel + " visible=" + visible Loading
core/java/com/android/internal/statusbar/StatusBarNotification.java +1 −1 Original line number Diff line number Diff line Loading @@ -103,7 +103,7 @@ public class StatusBarNotification implements Parcelable { } public String toString() { return "StatusBarNotification(package=" + pkg + " tag=" + tag return "StatusBarNotification(package=" + pkg + " id=" + id + " tag=" + tag + " notification=" + notification + ")"; } Loading
packages/StatusBarPhone/src/com/android/policy/statusbar/phone/NotificationData.java +13 −1 Original line number Diff line number Diff line Loading @@ -30,8 +30,9 @@ public class NotificationData { public static final class Entry { public IBinder key; public StatusBarNotification notification; public View expanded; public StatusBarIconView icon; public View expanded; // the outer expanded view public View contents; // the inflated RemoteViews } private final ArrayList<Entry> mEntries = new ArrayList<Entry>(); Loading @@ -43,6 +44,17 @@ public class NotificationData { return mEntries.get(index); } public int findEntry(IBinder key) { final int N = mEntries.size(); for (int i=0; i<N; i++) { Entry entry = mEntries.get(i); if (entry.key == key) { return i; } } return -1; } public int add(IBinder key, StatusBarNotification notification, View expanded, StatusBarIconView icon) { Entry entry = new Entry(); Loading
packages/StatusBarPhone/src/com/android/policy/statusbar/phone/PhoneStatusBarService.java +161 −170 Original line number Diff line number Diff line Loading @@ -297,10 +297,6 @@ public class PhoneStatusBarService extends StatusBarService { WindowManagerImpl.getDefault().addView(view, lp); } // ================================================================================ // Always called from the UI thread. // ================================================================================ public void addIcon(String slot, int index, int viewIndex, StatusBarIcon icon) { Slog.d(TAG, "addIcon slot=" + slot + " index=" + index + " viewIndex=" + viewIndex + " icon=" + icon); Loading @@ -323,30 +319,7 @@ public class PhoneStatusBarService extends StatusBarService { } public void addNotification(IBinder key, StatusBarNotification notification) { NotificationData list; ViewGroup parent; final boolean isOngoing = notification.isOngoing(); if (isOngoing) { list = mOngoing; parent = mOngoingItems; } else { list = mLatest; parent = mLatestItems; } // Construct the expanded view. final View view = makeNotificationView(notification, parent); // Construct the icon. StatusBarIconView iconView = new StatusBarIconView(this, notification.pkg + "/" + notification.id); iconView.set(new StatusBarIcon(notification.pkg, notification.notification.icon, notification.notification.iconLevel)); // Add the expanded view. final int viewIndex = list.add(key, notification, view, iconView); parent.addView(view, viewIndex); // Add the icon. final int iconIndex = chooseIconIndex(isOngoing, viewIndex); mNotificationIcons.addView(iconView, iconIndex, new LinearLayout.LayoutParams(mIconWidth, mHeight)); addNotificationViews(key, notification); // show the ticker // TODO Loading @@ -356,24 +329,66 @@ public class PhoneStatusBarService extends StatusBarService { } public void updateNotification(IBinder key, StatusBarNotification notification) { } Slog.d(TAG, "updateNotification key=" + key + " notification=" + notification); public void removeNotification(IBinder key) { Slog.d(TAG, "removeNotification key=" + key); NotificationData.Entry entry = mOngoing.remove(key); if (entry == null) { entry = mLatest.remove(key); if (entry == null) { Slog.w(TAG, "removeNotification for nonexistent key: " + key); NotificationData oldList; int oldIndex = mOngoing.findEntry(key); if (oldIndex >= 0) { oldList = mOngoing; } else { oldIndex = mLatest.findEntry(key); if (oldIndex < 0) { Slog.w(TAG, "updateNotification for unknown key: " + key); return; } oldList = mLatest; } final NotificationData.Entry oldEntry = oldList.getEntryAt(oldIndex); final StatusBarNotification oldNotification = oldEntry.notification; final RemoteViews oldContentView = oldNotification.notification.contentView; final RemoteViews contentView = notification.notification.contentView; // Can we just reapply the RemoteViews in place? If when didn't change, the order // didn't change. if (notification.notification.when == oldNotification.notification.when && notification.isOngoing() == oldNotification.isOngoing() && oldEntry.contents != null && contentView != null && oldContentView != null && contentView.getPackage() != null && oldContentView.getPackage() != null && oldContentView.getPackage().equals(contentView.getPackage()) && oldContentView.getLayoutId() == contentView.getLayoutId()) { Slog.d(TAG, "reusing notification"); oldEntry.notification = notification; try { // Reapply the RemoteViews contentView.reapply(this, oldEntry.contents); // update the contentIntent ViewGroup clickView = (ViewGroup)oldEntry.expanded.findViewById( com.android.internal.R.id.content); final PendingIntent contentIntent = notification.notification.contentIntent; if (contentIntent != null) { clickView.setOnClickListener(new Launcher(contentIntent, notification.pkg, notification.tag, notification.id)); } } catch (RuntimeException e) { // It failed to add cleanly. Log, and remove the view from the panel. Slog.w(TAG, "couldn't reapply views for package " + contentView.getPackage(), e); removeNotificationViews(key); addNotificationViews(key, notification); } // Update the icon. oldEntry.icon.set(new StatusBarIcon(notification.pkg, notification.notification.icon, notification.notification.iconLevel, notification.notification.number)); } else { Slog.d(TAG, "not reusing notification"); removeNotificationViews(key); addNotificationViews(key, notification); } // Remove the expanded view. ((ViewGroup)entry.expanded.getParent()).removeView(entry.expanded); // Remove the icon. ((ViewGroup)entry.icon.getParent()).removeView(entry.icon); // Cancel the ticker if it's still running // Restart the ticker if it's still running // TODO // Recalculate the position of the sliding windows and the titles. Loading @@ -381,65 +396,17 @@ public class PhoneStatusBarService extends StatusBarService { updateExpandedViewPos(EXPANDED_LEAVE_ALONE); } /** * State is one or more of the DISABLE constants from StatusBarManager. */ public void disable(int state) { final int old = mDisabled; final int diff = state ^ old; mDisabled = state; if ((diff & StatusBarManager.DISABLE_EXPAND) != 0) { if ((state & StatusBarManager.DISABLE_EXPAND) != 0) { Slog.d(TAG, "DISABLE_EXPAND: yes"); animateCollapse(); } } if ((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { if ((state & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: yes"); if (mTicking) { mTicker.halt(); } else { setNotificationIconVisibility(false, com.android.internal.R.anim.fade_out); } } else { Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: no"); if (!mExpandedVisible) { setNotificationIconVisibility(true, com.android.internal.R.anim.fade_in); } } } else if ((diff & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { if (mTicking && (state & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { Slog.d(TAG, "DISABLE_NOTIFICATION_TICKER: yes"); mTicker.halt(); } } } public void removeNotification(IBinder key) { Slog.d(TAG, "removeNotification key=" + key); removeNotificationViews(key); /** * All changes to the status bar and notifications funnel through here and are batched. */ private class H extends Handler { public void handleMessage(Message m) { switch (m.what) { case MSG_ANIMATE: doAnimation(); break; case MSG_ANIMATE_REVEAL: doRevealAnimation(); break; } } } // Cancel the ticker if it's still running // TODO View.OnFocusChangeListener mFocusChangeListener = new View.OnFocusChangeListener() { public void onFocusChange(View v, boolean hasFocus) { // Because 'v' is a ViewGroup, all its children will be (un)selected // too, which allows marqueeing to work. v.setSelected(hasFocus); // Recalculate the position of the sliding windows and the titles. setAreThereNotifications(); updateExpandedViewPos(EXPANDED_LEAVE_ALONE); } }; private int chooseIconIndex(boolean isOngoing, int index) { final int ongoingSize = mOngoing.size(); Loading Loading @@ -488,88 +455,51 @@ public class PhoneStatusBarService extends StatusBarService { row.setDrawingCacheEnabled(true); /* notification.view = row; notification.contentView = child; */ return row; } /* StatusBarIcon icon = new StatusBarIcon(pkg, notification.icon, notification.iconLevel); icon.number = notification.number; */ /* void addNotificationView(StatusBarNotification notification) { if (notification.view != null) { throw new RuntimeException("Assertion failed: notification.view=" + notification.view); } LinearLayout parent = notification.data.ongoingEvent ? mOngoingItems : mLatestItems; View child = makeNotificationView(notification, parent); if (child == null) { return ; void addNotificationViews(IBinder key, StatusBarNotification notification) { NotificationData list; ViewGroup parent; final boolean isOngoing = notification.isOngoing(); if (isOngoing) { list = mOngoing; parent = mOngoingItems; } else { list = mLatest; parent = mLatestItems; } // Construct the expanded view. final View view = makeNotificationView(notification, parent); // Construct the icon. StatusBarIconView iconView = new StatusBarIconView(this, notification.pkg + "/" + notification.id); iconView.set(new StatusBarIcon(notification.pkg, notification.notification.icon, notification.notification.iconLevel, notification.notification.number)); // Add the expanded view. final int viewIndex = list.add(key, notification, view, iconView); parent.addView(view, viewIndex); // Add the icon. final int iconIndex = chooseIconIndex(isOngoing, viewIndex); mNotificationIcons.addView(iconView, iconIndex, new LinearLayout.LayoutParams(mIconWidth, mHeight)); int index = mNotificationData.getExpandedIndex(notification); parent.addView(child, index); } */ /** * Remove the old one and put the new one in its place. * @param notification the notification */ /* void updateNotificationView(StatusBarNotification notification, NotificationData oldData) { NotificationData n = notification.data; if (oldData != null && n != null && n.when == oldData.when && n.ongoingEvent == oldData.ongoingEvent && n.contentView != null && oldData.contentView != null && n.contentView.getPackage() != null && oldData.contentView.getPackage() != null && oldData.contentView.getPackage().equals(n.contentView.getPackage()) && oldData.contentView.getLayoutId() == n.contentView.getLayoutId() && notification.view != null) { mNotificationData.update(notification); try { n.contentView.reapply(this, notification.contentView); // update the contentIntent ViewGroup content = (ViewGroup)notification.view.findViewById( com.android.internal.R.id.content); PendingIntent contentIntent = n.contentIntent; if (contentIntent != null) { content.setOnClickListener(new Launcher(contentIntent, n.pkg, n.tag, n.id)); } } catch (RuntimeException e) { // It failed to add cleanly. Log, and remove the view from the panel. Slog.w(TAG, "couldn't reapply views for package " + n.contentView.getPackage(), e); removeNotificationView(notification); } } else { mNotificationData.update(notification); removeNotificationView(notification); addNotificationView(notification); } setAreThereNotifications(); void removeNotificationViews(IBinder key) { NotificationData.Entry entry = mOngoing.remove(key); if (entry == null) { entry = mLatest.remove(key); if (entry == null) { Slog.w(TAG, "removeNotification for unknown key: " + key); return; } void removeNotificationView(StatusBarNotification notification) { View v = notification.view; if (v != null) { ViewGroup parent = (ViewGroup)v.getParent(); parent.removeView(v); notification.view = null; } // Remove the expanded view. ((ViewGroup)entry.expanded.getParent()).removeView(entry.expanded); // Remove the icon. ((ViewGroup)entry.icon.getParent()).removeView(entry.icon); } */ private void setAreThereNotifications() { /* Loading @@ -593,6 +523,67 @@ public class PhoneStatusBarService extends StatusBarService { */ } /** * State is one or more of the DISABLE constants from StatusBarManager. */ public void disable(int state) { final int old = mDisabled; final int diff = state ^ old; mDisabled = state; if ((diff & StatusBarManager.DISABLE_EXPAND) != 0) { if ((state & StatusBarManager.DISABLE_EXPAND) != 0) { Slog.d(TAG, "DISABLE_EXPAND: yes"); animateCollapse(); } } if ((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { if ((state & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: yes"); if (mTicking) { mTicker.halt(); } else { setNotificationIconVisibility(false, com.android.internal.R.anim.fade_out); } } else { Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: no"); if (!mExpandedVisible) { setNotificationIconVisibility(true, com.android.internal.R.anim.fade_in); } } } else if ((diff & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { if (mTicking && (state & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { Slog.d(TAG, "DISABLE_NOTIFICATION_TICKER: yes"); mTicker.halt(); } } } /** * All changes to the status bar and notifications funnel through here and are batched. */ private class H extends Handler { public void handleMessage(Message m) { switch (m.what) { case MSG_ANIMATE: doAnimation(); break; case MSG_ANIMATE_REVEAL: doRevealAnimation(); break; } } } View.OnFocusChangeListener mFocusChangeListener = new View.OnFocusChangeListener() { public void onFocusChange(View v, boolean hasFocus) { // Because 'v' is a ViewGroup, all its children will be (un)selected // too, which allows marqueeing to work. v.setSelected(hasFocus); } }; private void makeExpandedVisible() { if (SPEW) Slog.d(TAG, "Make expanded visible: expanded visible=" + mExpandedVisible); if (mExpandedVisible) { Loading
tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java +1 −3 Original line number Diff line number Diff line Loading @@ -623,9 +623,7 @@ public class NotificationTestList extends TestActivity private PendingIntent makeIntent() { Intent intent = new Intent(Intent.ACTION_MAIN); intent.setComponent(new android.content.ComponentName( "com.android.contacts", "com.android.contacts.ContactsActivity")); intent.addCategory(Intent.CATEGORY_HOME); return PendingIntent.getActivity(this, 0, intent, 0); } Loading