[Android] Prompt restart when an Origin Play Store purchase is auto-restored (#37036)

On a fresh profile with a prior Play Store Origin purchase, BraveActivity
auto-restores it at startup via verifyPurchase(). This enforces the Origin
policies (e.g. disabling Brave Wallet) live in the running session, but
unlike the in-settings purchase and the native web-purchase flows it never
prompted a restart. The browser then honours the freshly enforced policy
per navigation while already-configured renderers do not, which can leave
the two out of sync (e.g. the renderer keeps injecting window.ethereum and
requests a binder the browser no longer registers).

Open the Origin settings screen when a Play Store purchase is auto-restored,
reusing the existing fetching-spinner/restart snackbar, so the user restarts
and the policies take effect cleanly at boot. The prompt fires only on the
auto-restore transition (the subscription pref is inactive when verifyPurchase
runs); the in-settings first purchase keeps its own snackbar.

Resolves: https://github.com/brave/brave-browser/issues/56078
This commit is contained in:
Serg
2026-06-05 21:45:57 +02:00
committed by GitHub
parent da55cb86ca
commit ff016732ec
2 changed files with 11 additions and 3 deletions
@@ -16,13 +16,14 @@ import org.chromium.chrome.browser.settings.BraveOriginPreferences;
import org.chromium.chrome.browser.settings.SettingsNavigationFactory;
/**
* Opens the Brave Origin settings screen from native when a purchase is first detected, so the user
* can restart to apply the newly enforced policies.
* Opens the Brave Origin settings screen when a purchase is first detected (from native for web
* purchases, or from Java when a Play Store purchase is auto-restored), so the user can restart to
* apply the newly enforced policies.
*/
@NullMarked
public class BraveOriginSettingsLauncherHelper {
@CalledByNative
private static void showOriginSettingsForRestart() {
public static void showOriginSettingsForRestart() {
Activity activity = ApplicationStatus.getLastTrackedFocusedActivity();
if (activity == null) {
return;
@@ -145,6 +145,13 @@ public class BraveOriginSubscriptionPrefs {
setOriginPackageName(profile);
setOriginProductId(profile, activePurchaseModel.getProductId());
setOriginPurchaseToken(profile, activePurchaseModel.getPurchaseToken());
// We only reach verifyPurchase() while the subscription pref is inactive
// (see the BraveActivity guard), so a found purchase means a prior Play
// Store purchase is being auto-restored. setOriginPurchaseToken() above
// already started the credential fetch, so open the Origin settings screen:
// it shows the spinner while credentials are fetched and prompts a restart
// once the policies are enforced.
BraveOriginSettingsLauncherHelper.showOriginSettingsForRestart();
} else {
setOriginProductId(profile, "");
setOriginPurchaseToken(profile, "");