|
|
|
@ -38,6 +38,10 @@ public class SDL { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void loadLibrary(String libraryName) throws UnsatisfiedLinkError, SecurityException, NullPointerException { |
|
|
|
public static void loadLibrary(String libraryName) throws UnsatisfiedLinkError, SecurityException, NullPointerException { |
|
|
|
|
|
|
|
loadLibrary(libraryName, mContext); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void loadLibrary(String libraryName, Context context) throws UnsatisfiedLinkError, SecurityException, NullPointerException { |
|
|
|
|
|
|
|
|
|
|
|
if (libraryName == null) { |
|
|
|
if (libraryName == null) { |
|
|
|
throw new NullPointerException("No library name provided."); |
|
|
|
throw new NullPointerException("No library name provided."); |
|
|
|
@ -53,10 +57,10 @@ public class SDL { |
|
|
|
// To use ReLinker, just add it as a dependency. For more information, see
|
|
|
|
// To use ReLinker, just add it as a dependency. For more information, see
|
|
|
|
// https://github.com/KeepSafe/ReLinker for ReLinker's repository.
|
|
|
|
// https://github.com/KeepSafe/ReLinker for ReLinker's repository.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
Class<?> relinkClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker"); |
|
|
|
Class<?> relinkClass = context.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker"); |
|
|
|
Class<?> relinkListenerClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker$LoadListener"); |
|
|
|
Class<?> relinkListenerClass = context.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker$LoadListener"); |
|
|
|
Class<?> contextClass = mContext.getClassLoader().loadClass("android.content.Context"); |
|
|
|
Class<?> contextClass = context.getClassLoader().loadClass("android.content.Context"); |
|
|
|
Class<?> stringClass = mContext.getClassLoader().loadClass("java.lang.String"); |
|
|
|
Class<?> stringClass = context.getClassLoader().loadClass("java.lang.String"); |
|
|
|
|
|
|
|
|
|
|
|
// Get a 'force' instance of the ReLinker, so we can ensure libraries are reinstalled if
|
|
|
|
// Get a 'force' instance of the ReLinker, so we can ensure libraries are reinstalled if
|
|
|
|
// they've changed during updates.
|
|
|
|
// they've changed during updates.
|
|
|
|
@ -66,7 +70,7 @@ public class SDL { |
|
|
|
|
|
|
|
|
|
|
|
// Actually load the library!
|
|
|
|
// Actually load the library!
|
|
|
|
Method loadMethod = relinkInstanceClass.getDeclaredMethod("loadLibrary", contextClass, stringClass, stringClass, relinkListenerClass); |
|
|
|
Method loadMethod = relinkInstanceClass.getDeclaredMethod("loadLibrary", contextClass, stringClass, stringClass, relinkListenerClass); |
|
|
|
loadMethod.invoke(relinkInstance, mContext, libraryName, null, null); |
|
|
|
loadMethod.invoke(relinkInstance, context, libraryName, null, null); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (final Throwable e) { |
|
|
|
catch (final Throwable e) { |
|
|
|
// Fall back
|
|
|
|
// Fall back
|
|
|
|
|