Skip to content

Commit 5c4b1e2

Browse files
committed
Emergency fix for getting stuck in recovery mode
1 parent 2955446 commit 5c4b1e2

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

src/main/java/airsquared/blobsaver/app/natives/Libirecovery.java

+20-10
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,16 @@
1919
package airsquared.blobsaver.app.natives;
2020

2121
import airsquared.blobsaver.app.natives.NativeUtils.CFunctionName;
22+
import com.sun.jna.FunctionMapper;
23+
import com.sun.jna.Library;
24+
import com.sun.jna.Native;
25+
import com.sun.jna.NativeLibrary;
2226
import com.sun.jna.Pointer;
2327
import com.sun.jna.Structure;
2428
import com.sun.jna.ptr.PointerByReference;
2529

30+
import java.util.Map;
31+
2632
/**
2733
* https://github.com/libimobiledevice/libirecovery/blob/master/src/libirecovery.c
2834
*/
@@ -67,15 +73,19 @@ public static class irecv_device_info extends Structure {
6773

6874

6975
static {
70-
try {
71-
NativeUtils.register(Libimobiledevice.class, "irecovery");
72-
} catch (UnsatisfiedLinkError e) {
73-
try {
74-
NativeUtils.register(Libimobiledevice.class, "irecovery-1.0");
75-
} catch (UnsatisfiedLinkError e2) {
76-
e.addSuppressed(e2);
77-
throw e;
78-
}
79-
}
76+
// try {
77+
// NativeUtils.register(Libimobiledevice.class, "irecovery");
78+
// } catch (UnsatisfiedLinkError e) {
79+
// try {
80+
// NativeUtils.register(Libimobiledevice.class, "irecovery-1.0");
81+
// } catch (UnsatisfiedLinkError e2) {
82+
// e.addSuppressed(e2);
83+
// throw e;
84+
// }
85+
// }
86+
Native.register(Libirecovery.class, NativeLibrary.getInstance("irecovery", Map.of(Library.OPTION_CLASSLOADER, Libirecovery.class.getClassLoader(),
87+
Library.OPTION_FUNCTION_MAPPER, (FunctionMapper) (lib, method) ->
88+
method.isAnnotationPresent(CFunctionName.class) ?
89+
method.getAnnotation(CFunctionName.class).value() : method.getName())));
8090
}
8191
}

src/main/java/airsquared/blobsaver/app/natives/NativeUtils.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@
3232

3333
final class NativeUtils {
3434

35-
private static final Map<String, ?> libraryOptions = Map.of(Library.OPTION_CLASSLOADER, NativeUtils.class.getClassLoader(),
36-
Library.OPTION_FUNCTION_MAPPER, (FunctionMapper) (lib, method) ->
37-
method.isAnnotationPresent(CFunctionName.class) ?
38-
method.getAnnotation(CFunctionName.class).value() : method.getName());
35+
// private static final Map<String, ?> libraryOptions = ;
3936

4037
/**
4138
* Same exact implementation as Native.register(Class, String), except it
4239
* also includes a function mapper for methods annotated with @CFunctionName
4340
*/
4441
static void register(Class<?> cls, String libName) {
45-
Native.register(cls, NativeLibrary.getInstance(libName, libraryOptions));
42+
Native.register(cls, NativeLibrary.getInstance(libName, Map.of(Library.OPTION_CLASSLOADER, cls.getClassLoader(),
43+
Library.OPTION_FUNCTION_MAPPER, (FunctionMapper) (lib, method) ->
44+
method.isAnnotationPresent(CFunctionName.class) ?
45+
method.getAnnotation(CFunctionName.class).value() : method.getName())));
4646
}
4747

4848
@Documented

0 commit comments

Comments
 (0)