Skip to content

Commit bcf9e20

Browse files
authored
1.0R
1 parent 8ce34d2 commit bcf9e20

42 files changed

Lines changed: 1223 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/build.gradle

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
plugins {
2+
id 'com.android.application'
3+
}
4+
5+
android {
6+
compileSdk 32
7+
8+
defaultConfig {
9+
applicationId "com.zalexdev.neternelsaddon"
10+
minSdk 22
11+
targetSdk 32
12+
versionCode 1
13+
versionName "1.0"
14+
15+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16+
}
17+
18+
buildTypes {
19+
release {
20+
minifyEnabled true
21+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
22+
}
23+
}
24+
compileOptions {
25+
sourceCompatibility JavaVersion.VERSION_1_8
26+
targetCompatibility JavaVersion.VERSION_1_8
27+
}
28+
}
29+
30+
dependencies {
31+
32+
implementation 'androidx.appcompat:appcompat:1.5.1'
33+
implementation 'com.google.android.material:material:1.6.1'
34+
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
35+
36+
}

app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile

app/src/main/AndroidManifest.xml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
package="com.zalexdev.neternelsaddon">
5+
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
6+
<application
7+
android:allowBackup="true"
8+
android:icon="@mipmap/ic_launcher"
9+
android:label="@string/app_name"
10+
android:roundIcon="@mipmap/ic_launcher"
11+
android:supportsRtl="true"
12+
android:theme="@style/Theme.NetErnelsAddon"
13+
tools:targetApi="31">
14+
<activity
15+
android:name=".MainActivity"
16+
android:exported="true">
17+
<intent-filter>
18+
<action android:name="android.intent.action.MAIN" />
19+
20+
<category android:name="android.intent.category.LAUNCHER" />
21+
</intent-filter>
22+
</activity>
23+
<meta-data
24+
android:name="preloaded_fonts"
25+
android:resource="@array/preloaded_fonts" />
26+
<receiver android:name=".BootReceiver"
27+
android:permission="android.permission.RECEIVE_BOOT_COMPLETED"
28+
android:enabled="true"
29+
android:exported="true">
30+
<intent-filter android:priority="999">
31+
<action android:name="android.intent.action.BOOT_COMPLETED" />
32+
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
33+
34+
</intent-filter>
35+
</receiver>
36+
</application>
37+
38+
</manifest>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package com.zalexdev.neternelsaddon;
2+
3+
import static com.zalexdev.neternelsaddon.MainActivity.contains;
4+
import static com.zalexdev.neternelsaddon.MainActivity.customCommand;
5+
6+
import android.app.NotificationChannel;
7+
import android.app.NotificationManager;
8+
import android.app.PendingIntent;
9+
import android.content.BroadcastReceiver;
10+
import android.content.Context;
11+
import android.content.Intent;
12+
import android.os.Build;
13+
import android.util.Log;
14+
import android.widget.Toast;
15+
16+
import androidx.core.app.NotificationCompat;
17+
import androidx.core.app.NotificationManagerCompat;
18+
19+
import java.util.ArrayList;
20+
21+
public class BootReceiver extends BroadcastReceiver {
22+
23+
@Override
24+
public void onReceive(Context context, Intent intent) {
25+
26+
Log.e("BootReceiver", "onReceive: Boot completed");
27+
Prefs prefs = new Prefs(context);
28+
if (prefs.getBoolean("boot")) {
29+
int loaded = 0;
30+
for (String module : prefs.getModules()) {
31+
customCommand("insmod /system/lib/modules/"+module);
32+
ArrayList<String> driverList = customCommand("ls /sys/bus/usb/drivers");
33+
if (contains(driverList, module.replace(".ko", ""))){
34+
loaded++;
35+
}
36+
}
37+
NotificationCompat.Builder builder = new NotificationCompat.Builder(context,"NE")
38+
.setSmallIcon(R.mipmap.ic_launcher)
39+
.setContentTitle("Modules booted")
40+
.setContentText("Loaded "+loaded+" modules, "+(prefs.getModules().size()-loaded)+" failed")
41+
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
42+
.setAutoCancel(true);
43+
44+
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
45+
createNotificationChannel(context);
46+
notificationManager.notify(12, builder.build());
47+
}
48+
49+
50+
51+
52+
53+
54+
55+
}
56+
private void createNotificationChannel(Context context) {
57+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
58+
CharSequence name = "NetErnels Addon";
59+
String description = "Driver status notification..";
60+
int importance = NotificationManager.IMPORTANCE_DEFAULT;
61+
NotificationChannel channel = new NotificationChannel("NE", name, importance);
62+
channel.setDescription(description);
63+
NotificationManager notificationManager = context.getSystemService(NotificationManager.class);
64+
notificationManager.createNotificationChannel(channel);
65+
}
66+
}
67+
}
68+
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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

Comments
 (0)