Skip to content

Commit a01df2d

Browse files
Merge pull request #584 from appdevforall/fix/K2GO-415-hide-wikipedia-32bit
K2GO-415 K2GO-416 fix(runtime-abi): hide 64-bit-only content on all surfaces in a 32-bit runtime
2 parents 219c716 + cd389c0 commit a01df2d

4 files changed

Lines changed: 36 additions & 20 deletions

File tree

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ private void computeWizardAvailability() {
135135
if (tier == InstallationPlanner.Tier.FULL || tier == InstallationPlanner.Tier.STANDARD) {
136136
available.add("courses");
137137
}
138+
// K2GO-415: drop content whose backing module cannot run in this app runtime (a 32-bit app
139+
// cannot run a 64-bit module like Kiwix), so the user cannot pick content with nowhere to land.
140+
for (Item it : ITEMS) if (!archSupports(it.endpoint)) available.remove(it.key);
138141
}
139142

140143
@Override
@@ -262,10 +265,20 @@ private void probe(final Item it) {
262265
});
263266
}
264267

268+
/** K2GO-415: a 64-bit-only module (e.g. Kiwix) has nowhere to land when the app runtime is 32-bit
269+
* (its proot cannot run 64-bit binaries), so its content is not offered there. Keyed on the app
270+
* process bitness via Card.runsOnThisRuntime(); generalizes to any future requires64Bit module. */
271+
private static boolean archSupports(String endpoint) {
272+
ModuleCards.Card c = ModuleCards.byEndpoint(endpoint);
273+
return c == null || c.runsOnThisRuntime();
274+
}
275+
265276
/** The items to show: those whose module answered, in the declared order. */
266277
private List<Item> visibleItems() {
267278
List<Item> out = new ArrayList<>();
268-
for (Item it : ITEMS) if (available.contains(it.key)) out.add(it);
279+
// K2GO-415: also gate on the app runtime as defense in depth (live path), so a 64-bit-only
280+
// module never shows in a 32-bit runtime even if its endpoint somehow answered.
281+
for (Item it : ITEMS) if (available.contains(it.key) && archSupports(it.endpoint)) out.add(it);
269282
return out;
270283
}
271284

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ private void populateCards() {
187187
cards.add(new Card("maps", getString(R.string.k2go_card_maps), false, R.drawable.ic_card_maps));
188188
for (java.util.Iterator<Card> it = cards.iterator(); it.hasNext(); ) {
189189
Card card = it.next();
190+
// K2GO-415/416: hide a module the app runtime cannot run (a 64-bit-only module like Kiwix
191+
// on a 32-bit app), like Module management and Get more do, instead of showing a permanent
192+
// "Not supported" card on Home.
193+
if (unsupported(card)) { it.remove(); continue; }
190194
ModuleCards.Card m = ModuleCards.byEndpoint(card.endpoint);
191195
if (m != null && HiddenModules.contains(requireContext(), m.key())) it.remove();
192196
}
@@ -414,8 +418,12 @@ private boolean isScheduled(Card c) {
414418
@Override public void onResume() { super.onResume(); main.post(poll); }
415419
@Override public void onPause() { super.onPause(); main.removeCallbacks(poll); }
416420

421+
// K2GO-416: gate on the APP process bitness (Process.is64Bit()), not the device ABI list, so a
422+
// 64-bit-only module is unsupported whenever the app runtime is 32-bit (its proot cannot run it).
423+
// Home uses its own Card type (field requires64), so it reads the platform API directly rather than
424+
// ModuleCards.Card.runsOnThisRuntime() (which needs a ModuleCards.Card): same single runtime signal.
417425
private boolean unsupported(Card c) {
418-
return c.requires64 && android.os.Build.SUPPORTED_64_BIT_ABIS.length == 0;
426+
return c.requires64 && !android.os.Process.is64Bit();
419427
}
420428

421429
// ADFA-4853: guards a single in-flight readiness probe before the post-install drain.
@@ -488,7 +496,6 @@ private void refreshStatuses() {
488496
// answers — and every sheet offered to install a platform that was there. The
489497
// fact is asked for where it is needed (applyState, openSheet) instead.
490498
applyState(c, GRAY);
491-
if (unsupported(c) && c.status != null) c.status.setText(getString(R.string.k2go_not_supported));
492499
}
493500
updateHeaderFromCards();
494501
return;
@@ -540,15 +547,6 @@ private void refreshStatuses() {
540547
}
541548

542549
for (final Card c : cards) {
543-
if (unsupported(c)) {
544-
// ADFA-5061: grey, but not "absent". A 64-bit module on a 32-bit device is not
545-
// missing — it is never going to be there, which is why the sheet must not offer
546-
// to install it. Nothing is recorded, so "nothing established" withholds the
547-
// offer where ABSENT would have made it.
548-
applyState(c, GRAY);
549-
if (c.status != null) c.status.setText(getString(R.string.k2go_not_supported));
550-
continue;
551-
}
552550
// ADFA-4828: system is installed. Before the first probe resolves (or while the server
553551
// is still coming up) show "Connecting", never "Not installed" — the latter only appears
554552
// once a probe actually reports the content is absent (404 -> GRAY).
@@ -638,7 +636,7 @@ private void updateHeaderFromCards() {
638636
}
639637
boolean anyChecking = false, anyReady = false;
640638
for (Card c : cards) {
641-
if (unsupported(c) || c.state == GRAY) continue; // GRAY = content absent → doesn't gate
639+
if (c.state == GRAY) continue; // GRAY = content absent, does not gate
642640
if (c.state == AMBER) anyChecking = true;
643641
else if (c.state == GREEN) anyReady = true;
644642
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ public static final class Card {
4646
public String key() { return module.yamlBaseKey; }
4747
public String endpoint() { return module.endpoint; }
4848
public boolean requires64Bit() { return module.requires64Bit; }
49+
50+
/** K2GO-415: true when this module can run in the current app runtime. A 64-bit-only module
51+
* (e.g. Kiwix) runs inside the app's proot, so what matters is the APP process bitness
52+
* (Process.is64Bit()), NOT the device ABI list: a 32-bit app cannot run a 64-bit module even
53+
* on 64-bit hardware. Same signal RootfsManifest uses to pick the rootfs arch. One home for
54+
* this check so callers do not re-derive it. */
55+
public boolean runsOnThisRuntime() {
56+
return !requires64Bit() || android.os.Process.is64Bit();
57+
}
4958
}
5059

5160
// The modules we present as cards, in display order. maps is added when its selector flow lands

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package org.appdevforall.k2go.redesign;
1717

1818
import android.content.Context;
19-
import android.os.Build;
2019
import android.os.Bundle;
2120
import android.os.Handler;
2221
import android.os.Looper;
@@ -102,10 +101,6 @@ public class ModuleHubFragment extends Fragment {
102101

103102
private int px(int dp) { return Math.round(dp * getResources().getDisplayMetrics().density); }
104103

105-
private static boolean is64Bit() {
106-
return Build.SUPPORTED_64_BIT_ABIS != null && Build.SUPPORTED_64_BIT_ABIS.length > 0;
107-
}
108-
109104
@Nullable
110105
@Override
111106
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle s) {
@@ -202,7 +197,8 @@ private void probeAll() {
202197
private void confirmByProbe(final int gen) {
203198
final Set<String> answered = new HashSet<>();
204199
for (final ModuleCards.Card c : ModuleCards.all()) {
205-
if (c.requires64Bit() && !is64Bit()) continue; // hidden on this device
200+
// K2GO-416: delegate the runtime-ABI rule to its owner (Card), do not re-derive it here.
201+
if (!c.runsOnThisRuntime()) continue; // 64-bit-only module cannot run in this app runtime
206202
if (installed.contains(c.key())) continue; // disk already says yes
207203
// K2GO-393: a completion-gated module (maps, a proot install) is answered by its
208204
// iiab_state marker, which the disk floor above already read. It always writes that
@@ -298,7 +294,7 @@ private void buildCards() {
298294
// anything; it is the only place the answer exists.
299295
List<ModuleCards.Card> items = new ArrayList<>();
300296
for (ModuleCards.Card c : ModuleCards.all()) {
301-
if (c.requires64Bit() && !is64Bit()) continue; // never going to run here
297+
if (!c.runsOnThisRuntime()) continue; // never going to run in this app runtime
302298
items.add(c);
303299
}
304300
boolean anyInstallable = false;

0 commit comments

Comments
 (0)