• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 com.android.internal.annotations.GuardedBy;
23 
24 import java.util.Objects;
25 
26 /**
27  * A class that can find time zone-related information about telephony networks.
28  *
29  * @hide
30  */
31 public final class TelephonyLookup {
32 
33     private static final Object sLock = new Object();
34     @GuardedBy("sLock")
35     private static TelephonyLookup sInstance;
36 
37     /**
38      * Obtains an instance for use when resolving telephony time zone information.
39      */
40     @NonNull
getInstance()41     public static TelephonyLookup getInstance() {
42         synchronized (sLock) {
43             if (sInstance == null) {
44                 sInstance = new TelephonyLookup(com.android.i18n.timezone.TelephonyLookup
45                     .getInstance());
46             }
47             return sInstance;
48         }
49     }
50 
51     @NonNull
52     private final com.android.i18n.timezone.TelephonyLookup mDelegate;
53 
TelephonyLookup(@onNull com.android.i18n.timezone.TelephonyLookup delegate)54     private TelephonyLookup(@NonNull com.android.i18n.timezone.TelephonyLookup delegate) {
55         mDelegate = Objects.requireNonNull(delegate);
56     }
57 
58     /**
59      * Returns an object capable of querying telephony network information. This method can return
60      * {@code null} in the event of an error while reading the underlying data files.
61      */
62     @Nullable
getTelephonyNetworkFinder()63     public TelephonyNetworkFinder getTelephonyNetworkFinder() {
64         com.android.i18n.timezone.TelephonyNetworkFinder telephonyNetworkFinderDelegate =
65                 mDelegate.getTelephonyNetworkFinder();
66         return telephonyNetworkFinderDelegate != null
67                 ? new TelephonyNetworkFinder(telephonyNetworkFinderDelegate) : null;
68     }
69 }
70