Skip to content

Commit dbb8cf3

Browse files
committed
update code
1 parent 5db244f commit dbb8cf3

72 files changed

Lines changed: 3861 additions & 3323 deletions

File tree

Some content is hidden

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

app/src/main/java/com/aexon/ActivasiActivity.java

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
1+
/*
2+
* Copyright (c) 2026 Fora
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
*
17+
* Contact: Fora <fora060823@gmail.com>
18+
* Created: 27-01-2026
19+
*/
120
package com.aexon;
221

322
import android.app.Activity;
423
import android.content.Intent;
524
import android.graphics.PorterDuff;
625
import android.net.Uri;
26+
import android.os.Build;
727
import android.os.Bundle;
828
import android.text.Html;
929
import android.text.method.LinkMovementMethod;
@@ -12,16 +32,19 @@
1232
import android.widget.ScrollView;
1333
import android.widget.TextView;
1434

35+
import androidx.annotation.NonNull;
1536
import androidx.annotation.Nullable;
37+
import androidx.annotation.RequiresApi;
1638

1739
import com.aexon.aexon.AexonWindowHelper;
1840
import com.aexon.material.dialog.AexonAlertDialog;
19-
import com.aexon.material.toasty.AexonToast;
41+
import com.aexon.aexon.dialog.PathDialogFragment;
2042
import com.aexon.starter.AexonShizukuHelper;
2143
import com.aexon.starter.AexonStarter;
2244
import com.aexon.theme.AexonTheme;
2345
import com.aexon.widget.AexonCompatButton;
2446

