1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.timezone;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 
22 import java.util.Objects;
23 
24 /**
25  * A class that can find telephony network information loaded via {@link TelephonyLookup}.
26  *
27  * @hide
28  */
29 public final class TelephonyNetworkFinder {
30 
31     @NonNull
32     private final com.android.i18n.timezone.TelephonyNetworkFinder mDelegate;
33 
TelephonyNetworkFinder(com.android.i18n.timezone.TelephonyNetworkFinder delegate)34     TelephonyNetworkFinder(com.android.i18n.timezone.TelephonyNetworkFinder delegate) {
35         mDelegate = Objects.requireNonNull(delegate);
36     }
37 
38     /**
39      * Returns information held about a specific MCC + MNC combination. It is expected for this
40      * method to return {@code null}. Only known, unusual networks will typically have information
41      * returned, e.g. if they operate in countries other than the one suggested by their MCC.
42      */
43     @Nullable
findNetworkByMccMnc(@onNull String mcc, @NonNull String mnc)44     public TelephonyNetwork findNetworkByMccMnc(@NonNull String mcc, @NonNull String mnc) {
45         Objects.requireNonNull(mcc);
46         Objects.requireNonNull(mnc);
47 
48         com.android.i18n.timezone.TelephonyNetwork telephonyNetworkDelegate =
49                 mDelegate.findNetworkByMccMnc(mcc, mnc);
50         return telephonyNetworkDelegate != null
51                 ? new TelephonyNetwork(telephonyNetworkDelegate) : null;
52     }
53 }
54