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

Commit 73a41ca0 authored by Geoffrey Boullanger's avatar Geoffrey Boullanger Committed by Android (Google) Code Review
Browse files

Merge "Update TelephonyNetworkFinder return types in android/timezone wrapper" into main

parents 48a43b96 d1b897d6
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.timezone;

import android.annotation.NonNull;
import android.annotation.Nullable;

import java.util.Objects;
import java.util.Set;
@@ -43,6 +44,14 @@ public final class MobileCountries {
        return mDelegate.getMcc();
    }

    /**
     * Returns the Mobile Network Code of the network.
     */
    @Nullable
    public String getMnc() {
        return mDelegate.getMnc();
    }

    /**
     * Returns the Mobile Country Code of the network.
     */
+0 −85
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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 android.annotation.Nullable;

import java.util.Objects;

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

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

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

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

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

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

    @Override
    public boolean equals(@Nullable Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        TelephonyNetwork that = (TelephonyNetwork) o;
        return mDelegate.equals(that.mDelegate);
    }

    @Override
    public int hashCode() {
        return Objects.hash(mDelegate);
    }

    @Override
    public String toString() {
        return "TelephonyNetwork{"
                + "mDelegate=" + mDelegate
                + '}';
    }
}
+4 −4
Original line number Diff line number Diff line
@@ -41,14 +41,14 @@ public final class TelephonyNetworkFinder {
     * returned, e.g. if they operate in countries other than the one suggested by their MCC.
     */
    @Nullable
    public TelephonyNetwork findNetworkByMccMnc(@NonNull String mcc, @NonNull String mnc) {
    public MobileCountries findCountriesByMccMnc(@NonNull String mcc, @NonNull String mnc) {
        Objects.requireNonNull(mcc);
        Objects.requireNonNull(mnc);

        com.android.i18n.timezone.TelephonyNetwork telephonyNetworkDelegate =
                mDelegate.findNetworkByMccMnc(mcc, mnc);
        com.android.i18n.timezone.MobileCountries telephonyNetworkDelegate =
                mDelegate.findCountriesByMccMnc(mcc, mnc);
        return telephonyNetworkDelegate != null
                ? new TelephonyNetwork(telephonyNetworkDelegate) : null;
                ? new MobileCountries(telephonyNetworkDelegate) : null;
    }

    /**