47+
@RequiresApi(api = Build.VERSION_CODES.O)
2548
public class ActivasiActivity extends Activity {
2649

2750
private final Aexon.OnBinderReceivedListener activasiBinderReceived = () -> {
@@ -57,7 +80,7 @@ public class ActivasiActivity extends Activity {
5780
private ImageView imageview4;
5881
private TextView textview6;
5982

60-
private Intent aexon_intent = new Intent();
83+
private final Intent aexon_intent = new Intent();
6184

6285
@Override
6386
protected void onCreate(@Nullable Bundle _savedInstanceState) {
@@ -112,7 +135,7 @@ private void initialize(@Nullable Bundle _savedInstanceState) {
112135
}
113136

114137
if (!shizuku.isShizukuRunning()) {
115-
AexonToast.make(ActivasiActivity.this).title(getString(R.string.tag_not_running)).message(getString(R.string.tag_shizuku_dec_toasty)).show();
138+
SketchwareUtil.showMessage(ActivasiActivity.this, getString(R.string.tag_not_running));
116139
return;
117140
}
118141

@@ -121,7 +144,7 @@ private void initialize(@Nullable Bundle _savedInstanceState) {
121144
return;
122145
}
123146

124-
AexonToast.make(ActivasiActivity.this).title(getString(R.string.tag_shizuku_running)).message(getString(R.string.tag_shizuku_running_dec)).show();
147+
SketchwareUtil.showMessage(ActivasiActivity.this, getString(R.string.tag_shizuku_running));
125148
});
126149

127150
start_shizuku.setOnClickListener(_v -> {
@@ -155,14 +178,14 @@ private void initialize(@Nullable Bundle _savedInstanceState) {
155178
});
156179

157180
view_cmd.setOnClickListener(_v -> {
158-
InfoDialogPathDialogFragmentActivity bottomSheet = new InfoDialogPathDialogFragmentActivity();
181+
PathDialogFragment bottomSheet = new PathDialogFragment();
159182
bottomSheet.show(getFragmentManager(), "InfoDialog");
160183
});
161184

162185
start_root.setOnClickListener(_v -> {
163186
AexonShizukuHelper.isRooted(rooted -> {
164187
if (!rooted) {
165-
AexonToast.make(ActivasiActivity.this).title(getString(R.string.tag_root_not_support)).message(getString(R.string.tag_root_not_support_dec)).show();
188+
SketchwareUtil.showMessage(ActivasiActivity.this, getString(R.string.tag_root_not_support));
166189
return;
167190
}
168191
AexonStarter.newInstance(AexonStarter.MODE_ROOT, null).show(getFragmentManager(), "loading");
@@ -205,19 +228,19 @@ private void initializeLogic() {
205228
start_shizuku.setButtonBackgroundColor(theme.getColorPrimary());
206229
view_cmd.setButtonBackgroundColor(theme.getColorPrimary());
207230
start_root.setButtonBackgroundColor(theme.getColorPrimary());
208-
231+
209232
AexonWindowHelper.setWindowStyle(getWindow(), theme.getColorSurface());
210-
233+
211234
start_root.setTextColor(theme.getColorOnPrimary());
212235
view_cmd.setTextColor(theme.getColorOnPrimary());
213236
connect_shizuku.setTextColor(theme.getColorOnPrimary());
214237
start_shizuku.setTextColor(theme.getColorOnPrimary());
215238

216-
start_root.setButtonRippleColor(theme.getColorOnPrimaryDark());
217-
view_cmd.setButtonRippleColor(theme.getColorOnPrimaryDark());
218-
connect_shizuku.setButtonRippleColor(theme.getColorOnPrimaryDark());
219-
start_shizuku.setButtonRippleColor(theme.getColorOnPrimaryDark());
220-
239+
start_root.setButtonRippleColor(theme.getColorOnPrimaryDark());
240+
view_cmd.setButtonRippleColor(theme.getColorOnPrimaryDark());
241+
connect_shizuku.setButtonRippleColor(theme.getColorOnPrimaryDark());
242+
start_shizuku.setButtonRippleColor(theme.getColorOnPrimaryDark());
243+
221244
textview1.setTextColor(theme.getColorOnSurface());
222245
textview2.setTextColor(theme.getColorOnSurface());
223246
textview3.setTextColor(theme.getColorOnSurfaceVariant());

app/src/main/java/com/aexon/Aexon.java

Lines changed: 54 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,43 @@
1+
/*
2+
* Copyright (c) 2026 Fora
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
*
17+
* Contact: Fora <fora060823@gmail.com>
18+
* Created: 27-01-2026
19+
*/
120
package com.aexon;
221

322
import android.content.Context;
423
import android.os.Build;
524
import android.os.Handler;
625
import android.os.Looper;
726
import android.os.StrictMode;
27+
28+
import androidx.annotation.NonNull;
29+
import androidx.annotation.Nullable;
30+
import androidx.annotation.RequiresApi;
31+
832
import java.io.BufferedReader;
933
import java.io.InputStreamReader;
1034
import java.io.OutputStream;
1135
import java.net.Socket;
36+
import java.nio.charset.StandardCharsets;
1237
import java.util.List;
1338
import java.util.concurrent.CopyOnWriteArrayList;
1439

15-
import com.aexon.annotation.NonNull;
16-
import com.aexon.annotation.Nullable;
17-
40+
@RequiresApi(api = Build.VERSION_CODES.O)
1841
public class Aexon {
1942

2043
private static final String HOST = "127.0.0.1";
@@ -25,9 +48,9 @@ public class Aexon {
2548
private static final byte[] STARTER_PID_FILE_ENC = {0x75, 0x3E, 0x3B, 0x2E, 0x3B, 0x75, 0x36, 0x35, 0x39, 0x3B, 0x36, 0x75, 0x2E, 0x37, 0x2A, 0x75, 0x74, 0x3B, 0x22, 0x05, 0x29, 0x2E, 0x3B, 0x28, 0x2E, 0x3F, 0x28};
2649
private static final Handler mainHandler = new Handler(Looper.getMainLooper());
2750

28-
private @NonNull String[] command;
29-
private @Nullable String[] env;
30-
private @Nullable String dir;
51+
private final @NonNull String[] command;
52+
private final @Nullable String[] env;
53+
private final @Nullable String dir;
3154

3255
private static final List<OnBinderReceivedListener> binderReceivedListeners = new CopyOnWriteArrayList<>();
3356
private static final List<OnBinderDeadListener> binderDeadListeners = new CopyOnWriteArrayList<>();
@@ -59,11 +82,7 @@ private Aexon(@NonNull String[] command, @Nullable String[] env, @Nullable Strin
5982
for (int i = 0; i < enc.length; i++) {
6083
out[i] = (byte) (enc[i] ^ AX_KEY);
6184
}
62-
try {
63-
return new String(out, "UTF-8");
64-
} catch (Exception e) {
65-
return "";
66-
}
85+
return new String(out, StandardCharsets.UTF_8);
6786
}
6887

6988
private static void allowNetwork() {
@@ -77,8 +96,12 @@ private static void allowNetwork() {
7796
public void exec() {
7897
new Thread(() -> {
7998
StringBuilder cmd = new StringBuilder();
80-
if (env != null) for (String e : env) cmd.append(e).append(" ");
81-
if (dir != null) cmd.append("cd ").append(dir).append(" && ");
99+
if (env != null) {
100+
for (String e : env) cmd.append(e).append(" ");
101+
}
102+
if (dir != null) {
103+
cmd.append("cd ").append(dir).append(" && ");
104+
}
82105
for (int i = 0; i < command.length; i++) {
83106
cmd.append(command[i]);
84107
if (i < command.length - 1) cmd.append(" ");
@@ -89,8 +112,12 @@ public void exec() {
89112

90113
public @NonNull AexonProcess execResult() {
91114
StringBuilder cmd = new StringBuilder();
92-
if (env != null) for (String e : env) cmd.append(e).append(" ");
93-
if (dir != null) cmd.append("cd ").append(dir).append(" && ");
115+
if (env != null) {
116+
for (String e : env) cmd.append(e).append(" ");
117+
}
118+
if (dir != null) {
119+
cmd.append("cd ").append(dir).append(" && ");
120+
}
94121
for (int i = 0; i < command.length; i++) {
95122
cmd.append(command[i]);
96123
if (i < command.length - 1) cmd.append(" ");
@@ -100,21 +127,19 @@ public void exec() {
100127

101128
private static @NonNull String sendCommand(@NonNull String command) {
102129
allowNetwork();
103-
try {
104-
Socket socket = new Socket(HOST, PORT);
130+
try (Socket socket = new Socket(HOST, PORT)) {
105131
socket.setSoTimeout(5000);
106132
OutputStream out = socket.getOutputStream();
107-
out.write((axDecode(AUTH_TOKEN_ENC) + "\n").getBytes("UTF-8"));
133+
out.write((axDecode(AUTH_TOKEN_ENC) + "\n").getBytes(StandardCharsets.UTF_8));
108134
out.flush();
109-
out.write((command + "\n").getBytes("UTF-8"));
135+
out.write((command + "\n").getBytes(StandardCharsets.UTF_8));
110136
out.flush();
111-
BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), "UTF-8"));
137+
BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8));
112138
StringBuilder result = new StringBuilder();
113139
String line;
114140
while ((line = reader.readLine()) != null) {
115141
result.append(line).append("\n");
116142
}
117-
socket.close();
118143
return result.toString().trim();
119144
} catch (Exception e) {
120145
return "Error: " + e.getMessage();
@@ -123,15 +148,13 @@ public void exec() {
123148

124149
public static boolean isBinder() {
125150
allowNetwork();
126-
try {
127-
Socket socket = new Socket(HOST, PORT);
151+
try (Socket socket = new Socket(HOST, PORT)) {
128152
socket.setSoTimeout(500);
129153
OutputStream out = socket.getOutputStream();
130-
out.write((axDecode(AUTH_TOKEN_ENC) + "\n").getBytes("UTF-8"));
154+
out.write((axDecode(AUTH_TOKEN_ENC) + "\n").getBytes(StandardCharsets.UTF_8));
131155
out.flush();
132-
out.write(("echo ok\n").getBytes("UTF-8"));
156+
out.write(("echo ok\n").getBytes(StandardCharsets.UTF_8));
133157
out.flush();
134-
socket.close();
135158
return true;
136159
} catch (Exception e) {
137160
return false;
@@ -149,24 +172,22 @@ public static void stopDaemonPermanently() {
149172
public static void execStream(@NonNull String command, @NonNull OnProcessOutputListener callback) {
150173
new Thread(() -> {
151174
allowNetwork();
152-
try {
153-
Socket socket = new Socket(HOST, PORT);
175+
try (Socket socket = new Socket(HOST, PORT)) {
154176
socket.setSoTimeout(0);
155177
OutputStream out = socket.getOutputStream();
156-
out.write((axDecode(AUTH_TOKEN_ENC) + "\n").getBytes("UTF-8"));
178+
out.write((axDecode(AUTH_TOKEN_ENC) + "\n").getBytes(StandardCharsets.UTF_8));
157179
out.flush();
158-
out.write(("@@EXEC:" + command + "\n").getBytes("UTF-8"));
180+
out.write(("@@EXEC:" + command + "\n").getBytes(StandardCharsets.UTF_8));
159181
out.flush();
160182

161-
BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), "UTF-8"));
183+
BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8));
162184

163185
String pidLine = reader.readLine();
164186
long pid = -1;
165187
if (pidLine != null && pidLine.startsWith("@@PID:")) {
166188
try {
167189
pid = Long.parseLong(pidLine.substring(6).trim());
168190
} catch (Exception ignored) {
169-
170191
}
171192
}
172193
final long finalPid = pid;
@@ -179,14 +200,12 @@ public static void execStream(@NonNull String command, @NonNull OnProcessOutputL
179200
try {
180201
exitCode = Integer.parseInt(line.substring(7).trim());
181202
} catch (Exception ignored) {
182-
183203
}
184204
break;
185205
}
186206
final String outLine = line;
187207
mainHandler.post(() -> callback.onOutput(outLine));
188208
}
189-
socket.close();
190209
final int finalExit = exitCode;
191210
mainHandler.post(() -> callback.onExit(finalExit));
192211
} catch (Exception e) {
@@ -229,7 +248,6 @@ public static void addBinderReceivedListener(@NonNull OnBinderReceivedListener l
229248
try {
230249
Thread.sleep(500);
231250
} catch (Exception ignored) {
232-
233251
}
234252
}
235253
}).start();
@@ -254,10 +272,9 @@ private static void startMonitoring() {
254272
new Thread(() -> {
255273
boolean wasRunning = isBinder();
256274
while (true) {
257-
try {
275+
try {
258276
Thread.sleep(500);
259277
} catch (Exception ignored) {
260-
261278
}
262279
boolean isRunning = isBinder();
263280
if (wasRunning && !isRunning) {

app/src/main/java/com/aexon/AexonApplication.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ private void handleUncaughtException(@NonNull Thread thread, @NonNull Throwable
4848
startActivity(intent);
4949
} catch (Exception ignored) {
5050
}
51+
SketchLogger.broadcastLog(Log.getStackTraceString(throwable));
5152
Process.killProcess(Process.myPid());
5253
System.exit(1);
5354
}

app/src/main/java/com/aexon/AexonBuild.java

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,34 @@
1+
/*
2+
* Copyright (c) 2026 Fora
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
*
17+
* Contact: Fora <fora060823@gmail.com>
18+
* Created: 27-01-2026
19+
*/
120
package com.aexon;
221

322
import android.content.Context;
423
import android.content.pm.PackageInfo;
524
import android.content.pm.PackageManager;
625
import android.os.Build;
726

8-
import com.aexon.annotation.NonNull;
9-
import com.aexon.annotation.Nullable;
10-
import com.aexon.core.AexonApi;
27+
import androidx.annotation.NonNull;
28+
import androidx.annotation.Nullable;
29+
import androidx.annotation.RequiresApi;
1130

31+
@RequiresApi(api = Build.VERSION_CODES.O)
1232
public class AexonBuild {
1333

1434
@NonNull
@@ -30,10 +50,15 @@ public static String getVersionName(@NonNull Context ctx) {
3050
}
3151
}
3252

53+
@SuppressWarnings("deprecation")
3354
public static long getVersionCode(@NonNull Context ctx) {
3455
try {
3556
PackageInfo pi = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0);
36-
return AexonApi.minSdk(Build.VERSION_CODES.P) ? pi.getLongVersionCode() : pi.versionCode;
57+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
58+
return pi.getLongVersionCode();
59+
} else {
60+
return pi.versionCode;
61+
}
3762
} catch (PackageManager.NameNotFoundException e) {
3863
return -1;
3964
}

0 commit comments

Comments
 (0)