Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
openStream should not be intercepted if Firebase Perf is not initiali…
…zed (#5885) Proposed fix for #5584: ### Issue Crash happens if a URL connection is opened e.g. `url.openStream()` when `TransportManager` has not been initialized. If developer wants to programmatically enable Firebase using FirebaseOptions, but have included the Firebase Perf plugin, the app will crash after doing a network call. ### Steps to reproduce 1. Add Firebase perf plugin - Module `build.gradle` ``` plugins { alias(libs.plugins.android.application) apply false alias(libs.plugins.jetbrains.kotlin.android) apply false id("com.google.gms.google-services") version "4.4.1" apply false id("com.google.firebase.firebase-perf") version "1.4.2" apply false } ``` - App `build.gradle` ``` plugins { alias(libs.plugins.android.application) alias(libs.plugins.jetbrains.kotlin.android) id("com.google.gms.google-services") id("com.google.firebase.firebase-perf") } ``` 2. Disable Firebase ```xml <provider android:name="com.google.firebase.provider.FirebaseInitProvider" android:authorities="${applicationId}.firebaseinitprovider" tools:node="remove" /> ``` 3. Do a network call ``` val url = URL("https", "www.amazon.com", 443, "") val inputStream = url.openStream() ``` ### Investigation 1. `openStream` in `FirebasePerfUrlConnection` intercepts all urls that opens connections. 5. `openStream` requires `TransportManager` to be initialized 6. `TransportManager` is only initialized after `FirebasePerformance` has been initialized ### Solution If `TransportManager` is not initialized, we should simply return the URL openStream and not intercept the connection.
- Loading branch information