package com.evsuite.abrp; import java.io.File; import java.util.Locale; /** * Installing a car build from a USB stick — UNSTABLE BUILDS ONLY. For development: copy * {@code NilsMG4-unstable-.apk} and its {@code .sha256} (both from build-car) to the top * folder of a stick, plug it in, press the button on the Settings tab. * * The same checks as the over-the-air update apply, minus the server: the newest such file that * is newer than the installed version, a matching SHA-256 sidecar, this app's package, and the * installer's own signature check. The pure parts are here, unit-tested; UpdateHook does the IO. */ final class UsbUpdate { private UsbUpdate() { } /** The top folder of the volume [appFilesDir] lives on; see {@link UsbVolume#root}. */ static File volumeRoot(File appFilesDir) { return UsbVolume.root(appFilesDir); } /** * The car-build APK to install among [names]: the highest version that is newer than * [currentVersion], or null. Only names build-car writes count. */ static String pickNewest(String[] names, String currentVersion) { String best = null, bestVersion = null; if (names == null) return null; for (String name : names) { if (name == null || !name.toLowerCase(Locale.US).startsWith("nilsmg4-unstable-")) continue; String version = OtaUpdater.versionFromAssetName(name); if (version == null || !OtaUpdater.isNewer(version, currentVersion)) continue; if (bestVersion == null || OtaUpdater.isNewer(version, bestVersion)) { best = name; bestVersion = version; } } return best; } }