2424import android .content .pm .PackageInfo ;
2525import android .content .pm .PackageManager ;
2626import android .content .pm .PackageManager .NameNotFoundException ;
27+ import android .support .v4 .app .NotificationCompat ;
2728import android .util .Log ;
2829
2930import com .noshufou .android .su .util .Util ;
@@ -48,17 +49,19 @@ public void onReceive(Context context, Intent intent) {
4849 if (Util .isPackageMalicious (context , packageInfo ) != 0 ) {
4950 NotificationManager nm =
5051 (NotificationManager ) context .getSystemService (Context .NOTIFICATION_SERVICE );
51- Notification notification = new Notification (R .drawable .stat_su ,
52- context .getString (R .string .malicious_app_notification_ticker ),
53- System .currentTimeMillis ());
54- CharSequence contentTitle = context .getString (R .string .app_name );
55- CharSequence contentText = context .getString (R .string .malicious_app_notification_text ,
56- pm .getApplicationLabel (packageInfo .applicationInfo ));
5752 Intent notificationIntent = new Intent (Intent .ACTION_DELETE , intent .getData ());
5853 PendingIntent contentIntent =
5954 PendingIntent .getActivity (context , 0 , notificationIntent , 0 );
60- notification .setLatestEventInfo (context , contentTitle , contentText , contentIntent );
61- notification .flags |= Notification .FLAG_AUTO_CANCEL ;
55+ Notification notification = new NotificationCompat .Builder (context )
56+ .setSmallIcon (R .drawable .stat_su )
57+ .setTicker (context .getText (R .string .malicious_app_notification_ticker ))
58+ .setWhen (System .currentTimeMillis ())
59+ .setContentTitle (context .getText (R .string .app_name ))
60+ .setContentText (context .getString (R .string .malicious_app_notification_text ,
61+ pm .getApplicationLabel (packageInfo .applicationInfo )))
62+ .setContentIntent (contentIntent )
63+ .setAutoCancel (true )
64+ .getNotification ();
6265 nm .notify (0 , notification );
6366 }
6467 }
0 commit comments