feat: turn the OTA updater back on, behind a button in the top bar
OtaUpdater was complete and unreachable: upstream's UpdateHook returned false and had an empty checkInBackground, so nothing ever called the downloader or the installer. That seam was suspended for an audit of the published suite; this fork ships its own builds from its own repository, signed with the platform key the head unit already trusts, so it is live here. The release URL and the About link now point at this repository. An APK from anywhere else is signed with a different key, and OtaUpdater.install checks the archive's certificate against the running app's before calling pm install -r — a mismatch is deleted rather than installed. The refresh button sits outside the tab row, next to About, so it cannot read as a sixth page. It disables itself for the duration: the check, the download and the install are one background pass, and a second press would start a second download of the same APK. The result goes to a toast because the check is reachable from every page and no one page owns the answer. The stable flavour gains a matching no-op overload. It still contains no updater at all — the class is absent from that APK rather than disabled — and the overload exists only so the shared UI compiles in both flavours. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -41,7 +41,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
private static final int LOCATION_PERMISSION_REQUEST = 100;
|
||||
/** Shared with {@link AbrpUploadService}, which reads it on every tick. */
|
||||
static final String WIFI_AUTO_KEY = "wifi_auto_connect";
|
||||
private static final String REPOSITORY_URL = "https://github.com/fatihdonmezdev/EVABRP";
|
||||
private static final String REPOSITORY_URL = "https://github.com/fatihdonmezdev/MG4ABRP";
|
||||
|
||||
/** Top-bar tabs, in page order. Parallel to {@link #panes}. */
|
||||
private static final int[] TAB_IDS =
|
||||
@@ -230,6 +230,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
setUpPager();
|
||||
findViewById(R.id.about_button).setOnClickListener(v -> showAbout());
|
||||
findViewById(R.id.update_button).setOnClickListener(v -> checkForUpdate(v));
|
||||
|
||||
bindCadenceControls();
|
||||
|
||||
@@ -629,6 +630,30 @@ public class MainActivity extends AppCompatActivity {
|
||||
AbrpUploadService.reloadSettings();
|
||||
}
|
||||
|
||||
// ---------- Update check ----------
|
||||
|
||||
/**
|
||||
* Checks for a newer build, and installs one if it is there.
|
||||
*
|
||||
* The button is disabled for the duration rather than guarded by a flag: the whole
|
||||
* sequence — API call, download, {@code pm install} — runs on a background thread, and
|
||||
* a second press would start a second download of the same APK. It comes back on when
|
||||
* the result lands, whatever that result is.
|
||||
*
|
||||
* The outcome goes to a toast because there is nowhere better: the check is reachable
|
||||
* from every page, so no one page owns the answer.
|
||||
*/
|
||||
private void checkForUpdate(View button) {
|
||||
button.setEnabled(false);
|
||||
android.widget.Toast.makeText(this, R.string.update_checking,
|
||||
android.widget.Toast.LENGTH_SHORT).show();
|
||||
UpdateHook.checkInBackground(this, message -> {
|
||||
button.setEnabled(true);
|
||||
android.widget.Toast.makeText(this, message,
|
||||
android.widget.Toast.LENGTH_LONG).show();
|
||||
});
|
||||
}
|
||||
|
||||
// ---------- Wi-Fi page ----------
|
||||
|
||||
private void bindWifiPane() {
|
||||
|
||||
Reference in New Issue
Block a user