1 /*
2  * Copyright (C) 2017 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 com.android.dialer.constants;
18 
19 import android.content.Context;
20 import android.support.annotation.NonNull;
21 import com.android.dialer.common.Assert;
22 import com.android.dialer.proguard.UsedByReflection;
23 
24 /**
25  * Utility to access constants that are different across build variants (Google Dialer, AOSP,
26  * etc...). This functionality depends on a an implementation being present in the app that has the
27  * same package and the class name ending in "Impl". For example,
28  * com.android.dialer.constants.ConstantsImpl. This class is found by the module using reflection.
29  */
30 @UsedByReflection(value = "Constants.java")
31 public abstract class Constants {
32   private static Constants instance;
33   private static boolean didInitializeInstance;
34 
35   @NonNull
get()36   public static synchronized Constants get() {
37     if (!didInitializeInstance) {
38       didInitializeInstance = true;
39       try {
40         Class<?> clazz = Class.forName(Constants.class.getName() + "Impl");
41         instance = (Constants) clazz.getConstructor().newInstance();
42       } catch (ReflectiveOperationException e) {
43         Assert.fail(
44             "Unable to create an instance of ConstantsImpl. To fix this error include one of the "
45                 + "constants modules (googledialer, aosp etc...) in your target.");
46       }
47     }
48     return instance;
49   }
50 
51   @NonNull
getFilteredNumberProviderAuthority()52   public abstract String getFilteredNumberProviderAuthority();
53 
54   @NonNull
getFileProviderAuthority()55   public abstract String getFileProviderAuthority();
56 
57   @NonNull
getAnnotatedCallLogProviderAuthority()58   public abstract String getAnnotatedCallLogProviderAuthority();
59 
60   @NonNull
getPhoneLookupHistoryProviderAuthority()61   public abstract String getPhoneLookupHistoryProviderAuthority();
62 
63   @NonNull
getPreferredSimFallbackProviderAuthority()64   public abstract String getPreferredSimFallbackProviderAuthority();
65 
getUserAgent(Context context)66   public abstract String getUserAgent(Context context);
67 
68   @NonNull
getSettingsActivity()69   public abstract String getSettingsActivity();
70 
Constants()71   protected Constants() {}
72 }
73