From e97904662c8af26cd3d6fc6ffd7dba54c93fc9bd Mon Sep 17 00:00:00 2001 From: Jonathan Almeida Date: Tue, 14 Apr 2020 14:20:32 -0400 Subject: [PATCH] Remove duplicate FirebasePushService When we moved push to it's own component the class was supposed to have been moved but git might have only picked it up as an addition. --- app/src/main/AndroidManifest.xml | 2 +- .../fenix/components/FirebasePushService.kt | 62 ------------------- .../java/org/mozilla/fenix/components/Push.kt | 1 + 3 files changed, 2 insertions(+), 63 deletions(-) delete mode 100644 app/src/main/java/org/mozilla/fenix/components/FirebasePushService.kt diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 19fe3a9bc..09c3d6108 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -244,7 +244,7 @@ android:exported="false" /> diff --git a/app/src/main/java/org/mozilla/fenix/components/FirebasePushService.kt b/app/src/main/java/org/mozilla/fenix/components/FirebasePushService.kt deleted file mode 100644 index 0f0c6d062..000000000 --- a/app/src/main/java/org/mozilla/fenix/components/FirebasePushService.kt +++ /dev/null @@ -1,62 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -package org.mozilla.fenix.components - -import android.annotation.SuppressLint -import com.google.firebase.messaging.FirebaseMessagingService -import com.google.firebase.messaging.RemoteMessage -import com.leanplum.LeanplumPushFirebaseMessagingService -import mozilla.components.concept.push.PushService -import mozilla.components.feature.push.AutoPushFeature -import mozilla.components.lib.push.firebase.AbstractFirebasePushService - -/** - * A wrapper class that only exists to delegate to [FirebaseMessagingService] instances. - * - * Implementation notes: - * - * This was a doozy... - * - * With Firebase Cloud Messaging, we've been given some tight constraints in order to get this to - * work: - * - We want to have multiple FCM message receivers for AutoPush and LeanPlum (for now), however - * there can only be one registered [FirebaseMessagingService] in the AndroidManifest. - * - The [LeanplumPushFirebaseMessagingService] does not function as expected unless it's the - * inherited service that receives the messages. - * - The [AutoPushService] is not strongly tied to being the inherited service, but the - * [AutoPushFeature] requires a reference to the push instance as a [PushService]. - * - * We tried creating an empty [FirebaseMessagingService] that can hold a list of the services - * for delegating, but the [LeanplumPushFirebaseMessagingService] tries to get a reference to the - * Application Context, however,since the FCM service runs in a background process that gives a - * nullptr. Within LeanPlum, this is something that is probably provided internally. - * - * We tried to pass in an instance of the [AbstractFirebasePushService] to [FirebasePushService] - * through the constructor and delegate the implementation of a [PushService] to that, but alas, - * the service requires you to have an empty default constructor in order for the OS to do the - * initialization. For this reason, we created a singleton instance of the AutoPush instance since - * that lets us easily delegate the implementation to that, as well as make invocations when FCM - * receives new messages. - */ -class FirebasePushService : LeanplumPushFirebaseMessagingService(), - PushService by AutoPushService { - - override fun onNewToken(newToken: String) { - AutoPushService.onNewToken(newToken) - super.onNewToken(newToken) - } - - override fun onMessageReceived(remoteMessage: RemoteMessage?) { - AutoPushService.onMessageReceived(remoteMessage) - super.onMessageReceived(remoteMessage) - } -} - -/** - * A singleton instance of the FirebasePushService needed for communicating between FCM and the - * [AutoPushFeature]. - */ -@SuppressLint("MissingFirebaseInstanceTokenRefresh") // Implemented internally. -object AutoPushService : AbstractFirebasePushService() diff --git a/app/src/main/java/org/mozilla/fenix/components/Push.kt b/app/src/main/java/org/mozilla/fenix/components/Push.kt index 5e7b853bd..183157a61 100644 --- a/app/src/main/java/org/mozilla/fenix/components/Push.kt +++ b/app/src/main/java/org/mozilla/fenix/components/Push.kt @@ -6,6 +6,7 @@ import mozilla.components.feature.push.PushConfig import mozilla.components.lib.crash.CrashReporter import mozilla.components.support.base.log.logger.Logger import org.mozilla.fenix.R +import org.mozilla.fenix.push.FirebasePushService /** * Component group for push services. These components use services that strongly depend on