[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [Git][tpo/applications/tor-browser][tor-browser-152.0a1-16.0-2] 2 commits: fixup! [android] Implement Android-native Connection Assist UI



Title: GitLab

Dan Ballard pushed to branch tor-browser-152.0a1-16.0-2 at The Tor Project / Applications / Tor Browser

Commits:

  • bff7e7d7
    by clairehurst at 2026-06-08T11:44:47-06:00
    fixup! [android] Implement Android-native Connection Assist UI
    
    Bug 43576: Connection Assist on Android Fast Follows (Bug 41188)
    Add frequent regions
    
  • bfdbead3
    by clairehurst at 2026-06-08T11:44:47-06:00
    fixup! TB 42247: Android helpers for the TorProvider
    
    Bug 43576: Connection Assist on Android Fast Follows (Bug 41188)
    Add frequent regions
    

4 changed files:

Changes:

  • mobile/android/fenix/app/src/main/java/org/mozilla/fenix/tor/TorConnectionAssistFragment.kt
    ... ... @@ -212,6 +212,7 @@ class TorConnectionAssistFragment : Fragment(), UserInteractionHandler, SystemIn
    212 212
             if (screen.regionDropDownVisible) {
    
    213 213
                 if (binding.countryDropDown.isEmpty()) {
    
    214 214
                     regionDropDownSpinnerAdapter = initializeSpinner()
    
    215
    +                torConnectionAssistViewModel.fetchFrequentRegions()
    
    215 216
                     torConnectionAssistViewModel.fetchRegionNames()
    
    216 217
                 }
    
    217 218
     
    
    ... ... @@ -285,6 +286,18 @@ class TorConnectionAssistFragment : Fragment(), UserInteractionHandler, SystemIn
    285 286
                 }
    
    286 287
             }
    
    287 288
     
    
    289
    +        viewLifecycleOwner.lifecycleScope.launch {
    
    290
    +            repeatOnLifecycle(Lifecycle.State.STARTED) {
    
    291
    +                torConnectionAssistViewModel.frequentRegionCodes.collect {
    
    292
    +                    if (it != null) {
    
    293
    +                        for (region in it) {
    
    294
    +                            Log.d(TAG, "collected region: $region")
    
    295
    +                        }
    
    296
    +                    }
    
    297
    +                }
    
    298
    +            }
    
    299
    +        }
    
    300
    +
    
    288 301
             return spinnerAdapter
    
    289 302
         }
    
    290 303
     
    

  • mobile/android/fenix/app/src/main/java/org/mozilla/fenix/tor/TorConnectionAssistViewModel.kt
    ... ... @@ -80,6 +80,14 @@ class TorConnectionAssistViewModel(
    80 80
             }
    
    81 81
         }
    
    82 82
     
    
    83
    +    fun fetchFrequentRegions() {
    
    84
    +        torAndroidIntegration.frequentRegionNamesGet { frequentRegionNames ->
    
    85
    +            if (frequentRegionNames != null) {
    
    86
    +                frequentRegionCodes.value = frequentRegionNames
    
    87
    +            }
    
    88
    +        }
    
    89
    +    }
    
    90
    +
    
    83 91
         override fun onCleared() {
    
    84 92
             torAndroidIntegration.unregisterBootstrapStateChangeListener(this)
    
    85 93
             super.onCleared()
    
    ... ... @@ -96,6 +104,10 @@ class TorConnectionAssistViewModel(
    96 104
             MutableStateFlow(null)
    
    97 105
         }
    
    98 106
     
    
    107
    +    val frequentRegionCodes: MutableStateFlow<Array<String>?> by lazy {
    
    108
    +        MutableStateFlow(null)
    
    109
    +    }
    
    110
    +
    
    99 111
         val selectedCountryCode: MutableStateFlow<String> by lazy {
    
    100 112
             MutableStateFlow("automatic")
    
    101 113
         }
    

  • mobile/android/geckoview/src/main/java/org/mozilla/geckoview/TorAndroidIntegration.java
    ... ... @@ -60,6 +60,7 @@ public class TorAndroidIntegration implements BundleEventListener {
    60 60
       private static final String EVENT_QUICKSTART_GET = "GeckoView:Tor:QuickstartGet";
    
    61 61
       private static final String EVENT_QUICKSTART_SET = "GeckoView:Tor:QuickstartSet";
    
    62 62
       private static final String EVENT_REGION_NAMES_GET = "GeckoView:Tor:RegionNamesGet";
    
    63
    +  private static final String EVENT_FREQUENT_REGION_NAMES_GET = "GeckoView:Tor:FrequentRegionNamesGet";
    
    63 64
       private static final String EVENT_SHOULD_SHOW_TOR_CONNECT = "GeckoView:Tor:ShouldShowTorConnect";
    
    64 65
     
    
    65 66
       private static final String CONTROL_PORT_FILE = "/control-ipc";
    
    ... ... @@ -709,6 +710,19 @@ public class TorAndroidIntegration implements BundleEventListener {
    709 710
         });
    
    710 711
       }
    
    711 712
     
    
    713
    +  public interface FrequentRegionNamesGetter {
    
    714
    +    void onValue(String[] frequentRegionNames);
    
    715
    +  }
    
    716
    +
    
    717
    +  public void frequentRegionNamesGet(FrequentRegionNamesGetter frequentRegionNamesGetter) {
    
    718
    +    EventDispatcher.getInstance().queryBundle(EVENT_FREQUENT_REGION_NAMES_GET).then( frequentRegionNames -> {
    
    719
    +      if (frequentRegionNames != null) {
    
    720
    +        frequentRegionNamesGetter.onValue(frequentRegionNames.getStringArray("codes"));
    
    721
    +      }
    
    722
    +      return new GeckoResult<Void>();
    
    723
    +    });
    
    724
    +  }
    
    725
    +
    
    712 726
       public interface ShouldShowTorConnectGetter {
    
    713 727
         void onValue(Boolean shouldShowTorConnect);
    
    714 728
       }
    

  • toolkit/modules/TorAndroidIntegration.sys.mjs
    ... ... @@ -49,6 +49,7 @@ const ListenedEvents = Object.freeze({
    49 49
       quickstartGet: "GeckoView:Tor:QuickstartGet",
    
    50 50
       quickstartSet: "GeckoView:Tor:QuickstartSet",
    
    51 51
       regionNamesGet: "GeckoView:Tor:RegionNamesGet",
    
    52
    +  frequentRegionNamesGet: "GeckoView:Tor:FrequentRegionNamesGet",
    
    52 53
       shouldShowTorConnectGet: "GeckoView:Tor:ShouldShowTorConnect",
    
    53 54
     });
    
    54 55
     
    
    ... ... @@ -213,6 +214,11 @@ class TorAndroidIntegrationImpl {
    213 214
             case ListenedEvents.regionNamesGet:
    
    214 215
               callback?.onSuccess(lazy.TorConnect.getRegionNames());
    
    215 216
               return;
    
    217
    +        case ListenedEvents.frequentRegionNamesGet:
    
    218
    +          callback?.onSuccess({
    
    219
    +            codes: await lazy.TorConnect.getFrequentRegions(),
    
    220
    +          });
    
    221
    +          return;
    
    216 222
             case ListenedEvents.shouldShowTorConnectGet:
    
    217 223
               callback?.onSuccess(lazy.TorConnect.shouldShowTorConnect());
    
    218 224
               return;
    

  • _______________________________________________
    tor-commits mailing list -- tor-commits@xxxxxxxxxxxxxxxxxxxx
    To unsubscribe send an email to tor-commits-leave@xxxxxxxxxxxxxxxxxxxx