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

Commit c8064f32 authored by Geoffrey Boullanger's avatar Geoffrey Boullanger
Browse files

Made findCountriesByMcc use delegate like findNetworkByMccMnc

This code is used in the telephony codebase and it makes sense to have everything consistent rather than importing deps of i18n for half of the methods.

Bug: 376493245
Test: atest still passing
Flag: com.android.icu.telephony_lookup_mcc_extension

Change-Id: Ic526683b2587e367bb13fdfdb52d776861d2f57f
parent 01611f83
Loading
Loading
Loading
Loading
+68 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.timezone;

import android.annotation.NonNull;

import java.util.Objects;
import java.util.Set;

/**
 * Information about a telephony network.
 *
 * @hide
 */
public final class MobileCountries {

    @NonNull
    private final com.android.i18n.timezone.MobileCountries mDelegate;

    MobileCountries(@NonNull com.android.i18n.timezone.MobileCountries delegate) {
        mDelegate = Objects.requireNonNull(delegate);
    }

    /**
     * Returns the Mobile Country Code of the network.
     */
    @NonNull
    public String getMcc() {
        return mDelegate.getMcc();
    }

    /**
     * Returns the Mobile Country Code of the network.
     */
    @NonNull
    public Set<String> getCountryIsoCodes() {
        return mDelegate.getCountryIsoCodes();
    }

    /**
     * Returns the country in which the network operates as an ISO 3166 alpha-2 (lower case).
     */
    @NonNull
    public String getDefaultCountryIsoCode() {
        return mDelegate.getDefaultCountryIsoCode();
    }

    @Override
    public String toString() {
        return "MobileCountries{"
                + "mDelegate=" + mDelegate
                + '}';
    }
}
+5 −4
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package android.timezone;
import android.annotation.NonNull;
import android.annotation.Nullable;

import com.android.i18n.timezone.MobileCountries;
import com.android.icu.Flags;

import java.util.Objects;
@@ -59,11 +58,13 @@ public final class TelephonyNetworkFinder {
     */
    @Nullable
    public MobileCountries findCountriesByMcc(@NonNull String mcc) {
        Objects.requireNonNull(mcc);

        if (!Flags.telephonyLookupMccExtension()) {
            return null;
        }
        return mDelegate.findCountriesByMcc(mcc);
        Objects.requireNonNull(mcc);

        com.android.i18n.timezone.MobileCountries countriesByMcc =
                mDelegate.findCountriesByMcc(mcc);
        return countriesByMcc != null ? new MobileCountries(countriesByMcc) : null;
    }
}