Skip to content

Commit 5e1ce54

Browse files
Merge pull request #581 from appdevforall/feat/K2GO-403-disable-ota-fdroid
K2GO-403 feat(update): disable the in-app OTA self-updater in the fdroid build
2 parents caa5e38 + 78f5b19 commit 5e1ce54

4 files changed

Lines changed: 32 additions & 8 deletions

File tree

‎controller/app/build.gradle‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ android {
5858
// Default state of the crash-report opt-in (K2GO-401). True for conventional builds. The
5959
// F-Droid recipe overrides this to false so that build ships crash reporting OFF by default.
6060
buildConfigField "boolean", "CRASH_REPORTS_DEFAULT_ON", "true"
61+
// K2GO-403: the in-app OTA self-updater. On for conventional builds; the fdroid flavor forces it
62+
// off (F-Droid forbids an app that downloads and installs its own APK; the store updates it).
63+
buildConfigField "boolean", "OTA_ENABLED", "true"
6164

6265
// The APK carries the product's name, not its technical identifier: these files are
6366
// downloaded by people from a public bucket. The identifier still lives inside the APK.
@@ -135,6 +138,8 @@ android {
135138
dimension "distribution"
136139
buildConfigField "boolean", "ANALYTICS_ENABLED", "false"
137140
buildConfigField "boolean", "CRASH_REPORTS_DEFAULT_ON", "false"
141+
// K2GO-403: no in-app OTA self-updater in the fdroid build (F-Droid forbids self-install).
142+
buildConfigField "boolean", "OTA_ENABLED", "false"
138143
}
139144
}
140145

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools">
4+
5+
<!-- K2GO-403: the fdroid build ships no in-app OTA self-updater. F-Droid forbids an app that
6+
downloads and installs its own APK, so remove the self-install permission from this variant.
7+
The update path is also gated off in code via BuildConfig.OTA_ENABLED (updater not created,
8+
"Check for updates" row hidden). The store is the update channel for this build. -->
9+
<uses-permission
10+
android:name="android.permission.REQUEST_INSTALL_PACKAGES"
11+
tools:node="remove" />
12+
</manifest>

‎controller/app/src/main/java/org/appdevforall/k2go/redesign/LibraryActivity.java‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,11 @@ protected void onCreate(Bundle savedInstanceState) {
123123

124124
// ADFA-4984: OTA self-updater, active on the library screen. The manual entry lives in
125125
// Settings -> About; onResume runs one silent check and wires the download receiver.
126-
updateController = new org.appdevforall.k2go.update.presentation.UpdateController(this);
126+
// K2GO-403: the fdroid build ships no in-app OTA (F-Droid forbids self-install). Leaving the
127+
// controller null keeps every OTA path off, since all call sites already null-guard it.
128+
if (org.appdevforall.k2go.BuildConfig.OTA_ENABLED) {
129+
updateController = new org.appdevforall.k2go.update.presentation.UpdateController(this);
130+
}
127131

128132
bottomNav = findViewById(R.id.k2go_bottom_nav);
129133
railNav = findViewById(R.id.k2go_nav_rail);

‎controller/app/src/main/java/org/appdevforall/k2go/redesign/SettingsSubFragment.java‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,16 @@ private String endonymOf(String tag) {
182182
private void buildAbout(Context ctx, LinearLayout list) {
183183
SettingsUi.infoRow(ctx, list, getString(R.string.k2go_settings_app_version), versionName(ctx));
184184
// ADFA-4984: manual OTA entry ("update on the air"). LibraryActivity owns the UpdateController.
185-
SettingsUi.row(ctx, list, getString(R.string.k2go_settings_check_updates), null, null, v -> {
186-
if (getActivity() instanceof LibraryActivity) {
187-
org.appdevforall.k2go.update.presentation.UpdateController uc =
188-
((LibraryActivity) getActivity()).updateController();
189-
if (uc != null) uc.checkForUpdatesManual();
190-
}
191-
});
185+
// K2GO-403: hidden in the fdroid build, which ships no in-app updater (updates come from F-Droid).
186+
if (org.appdevforall.k2go.BuildConfig.OTA_ENABLED) {
187+
SettingsUi.row(ctx, list, getString(R.string.k2go_settings_check_updates), null, null, v -> {
188+
if (getActivity() instanceof LibraryActivity) {
189+
org.appdevforall.k2go.update.presentation.UpdateController uc =
190+
((LibraryActivity) getActivity()).updateController();
191+
if (uc != null) uc.checkForUpdatesManual();
192+
}
193+
});
194+
}
192195
SettingsUi.row(ctx, list, getString(R.string.k2go_settings_permissions), null, null, v -> openAppSettings(ctx));
193196
// ADFA-5337: hide the usage-statistics toggle when analytics is compiled out (no
194197
// google-services.json), since there's nothing to share and the switch would do nothing.

0 commit comments

Comments
 (0)