@@ -272,25 +272,25 @@ public static int launchJavaVM(final Activity activity,String javaPath,String ho
272272 return exitCode ;
273273 }
274274
275- public static int launchAPIInstaller (Activity activity ,String javaPath , Vector <String > args , String home ) {
275+ public static int launchAPIInstaller (Context context ,String javaPath , ArrayList <String > args , String home ) {
276276 try {
277- redirectAndPrintJRELog (activity );
278- relocateLibPath (activity ,javaPath );
277+ args .remove (0 );
278+ redirectAndPrintJRELog (context );
279+ relocateLibPath (context ,javaPath );
279280 Os .setenv ("HOME" , home , true );
280281 Os .setenv ("JAVA_HOME" , javaPath , true );
281282 File serverFile = new File (javaPath + "/lib/server/libjvm.so" );
282283 jvmLibraryPath = javaPath + "/lib/" + (serverFile .exists () ? "server" : "client" );
283284 Log .d ("DynamicLoader" ,"Base LD_LIBRARY_PATH: " + LD_LIBRARY_PATH );
284285 Log .d ("DynamicLoader" ,"Internal LD_LIBRARY_PATH: " + jvmLibraryPath + ":" + LD_LIBRARY_PATH );
285286 setLdLibraryPath (jvmLibraryPath + ":" + LD_LIBRARY_PATH );
286- List <String > userArgs = new ArrayList <>();
287- userArgs .addAll (args );
287+ List <String > userArgs = new ArrayList <>(args );
288288 initJavaRuntime (javaPath );
289- setupExitTrap (activity . getApplication () );
289+ setupExitTrap (context );
290290 chdir (home );
291291 userArgs .add (0 ,"java" );
292292 final int exitCode = VMLauncher .launchJVM ((String []) userArgs .toArray (new String [0 ]));
293- Logger .getInstance (activity ).appendToLog ("Java Exit code: " + exitCode );
293+ Logger .getInstance (context ).appendToLog ("Java Exit code: " + exitCode );
294294 return exitCode ;
295295 } catch (ErrnoException | IOException e ) {
296296 e .printStackTrace ();
@@ -391,92 +391,6 @@ public static String findInLdLibPath(String libName) {
391391 return libName ;
392392 }
393393
394- /**
395- * Remove the argument from the list, if it exists
396- * If the argument exists multiple times, they will all be removed.
397- * @param argList The argument list to purge
398- * @param argStart The argument to purge from the list.
399- */
400- private static void purgeArg (List <String > argList , String argStart ) {
401- for (int i = 0 ; i < argList .size (); i ++) {
402- final String arg = argList .get (i );
403- if (arg .startsWith (argStart )) {
404- argList .remove (i );
405- }
406- }
407- }
408- private static final int EGL_OPENGL_ES_BIT = 0x0001 ;
409- private static final int EGL_OPENGL_ES2_BIT = 0x0004 ;
410- private static final int EGL_OPENGL_ES3_BIT_KHR = 0x0040 ;
411- private static boolean hasExtension (String extensions , String name ) {
412- int start = extensions .indexOf (name );
413- while (start >= 0 ) {
414- // check that we didn't find a prefix of a longer extension name
415- int end = start + name .length ();
416- if (end == extensions .length () || extensions .charAt (end ) == ' ' ) {
417- return true ;
418- }
419- start = extensions .indexOf (name , end );
420- }
421- return false ;
422- }
423- private static int getDetectedVersion () {
424- /*
425- * Get all the device configurations and check the EGL_RENDERABLE_TYPE attribute
426- * to determine the highest ES version supported by any config. The
427- * EGL_KHR_create_context extension is required to check for ES3 support; if the
428- * extension is not present this test will fail to detect ES3 support. This
429- * effectively makes the extension mandatory for ES3-capable devices.
430- */
431- EGL10 egl = (EGL10 ) EGLContext .getEGL ();
432- EGLDisplay display = egl .eglGetDisplay (EGL10 .EGL_DEFAULT_DISPLAY );
433- int [] numConfigs = new int [1 ];
434- if (egl .eglInitialize (display , null )) {
435- try {
436- boolean checkES3 = hasExtension (egl .eglQueryString (display , EGL10 .EGL_EXTENSIONS ),
437- "EGL_KHR_create_context" );
438- if (egl .eglGetConfigs (display , null , 0 , numConfigs )) {
439- EGLConfig [] configs = new EGLConfig [numConfigs [0 ]];
440- if (egl .eglGetConfigs (display , configs , numConfigs [0 ], numConfigs )) {
441- int highestEsVersion = 0 ;
442- int [] value = new int [1 ];
443- for (int i = 0 ; i < numConfigs [0 ]; i ++) {
444- if (egl .eglGetConfigAttrib (display , configs [i ],
445- EGL10 .EGL_RENDERABLE_TYPE , value )) {
446- if (checkES3 && ((value [0 ] & EGL_OPENGL_ES3_BIT_KHR ) ==
447- EGL_OPENGL_ES3_BIT_KHR )) {
448- if (highestEsVersion < 3 ) highestEsVersion = 3 ;
449- } else if ((value [0 ] & EGL_OPENGL_ES2_BIT ) == EGL_OPENGL_ES2_BIT ) {
450- if (highestEsVersion < 2 ) highestEsVersion = 2 ;
451- } else if ((value [0 ] & EGL_OPENGL_ES_BIT ) == EGL_OPENGL_ES_BIT ) {
452- if (highestEsVersion < 1 ) highestEsVersion = 1 ;
453- }
454- } else {
455- Log .w ("glesDetect" , "Getting config attribute with "
456- + "EGL10#eglGetConfigAttrib failed "
457- + "(" + i + "/" + numConfigs [0 ] + "): "
458- + egl .eglGetError ());
459- }
460- }
461- return highestEsVersion ;
462- } else {
463- Log .e ("glesDetect" , "Getting configs with EGL10#eglGetConfigs failed: "
464- + egl .eglGetError ());
465- return -1 ;
466- }
467- } else {
468- Log .e ("glesDetect" , "Getting number of configs with EGL10#eglGetConfigs failed: "
469- + egl .eglGetError ());
470- return -2 ;
471- }
472- } finally {
473- egl .eglTerminate (display );
474- }
475- } else {
476- Log .e ("glesDetect" , "Couldn't initialize EGL." );
477- return -3 ;
478- }
479- }
480394 public static native int chdir (String path );
481395 public static native void logToLogger (final Logger logger );
482396 public static native boolean dlopen (String libPath );
0 commit comments