@@ -39,17 +39,19 @@ public class ParsedNotification {
3939 private final String appName ;
4040 private final String title ;
4141 private final String text ;
42+ private final String packageName ;
4243 private final byte [] icon ;
4344
44- public ParsedNotification (String appName , String title , String text , byte [] icon ) {
45+ public ParsedNotification (String appName , String title , String text , String packageName , byte [] icon ) {
4546 this .appName = appName ;
4647 this .title = title ;
4748 this .text = text ;
4849 this .icon = icon ;
50+ this .packageName = packageName ;
4951 }
5052
51- public ParsedNotification (String appName , String title , String text ) {
52- this (appName , title , text , null );
53+ public ParsedNotification (String appName , String title , String text , String packageName ) {
54+ this (appName , title , text , packageName , null );
5355 }
5456
5557 public static Optional <ParsedNotification > parseNotification (StatusBarNotification statusBarNotification , Context context ) {
@@ -62,7 +64,8 @@ public static Optional<ParsedNotification> parseNotification(StatusBarNotificati
6264 return Optional .empty ();
6365 }
6466
65- String appName = Util .getAppName (context .getPackageManager (), statusBarNotification .getPackageName ()).orElse ("" );
67+ String packageName = statusBarNotification .getPackageName ();
68+ String appName = Util .getAppName (context .getPackageManager (), packageName ).orElse ("" );
6669
6770 Icon largeIcon = notification .getLargeIcon ();
6871
@@ -73,14 +76,14 @@ public static Optional<ParsedNotification> parseNotification(StatusBarNotificati
7376 if (drawable instanceof BitmapDrawable ) {
7477 ((BitmapDrawable ) drawable ).getBitmap ().compress (Bitmap .CompressFormat .PNG , 100 , byteArrayOutputStream );
7578
76- return Optional .of (new ParsedNotification (appName , title , text , byteArrayOutputStream .toByteArray ()));
79+ return Optional .of (new ParsedNotification (appName , title , text , packageName , byteArrayOutputStream .toByteArray ()));
7780 }
7881 } catch (IOException exception ) {
7982 Log .e (TAG , "Failed to convert picture to bytes" , exception );
8083 }
8184 }
8285
83- return Optional .of (new ParsedNotification (appName , title , text ));
86+ return Optional .of (new ParsedNotification (appName , title , text , packageName ));
8487 }
8588
8689 public String getAppName () {
@@ -95,6 +98,10 @@ public String getText() {
9598 return text ;
9699 }
97100
101+ public String getPackageName () {
102+ return packageName ;
103+ }
104+
98105 public Optional <byte []> getIcon () {
99106 return Optional .ofNullable (icon );
100107 }
0 commit comments