Skip to content

Commit 7ef8e0f

Browse files
committed
refactor: fix android usage
1 parent 248e1e9 commit 7ef8e0f

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

src/main/java/org/sqlite/util/OSInfo.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -144,18 +144,12 @@ public static boolean isAndroidTermux() {
144144
}
145145
}
146146

147+
@AndroidSignatureIgnore(explanation = "Should not reach this code path")
147148
public static boolean isMusl() {
148149
Path mapFilesDir = Paths.get("/proc/self/map_files");
149150
try (Stream<Path> dirStream = Files.list(mapFilesDir)) {
150151
return dirStream
151-
.map(
152-
path -> {
153-
try {
154-
return path.toRealPath().toString();
155-
} catch (IOException e) {
156-
return "";
157-
}
158-
})
152+
.map(OSInfo::toRealPathOrEmpty)
159153
.anyMatch(s -> s.toLowerCase().contains("musl"));
160154
} catch (Exception ignored) {
161155
// fall back to checking for alpine linux in the event we're using an older kernel which
@@ -164,6 +158,16 @@ public static boolean isMusl() {
164158
}
165159
}
166160

161+
@AndroidSignatureIgnore(explanation = "Should not reach this code path")
162+
private static String toRealPathOrEmpty(Path path) {
163+
try {
164+
return path.toRealPath().toString();
165+
} catch (IOException e) {
166+
return "";
167+
}
168+
}
169+
170+
@AndroidSignatureIgnore(explanation = "Should not reach this code path")
167171
private static boolean isAlpineLinux() {
168172
try (Stream<String> osLines = Files.lines(Paths.get("/etc/os-release"))) {
169173
return osLines.anyMatch(l -> l.startsWith("ID") && l.contains("alpine"));
@@ -279,10 +283,10 @@ static String translateOSNameToFolderName(String osName) {
279283
return "Mac";
280284
} else if (osName.contains("AIX")) {
281285
return "AIX";
282-
} else if (isMusl()) {
283-
return "Linux-Musl";
284286
} else if (isAndroid()) {
285287
return "Linux-Android";
288+
} else if (isMusl()) {
289+
return "Linux-Musl";
286290
} else if (osName.contains("Linux")) {
287291
return "Linux";
288292
} else {

0 commit comments

Comments
 (0)