From dde5a83990a6fc86c08aa8ef27e2ea04ade34ebf Mon Sep 17 00:00:00 2001 From: Kelvin Amoaba <97001695+AmoabaKelvin@users.noreply.github.com> Date: Mon, 16 Nov 2026 21:22:07 +0000 Subject: [PATCH] fix(mobile): update GitHub installs from GitHub, not Google Play (#43218) * fix(mobile): open the GitHub release the update check found, not Google Play GitHub installs outside mainland China had Update open Google Play. The check reads GitHub, and Play production is published by hand after GitHub, so Play could lack that version and offer nothing to update. * fix(mobile): send GitHub installs to GitHub on the update-required screen too Drops the Play preference from #43080: Play production lags GitHub, so it can lack the version the desktop needs. --- mobile/src/app-update/app-update-runtime.ts | 32 +------------ .../src/app-update/google-play-preference.ts | 46 ------------------- mobile/src/app-update/use-wall-app-update.ts | 2 +- .../src/app-update/use-wall-app-update.web.ts | 1 - .../host-connection/ProtocolBlockScreen.tsx | 11 ++--- 5 files changed, 6 insertions(+), 86 deletions(-) delete mode 100644 mobile/src/app-update/google-play-preference.ts diff --git a/mobile/src/app-update/app-update-runtime.ts b/mobile/src/app-update/app-update-runtime.ts index 2f092848075..3b56df16375 100644 --- a/mobile/src/app-update/app-update-runtime.ts +++ b/mobile/src/app-update/app-update-runtime.ts @@ -1,5 +1,4 @@ import Constants from 'expo-constants' -import { getCalendars, getLocales } from 'expo-localization' import * as Linking from 'expo-linking' import { useSyncExternalStore } from 'react' import { AppState, Platform } from 'react-native' @@ -12,7 +11,6 @@ import { import { appStoreUpdateSource } from './app-store-update-source' import { createAppUpdateChecker, type AppUpdateState } from './app-update-checker' import type { AppUpdateSource } from './app-update-source' -import { isLikelyInMainlandChina, shouldPreferGooglePlay } from './google-play-preference' import { ANDROID_RELEASE_TAG_PREFIX, createGithubReleaseUpdateSource, @@ -30,32 +28,6 @@ export const isRetiredGithubAndroidApp = export const isGooglePlayInstall = Platform.OS === 'android' && (OrcaPlayStorePresence?.isInstalledByPlayStore() ?? false) -export const GOOGLE_PLAY_URL = 'https://play.google.com/store/apps/details?id=dev.orca.app' - -function deviceIsInMainlandChina(): boolean { - try { - return isLikelyInMainlandChina({ - regionCodes: getLocales().map((locale) => locale.regionCode), - timeZone: getCalendars()[0]?.timeZone - }) - } catch { - // Unknown region: stay on GitHub, which works everywhere. - return true - } -} - -/** - * A GitHub (sideloaded) install outside mainland China is sent to Google Play, which updates it in - * place because both carry Google's signing key. Mainland China keeps GitHub: Play is unreachable. - */ -export const prefersGooglePlayUpdate = shouldPreferGooglePlay({ - isAndroid: Platform.OS === 'android', - isRetiredApp: isRetiredGithubAndroidApp, - isInstalledByPlay: isGooglePlayInstall, - playStoreUsable: OrcaPlayStorePresence?.isPlayStoreInstalled() ?? false, - inMainlandChina: deviceIsInMainlandChina() -}) - /** The channel that installed this binary. */ function resolveAppUpdateSource(): AppUpdateSource | null { if (Platform.OS === 'android') { @@ -101,7 +73,7 @@ export function useAppUpdateState(): AppUpdateState { return useSyncExternalStore(appUpdateChecker.subscribe, appUpdateChecker.getSnapshot) } -/** Opens the update's page: Google Play where it applies, else the GitHub release (Android) or App Store (iOS). */ +/** Opens the update the check found: the GitHub release (Android) or App Store (iOS). */ export function openAppUpdate(url: string): void { - void Linking.openURL(prefersGooglePlayUpdate ? GOOGLE_PLAY_URL : url).catch(() => {}) + void Linking.openURL(url).catch(() => {}) } diff --git a/mobile/src/app-update/google-play-preference.ts b/mobile/src/app-update/google-play-preference.ts deleted file mode 100644 index 9593c214da3..00000000000 --- a/mobile/src/app-update/google-play-preference.ts +++ /dev/null @@ -1,46 +0,0 @@ -// Google Play is unreachable from mainland China, so GitHub installs there must keep updating from GitHub. -// Anywhere else a GitHub install is steered to Play, which updates it in place (same signing key). - -// Mainland China's zones; Hong Kong, Macau and Taiwan reach Play and are not listed. -const MAINLAND_CHINA_TIME_ZONES: ReadonlySet = new Set([ - 'Asia/Shanghai', - 'Asia/Chongqing', - 'Asia/Harbin', - 'Asia/Urumqi', - 'Asia/Kashgar', - 'PRC' -]) - -export type DeviceRegionSignals = { - /** Region subtags of the phone's preferred languages, such as `CN` for zh-Hans-CN. */ - readonly regionCodes: readonly (string | null | undefined)[] - readonly timeZone: string | null | undefined -} - -/** - * True when either signal says mainland China. A phone set to US English but sitting in a Chinese - * time zone is still behind the firewall, so either signal alone is enough. - */ -export function isLikelyInMainlandChina(signals: DeviceRegionSignals): boolean { - if (signals.regionCodes.some((code) => code?.toUpperCase() === 'CN')) { - return true - } - return signals.timeZone != null && MAINLAND_CHINA_TIME_ZONES.has(signals.timeZone) -} - -/** A GitHub install is pointed at Play only where Play works and the Play Store app can open it. */ -export function shouldPreferGooglePlay(input: { - readonly isAndroid: boolean - readonly isRetiredApp: boolean - readonly isInstalledByPlay: boolean - readonly playStoreUsable: boolean - readonly inMainlandChina: boolean -}): boolean { - return ( - input.isAndroid && - !input.isRetiredApp && - !input.isInstalledByPlay && - input.playStoreUsable && - !input.inMainlandChina - ) -} diff --git a/mobile/src/app-update/use-wall-app-update.ts b/mobile/src/app-update/use-wall-app-update.ts index 86daadddd8c..6ca0c350038 100644 --- a/mobile/src/app-update/use-wall-app-update.ts +++ b/mobile/src/app-update/use-wall-app-update.ts @@ -1,7 +1,7 @@ import type { KnownAppUpdate } from '../storage/app-update-preferences' import { useAppUpdateState } from './app-update-runtime' -export { isGooglePlayInstall, prefersGooglePlayUpdate } from './app-update-runtime' +export { isGooglePlayInstall } from './app-update-runtime' // Ignore dismissal at update wall; checker’s existing cadence covers it without extra triggers. export function useWallAppUpdate(): KnownAppUpdate | null { diff --git a/mobile/src/app-update/use-wall-app-update.web.ts b/mobile/src/app-update/use-wall-app-update.web.ts index 5c1d48da609..8638ec553c4 100644 --- a/mobile/src/app-update/use-wall-app-update.web.ts +++ b/mobile/src/app-update/use-wall-app-update.web.ts @@ -2,7 +2,6 @@ import type { KnownAppUpdate } from '../storage/app-update-preferences' // The page bundle cannot see the native app's install source. export const isGooglePlayInstall = false -export const prefersGooglePlayUpdate = false // The page bundle must not carry the checker; the wall inside the page keeps the fallback link. export function useWallAppUpdate(): KnownAppUpdate | null { diff --git a/mobile/src/components/host-connection/ProtocolBlockScreen.tsx b/mobile/src/components/host-connection/ProtocolBlockScreen.tsx index e17927e010a..a522afe63df 100644 --- a/mobile/src/components/host-connection/ProtocolBlockScreen.tsx +++ b/mobile/src/components/host-connection/ProtocolBlockScreen.tsx @@ -1,8 +1,4 @@ -import { - isGooglePlayInstall, - prefersGooglePlayUpdate, - useWallAppUpdate -} from '../../app-update/use-wall-app-update' +import { isGooglePlayInstall, useWallAppUpdate } from '../../app-update/use-wall-app-update' import { openExternalLink } from '../../platform/external-links/external-link' import { useRouteHandoff } from '../../navigation/route-handoff' import { Platform, Pressable, Text, View } from 'react-native' @@ -47,13 +43,12 @@ function blockRemedy(verdict: BlockedVerdict): BlockRemedy { } } -// Play installs may only update through Play, and GitHub installs outside mainland China are steered -// there too; other Android installs came from GitHub Releases. +// Play installs may only update through Play; other Android installs came from GitHub Releases. function mobileUpdateChannel(): 'app-store' | 'google-play' | 'github-releases' { if (Platform.OS === 'ios') { return 'app-store' } - return isGooglePlayInstall || prefersGooglePlayUpdate ? 'google-play' : 'github-releases' + return isGooglePlayInstall ? 'google-play' : 'github-releases' } function mobileUpdateChannelTarget(t: Translate): { label: string; url: string } {