Skip to content
This repository was archived by the owner on Dec 29, 2025. It is now read-only.

Commit 95287d3

Browse files
authored
Update LibsManager.java
1 parent b20fdc9 commit 95287d3

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

src/main/java/id.my.alvinq.prokitid.app/libs/LibsManager.java

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,14 @@ public static LibsManager get(Context ctx) {
2424
LibsManager lm = new LibsManager(ctx);
2525
return lm;
2626
}
27+
private static String getIsIis(File fl) {
28+
File file = new File(fl, "native");
29+
if(getNaviteLibsFromManifest(fl)) return file.getAbsolutePath();
30+
return null;
31+
}
2732
public void loadLib(File file) {
28-
DexClassLoader dcl = new DexClassLoader(file.getAbsolutePath(),this.cDir.getAbsolutePath(),null,this.context.getClassLoader());
33+
34+
DexClassLoader dcl = new DexClassLoader(file.getAbsolutePath(),this.cDir.getAbsolutePath(),getIsIis(file),this.context.getClassLoader());
2935
String className = getMainClassFromManifest(jarFile);
3036
if (className == null) {
3137
Logger.get().error("main class tidak ditemukan di manifest.json di jar: " + jarFile.getName());
@@ -44,6 +50,7 @@ public void loadLib(File file) {
4450
Logger.get().error("Error!: " + errorLog);
4551
}
4652
}
53+
/*
4754
public void unLoadLib(File file) {
4855
DexClassLoader dcl = new DexClassLoader(file.getAbsolutePath(),this.cDir.getAbsolutePath(),null,this.context.getClassLoader());
4956
String className = getMainClassFromManifest(jarFile);
@@ -64,6 +71,7 @@ public void unLoadLib(File file) {
6471
Logger.get().error("Error!: " + errorLog);
6572
}
6673
}
74+
*/
6775
private String getMainClassFromManifest(File jarFile) {
6876
try (JarFile jar = new JarFile(jarFile)) {
6977
JarEntry entry = jar.getJarEntry("manifest.json");
@@ -80,13 +88,38 @@ private String getMainClassFromManifest(File jarFile) {
8088
}
8189

8290
JSONObject json = new JSONObject(jsonBuilder.toString());
91+
if(!json.has("main") return null;
8392
return json.getString("main");
8493

8594
} catch (Exception e) {
8695
Logger.get().error("Error!: " + e.toString());
8796
}
8897
return null;
8998
}
99+
private Boolean getNaviteLibsFromManifest(File jarFile) {
100+
try (JarFile jar = new JarFile(jarFile)) {
101+
JarEntry entry = jar.getJarEntry("manifest.json");
102+
if (entry == null) return null;
103+
104+
InputStream input = jar.getInputStream(entry);
105+
StringBuilder jsonBuilder = new StringBuilder();
106+
107+
try (BufferedReader reader = new BufferedReader(new InputStreamReader(input))) {
108+
String line;
109+
while ((line = reader.readLine()) != null) {
110+
jsonBuilder.append(line);
111+
}
112+
}
113+
114+
JSONObject json = new JSONObject(jsonBuilder.toString());
115+
if(!json.has("native") return false;
116+
return json.getBoolean("native");
117+
118+
} catch (Exception e) {
119+
Logger.get().error("Error!: " + e.toString());
120+
}
121+
return null;
122+
}
90123
public static String getStackTraceAsString(Throwable th) {
91124
StringWriter sw = new StringWriter();
92125
PrintWriter pw = new PrintWriter(sw);

0 commit comments

Comments
 (0)