Loading core/java/android/service/notification/NotificationListenerService.java +26 −1 Original line number Original line Diff line number Diff line Loading @@ -27,6 +27,10 @@ import android.content.ComponentName; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.Intent; import android.content.pm.ParceledListSlice; import android.content.pm.ParceledListSlice; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.Icon; import android.graphics.Bitmap; import android.os.Bundle; import android.os.Bundle; import android.os.IBinder; import android.os.IBinder; import android.os.Parcel; import android.os.Parcel; Loading Loading @@ -636,6 +640,24 @@ public abstract class NotificationListenerService extends Service { } } } } /** Convert new-style Icons to legacy representations for pre-M clients. */ private void createLegacyIconExtras(Notification n) { Icon smallIcon = n.getSmallIcon(); Icon largeIcon = n.getLargeIcon(); if (smallIcon.getType() == Icon.TYPE_RESOURCE) { n.extras.putInt(Notification.EXTRA_SMALL_ICON, smallIcon.getResId()); n.icon = smallIcon.getResId(); } if (largeIcon != null) { Drawable d = largeIcon.loadDrawable(getContext()); if (d != null && d instanceof BitmapDrawable) { final Bitmap largeIconBits = ((BitmapDrawable) d).getBitmap(); n.extras.putParcelable(Notification.EXTRA_LARGE_ICON, largeIconBits); n.largeIcon = largeIconBits; } } } private class INotificationListenerWrapper extends INotificationListener.Stub { private class INotificationListenerWrapper extends INotificationListener.Stub { @Override @Override public void onNotificationPosted(IStatusBarNotificationHolder sbnHolder, public void onNotificationPosted(IStatusBarNotificationHolder sbnHolder, Loading @@ -649,6 +671,9 @@ public abstract class NotificationListenerService extends Service { } } Notification.Builder.rebuild(getContext(), sbn.getNotification()); Notification.Builder.rebuild(getContext(), sbn.getNotification()); // convert icon metadata to legacy format for older clients createLegacyIconExtras(sbn.getNotification()); // protect subclass from concurrent modifications of (@link mNotificationKeys}. // protect subclass from concurrent modifications of (@link mNotificationKeys}. synchronized (mWrapper) { synchronized (mWrapper) { applyUpdate(update); applyUpdate(update); Loading Loading
core/java/android/service/notification/NotificationListenerService.java +26 −1 Original line number Original line Diff line number Diff line Loading @@ -27,6 +27,10 @@ import android.content.ComponentName; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.Intent; import android.content.pm.ParceledListSlice; import android.content.pm.ParceledListSlice; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.Icon; import android.graphics.Bitmap; import android.os.Bundle; import android.os.Bundle; import android.os.IBinder; import android.os.IBinder; import android.os.Parcel; import android.os.Parcel; Loading Loading @@ -636,6 +640,24 @@ public abstract class NotificationListenerService extends Service { } } } } /** Convert new-style Icons to legacy representations for pre-M clients. */ private void createLegacyIconExtras(Notification n) { Icon smallIcon = n.getSmallIcon(); Icon largeIcon = n.getLargeIcon(); if (smallIcon.getType() == Icon.TYPE_RESOURCE) { n.extras.putInt(Notification.EXTRA_SMALL_ICON, smallIcon.getResId()); n.icon = smallIcon.getResId(); } if (largeIcon != null) { Drawable d = largeIcon.loadDrawable(getContext()); if (d != null && d instanceof BitmapDrawable) { final Bitmap largeIconBits = ((BitmapDrawable) d).getBitmap(); n.extras.putParcelable(Notification.EXTRA_LARGE_ICON, largeIconBits); n.largeIcon = largeIconBits; } } } private class INotificationListenerWrapper extends INotificationListener.Stub { private class INotificationListenerWrapper extends INotificationListener.Stub { @Override @Override public void onNotificationPosted(IStatusBarNotificationHolder sbnHolder, public void onNotificationPosted(IStatusBarNotificationHolder sbnHolder, Loading @@ -649,6 +671,9 @@ public abstract class NotificationListenerService extends Service { } } Notification.Builder.rebuild(getContext(), sbn.getNotification()); Notification.Builder.rebuild(getContext(), sbn.getNotification()); // convert icon metadata to legacy format for older clients createLegacyIconExtras(sbn.getNotification()); // protect subclass from concurrent modifications of (@link mNotificationKeys}. // protect subclass from concurrent modifications of (@link mNotificationKeys}. synchronized (mWrapper) { synchronized (mWrapper) { applyUpdate(update); applyUpdate(update); Loading