1+ package com .zalexdev .neternelsaddon ;
2+
3+ import androidx .appcompat .app .AppCompatActivity ;
4+ import androidx .recyclerview .widget .LinearLayoutManager ;
5+ import androidx .recyclerview .widget .RecyclerView ;
6+
7+ import android .os .Bundle ;
8+ import android .util .Log ;
9+ import android .view .View ;
10+ import android .widget .CheckBox ;
11+ import android .widget .CompoundButton ;
12+ import android .widget .TextView ;
13+
14+ import java .io .BufferedReader ;
15+ import java .io .IOException ;
16+ import java .io .InputStream ;
17+ import java .io .InputStreamReader ;
18+ import java .io .OutputStream ;
19+ import java .util .ArrayList ;
20+
21+ public class MainActivity extends AppCompatActivity {
22+
23+ @ Override
24+ protected void onCreate (Bundle savedInstanceState ) {
25+ super .onCreate (savedInstanceState );
26+ setContentView (R .layout .activity_main );
27+ RecyclerView recyclerView = findViewById (R .id .list );
28+ recyclerView .setLayoutManager (new LinearLayoutManager (this ));
29+ TextView loading = findViewById (R .id .loading );
30+ TextView driverListText = findViewById (R .id .driverList );
31+ CheckBox checkBox = findViewById (R .id .boot );
32+ checkBox .setChecked (new Prefs (this ).getBoolean ("boot" ));
33+ checkBox .setOnCheckedChangeListener ((buttonView , isChecked ) -> {
34+ Prefs prefs = new Prefs (MainActivity .this );
35+ prefs .putBoolean ("boot" , isChecked );
36+ });
37+ new Thread (() -> {
38+ ArrayList <String > pathList = customCommand ("ls /sys/bus/usb/drivers" );
39+ ArrayList <String > driverList = customCommand ("ls /system/lib/modules/" );
40+ ModulesAdapter adapter = new ModulesAdapter (MainActivity .this ,MainActivity .this ,driverList ,pathList );
41+ runOnUiThread (() -> {
42+ recyclerView .setAdapter (adapter );
43+ loading .setVisibility (View .INVISIBLE );
44+ driverListText .setText ("" );
45+ for (String s : pathList ){
46+ driverListText .append (s + "\n " );
47+ }
48+ });
49+ }).start ();
50+
51+ }
52+
53+ public static ArrayList <String > customCommand (String command ){
54+ ArrayList <String > result = new ArrayList <>();
55+ Process process = generateSuProcess ();
56+ try {
57+ OutputStream stdin = process .getOutputStream ();
58+ InputStream stderr = process .getErrorStream ();
59+ InputStream stdout = process .getInputStream ();
60+ stdin .write ((command + '\n' ).getBytes ());
61+ stdin .write (("exit\n " ).getBytes ());
62+ stdin .flush ();
63+ stdin .close ();
64+ BufferedReader br = new BufferedReader (new InputStreamReader (stdout ));
65+ String line ;
66+ while ((line = br .readLine ()) != null ) {
67+ Log .d ("OUTPUT" , line );
68+ result .add (line );}
69+ br .close ();
70+ BufferedReader br2 = new BufferedReader (new InputStreamReader (stderr ));
71+ String lineError ;
72+ while ((lineError = br2 .readLine ()) != null ) {
73+ Log .e ("ERROR" , lineError );
74+ result .add (lineError );}
75+ br2 .close ();
76+ } catch (IOException ignored ) {}
77+ process .destroy ();
78+ return result ;
79+ }
80+ public static Process generateSuProcess (){
81+ Process process = null ;
82+ try {
83+ process = Runtime .getRuntime ().exec ("su" );
84+ } catch (IOException e ) {
85+ e .printStackTrace ();
86+ try { process = Runtime .getRuntime ().exec ("echo noroot" );} catch (IOException ex ) {ex .printStackTrace ();}
87+ }
88+ return process ;
89+ }
90+ public static boolean contains (ArrayList <String > list , String item ){
91+ for (String s : list ){if (s .contains (item )){return true ;}}
92+ return false ;
93+ }
94+ }
0 commit comments