11package com .tungsten .hmclpe .launcher .setting ;
22
3+ import static net .kdt .pojavlaunch .utils .Architecture .ARCH_ARM ;
4+ import static net .kdt .pojavlaunch .utils .Architecture .ARCH_ARM64 ;
5+ import static net .kdt .pojavlaunch .utils .Architecture .ARCH_X86 ;
6+ import static net .kdt .pojavlaunch .utils .Architecture .ARCH_X86_64 ;
37import static org .apache .commons .io .FileUtils .listFiles ;
48
59import android .annotation .SuppressLint ;
10+ import android .content .Context ;
611import android .content .Intent ;
712import android .os .Bundle ;
813import android .util .Log ;
1621import com .tungsten .hmclpe .utils .file .FileStringUtils ;
1722import com .tungsten .hmclpe .utils .file .FileUtils ;
1823
24+ import org .apache .commons .io .IOUtils ;
25+
1926import java .io .File ;
27+ import java .io .FileInputStream ;
28+ import java .io .FileOutputStream ;
2029import java .io .IOException ;
2130import java .util .Collection ;
2231import java .util .Objects ;
@@ -121,6 +130,11 @@ public static void checkJava8(SplashActivity activity, AssetsUtils.ProgressCallb
121130 AssetsUtils .getInstance (activity ).setProgressCallback (callback ).copyOnMainThread ("app_runtime/java/8-x86_64" ,AppManifest .JAVA_DIR + "/default" );
122131 }
123132 unpack200 (activity .getApplicationContext ().getApplicationInfo ().nativeLibraryDir , AppManifest .JAVA_DIR + "/default" );
133+ try {
134+ postPrepare (activity , "default" );
135+ } catch (IOException e ) {
136+ e .printStackTrace ();
137+ }
124138 }
125139 }
126140
@@ -145,6 +159,11 @@ public static void checkJava17(SplashActivity activity, AssetsUtils.ProgressCall
145159 AssetsUtils .getInstance (activity ).setProgressCallback (callback ).copyOnMainThread ("app_runtime/java/17-x86_64" ,AppManifest .JAVA_DIR + "/JRE17" );
146160 }
147161 unpack200 (activity .getApplicationContext ().getApplicationInfo ().nativeLibraryDir , AppManifest .JAVA_DIR + "/JRE17" );
162+ try {
163+ postPrepare (activity , "default" );
164+ } catch (IOException e ) {
165+ e .printStackTrace ();
166+ }
148167 }
149168 }
150169
@@ -171,6 +190,44 @@ private static void unpack200(String nativeLibraryDir, String runtimePath) {
171190 }
172191 }
173192
193+ public static void postPrepare (Context context , String name ) throws IOException {
194+ File dest = new File (AppManifest .JAVA_DIR ,"/" + name );
195+ if (!dest .exists ()) return ;
196+ String libFolder = "lib" ;
197+ String arch = "" ;
198+ if (net .kdt .pojavlaunch .utils .Architecture .getDeviceArchitecture () == ARCH_ARM ) {
199+ arch = "aarch32" ;
200+ }
201+ if (net .kdt .pojavlaunch .utils .Architecture .getDeviceArchitecture () == ARCH_ARM64 ) {
202+ arch = "aarch64" ;
203+ }
204+ if (net .kdt .pojavlaunch .utils .Architecture .getDeviceArchitecture () == ARCH_X86 ) {
205+ arch = "i386" ;
206+ }
207+ if (net .kdt .pojavlaunch .utils .Architecture .getDeviceArchitecture () == ARCH_X86_64 ) {
208+ arch = "amd64" ;
209+ }
210+ if (new File (dest ,libFolder + "/" + arch ).exists ()) libFolder = libFolder + "/" + arch ;
211+ File ftIn = new File (dest , libFolder + "/libfreetype.so.6" );
212+ File ftOut = new File (dest , libFolder + "/libfreetype.so" );
213+ if (ftIn .exists () && (!ftOut .exists () || ftIn .length () != ftOut .length ())) {
214+ ftIn .renameTo (ftOut );
215+ }
216+
217+ // Refresh libraries
218+ copyDummyNativeLib (context ,"libawt_xawt.so" , dest , libFolder );
219+ }
220+
221+ private static void copyDummyNativeLib (Context ctx , String name , File dest , String libFolder ) throws IOException {
222+ File fileLib = new File (dest , "/" +libFolder + "/" + name );
223+ fileLib .delete ();
224+ FileInputStream is = new FileInputStream (new File (ctx .getApplicationInfo ().nativeLibraryDir , name ));
225+ FileOutputStream os = new FileOutputStream (fileLib );
226+ IOUtils .copy (is , os );
227+ is .close ();
228+ os .close ();
229+ }
230+
174231 @ SuppressLint ("SetTextI18n" )
175232 public static void enterLauncher (SplashActivity activity ) {
176233 activity .loadingText .setText (activity .getString (R .string .loading_hint_ready ));
0 commit comments