Skip to content

Add names to all Firebase components #4117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
*/
@KeepForSdk
public class FirebaseAppCheckDebugRegistrar implements ComponentRegistrar {
public static final String LIBRARY_NAME = "fire-app-check-debug";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, here and throughout

Suggested change
public static final String LIBRARY_NAME = "fire-app-check-debug";
private static final String LIBRARY_NAME = "fire-app-check-debug";

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed all constants to be private. Can you help me take another look?


@Override
public List<Component<?>> getComponents() {
return Arrays.asList(
LibraryVersionComponent.create("fire-app-check-debug", BuildConfig.VERSION_NAME));
LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
*/
@KeepForSdk
public class FirebaseAppCheckPlayIntegrityRegistrar implements ComponentRegistrar {
public static final String LIBRARY_NAME = "fire-app-check-play-integrity";

@Override
public List<Component<?>> getComponents() {
return Arrays.asList(
LibraryVersionComponent.create("fire-app-check-play-integrity", BuildConfig.VERSION_NAME));
LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
*/
@KeepForSdk
public class FirebaseAppCheckSafetyNetRegistrar implements ComponentRegistrar {
public static final String LIBRARY_NAME = "fire-app-check-safety-net";

@Override
public List<Component<?>> getComponents() {
return Arrays.asList(
LibraryVersionComponent.create("fire-app-check-safety-net", BuildConfig.VERSION_NAME));
LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@
*/
@KeepForSdk
public class FirebaseAppCheckRegistrar implements ComponentRegistrar {
public static final String LIBRARY_NAME = "fire-app-check";

@Override
public List<Component<?>> getComponents() {
return Arrays.asList(
Component.builder(FirebaseAppCheck.class, (InternalAppCheckTokenProvider.class))
.name(LIBRARY_NAME)
.add(Dependency.required(FirebaseApp.class))
.add(Dependency.optionalProvider(HeartBeatController.class))
.factory(
Expand All @@ -50,6 +52,6 @@ public List<Component<?>> getComponents() {
.alwaysEager()
.build(),
HeartBeatConsumerComponent.create(),
LibraryVersionComponent.create("fire-app-check", BuildConfig.VERSION_NAME));
LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@
*/
@Keep
public class AbtRegistrar implements ComponentRegistrar {
public static final String LIBRARY_NAME = "fire-abt";

@Override
public List<Component<?>> getComponents() {
return Arrays.asList(
Component.builder(AbtComponent.class)
.name(LIBRARY_NAME)
.add(Dependency.required(Context.class))
.add(Dependency.optionalProvider(AnalyticsConnector.class))
.factory(
Expand All @@ -45,6 +47,6 @@ public List<Component<?>> getComponents() {
container.get(Context.class),
container.getProvider(AnalyticsConnector.class)))
.build(),
LibraryVersionComponent.create("fire-abt", BuildConfig.VERSION_NAME));
LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,20 @@
*/
@Keep
public class FirebaseAppDistributionApiRegistrar implements ComponentRegistrar {
public static final String LIBRARY_NAME = "fire-appdistribution-api";

@Override
public @NonNull List<Component<?>> getComponents() {
return Arrays.asList(
Component.builder(FirebaseAppDistributionProxy.class)
.name(LIBRARY_NAME)
.add(Dependency.optionalProvider(FirebaseAppDistribution.class))
.factory(this::buildFirebaseAppDistributionProxy)
// construct FirebaseAppDistribution instance on startup so we can register for
// activity lifecycle callbacks before the API is called
.alwaysEager()
.build(),
LibraryVersionComponent.create("fire-appdistribution-api", BuildConfig.VERSION_NAME));
LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME));
}

private FirebaseAppDistributionProxy buildFirebaseAppDistributionProxy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,23 @@
*/
@Keep
public class FirebaseAppDistributionRegistrar implements ComponentRegistrar {
public static final String LIBRARY_NAME = "fire-appdistribution";

private static String TAG = "Registrar:";

@Override
public @NonNull List<Component<?>> getComponents() {
return Arrays.asList(
Component.builder(FirebaseAppDistribution.class)
.name(LIBRARY_NAME)
.add(Dependency.required(FirebaseApp.class))
.add(Dependency.requiredProvider(FirebaseInstallationsApi.class))
.factory(this::buildFirebaseAppDistribution)
// construct FirebaseAppDistribution instance on startup so we can register for
// activity lifecycle callbacks before the API is called
.alwaysEager()
.build(),
LibraryVersionComponent.create("fire-appdistribution", BuildConfig.VERSION_NAME));
LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME));
}

private FirebaseAppDistribution buildFirebaseAppDistribution(ComponentContainer container) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
import java.util.List;

public class DynamicLoadingRegistrar implements ComponentRegistrar {
public static final String LIBRARY_NAME = "fire-dyn-mod";

@Override
public List<Component<?>> getComponents() {
return Arrays.asList(
Component.builder(DynamicLoadingSupport.class)
.name(LIBRARY_NAME)
.add(Dependency.required(Context.class))
.add(Dependency.required(ComponentLoader.class))
.alwaysEager()
Expand All @@ -36,6 +38,6 @@ public List<Component<?>> getComponents() {
new DynamicLoadingSupport(
container.get(Context.class), container.get(ComponentLoader.class)))
.build(),
LibraryVersionComponent.create("fire-dyn-mod", BuildConfig.VERSION_NAME));
LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@
*/
@Keep
public class RemoteConfigRegistrar implements ComponentRegistrar {
public static final String LIBRARY_NAME = "fire-rc";

@Override
public List<Component<?>> getComponents() {
return Arrays.asList(
Component.builder(RemoteConfigComponent.class)
.name(LIBRARY_NAME)
.add(Dependency.required(Context.class))
.add(Dependency.required(FirebaseApp.class))
.add(Dependency.required(FirebaseInstallationsApi.class))
Expand All @@ -56,6 +59,6 @@ public List<Component<?>> getComponents() {
container.getProvider(AnalyticsConnector.class)))
.eagerInDefaultApp()
.build(),
LibraryVersionComponent.create("fire-rc", BuildConfig.VERSION_NAME));
LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,18 @@
import java.util.List;

public class CrashlyticsNdkRegistrar implements ComponentRegistrar {
public static final String LIBRARY_NAME = "fire-cls-ndk";

@Override
public List<Component<?>> getComponents() {
return Arrays.asList(
Component.builder(CrashlyticsNativeComponent.class)
.name(LIBRARY_NAME)
.add(Dependency.required(Context.class))
.factory(this::buildCrashlyticsNdk)
.eagerInDefaultApp()
.build(),
LibraryVersionComponent.create("fire-cls-ndk", BuildConfig.VERSION_NAME));
LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME));
}

private CrashlyticsNativeComponent buildCrashlyticsNdk(ComponentContainer container) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,21 @@

/** @hide */
public class CrashlyticsRegistrar implements ComponentRegistrar {
public static final String LIBRARY_NAME = "fire-cls";

@Override
public List<Component<?>> getComponents() {
return Arrays.asList(
Component.builder(FirebaseCrashlytics.class)
.name(LIBRARY_NAME)
.add(Dependency.required(FirebaseApp.class))
.add(Dependency.required(FirebaseInstallationsApi.class))
.add(Dependency.deferred(CrashlyticsNativeComponent.class))
.add(Dependency.deferred(AnalyticsConnector.class))
.factory(this::buildCrashlytics)
.eagerInDefaultApp()
.build(),
LibraryVersionComponent.create("fire-cls", BuildConfig.VERSION_NAME));
LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME));
}

private FirebaseCrashlytics buildCrashlytics(ComponentContainer container) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@
@Keep
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public class DatabaseRegistrar implements ComponentRegistrar {
public static final String LIBRARY_NAME = "fire-rtdb";

@Override
public List<Component<?>> getComponents() {
return Arrays.asList(
Component.builder(FirebaseDatabaseComponent.class)
.name(LIBRARY_NAME)
.add(Dependency.required(FirebaseApp.class))
.add(Dependency.deferred(InternalAuthProvider.class))
.add(Dependency.deferred(InternalAppCheckTokenProvider.class))
Expand All @@ -44,6 +47,6 @@ public List<Component<?>> getComponents() {
c.getDeferred(InternalAuthProvider.class),
c.getDeferred(InternalAppCheckTokenProvider.class)))
.build(),
LibraryVersionComponent.create("fire-rtdb", BuildConfig.VERSION_NAME));
LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,20 @@

@Keep
public class TransportRegistrar implements ComponentRegistrar {
public static final String LIBRARY_NAME = "fire-transport";

@Override
public List<Component<?>> getComponents() {
return Arrays.asList(
Component.builder(TransportFactory.class)
.name(LIBRARY_NAME)
.add(Dependency.required(Context.class))
.factory(
c -> {
TransportRuntime.initialize(c.get(Context.class));
return TransportRuntime.getInstance().newFactory(CCTDestination.LEGACY_INSTANCE);
})
.build(),
LibraryVersionComponent.create("fire-transport", BuildConfig.VERSION_NAME));
LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@
@KeepForSdk
@Keep
public final class FirebaseDynamicLinkRegistrar implements ComponentRegistrar {
public static final String LIBRARY_NAME = "fire-dl";

@Override
@Keep
public List<Component<?>> getComponents() {
Component<FirebaseDynamicLinks> firebaseDynamicLinks =
Component.builder(FirebaseDynamicLinks.class)
.name(LIBRARY_NAME)
.add(Dependency.required(FirebaseApp.class))
.add(Dependency.optionalProvider(AnalyticsConnector.class))
.factory(
Expand All @@ -53,6 +55,6 @@ public List<Component<?>> getComponents() {
.build(); // no need for eager init for the Internal component.

return Arrays.asList(
firebaseDynamicLinks, LibraryVersionComponent.create("fire-dl", BuildConfig.VERSION_NAME));
firebaseDynamicLinks, LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@
@Keep
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public class FirestoreRegistrar implements ComponentRegistrar {
public static final String LIBRARY_NAME = "fire-fst";

@Override
@Keep
public List<Component<?>> getComponents() {
return Arrays.asList(
Component.builder(FirestoreMultiDbComponent.class)
.name(LIBRARY_NAME)
.add(Dependency.required(FirebaseApp.class))
.add(Dependency.required(Context.class))
.add(Dependency.optionalProvider(HeartBeatInfo.class))
Expand All @@ -63,6 +66,6 @@ public List<Component<?>> getComponents() {
c.getProvider(HeartBeatInfo.class),
c.get(FirebaseOptions.class))))
.build(),
LibraryVersionComponent.create("fire-fst", BuildConfig.VERSION_NAME));
LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
*/
@Keep
public class FunctionsRegistrar implements ComponentRegistrar {
public static final String LIBRARY_NAME = "fire-fn";

@Override
public List<Component<?>> getComponents() {
return Arrays.asList(
Expand All @@ -49,6 +51,7 @@ public List<Component<?>> getComponents() {
c.getDeferred(InternalAppCheckTokenProvider.class)))
.build(),
Component.builder(FunctionsMultiResourceComponent.class)
.name(LIBRARY_NAME)
.add(Dependency.required(Context.class))
.add(Dependency.required(ContextProvider.class))
.add(Dependency.required(FirebaseApp.class))
Expand All @@ -59,6 +62,6 @@ public List<Component<?>> getComponents() {
c.get(ContextProvider.class),
c.get(FirebaseApp.class)))
.build(),
LibraryVersionComponent.create("fire-fn", BuildConfig.VERSION_NAME));
LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,20 @@
*/
@Keep
public class FirebaseInAppMessagingDisplayRegistrar implements ComponentRegistrar {
public static final String LIBRARY_NAME = "fire-fiamd";

@Override
@Keep
public List<Component<?>> getComponents() {
return Arrays.asList(
Component.builder(FirebaseInAppMessagingDisplay.class)
.name(LIBRARY_NAME)
.add(Dependency.required(FirebaseApp.class))
.add(Dependency.required(FirebaseInAppMessaging.class))
.factory(this::buildFirebaseInAppMessagingUI)
.eagerInDefaultApp()
.build(),
LibraryVersionComponent.create("fire-fiamd", BuildConfig.VERSION_NAME));
LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME));
}

private FirebaseInAppMessagingDisplay buildFirebaseInAppMessagingUI(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,14 @@
*/
@Keep
public class FirebaseInAppMessagingRegistrar implements ComponentRegistrar {
public static final String LIBRARY_NAME = "fire-fiam";

@Override
@Keep
public List<Component<?>> getComponents() {
return Arrays.asList(
Component.builder(FirebaseInAppMessaging.class)
.name(LIBRARY_NAME)
.add(Dependency.required(Context.class))
.add(Dependency.required(FirebaseInstallationsApi.class))
.add(Dependency.required(FirebaseApp.class))
Expand All @@ -67,7 +70,7 @@ public List<Component<?>> getComponents() {
.factory(this::providesFirebaseInAppMessaging)
.eagerInDefaultApp()
.build(),
LibraryVersionComponent.create("fire-fiam", BuildConfig.VERSION_NAME));
LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME));
}

private FirebaseInAppMessaging providesFirebaseInAppMessaging(ComponentContainer container) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@
/** @hide */
@Keep
public class FirebaseInstallationsRegistrar implements ComponentRegistrar {
public static final String LIBRARY_NAME = "fire-installations";

@Override
public List<Component<?>> getComponents() {
return Arrays.asList(
Component.builder(FirebaseInstallationsApi.class)
.name(LIBRARY_NAME)
.add(Dependency.required(FirebaseApp.class))
.add(Dependency.optionalProvider(HeartBeatController.class))
.factory(
Expand All @@ -41,6 +43,6 @@ public List<Component<?>> getComponents() {
c.get(FirebaseApp.class), c.getProvider(HeartBeatController.class)))
.build(),
HeartBeatConsumerComponent.create(),
LibraryVersionComponent.create("fire-installations", BuildConfig.VERSION_NAME));
LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME));
}
}
Loading