-
-
Notifications
You must be signed in to change notification settings - Fork 48
Allow CommCare to build and run without Firebase configuration #3613
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
Open
avazirna
wants to merge
21
commits into
master
Choose a base branch
from
feature/conditional-firebase-init
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
5d84b7f
docs: add implementation plan for conditional Firebase initialization
avazirna 00e9384
build: add FIREBASE_ENABLED BuildConfig flag auto-detected from API k…
avazirna c9a18b5
fix: disable FirebaseInitProvider when Firebase is not configured
avazirna e6ab718
feat: add FirebaseUtils central gate for conditional Firebase usage
avazirna 904d64c
feat: gate Firebase init calls in CommCareApplication behind Firebase…
avazirna 4805c2a
feat: gate CrashUtil behind FirebaseUtils in addition to USE_CRASHLYTICS
avazirna daaad5e
feat: gate FirebaseAnalyticsUtil behind FirebaseUtils
avazirna ff8d37b
feat: gate FirebaseMessagingUtil.verifyToken behind FirebaseUtils
avazirna dc7796e
feat: gate CCPerfMonitoring behind FirebaseUtils
avazirna c650102
feat: guard FirebaseAuthService instantiation when Firebase is unavai…
avazirna 69d5c93
feat: guard Firebase messaging service and OtpManager when Firebase i…
avazirna 9e1e70b
chore: remove implementation plan document
avazirna 884cb1b
Nit
avazirna 0729fa5
Refactor
avazirna 5457d29
Disable FCM-dependent service when Firebase is unavailable
avazirna be60214
Use OTP fallback provider when Firebase is unavailable
avazirna 09914a3
Add null check for analytics instance in setUserProperty
avazirna 7d3d837
Revert "feat: guard FirebaseAuthService instantiation when Firebase i…
avazirna ab6a352
Refactor move analytics availability check to FirebaseUtils
avazirna ea020e8
Refactor convert new java class to kotlin object
avazirna a9df806
Merge branch 'master' into feature/conditional-firebase-init
avazirna File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package org.commcare.utils | ||
|
|
||
| import org.commcare.dalvik.BuildConfig | ||
| import org.commcare.preferences.MainConfigurablePreferences | ||
|
|
||
| object FirebaseUtils { | ||
| @JvmStatic | ||
| val isFirebaseEnabled: Boolean | ||
| /** | ||
| * Returns whether Firebase services are available and configured. Firebase is disabled in debug mode | ||
| * When false, all Firebase API calls must be skipped. | ||
| */ | ||
| get() = !BuildConfig.DEBUG && BuildConfig.FIREBASE_ENABLED | ||
|
|
||
| @JvmStatic | ||
| val isCrashlyticsEnabled: Boolean | ||
| get() = isFirebaseEnabled && BuildConfig.USE_CRASHLYTICS | ||
|
|
||
| @JvmStatic | ||
| val isAnalyticsEnabled: Boolean | ||
| get() = isFirebaseEnabled && MainConfigurablePreferences.isAnalyticsEnabled() | ||
| } |
21 changes: 21 additions & 0 deletions
21
app/unit-tests/src/org/commcare/android/tests/firebase/FirebaseUtilsTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package org.commcare.android.tests.firebase; | ||
|
|
||
| import static org.junit.Assert.assertEquals; | ||
|
|
||
| import org.commcare.dalvik.BuildConfig; | ||
| import org.commcare.utils.FirebaseUtils; | ||
| import org.junit.Test; | ||
| import org.junit.runner.RunWith; | ||
| import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
| import org.commcare.CommCareTestApplication; | ||
| import org.robolectric.annotation.Config; | ||
|
|
||
| @Config(application = CommCareTestApplication.class) | ||
| @RunWith(AndroidJUnit4.class) | ||
| public class FirebaseUtilsTest { | ||
|
|
||
| @Test | ||
| public void testIsFirebaseEnabled_matchesBuildConfig() { | ||
| assertEquals(BuildConfig.FIREBASE_ENABLED, FirebaseUtils.isFirebaseEnabled()); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: can we convert this new class to Kotlin