2222import android .app .Activity ;
2323import android .app .FragmentManager ;
2424import android .app .FragmentTransaction ;
25+ import android .app .NotificationChannel ;
2526import android .app .NotificationManager ;
2627import android .app .PendingIntent ;
2728import android .content .ClipData ;
@@ -113,7 +114,7 @@ public class MainActivity extends AppCompatActivity{
113114 static int aireplay_running = 0 , currentFragment = FRAGMENT_AIRODUMP ; //Set currentFragment in onResume of each Fragment
114115 //Filters
115116 static boolean show_ap = true , show_st = true , show_na_st = true , wpa = true , wep = true , opn = true ;
116- static boolean show_ch [] = {true , false , false , false , false , false , false , false , false , false , false , false , false , false , false };
117+ static boolean [] show_ch = {true , false , false , false , false , false , false , false , false , false , false , false , false , false , false };
117118 static int pwr_filter = 120 ;
118119 static String manuf_filter = "" ;
119120 //Airodump list sort
@@ -128,8 +129,8 @@ public class MainActivity extends AppCompatActivity{
128129 static DrawerLayout mDrawerLayout ;
129130 static NavigationView navigationView ;
130131 static SparseArray <String > navTitlesMap = new SparseArray <>(); //SparseArray to map fragment IDs to their respective navigation titles
131- static Drawable overflow [] = {null , null , null , null , null , null , null , null }; //Drawables to use for overflow button icon
132- static ImageView status [] = {null , null , null , null , null }; //Icons in TestDialog, set in TestDialog class
132+ static Drawable [] overflow = {null , null , null , null , null , null , null , null }; //Drawables to use for overflow button icon
133+ static ImageView [] status = {null , null , null , null , null }; //Icons in TestDialog, set in TestDialog class
133134 static int progress_int ;
134135 static long last_action ; //Timestamp for the last action. Used in watchdog to avoid false positives
135136 static Thread wpa_thread ;
@@ -175,16 +176,16 @@ protected void onCreate(Bundle savedInstanceState){
175176 @ Override
176177 public void uncaughtException (Thread thread , Throwable throwable ){
177178 throwable .printStackTrace ();
178- String stackTrace = "" ;
179- stackTrace += throwable .getMessage () + '\n' ;
179+ StringBuilder stackTrace = new StringBuilder () ;
180+ stackTrace . append ( throwable .getMessage ()). append ( '\n' ) ;
180181 for (int i =0 ;i <throwable .getStackTrace ().length ;i ++){
181- stackTrace += throwable .getStackTrace ()[i ].toString () + '\n' ;
182+ stackTrace . append ( throwable .getStackTrace ()[i ].toString ()). append ( '\n' ) ;
182183 }
183184
184185 Intent intent = new Intent ();
185186 intent .setAction ("com.hijacker.SendLogActivity" );
186187 intent .setFlags (Intent .FLAG_ACTIVITY_NEW_TASK );
187- intent .putExtra ("exception" , stackTrace );
188+ intent .putExtra ("exception" , stackTrace . toString () );
188189 startActivity (intent );
189190
190191 finish ();
@@ -381,7 +382,7 @@ protected Boolean doInBackground(Void... params){
381382 //cap directory was never changed so there may be files in /sdcard/cap/
382383 File old_dir = new File ("/sdcard/cap" );
383384 if (old_dir .exists () && old_dir .isDirectory ()){
384- File files [] = old_dir .listFiles ();
385+ File [] files = old_dir .listFiles ();
385386 if (files !=null ){
386387 Toast .makeText (MainActivity .this , "Moving cap files from " + old_dir .getAbsolutePath () + " to " + cap_path , Toast .LENGTH_LONG ).show ();
387388 for (File f : old_dir .listFiles ()){
@@ -395,15 +396,23 @@ protected Boolean doInBackground(Void... params){
395396
396397 //Initialize notifications
397398 publishProgress (getString (R .string .init_notifications ));
398- //Create intents
399+ //Create intents
399400 Intent cancel_intent = new Intent (MainActivity .this , DismissReceiver .class );
400401 Intent stop_intent = new Intent (MainActivity .this , StopReceiver .class );
401402 Intent notificationIntent = new Intent (MainActivity .this , MainActivity .class );
402403 notificationIntent .setFlags (Intent .FLAG_ACTIVITY_REORDER_TO_FRONT );
403404 PendingIntent click_intent = PendingIntent .getActivity (MainActivity .this , 0 , notificationIntent , 0 );
404405
405- //Create 'running' notification
406- notif = new NotificationCompat .Builder (MainActivity .this );
406+ // Get a channel ID
407+ String channelID ;
408+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .O ){
409+ channelID = NotificationChannel .DEFAULT_CHANNEL_ID ;
410+ }else {
411+ channelID = getString (R .string .DEFAULT_CHANNEL_ID );
412+ }
413+
414+ //Create 'running' notification
415+ notif = new NotificationCompat .Builder (MainActivity .this , channelID );
407416 notif .setContentTitle (getString (R .string .notification_title ));
408417 notif .setContentText (" " );
409418 notif .setSmallIcon (R .drawable .ic_notification );
@@ -414,17 +423,17 @@ protected Boolean doInBackground(Void... params){
414423 notif .addAction (R .drawable .stop_drawable , getString (R .string .stop_attacks ), PendingIntent .getBroadcast (MainActivity .this .getApplicationContext (), 0 , stop_intent , 0 ));
415424 notif .setContentIntent (click_intent );
416425
417- //Create 'error' notification (used by watchdog)
418- error_notif = new NotificationCompat .Builder (MainActivity .this );
426+ //Create 'error' notification (used by watchdog)
427+ error_notif = new NotificationCompat .Builder (MainActivity .this , channelID );
419428 error_notif .setSmallIcon (R .drawable .ic_notification );
420429 if (Build .VERSION .SDK_INT >=Build .VERSION_CODES .M ){
421430 error_notif .setColor (getColor (android .R .color .holo_red_dark ));
422431 }
423432 error_notif .setContentIntent (click_intent );
424433 error_notif .setVibrate (new long []{500 , 500 });
425434
426- //Create 'handshake captured' notification (used by wpa_thread)
427- handshake_notif = new NotificationCompat .Builder (MainActivity .this );
435+ //Create 'handshake captured' notification (used by wpa_thread)
436+ handshake_notif = new NotificationCompat .Builder (MainActivity .this , channelID );
428437 handshake_notif .setContentTitle (getString (R .string .handshake_captured ));
429438 if (Build .VERSION .SDK_INT >=Build .VERSION_CODES .M ){
430439 handshake_notif .setColor (getColor (android .R .color .holo_green_dark ));
@@ -1229,7 +1238,6 @@ public boolean onOptionsItemSelected(MenuItem item){
12291238 return super .onOptionsItemSelected (item );
12301239 }
12311240 }
1232- // See https://g.co/AppIndexing/AndroidStudio for more information.
12331241 @ Override
12341242 protected void onResume (){
12351243 super .onResume ();
@@ -1299,7 +1307,7 @@ public boolean onCreateOptionsMenu(Menu menu){
12991307 return true ;
13001308 }
13011309 @ Override
1302- public void onRequestPermissionsResult (int requestCode , @ NonNull String permissions [] , @ NonNull int [] grantResults ) {
1310+ public void onRequestPermissionsResult (int requestCode , @ NonNull String [] permissions , @ NonNull int [] grantResults ) {
13031311 if (requestCode ==0 ){
13041312 //The one and only request this app sends
13051313 if (grantResults .length > 0 && grantResults [2 ]==PackageManager .PERMISSION_GRANTED ) {
@@ -1595,9 +1603,9 @@ static String getFixed(String text, int size){
15951603 if (text .length () > size ){
15961604 text = text .substring (0 , size );
15971605 }
1598- String str = "" ;
1606+ StringBuilder str = new StringBuilder () ;
15991607 for (int i =0 ;i < size -text .length ();i ++){
1600- str += " " ;
1608+ str . append ( " " ) ;
16011609 }
16021610 return str + text ;
16031611 }
@@ -1608,7 +1616,7 @@ static int checkChroot(){
16081616 shell .run ("echo $PATH; echo ENDOFPATH" );
16091617 String path = getLastLine (shell .getShell_out (), "ENDOFPATH" );
16101618 shell .done ();
1611- String paths [] = path .split (":" );
1619+ String [] paths = path .split (":" );
16121620 for (String temp : paths ){
16131621 if (new RootFile (temp + "/bootkali_init" ).exists ()){
16141622 bin = true ;
0 commit comments