Loading core/java/android/service/notification/NotificationListenerService.java +2 −1 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.Icon; import android.os.BadParcelableException; import android.os.Build; import android.os.Bundle; import android.os.Handler; Loading Loading @@ -1056,7 +1057,7 @@ public abstract class NotificationListenerService extends Service { ParceledListSlice<StatusBarNotification> parceledList = getNotificationInterface() .getActiveNotificationsFromListener(mWrapper, keys, trim); return cleanUpNotificationList(parceledList); } catch (android.os.RemoteException ex) { } catch (android.os.RemoteException | BadParcelableException ex) { Log.v(TAG, "Unable to contact notification manager", ex); } return null; Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationListenerServiceTest.java +16 −0 Original line number Diff line number Diff line Loading @@ -44,8 +44,10 @@ import android.content.pm.ParceledListSlice; import android.content.pm.ShortcutInfo; import android.graphics.Bitmap; import android.graphics.drawable.Icon; import android.os.BadParcelableException; import android.os.Binder; import android.os.Build; import android.os.DeadObjectException; import android.os.IBinder; import android.os.RemoteException; import android.os.UserHandle; Loading Loading @@ -98,6 +100,20 @@ public class NotificationListenerServiceTest extends UiServiceTestCase { new String[0], NotificationListenerService.TRIM_LIGHT)); } @Test public void testGetActiveNotifications_handlesBinderErrors() throws RemoteException { TestListenerService service = new TestListenerService(); INotificationManager noMan = service.getNoMan(); when(noMan.getActiveNotificationsFromListener(any(), any(), anyInt())) .thenThrow(new BadParcelableException("oops", new DeadObjectException(""))); assertNotNull(service.getActiveNotifications()); assertNotNull(service.getActiveNotifications(NotificationListenerService.TRIM_FULL)); assertNotNull(service.getActiveNotifications(new String[0])); assertNull(service.getActiveNotifications( new String[0], NotificationListenerService.TRIM_LIGHT)); } @Test public void testGetActiveNotifications_preP_mapsExtraPeople() throws RemoteException { TestListenerService service = new TestListenerService(); Loading Loading
core/java/android/service/notification/NotificationListenerService.java +2 −1 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.Icon; import android.os.BadParcelableException; import android.os.Build; import android.os.Bundle; import android.os.Handler; Loading Loading @@ -1056,7 +1057,7 @@ public abstract class NotificationListenerService extends Service { ParceledListSlice<StatusBarNotification> parceledList = getNotificationInterface() .getActiveNotificationsFromListener(mWrapper, keys, trim); return cleanUpNotificationList(parceledList); } catch (android.os.RemoteException ex) { } catch (android.os.RemoteException | BadParcelableException ex) { Log.v(TAG, "Unable to contact notification manager", ex); } return null; Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationListenerServiceTest.java +16 −0 Original line number Diff line number Diff line Loading @@ -44,8 +44,10 @@ import android.content.pm.ParceledListSlice; import android.content.pm.ShortcutInfo; import android.graphics.Bitmap; import android.graphics.drawable.Icon; import android.os.BadParcelableException; import android.os.Binder; import android.os.Build; import android.os.DeadObjectException; import android.os.IBinder; import android.os.RemoteException; import android.os.UserHandle; Loading Loading @@ -98,6 +100,20 @@ public class NotificationListenerServiceTest extends UiServiceTestCase { new String[0], NotificationListenerService.TRIM_LIGHT)); } @Test public void testGetActiveNotifications_handlesBinderErrors() throws RemoteException { TestListenerService service = new TestListenerService(); INotificationManager noMan = service.getNoMan(); when(noMan.getActiveNotificationsFromListener(any(), any(), anyInt())) .thenThrow(new BadParcelableException("oops", new DeadObjectException(""))); assertNotNull(service.getActiveNotifications()); assertNotNull(service.getActiveNotifications(NotificationListenerService.TRIM_FULL)); assertNotNull(service.getActiveNotifications(new String[0])); assertNull(service.getActiveNotifications( new String[0], NotificationListenerService.TRIM_LIGHT)); } @Test public void testGetActiveNotifications_preP_mapsExtraPeople() throws RemoteException { TestListenerService service = new TestListenerService(); Loading