Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 65ba4e7b authored by Chiachang Wang's avatar Chiachang Wang
Browse files

Use location mcc to load the array config resource

Align the mechanism to load resource with others inside
NetworkMonitor.

Bug: 141406258
Test: atest NetworkStackTests
Change-Id: I66141e4bdc71d19e766aeec6ca33db8e1cb737fe
Merged-In: I66141e4bdc71d19e766aeec6ca33db8e1cb737fe
(cherry picked from commit a2d25ddb)
parent 347f667a
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -1608,7 +1608,8 @@ public class NetworkMonitor extends StateMachine {
                settingProviderUrls = new URL[0];
            }

            return getArrayConfig(settingProviderUrls, R.array.config_captive_portal_fallback_urls,
            return getProbeUrlArrayConfig(settingProviderUrls,
                    R.array.config_captive_portal_fallback_urls,
                    R.array.default_captive_portal_fallback_urls, this::makeURL);
        } catch (Exception e) {
            // Don't let a misconfiguration bootloop the system.
@@ -1627,7 +1628,8 @@ public class NetworkMonitor extends StateMachine {
                    ? emptySpecs
                    : parseCaptivePortalProbeSpecs(settingsValue).toArray(emptySpecs);

            return getArrayConfig(providerValue, R.array.config_captive_portal_fallback_probe_specs,
            return getProbeUrlArrayConfig(providerValue,
                    R.array.config_captive_portal_fallback_probe_specs,
                    R.array.default_captive_portal_fallback_probe_specs,
                    CaptivePortalProbeSpec::parseSpecOrNull);
        } catch (Exception e) {
@@ -1674,9 +1676,9 @@ public class NetworkMonitor extends StateMachine {
     * @param resourceConverter Converter from the resource strings to stored setting class. Null
     *                          return values are ignored.
     */
    private <T> T[] getArrayConfig(@NonNull T[] providerValue, @ArrayRes int configResId,
    private <T> T[] getProbeUrlArrayConfig(@NonNull T[] providerValue, @ArrayRes int configResId,
            @ArrayRes int defaultResId, @NonNull Function<String, T> resourceConverter) {
        final Resources res = mContext.getResources();
        final Resources res = getContextByMccIfNoSimCardOrDefault().getResources();
        String[] configValue = res.getStringArray(configResId);

        if (configValue.length == 0) {