Dialer: Merge ConstantsImpl into Constants [18/x]
* We don't have more than one Implementation, so no need to use
reflection to find our actual Constants - so merge them into one
* Remove getSettingsActivity() while at it, it's unused
* Remove getUserAgent() as well, we only return null which we can use
to simplify the call to it
Change-Id: I1f2cdf4842d161e431b28ea8aa4d2230a8d06739
diff --git a/java/com/android/dialer/constants/Constants.java b/java/com/android/dialer/constants/Constants.java
index 4071e48..dedcf15 100644
--- a/java/com/android/dialer/constants/Constants.java
+++ b/java/com/android/dialer/constants/Constants.java
@@ -16,21 +16,12 @@
package com.android.dialer.constants;
-import android.content.Context;
-
import androidx.annotation.NonNull;
-import com.android.dialer.common.Assert;
-import com.android.dialer.proguard.UsedByReflection;
-
/**
- * Utility to access constants that are different across build variants (Google Dialer, AOSP,
- * etc...). This functionality depends on a an implementation being present in the app that has the
- * same package and the class name ending in "Impl". For example,
- * com.android.dialer.constants.ConstantsImpl. This class is found by the module using reflection.
+ * Utility to access constants
*/
-@UsedByReflection(value = "Constants.java")
-public abstract class Constants {
+public class Constants {
private static Constants instance;
private static boolean didInitializeInstance;
@@ -38,34 +29,30 @@
public static synchronized Constants get() {
if (!didInitializeInstance) {
didInitializeInstance = true;
- try {
- Class<?> clazz = Class.forName(Constants.class.getName() + "Impl");
- instance = (Constants) clazz.getConstructor().newInstance();
- } catch (ReflectiveOperationException e) {
- Assert.fail(
- "Unable to create an instance of ConstantsImpl. To fix this error include one of the "
- + "constants modules (googledialer, aosp etc...) in your target.");
- }
+ instance = new Constants();
}
return instance;
}
@NonNull
- public abstract String getFileProviderAuthority();
+ public String getFileProviderAuthority() {
+ return "com.android.dialer.files";
+ }
@NonNull
- public abstract String getAnnotatedCallLogProviderAuthority();
+ public String getAnnotatedCallLogProviderAuthority() {
+ return "com.android.dialer.annotatedcalllog";
+ }
@NonNull
- public abstract String getPhoneLookupHistoryProviderAuthority();
+ public String getPhoneLookupHistoryProviderAuthority() {
+ return "com.android.dialer.phonelookuphistory";
+ }
@NonNull
- public abstract String getPreferredSimFallbackProviderAuthority();
-
- public abstract String getUserAgent(Context context);
-
- @NonNull
- public abstract String getSettingsActivity();
+ public String getPreferredSimFallbackProviderAuthority() {
+ return "com.android.dialer.preferredsimfallback";
+ }
protected Constants() {}
}
diff --git a/java/com/android/dialer/constants/aospdialer/ConstantsImpl.java b/java/com/android/dialer/constants/aospdialer/ConstantsImpl.java
deleted file mode 100644
index 81ba218..0000000
--- a/java/com/android/dialer/constants/aospdialer/ConstantsImpl.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2017 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 com.android.dialer.constants;
-
-import android.content.Context;
-
-import androidx.annotation.NonNull;
-
-import com.android.dialer.proguard.UsedByReflection;
-
-/** Provider config values for AOSP Dialer. */
-@UsedByReflection(value = "Constants.java")
-public class ConstantsImpl extends Constants {
-
- @Override
- @NonNull
- public String getFileProviderAuthority() {
- return "com.android.dialer.files";
- }
-
- @NonNull
- @Override
- public String getAnnotatedCallLogProviderAuthority() {
- return "com.android.dialer.annotatedcalllog";
- }
-
- @NonNull
- @Override
- public String getPhoneLookupHistoryProviderAuthority() {
- return "com.android.dialer.phonelookuphistory";
- }
-
- @NonNull
- @Override
- public String getPreferredSimFallbackProviderAuthority() {
- return "com.android.dialer.preferredsimfallback";
- }
-
- @Override
- public String getUserAgent(Context context) {
- return null;
- }
-
- @NonNull
- @Override
- public String getSettingsActivity() {
- return "com.android.dialer.app.settings.DialerSettingsActivity";
- }
-}
diff --git a/java/com/android/dialer/contactphoto/ContactPhotoManagerImpl.java b/java/com/android/dialer/contactphoto/ContactPhotoManagerImpl.java
index b3a3d6d..97e984b 100644
--- a/java/com/android/dialer/contactphoto/ContactPhotoManagerImpl.java
+++ b/java/com/android/dialer/contactphoto/ContactPhotoManagerImpl.java
@@ -201,10 +201,7 @@
context.getResources().getDimensionPixelSize(R.dimen.contact_browser_list_item_photo_size);
// Get a user agent string to use for URI photo requests.
- userAgent = Constants.get().getUserAgent(context);
- if (userAgent == null) {
- userAgent = "";
- }
+ userAgent = "";
}
/** Converts bytes to K bytes, rounding up. Used only for debug log. */