From 383f7277d683ae391f3d4a3aa5d8cb676d3ca358 Mon Sep 17 00:00:00 2001 From: Emily Ploszaj Date: Tue, 8 Jul 2025 12:41:24 -0500 Subject: [PATCH 01/11] MinSDK 23 --- build.gradle.kts | 2 +- firebase-ai/firebase-ai.gradle.kts | 2 +- firebase-config/firebase-config.gradle.kts | 2 +- firebase-dataconnect/demo/build.gradle.kts | 2 +- firebase-dataconnect/google-services.json | 24 ------------------- .../firestore/spec/MemorySpecTest.java | 2 +- .../FirebaseInAppMessagingDisplayTest.java | 2 +- .../display/OnSwipeListenerTest.java | 2 +- .../display/internal/FiamImageLoaderTest.java | 2 +- .../internal/FiamWindowManagerTest.java | 2 +- .../src/test/resources/robolectric.properties | 2 +- .../firebase-vertexai.gradle.kts | 2 +- 12 files changed, 11 insertions(+), 35 deletions(-) delete mode 100644 firebase-dataconnect/google-services.json diff --git a/build.gradle.kts b/build.gradle.kts index a10ac0119ea..ec33368b81e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -33,7 +33,7 @@ extra["targetSdkVersion"] = 34 extra["compileSdkVersion"] = 34 -extra["minSdkVersion"] = 21 +extra["minSdkVersion"] = 23 firebaseContinuousIntegration { ignorePaths = diff --git a/firebase-ai/firebase-ai.gradle.kts b/firebase-ai/firebase-ai.gradle.kts index fb4a8bd6f1a..220225521d7 100644 --- a/firebase-ai/firebase-ai.gradle.kts +++ b/firebase-ai/firebase-ai.gradle.kts @@ -40,7 +40,7 @@ android { namespace = "com.google.firebase.ai" compileSdk = 34 defaultConfig { - minSdk = 21 + minSdk = 23 consumerProguardFiles("consumer-rules.pro") multiDexEnabled = true testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" diff --git a/firebase-config/firebase-config.gradle.kts b/firebase-config/firebase-config.gradle.kts index a8024d79c77..fb6711c1d13 100644 --- a/firebase-config/firebase-config.gradle.kts +++ b/firebase-config/firebase-config.gradle.kts @@ -37,7 +37,7 @@ android { compileSdk = targetSdkVersion defaultConfig { - minSdk = 21 + minSdk = 23 multiDexEnabled = true testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } diff --git a/firebase-dataconnect/demo/build.gradle.kts b/firebase-dataconnect/demo/build.gradle.kts index c27cc6ab181..9259b4f6b0b 100644 --- a/firebase-dataconnect/demo/build.gradle.kts +++ b/firebase-dataconnect/demo/build.gradle.kts @@ -72,7 +72,7 @@ android { namespace = "com.google.firebase.dataconnect.minimaldemo" compileSdk = 35 defaultConfig { - minSdk = 21 + minSdk = 23 targetSdk = 35 versionCode = 1 versionName = "1.0" diff --git a/firebase-dataconnect/google-services.json b/firebase-dataconnect/google-services.json deleted file mode 100644 index 162aa66b572..00000000000 --- a/firebase-dataconnect/google-services.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "project_info": { - "project_number": "12345678901", - "firebase_url": "https://prjh5zbv64sv6.firebaseio.com", - "project_id": "prjh5zbv64sv6", - "storage_bucket": "prjh5zbv64sv6.appspot.com" - }, - "client": [ - { - "client_info": { - "mobilesdk_app_id": "1:12345678901:android:1234567890abcdef123456", - "android_client_info": { - "package_name": "com.google.firebase.dataconnect" - } - }, - "api_key": [ - { - "current_key": "AIzayDNSXIbFmlXbIE6mCzDLQAqITYefhixbX4A" - } - ] - } - ], - "configuration_version": "1" -} \ No newline at end of file diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/spec/MemorySpecTest.java b/firebase-firestore/src/test/java/com/google/firebase/firestore/spec/MemorySpecTest.java index d07e3c6c886..324cf2716b0 100644 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/spec/MemorySpecTest.java +++ b/firebase-firestore/src/test/java/com/google/firebase/firestore/spec/MemorySpecTest.java @@ -28,7 +28,7 @@ import org.robolectric.annotation.Config; @RunWith(RobolectricTestRunner.class) -@Config(sdk = 21, manifest = Config.NONE) +@Config(sdk = 23, manifest = Config.NONE) public class MemorySpecTest extends SpecTestCase { private static final String DURABLE_PERSISTENCE = "durable-persistence"; diff --git a/firebase-inappmessaging-display/src/test/java/com/google/firebase/inappmessaging/display/FirebaseInAppMessagingDisplayTest.java b/firebase-inappmessaging-display/src/test/java/com/google/firebase/inappmessaging/display/FirebaseInAppMessagingDisplayTest.java index a4e8d722fce..803ec125db5 100644 --- a/firebase-inappmessaging-display/src/test/java/com/google/firebase/inappmessaging/display/FirebaseInAppMessagingDisplayTest.java +++ b/firebase-inappmessaging-display/src/test/java/com/google/firebase/inappmessaging/display/FirebaseInAppMessagingDisplayTest.java @@ -94,7 +94,7 @@ import org.robolectric.shadows.ShadowPackageManager; @RunWith(RobolectricTestRunner.class) -@Config(sdk = 21, qualifiers = "port") +@Config(sdk = 23, qualifiers = "port") @LooperMode(LooperMode.Mode.LEGACY) public class FirebaseInAppMessagingDisplayTest { diff --git a/firebase-inappmessaging-display/src/test/java/com/google/firebase/inappmessaging/display/OnSwipeListenerTest.java b/firebase-inappmessaging-display/src/test/java/com/google/firebase/inappmessaging/display/OnSwipeListenerTest.java index 33d68346285..da2872acbdd 100644 --- a/firebase-inappmessaging-display/src/test/java/com/google/firebase/inappmessaging/display/OnSwipeListenerTest.java +++ b/firebase-inappmessaging-display/src/test/java/com/google/firebase/inappmessaging/display/OnSwipeListenerTest.java @@ -25,7 +25,7 @@ import org.robolectric.annotation.Config; @RunWith(RobolectricTestRunner.class) -@Config(sdk = 21) +@Config(sdk = 23) public class OnSwipeListenerTest { private OnSwipeUpListener onSwipeListener; private boolean sweptUp; diff --git a/firebase-inappmessaging-display/src/test/java/com/google/firebase/inappmessaging/display/internal/FiamImageLoaderTest.java b/firebase-inappmessaging-display/src/test/java/com/google/firebase/inappmessaging/display/internal/FiamImageLoaderTest.java index 0567a1e65fe..a319395a344 100644 --- a/firebase-inappmessaging-display/src/test/java/com/google/firebase/inappmessaging/display/internal/FiamImageLoaderTest.java +++ b/firebase-inappmessaging-display/src/test/java/com/google/firebase/inappmessaging/display/internal/FiamImageLoaderTest.java @@ -36,7 +36,7 @@ import org.robolectric.annotation.Config; @RunWith(RobolectricTestRunner.class) -@Config(sdk = 21, qualifiers = "por") +@Config(sdk = 23, qualifiers = "por") public class FiamImageLoaderTest { private static final String IMAGE_URL = "https://www.imgur.com"; @Mock private RequestManager glideRequestManager; diff --git a/firebase-inappmessaging-display/src/test/java/com/google/firebase/inappmessaging/display/internal/FiamWindowManagerTest.java b/firebase-inappmessaging-display/src/test/java/com/google/firebase/inappmessaging/display/internal/FiamWindowManagerTest.java index 714fa513f11..5297590c3a8 100644 --- a/firebase-inappmessaging-display/src/test/java/com/google/firebase/inappmessaging/display/internal/FiamWindowManagerTest.java +++ b/firebase-inappmessaging-display/src/test/java/com/google/firebase/inappmessaging/display/internal/FiamWindowManagerTest.java @@ -42,7 +42,7 @@ import org.robolectric.annotation.Config; @RunWith(RobolectricTestRunner.class) -@Config(sdk = 21, qualifiers = "port") +@Config(sdk = 23, qualifiers = "port") public class FiamWindowManagerTest { private static final Context appContext = ApplicationProvider.getApplicationContext(); private static final int WINDOW_GRAVITY = Gravity.CENTER; diff --git a/firebase-messaging/src/test/resources/robolectric.properties b/firebase-messaging/src/test/resources/robolectric.properties index 8bfbb3c5552..a44b8420266 100644 --- a/firebase-messaging/src/test/resources/robolectric.properties +++ b/firebase-messaging/src/test/resources/robolectric.properties @@ -1 +1 @@ -sdk=21 +sdk=23 diff --git a/firebase-vertexai/firebase-vertexai.gradle.kts b/firebase-vertexai/firebase-vertexai.gradle.kts index 99e45f79253..580e070c674 100644 --- a/firebase-vertexai/firebase-vertexai.gradle.kts +++ b/firebase-vertexai/firebase-vertexai.gradle.kts @@ -40,7 +40,7 @@ android { namespace = "com.google.firebase.vertexai" compileSdk = 34 defaultConfig { - minSdk = 21 + minSdk = 23 consumerProguardFiles("consumer-rules.pro") multiDexEnabled = true testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" From bb2cd8409d3e80d14cd3df110994a6b0369f0632 Mon Sep 17 00:00:00 2001 From: Emily Ploszaj Date: Tue, 8 Jul 2025 14:52:20 -0500 Subject: [PATCH 02/11] Adjust target SDK --- build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index ec33368b81e..61573c624c3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -29,9 +29,9 @@ plugins { alias(libs.plugins.kotlinx.serialization) apply false } -extra["targetSdkVersion"] = 34 +extra["targetSdkVersion"] = 35 -extra["compileSdkVersion"] = 34 +extra["compileSdkVersion"] = 35 extra["minSdkVersion"] = 23 From 16d543cf5ca591731115d7db13879b1ed618d165 Mon Sep 17 00:00:00 2001 From: Emily Ploszaj Date: Tue, 8 Jul 2025 14:57:58 -0500 Subject: [PATCH 03/11] Pin minSdk --- firebase-ai/firebase-ai.gradle.kts | 2 +- .../androidTest/java/com/google/firebase/FirebaseAppTest.java | 2 +- firebase-config/firebase-config.gradle.kts | 2 +- firebase-vertexai/firebase-vertexai.gradle.kts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firebase-ai/firebase-ai.gradle.kts b/firebase-ai/firebase-ai.gradle.kts index 220225521d7..b3f75f29180 100644 --- a/firebase-ai/firebase-ai.gradle.kts +++ b/firebase-ai/firebase-ai.gradle.kts @@ -40,7 +40,7 @@ android { namespace = "com.google.firebase.ai" compileSdk = 34 defaultConfig { - minSdk = 23 + minSdk = rootProject.extra["minSdkVersion"] as Int consumerProguardFiles("consumer-rules.pro") multiDexEnabled = true testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" diff --git a/firebase-common/src/androidTest/java/com/google/firebase/FirebaseAppTest.java b/firebase-common/src/androidTest/java/com/google/firebase/FirebaseAppTest.java index f24a56c74c5..43417766dba 100644 --- a/firebase-common/src/androidTest/java/com/google/firebase/FirebaseAppTest.java +++ b/firebase-common/src/androidTest/java/com/google/firebase/FirebaseAppTest.java @@ -143,7 +143,7 @@ public void testInitializeApp_shouldPublishVersionForFirebaseCommon() { // After sorting the user agents are expected to be {"fire-android/", "fire-auth/x.y.z", // "fire-core/x.y.z", "test-component/1.2.3"} assertThat(actualUserAgent[0]).contains("android-installer"); - assertThat(actualUserAgent[1]).contains("android-min-sdk/21"); + assertThat(actualUserAgent[1]).contains("android-min-sdk/23"); assertThat(actualUserAgent[2]).contains("android-platform"); assertThat(actualUserAgent[3]).contains("android-target-sdk"); assertThat(actualUserAgent[4]).contains("device-brand"); diff --git a/firebase-config/firebase-config.gradle.kts b/firebase-config/firebase-config.gradle.kts index fb6711c1d13..9e26f3110a6 100644 --- a/firebase-config/firebase-config.gradle.kts +++ b/firebase-config/firebase-config.gradle.kts @@ -37,7 +37,7 @@ android { compileSdk = targetSdkVersion defaultConfig { - minSdk = 23 + minSdk = rootProject.extra["minSdkVersion"] as Int multiDexEnabled = true testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } diff --git a/firebase-vertexai/firebase-vertexai.gradle.kts b/firebase-vertexai/firebase-vertexai.gradle.kts index 580e070c674..8f73894bd70 100644 --- a/firebase-vertexai/firebase-vertexai.gradle.kts +++ b/firebase-vertexai/firebase-vertexai.gradle.kts @@ -40,7 +40,7 @@ android { namespace = "com.google.firebase.vertexai" compileSdk = 34 defaultConfig { - minSdk = 23 + minSdk = rootProject.extra["minSdkVersion"] as Int consumerProguardFiles("consumer-rules.pro") multiDexEnabled = true testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" From 181b798c4baca673d515daba1c0e61e26c2686e7 Mon Sep 17 00:00:00 2001 From: Emily Ploszaj Date: Tue, 8 Jul 2025 15:30:01 -0500 Subject: [PATCH 04/11] Update dependencies --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 544bd51cf69..9c5ceb00fd6 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -64,7 +64,7 @@ protobufjavautil = "3.25.5" protoc = "3.25.5" quickcheck = "0.6" reactiveStreams = "1.0.4" -robolectric = "4.12" +robolectric = "4.14" runner = "1.0.2" rxandroid = "2.0.2" rxjava = "2.1.14" From 1bdba65d41761237a889813ac1542c7e806bccb0 Mon Sep 17 00:00:00 2001 From: Emily Ploszaj Date: Tue, 8 Jul 2025 15:57:30 -0500 Subject: [PATCH 05/11] Fix storage tests --- .../src/test/java/com/google/firebase/storage/DeleteTest.java | 2 +- .../src/test/java/com/google/firebase/storage/ListTest.java | 2 +- .../src/test/java/com/google/firebase/storage/MetadataTest.java | 2 +- .../java/com/google/firebase/storage/NetworkRequestTest.java | 2 +- .../src/test/java/com/google/firebase/storage/PathingTest.java | 2 +- .../src/test/java/com/google/firebase/storage/UploadTest.java | 2 +- .../firebase/storage/internal/StorageReferenceUriTest.java | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/firebase-storage/src/test/java/com/google/firebase/storage/DeleteTest.java b/firebase-storage/src/test/java/com/google/firebase/storage/DeleteTest.java index 592c7f1584a..f51a3fc6c62 100644 --- a/firebase-storage/src/test/java/com/google/firebase/storage/DeleteTest.java +++ b/firebase-storage/src/test/java/com/google/firebase/storage/DeleteTest.java @@ -32,7 +32,7 @@ /** Tests for {@link FirebaseStorage}. */ @RunWith(RobolectricTestRunner.class) -@Config(sdk = Build.VERSION_CODES.LOLLIPOP_MR1) +@Config(sdk = Build.VERSION_CODES.M) public class DeleteTest { @Rule public RetryRule retryRule = new RetryRule(3); diff --git a/firebase-storage/src/test/java/com/google/firebase/storage/ListTest.java b/firebase-storage/src/test/java/com/google/firebase/storage/ListTest.java index fda83ae5b80..dd7958c547a 100644 --- a/firebase-storage/src/test/java/com/google/firebase/storage/ListTest.java +++ b/firebase-storage/src/test/java/com/google/firebase/storage/ListTest.java @@ -34,7 +34,7 @@ /** Tests for {@link FirebaseStorage}. */ @RunWith(RobolectricTestRunner.class) -@Config(sdk = Build.VERSION_CODES.LOLLIPOP_MR1) +@Config(sdk = Build.VERSION_CODES.M) public class ListTest { @Rule public RetryRule retryRule = new RetryRule(3); diff --git a/firebase-storage/src/test/java/com/google/firebase/storage/MetadataTest.java b/firebase-storage/src/test/java/com/google/firebase/storage/MetadataTest.java index 0dbfbcf0330..24c9ddc5093 100644 --- a/firebase-storage/src/test/java/com/google/firebase/storage/MetadataTest.java +++ b/firebase-storage/src/test/java/com/google/firebase/storage/MetadataTest.java @@ -32,7 +32,7 @@ /** Tests for {@link FirebaseStorage}. */ @RunWith(RobolectricTestRunner.class) -@Config(sdk = Build.VERSION_CODES.LOLLIPOP_MR1) +@Config(sdk = Build.VERSION_CODES.M) public class MetadataTest { @Rule public RetryRule retryRule = new RetryRule(3); diff --git a/firebase-storage/src/test/java/com/google/firebase/storage/NetworkRequestTest.java b/firebase-storage/src/test/java/com/google/firebase/storage/NetworkRequestTest.java index 04afe3c8c1e..c3d3322e5c5 100644 --- a/firebase-storage/src/test/java/com/google/firebase/storage/NetworkRequestTest.java +++ b/firebase-storage/src/test/java/com/google/firebase/storage/NetworkRequestTest.java @@ -30,7 +30,7 @@ import org.robolectric.annotation.Config; @RunWith(RobolectricTestRunner.class) -@Config(sdk = Build.VERSION_CODES.LOLLIPOP_MR1) +@Config(sdk = Build.VERSION_CODES.M) public class NetworkRequestTest { private FirebaseApp app; diff --git a/firebase-storage/src/test/java/com/google/firebase/storage/PathingTest.java b/firebase-storage/src/test/java/com/google/firebase/storage/PathingTest.java index d450e0ae8e6..881fda6e5f1 100644 --- a/firebase-storage/src/test/java/com/google/firebase/storage/PathingTest.java +++ b/firebase-storage/src/test/java/com/google/firebase/storage/PathingTest.java @@ -36,7 +36,7 @@ /** Tests for {@link FirebaseStorage}. */ @RunWith(RobolectricTestRunner.class) -@Config(sdk = Build.VERSION_CODES.LOLLIPOP_MR1) +@Config(sdk = Build.VERSION_CODES.M) public class PathingTest { @Rule public RetryRule retryRule = new RetryRule(3); diff --git a/firebase-storage/src/test/java/com/google/firebase/storage/UploadTest.java b/firebase-storage/src/test/java/com/google/firebase/storage/UploadTest.java index e97028667ae..8d42f688221 100644 --- a/firebase-storage/src/test/java/com/google/firebase/storage/UploadTest.java +++ b/firebase-storage/src/test/java/com/google/firebase/storage/UploadTest.java @@ -62,7 +62,7 @@ /** Tests for {@link FirebaseStorage}. */ @SuppressWarnings("ConstantConditions") @RunWith(RobolectricTestRunner.class) -@Config(sdk = Build.VERSION_CODES.LOLLIPOP_MR1) +@Config(sdk = Build.VERSION_CODES.M) public class UploadTest { private static final String TEST_ASSET_ROOT = "assets/"; diff --git a/firebase-storage/src/test/java/com/google/firebase/storage/internal/StorageReferenceUriTest.java b/firebase-storage/src/test/java/com/google/firebase/storage/internal/StorageReferenceUriTest.java index 88a7e10f724..690c9c91f96 100644 --- a/firebase-storage/src/test/java/com/google/firebase/storage/internal/StorageReferenceUriTest.java +++ b/firebase-storage/src/test/java/com/google/firebase/storage/internal/StorageReferenceUriTest.java @@ -24,7 +24,7 @@ import org.robolectric.annotation.Config; @RunWith(RobolectricTestRunner.class) -@Config(sdk = Build.VERSION_CODES.LOLLIPOP_MR1) +@Config(sdk = Build.VERSION_CODES.M) public class StorageReferenceUriTest { private static final EmulatedServiceSettings EMULATOR_SETTINGS = From 0b4e56836833849e5eb37e222681f88f9212e9be Mon Sep 17 00:00:00 2001 From: Emily Ploszaj Date: Tue, 8 Jul 2025 16:20:27 -0500 Subject: [PATCH 06/11] Resolve data connect issues --- .../com/google/firebase/dataconnect/testutil/FactoryTestRule.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firebase-dataconnect/testutil/src/main/kotlin/com/google/firebase/dataconnect/testutil/FactoryTestRule.kt b/firebase-dataconnect/testutil/src/main/kotlin/com/google/firebase/dataconnect/testutil/FactoryTestRule.kt index c6345a391f8..aee763c0db1 100644 --- a/firebase-dataconnect/testutil/src/main/kotlin/com/google/firebase/dataconnect/testutil/FactoryTestRule.kt +++ b/firebase-dataconnect/testutil/src/main/kotlin/com/google/firebase/dataconnect/testutil/FactoryTestRule.kt @@ -48,7 +48,7 @@ abstract class FactoryTestRule : ExternalResource() { override fun after() { active.set(false) while (instances.isNotEmpty()) { - destroyInstance(instances.removeLast()) + destroyInstance(instances.removeAt(instances.lastIndex)) } } From e314efd8a2b4c8b5207511efa55492a4a7e1768e Mon Sep 17 00:00:00 2001 From: Vinay Guthal Date: Tue, 8 Jul 2025 17:13:53 -0400 Subject: [PATCH 07/11] remove ktx libraries (#7106) This PR removes all the KTX libraries and the docs associated with them. KTX libraries were deprecated a long time ago and now we are removing these as a part of our breaking change release. --------- Co-authored-by: Rodrigo Lazo Paz Co-authored-by: Rodrigo Lazo --- .../firebase-appcheck-playintegrity.gradle | 1 - appcheck/firebase-appcheck/api.txt | 11 - appcheck/firebase-appcheck/ktx/api.txt | 1 - .../firebase-appcheck/ktx/gradle.properties | 1 - appcheck/firebase-appcheck/ktx/ktx.gradle | 73 --- .../ktx/src/androidTest/AndroidManifest.xml | 12 - .../appcheck/ktx/FirebaseAppCheckTests.kt | 108 ---- .../ktx/src/main/AndroidManifest.xml | 24 - .../google/firebase/appcheck/ktx/Logging.kt | 33 -- .../appcheck/ktx/FirebaseAppCheckTests.kt | 105 ---- .../firebase/appcheck/ktx/FirebaseAppCheck.kt | 100 ---- docs/ktx/common.md | 42 -- docs/ktx/crashlytics.md | 50 -- docs/ktx/database.md | 100 ---- docs/ktx/firestore.md | 150 ------ docs/ktx/functions.md | 62 --- docs/ktx/inappmessaging-display.md | 26 - docs/ktx/inappmessaging.md | 26 - docs/ktx/remote-config.md | 86 --- docs/ktx/storage.md | 62 --- firebase-appdistribution-api/api.txt | 15 - .../firebase-appdistribution-api.gradle | 1 - firebase-appdistribution-api/ktx/api.txt | 1 - .../ktx/gradle.properties | 1 - firebase-appdistribution-api/ktx/ktx.gradle | 73 --- .../ktx/src/androidTest/AndroidManifest.xml | 12 - .../ktx/FirebaseAppDistributionTests.kt | 129 ----- .../ktx/src/main/AndroidManifest.xml | 24 - .../firebase/appdistribution/ktx/Logging.kt | 33 -- .../ktx/FirebaseAppDistribution.kt | 169 ------ .../CustomNotificationFeedbackTrigger.kt | 4 +- .../appdistribution/testapp/MainActivity.kt | 4 +- .../ScreenshotDetectionFeedbackTrigger.kt | 4 +- .../appdistribution/testapp/SecondActivity.kt | 4 +- .../testapp/ShakeDetectionFeedbackTrigger.kt | 4 +- .../test-app/test-app.gradle | 2 - firebase-common/api.txt | 17 - firebase-common/firebase-common.gradle.kts | 1 - firebase-common/ktx/api.txt | 1 - firebase-common/ktx/gradle.properties | 1 - firebase-common/ktx/ktx.gradle.kts | 53 -- .../ktx/src/main/AndroidManifest.xml | 11 - .../kotlin/com/google/firebase/ktx/Logging.kt | 33 -- .../kotlin/com/google/firebase/ktx/Tests.kt | 144 ----- .../java/com/google/firebase/ktx/Firebase.kt | 157 ------ .../java/com/google/firebase/ktx/Tests.kt | 143 ----- firebase-config/api.txt | 12 - .../bandwagoner/bandwagoner.gradle | 5 - .../bandwagoner/RealtimeKtListener.kt | 6 +- firebase-config/firebase-config.gradle.kts | 1 - firebase-config/ktx/api.txt | 1 - firebase-config/ktx/gradle.properties | 2 - firebase-config/ktx/ktx.gradle | 68 --- .../ktx/src/main/AndroidManifest.xml | 11 - .../firebase/remoteconfig/ktx/Logging.kt | 33 -- .../remoteconfig/TestConstructorUtil.kt | 63 --- .../remoteconfig/ktx/RemoteConfigTests.kt | 162 ------ .../firebase/remoteconfig/ktx/RemoteConfig.kt | 137 ----- .../remoteconfig/ktx/RemoteConfigTests.kt | 161 ------ .../testing/config/FirebaseConfigTest.kt | 4 +- firebase-config/test-app/test-app.gradle.kts | 3 - .../firebase-crashlytics-ndk.gradle | 1 - firebase-crashlytics/api.txt | 19 - .../firebase-crashlytics.gradle | 1 - firebase-crashlytics/ktx/api.txt | 1 - firebase-crashlytics/ktx/gradle.properties | 1 - firebase-crashlytics/ktx/ktx.gradle | 59 --- .../ktx/src/androidTest/AndroidManifest.xml | 26 - .../crashlytics/ktx/CrashlyticsTests.kt | 69 --- .../src/androidTest/res/values/strings.xml | 16 - .../ktx/src/main/AndroidManifest.xml | 24 - .../firebase/crashlytics/ktx/Logging.kt | 33 -- .../crashlytics/ktx/CrashlyticsTests.kt | 69 --- .../crashlytics/ktx/FirebaseCrashlytics.kt | 74 --- .../crashlytics/ktx/KeyValueBuilder.kt | 110 ---- firebase-database/api.txt | 60 --- .../firebase-database.gradle.kts | 1 - firebase-database/ktx/api.txt | 1 - firebase-database/ktx/gradle.properties | 1 - firebase-database/ktx/ktx.gradle.kts | 62 --- .../ktx/src/main/AndroidManifest.xml | 11 - .../google/firebase/database/ktx/Logging.kt | 33 -- .../firebase/database/DataSnapshotUtil.kt | 43 -- .../firebase/database/ktx/DatabaseTests.kt | 219 -------- .../firebase/database/ktx/ChildEvent.kt | 110 ---- .../google/firebase/database/ktx/Database.kt | 242 --------- .../firebase/database/ktx/DatabaseTests.kt | 218 -------- firebase-dataconnect/google-services.json | 29 ++ .../firebase-dynamic-links.gradle | 99 ++++ firebase-firestore/api.txt | 30 -- firebase-firestore/firebase-firestore.gradle | 1 - firebase-firestore/ktx/api.txt | 1 - firebase-firestore/ktx/gradle.properties | 2 - firebase-firestore/ktx/ktx.gradle | 74 --- .../ktx/src/main/AndroidManifest.xml | 11 - .../google/firebase/firestore/ktx/Logging.kt | 33 -- .../google/firebase/firestore/TestUtil.java | 112 ---- .../firebase/firestore/testutil/TestUtil.java | 89 ---- .../firebase/firestore/ktx/FirestoreTests.kt | 270 ---------- .../firebase/firestore/ktx/Firestore.kt | 493 ------------------ .../firebase/firestore/ktx/FirestoreTests.kt | 269 ---------- firebase-functions/api.txt | 13 - .../firebase-functions.gradle.kts | 1 - firebase-functions/ktx/api.txt | 1 - firebase-functions/ktx/gradle.properties | 2 - firebase-functions/ktx/ktx.gradle.kts | 63 --- .../ktx/src/androidTest/AndroidManifest.xml | 13 - .../ktx/src/androidTest/README.md | 4 - .../ktx/src/main/AndroidManifest.xml | 11 - .../google/firebase/functions/ktx/Logging.kt | 33 -- .../firebase/functions/ktx/CallTests.kt | 93 ---- .../firebase/functions/ktx/Functions.kt | 142 ----- .../firebase/functions/ktx/FunctionsTests.kt | 152 ------ firebase-inappmessaging-display/api.txt | 8 - .../firebase-inappmessaging-display.gradle | 1 - firebase-inappmessaging-display/ktx/api.txt | 1 - .../ktx/gradle.properties | 2 - .../ktx/ktx.gradle | 65 --- .../ktx/src/main/AndroidManifest.xml | 11 - .../inappmessaging/display/ktx/Logging.kt | 33 -- .../display/ktx/InAppMessagingDisplayTests.kt | 86 --- .../display/ktx/InAppMessagingDisplay.kt | 55 -- .../display/ktx/InAppMessagingDisplayTests.kt | 85 --- firebase-inappmessaging/api.txt | 8 - .../firebase-inappmessaging.gradle | 1 - firebase-inappmessaging/ktx/api.txt | 1 - firebase-inappmessaging/ktx/gradle.properties | 2 - firebase-inappmessaging/ktx/ktx.gradle | 61 --- .../ktx/src/main/AndroidManifest.xml | 11 - .../firebase/inappmessaging/ktx/Logging.kt | 33 -- .../ktx/InAppMessaggingTests.kt | 86 --- .../inappmessaging/ktx/InAppMessaging.kt | 55 -- firebase-installations/api.txt | 9 - .../firebase-installations.gradle | 1 - firebase-installations/ktx/api.txt | 1 - firebase-installations/ktx/gradle.properties | 1 - firebase-installations/ktx/ktx.gradle | 61 --- .../ktx/src/main/AndroidManifest.xml | 12 - .../firebase/installations/ktx/Logging.kt | 33 -- .../installations/ktx/InstallationsTests.kt | 90 ---- .../installations/ktx/Installations.kt | 60 --- .../installations/ktx/InstallationsTests.kt | 89 ---- firebase-messaging/api.txt | 9 - firebase-messaging/firebase-messaging.gradle | 1 - firebase-messaging/ktx/api.txt | 1 - firebase-messaging/ktx/gradle.properties | 2 - firebase-messaging/ktx/ktx.gradle | 60 --- .../ktx/src/main/AndroidManifest.xml | 26 - .../google/firebase/messaging/ktx/Logging.kt | 33 -- .../firebase/messaging/ktx/MessagingTests.kt | 94 ---- .../firebase/messaging/ktx/Messaging.kt | 75 --- .../firebase/messaging/ktx/MessagingTests.kt | 93 ---- firebase-ml-modeldownloader/api.txt | 15 - .../firebase-ml-modeldownloader.gradle | 1 - firebase-ml-modeldownloader/ktx/api.txt | 1 - .../ktx/gradle.properties | 2 - firebase-ml-modeldownloader/ktx/ktx.gradle | 59 --- .../ktx/src/main/AndroidManifest.xml | 24 - .../ml/modeldownloader/ktx/Logging.kt | 33 -- .../ktx/ModelDownloaderTests.kt | 123 ----- .../ml-data-collection-tests.gradle | 1 - .../ml/modeldownloader/ktx/ModelDownloader.kt | 99 ---- .../ktx/ModelDownloaderTests.kt | 122 ----- firebase-perf/api.txt | 11 - firebase-perf/dev-app/dev-app.gradle | 1 - firebase-perf/firebase-perf.gradle | 1 - firebase-perf/ktx/api.txt | 1 - firebase-perf/ktx/gradle.properties | 2 - firebase-perf/ktx/ktx.gradle | 62 --- .../ktx/src/main/AndroidManifest.xml | 11 - .../com/google/firebase/perf/ktx/Logging.kt | 33 -- .../firebase/perf/ktx/PerformanceTests.kt | 165 ------ .../google/firebase/perf/metrics/TestUtil.kt | 25 - .../google/firebase/perf/ktx/Performance.kt | 116 ----- .../firebase/perf/ktx/PerformanceTests.kt | 164 ------ .../firebase-sessions.gradle.kts | 1 - firebase-storage/api.txt | 40 -- firebase-storage/firebase-storage.gradle | 1 - firebase-storage/ktx/api.txt | 1 - firebase-storage/ktx/gradle.properties | 2 - firebase-storage/ktx/ktx.gradle | 76 --- .../ktx/src/main/AndroidManifest.xml | 11 - .../google/firebase/storage/ktx/Logging.kt | 33 -- .../firebase/storage/ktx/StorageTest.kt | 187 ------- .../google/firebase/storage/ktx/Storage.kt | 374 ------------- .../google/firebase/storage/ktx/TaskState.kt | 60 --- .../firebase/storage/ktx/StorageTest.kt | 186 ------- integ-testing/integ-testing.gradle.kts | 1 - .../gradle/plugins/PublishingPlugin.kt | 18 - subprojects.cfg | 15 - 190 files changed, 143 insertions(+), 9619 deletions(-) delete mode 100644 appcheck/firebase-appcheck/ktx/api.txt delete mode 100644 appcheck/firebase-appcheck/ktx/gradle.properties delete mode 100644 appcheck/firebase-appcheck/ktx/ktx.gradle delete mode 100644 appcheck/firebase-appcheck/ktx/src/androidTest/AndroidManifest.xml delete mode 100644 appcheck/firebase-appcheck/ktx/src/androidTest/kotlin/com/google/firebase/appcheck/ktx/FirebaseAppCheckTests.kt delete mode 100644 appcheck/firebase-appcheck/ktx/src/main/AndroidManifest.xml delete mode 100644 appcheck/firebase-appcheck/ktx/src/main/kotlin/com/google/firebase/appcheck/ktx/Logging.kt delete mode 100644 appcheck/firebase-appcheck/src/androidTest/java/com/google/firebase/appcheck/ktx/FirebaseAppCheckTests.kt delete mode 100644 appcheck/firebase-appcheck/src/main/java/com/google/firebase/appcheck/ktx/FirebaseAppCheck.kt delete mode 100644 docs/ktx/common.md delete mode 100644 docs/ktx/crashlytics.md delete mode 100644 docs/ktx/database.md delete mode 100644 docs/ktx/firestore.md delete mode 100644 docs/ktx/functions.md delete mode 100644 docs/ktx/inappmessaging-display.md delete mode 100644 docs/ktx/inappmessaging.md delete mode 100644 docs/ktx/remote-config.md delete mode 100644 docs/ktx/storage.md delete mode 100644 firebase-appdistribution-api/ktx/api.txt delete mode 100644 firebase-appdistribution-api/ktx/gradle.properties delete mode 100644 firebase-appdistribution-api/ktx/ktx.gradle delete mode 100644 firebase-appdistribution-api/ktx/src/androidTest/AndroidManifest.xml delete mode 100644 firebase-appdistribution-api/ktx/src/androidTest/kotlin/com/google/firebase/app/distribution/ktx/FirebaseAppDistributionTests.kt delete mode 100644 firebase-appdistribution-api/ktx/src/main/AndroidManifest.xml delete mode 100644 firebase-appdistribution-api/ktx/src/main/kotlin/com/google/firebase/appdistribution/ktx/Logging.kt delete mode 100644 firebase-appdistribution-api/src/main/java/com/google/firebase/appdistribution/ktx/FirebaseAppDistribution.kt delete mode 100644 firebase-common/ktx/api.txt delete mode 100644 firebase-common/ktx/gradle.properties delete mode 100644 firebase-common/ktx/ktx.gradle.kts delete mode 100644 firebase-common/ktx/src/main/AndroidManifest.xml delete mode 100644 firebase-common/ktx/src/main/kotlin/com/google/firebase/ktx/Logging.kt delete mode 100644 firebase-common/ktx/src/test/kotlin/com/google/firebase/ktx/Tests.kt delete mode 100644 firebase-common/src/main/java/com/google/firebase/ktx/Firebase.kt delete mode 100644 firebase-common/src/test/java/com/google/firebase/ktx/Tests.kt delete mode 100644 firebase-config/ktx/api.txt delete mode 100644 firebase-config/ktx/gradle.properties delete mode 100644 firebase-config/ktx/ktx.gradle delete mode 100644 firebase-config/ktx/src/main/AndroidManifest.xml delete mode 100644 firebase-config/ktx/src/main/kotlin/com/google/firebase/remoteconfig/ktx/Logging.kt delete mode 100644 firebase-config/ktx/src/test/kotlin/com/google/firebase/remoteconfig/TestConstructorUtil.kt delete mode 100644 firebase-config/ktx/src/test/kotlin/com/google/firebase/remoteconfig/ktx/RemoteConfigTests.kt delete mode 100644 firebase-config/src/main/java/com/google/firebase/remoteconfig/ktx/RemoteConfig.kt delete mode 100644 firebase-config/src/test/java/com/google/firebase/remoteconfig/ktx/RemoteConfigTests.kt delete mode 100644 firebase-crashlytics/ktx/api.txt delete mode 100644 firebase-crashlytics/ktx/gradle.properties delete mode 100644 firebase-crashlytics/ktx/ktx.gradle delete mode 100644 firebase-crashlytics/ktx/src/androidTest/AndroidManifest.xml delete mode 100644 firebase-crashlytics/ktx/src/androidTest/kotlin/com/google/firebase/crashlytics/ktx/CrashlyticsTests.kt delete mode 100644 firebase-crashlytics/ktx/src/androidTest/res/values/strings.xml delete mode 100644 firebase-crashlytics/ktx/src/main/AndroidManifest.xml delete mode 100644 firebase-crashlytics/ktx/src/main/kotlin/com/google/firebase/crashlytics/ktx/Logging.kt delete mode 100644 firebase-crashlytics/src/androidTest/java/com/google/firebase/crashlytics/ktx/CrashlyticsTests.kt delete mode 100644 firebase-crashlytics/src/main/java/com/google/firebase/crashlytics/ktx/FirebaseCrashlytics.kt delete mode 100644 firebase-crashlytics/src/main/java/com/google/firebase/crashlytics/ktx/KeyValueBuilder.kt delete mode 100644 firebase-database/ktx/api.txt delete mode 100644 firebase-database/ktx/gradle.properties delete mode 100644 firebase-database/ktx/ktx.gradle.kts delete mode 100644 firebase-database/ktx/src/main/AndroidManifest.xml delete mode 100644 firebase-database/ktx/src/main/kotlin/com/google/firebase/database/ktx/Logging.kt delete mode 100644 firebase-database/ktx/src/test/kotlin/com/google/firebase/database/DataSnapshotUtil.kt delete mode 100644 firebase-database/ktx/src/test/kotlin/com/google/firebase/database/ktx/DatabaseTests.kt delete mode 100644 firebase-database/src/main/java/com/google/firebase/database/ktx/ChildEvent.kt delete mode 100644 firebase-database/src/main/java/com/google/firebase/database/ktx/Database.kt delete mode 100644 firebase-database/src/test/java/com/google/firebase/database/ktx/DatabaseTests.kt create mode 100644 firebase-dataconnect/google-services.json create mode 100644 firebase-dynamic-links/firebase-dynamic-links.gradle delete mode 100644 firebase-firestore/ktx/api.txt delete mode 100644 firebase-firestore/ktx/gradle.properties delete mode 100644 firebase-firestore/ktx/ktx.gradle delete mode 100644 firebase-firestore/ktx/src/main/AndroidManifest.xml delete mode 100644 firebase-firestore/ktx/src/main/kotlin/com/google/firebase/firestore/ktx/Logging.kt delete mode 100644 firebase-firestore/ktx/src/test/java/com/google/firebase/firestore/TestUtil.java delete mode 100644 firebase-firestore/ktx/src/test/java/com/google/firebase/firestore/testutil/TestUtil.java delete mode 100644 firebase-firestore/ktx/src/test/kotlin/com/google/firebase/firestore/ktx/FirestoreTests.kt delete mode 100644 firebase-firestore/src/main/java/com/google/firebase/firestore/ktx/Firestore.kt delete mode 100644 firebase-firestore/src/test/java/com/google/firebase/firestore/ktx/FirestoreTests.kt delete mode 100644 firebase-functions/ktx/api.txt delete mode 100644 firebase-functions/ktx/gradle.properties delete mode 100644 firebase-functions/ktx/ktx.gradle.kts delete mode 100644 firebase-functions/ktx/src/androidTest/AndroidManifest.xml delete mode 100644 firebase-functions/ktx/src/androidTest/README.md delete mode 100644 firebase-functions/ktx/src/main/AndroidManifest.xml delete mode 100644 firebase-functions/ktx/src/main/kotlin/com/google/firebase/functions/ktx/Logging.kt delete mode 100644 firebase-functions/src/androidTest/java/com/google/firebase/functions/ktx/CallTests.kt delete mode 100644 firebase-functions/src/main/java/com/google/firebase/functions/ktx/Functions.kt delete mode 100644 firebase-functions/src/test/java/com/google/firebase/functions/ktx/FunctionsTests.kt delete mode 100644 firebase-inappmessaging-display/ktx/api.txt delete mode 100644 firebase-inappmessaging-display/ktx/gradle.properties delete mode 100644 firebase-inappmessaging-display/ktx/ktx.gradle delete mode 100644 firebase-inappmessaging-display/ktx/src/main/AndroidManifest.xml delete mode 100644 firebase-inappmessaging-display/ktx/src/main/kotlin/com/google/firebase/inappmessaging/display/ktx/Logging.kt delete mode 100644 firebase-inappmessaging-display/ktx/src/test/kotlin/com/google/firebase/inappmessaging/display/ktx/InAppMessagingDisplayTests.kt delete mode 100644 firebase-inappmessaging-display/src/main/java/com/google/firebase/inappmessaging/display/ktx/InAppMessagingDisplay.kt delete mode 100644 firebase-inappmessaging-display/src/test/java/com/google/firebase/inappmessaging/display/ktx/InAppMessagingDisplayTests.kt delete mode 100644 firebase-inappmessaging/ktx/api.txt delete mode 100644 firebase-inappmessaging/ktx/gradle.properties delete mode 100644 firebase-inappmessaging/ktx/ktx.gradle delete mode 100644 firebase-inappmessaging/ktx/src/main/AndroidManifest.xml delete mode 100644 firebase-inappmessaging/ktx/src/main/kotlin/com/google/firebase/inappmessaging/ktx/Logging.kt delete mode 100644 firebase-inappmessaging/ktx/src/test/kotlin/com/google/firebase/inappmessagging/ktx/InAppMessaggingTests.kt delete mode 100644 firebase-inappmessaging/src/main/java/com/google/firebase/inappmessaging/ktx/InAppMessaging.kt delete mode 100644 firebase-installations/ktx/api.txt delete mode 100644 firebase-installations/ktx/gradle.properties delete mode 100644 firebase-installations/ktx/ktx.gradle delete mode 100644 firebase-installations/ktx/src/main/AndroidManifest.xml delete mode 100644 firebase-installations/ktx/src/main/kotlin/com/google/firebase/installations/ktx/Logging.kt delete mode 100644 firebase-installations/ktx/src/test/kotlin/com/google/firebase/installations/ktx/InstallationsTests.kt delete mode 100644 firebase-installations/src/main/java/com/google/firebase/installations/ktx/Installations.kt delete mode 100644 firebase-installations/src/test/java/com/google/firebase/installations/ktx/InstallationsTests.kt delete mode 100644 firebase-messaging/ktx/api.txt delete mode 100644 firebase-messaging/ktx/gradle.properties delete mode 100644 firebase-messaging/ktx/ktx.gradle delete mode 100644 firebase-messaging/ktx/src/main/AndroidManifest.xml delete mode 100644 firebase-messaging/ktx/src/main/kotlin/com/google/firebase/messaging/ktx/Logging.kt delete mode 100644 firebase-messaging/ktx/src/test/kotlin/com/google/firebase/messaging/ktx/MessagingTests.kt delete mode 100644 firebase-messaging/src/main/java/com/google/firebase/messaging/ktx/Messaging.kt delete mode 100644 firebase-messaging/src/test/java/com/google/firebase/messaging/ktx/MessagingTests.kt delete mode 100644 firebase-ml-modeldownloader/ktx/api.txt delete mode 100644 firebase-ml-modeldownloader/ktx/gradle.properties delete mode 100644 firebase-ml-modeldownloader/ktx/ktx.gradle delete mode 100644 firebase-ml-modeldownloader/ktx/src/main/AndroidManifest.xml delete mode 100644 firebase-ml-modeldownloader/ktx/src/main/kotlin/com/google/firebase/ml/modeldownloader/ktx/Logging.kt delete mode 100644 firebase-ml-modeldownloader/ktx/src/test/kotlin/com/google/firebase/ml/modeldownloader/ktx/ModelDownloaderTests.kt delete mode 100644 firebase-ml-modeldownloader/src/main/java/com/google/firebase/ml/modeldownloader/ktx/ModelDownloader.kt delete mode 100644 firebase-ml-modeldownloader/src/test/java/com/google/firebase/ml/modeldownloader/ktx/ModelDownloaderTests.kt delete mode 100644 firebase-perf/ktx/api.txt delete mode 100644 firebase-perf/ktx/gradle.properties delete mode 100644 firebase-perf/ktx/ktx.gradle delete mode 100644 firebase-perf/ktx/src/main/AndroidManifest.xml delete mode 100644 firebase-perf/ktx/src/main/kotlin/com/google/firebase/perf/ktx/Logging.kt delete mode 100644 firebase-perf/ktx/src/test/kotlin/com/google/firebase/perf/ktx/PerformanceTests.kt delete mode 100644 firebase-perf/ktx/src/test/kotlin/com/google/firebase/perf/metrics/TestUtil.kt delete mode 100644 firebase-perf/src/main/java/com/google/firebase/perf/ktx/Performance.kt delete mode 100644 firebase-perf/src/test/java/com/google/firebase/perf/ktx/PerformanceTests.kt delete mode 100644 firebase-storage/ktx/api.txt delete mode 100644 firebase-storage/ktx/gradle.properties delete mode 100644 firebase-storage/ktx/ktx.gradle delete mode 100644 firebase-storage/ktx/src/main/AndroidManifest.xml delete mode 100644 firebase-storage/ktx/src/main/kotlin/com/google/firebase/storage/ktx/Logging.kt delete mode 100644 firebase-storage/ktx/src/test/kotlin/com/google/firebase/storage/ktx/StorageTest.kt delete mode 100644 firebase-storage/src/main/java/com/google/firebase/storage/ktx/Storage.kt delete mode 100644 firebase-storage/src/main/java/com/google/firebase/storage/ktx/TaskState.kt delete mode 100644 firebase-storage/src/test/java/com/google/firebase/storage/ktx/StorageTest.kt diff --git a/appcheck/firebase-appcheck-playintegrity/firebase-appcheck-playintegrity.gradle b/appcheck/firebase-appcheck-playintegrity/firebase-appcheck-playintegrity.gradle index 975401af098..82a4ba07e2d 100644 --- a/appcheck/firebase-appcheck-playintegrity/firebase-appcheck-playintegrity.gradle +++ b/appcheck/firebase-appcheck-playintegrity/firebase-appcheck-playintegrity.gradle @@ -52,7 +52,6 @@ dependencies { api project(':appcheck:firebase-appcheck') api 'com.google.firebase:firebase-annotations:16.2.0' api 'com.google.firebase:firebase-common:21.0.0' - api 'com.google.firebase:firebase-common-ktx:21.0.0' api 'com.google.firebase:firebase-components:18.0.0' implementation libs.playservices.base diff --git a/appcheck/firebase-appcheck/api.txt b/appcheck/firebase-appcheck/api.txt index fe214cd0b66..557c950dd0e 100644 --- a/appcheck/firebase-appcheck/api.txt +++ b/appcheck/firebase-appcheck/api.txt @@ -41,14 +41,3 @@ package com.google.firebase.appcheck { } -package com.google.firebase.appcheck.ktx { - - public final class FirebaseAppCheckKt { - method @Deprecated public static com.google.firebase.appcheck.FirebaseAppCheck appCheck(com.google.firebase.ktx.Firebase, com.google.firebase.FirebaseApp app); - method @Deprecated public static operator String component1(com.google.firebase.appcheck.AppCheckToken); - method @Deprecated public static operator long component2(com.google.firebase.appcheck.AppCheckToken); - method @Deprecated public static com.google.firebase.appcheck.FirebaseAppCheck getAppCheck(com.google.firebase.ktx.Firebase); - } - -} - diff --git a/appcheck/firebase-appcheck/ktx/api.txt b/appcheck/firebase-appcheck/ktx/api.txt deleted file mode 100644 index da4f6cc18fe..00000000000 --- a/appcheck/firebase-appcheck/ktx/api.txt +++ /dev/null @@ -1 +0,0 @@ -// Signature format: 3.0 diff --git a/appcheck/firebase-appcheck/ktx/gradle.properties b/appcheck/firebase-appcheck/ktx/gradle.properties deleted file mode 100644 index 9eff84e6c72..00000000000 --- a/appcheck/firebase-appcheck/ktx/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -android.enableUnitTestBinaryResources=true diff --git a/appcheck/firebase-appcheck/ktx/ktx.gradle b/appcheck/firebase-appcheck/ktx/ktx.gradle deleted file mode 100644 index ed498a84e28..00000000000 --- a/appcheck/firebase-appcheck/ktx/ktx.gradle +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2022 Google LLC -// -// 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. - -plugins { - id 'firebase-library' - id("kotlin-android") -} - -firebaseLibrary { - libraryGroup = "appcheck" - testLab.enabled = true - publishJavadoc = false - releaseNotes { - enabled.set(false) - } -} - -android { - namespace "com.google.firebase.appcheck.ktx" - compileSdkVersion project.compileSdkVersion - defaultConfig { - minSdkVersion project.minSdkVersion - multiDexEnabled true - targetSdkVersion project.targetSdkVersion - versionName version - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - test.java { - srcDir 'src/test/kotlin' - } - androidTest.java.srcDirs += 'src/androidTest/kotlin' - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = '1.8' - } - testOptions.unitTests.includeAndroidResources = true -} - -dependencies { - api(project(":appcheck:firebase-appcheck")) - api("com.google.firebase:firebase-common:21.0.0") - api("com.google.firebase:firebase-common-ktx:21.0.0") - - implementation("com.google.firebase:firebase-components:18.0.0") - - testImplementation libs.truth - testImplementation libs.junit - testImplementation libs.mockito.core - testImplementation libs.robolectric - - androidTestImplementation libs.androidx.test.core - androidTestImplementation libs.androidx.test.runner - androidTestImplementation 'com.google.firebase:firebase-appcheck-interop:17.1.0' - androidTestImplementation libs.truth - androidTestImplementation libs.junit -} diff --git a/appcheck/firebase-appcheck/ktx/src/androidTest/AndroidManifest.xml b/appcheck/firebase-appcheck/ktx/src/androidTest/AndroidManifest.xml deleted file mode 100644 index 1b0d1dff1e4..00000000000 --- a/appcheck/firebase-appcheck/ktx/src/androidTest/AndroidManifest.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - diff --git a/appcheck/firebase-appcheck/ktx/src/androidTest/kotlin/com/google/firebase/appcheck/ktx/FirebaseAppCheckTests.kt b/appcheck/firebase-appcheck/ktx/src/androidTest/kotlin/com/google/firebase/appcheck/ktx/FirebaseAppCheckTests.kt deleted file mode 100644 index 2989924a2c5..00000000000 --- a/appcheck/firebase-appcheck/ktx/src/androidTest/kotlin/com/google/firebase/appcheck/ktx/FirebaseAppCheckTests.kt +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright 2022 Google LLC - * - * 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.google.firebase.appcheck.ktx - -import androidx.test.core.app.ApplicationProvider -import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner -import com.google.common.truth.Truth.assertThat -import com.google.firebase.FirebaseApp -import com.google.firebase.FirebaseOptions -import com.google.firebase.appcheck.AppCheckToken -import com.google.firebase.appcheck.FirebaseAppCheck -import com.google.firebase.ktx.Firebase -import com.google.firebase.ktx.app -import com.google.firebase.ktx.initialize -import com.google.firebase.platforminfo.UserAgentPublisher -import org.junit.After -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith - -const val APP_ID = "APP_ID" -const val API_KEY = "API_KEY" - -const val EXISTING_APP = "existing" - -@RunWith(AndroidJUnit4ClassRunner::class) -abstract class BaseTestCase { - @Before - fun setUp() { - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build() - ) - - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build(), - EXISTING_APP - ) - } - - @After - fun cleanUp() { - FirebaseApp.clearInstancesForTest() - } -} - -@RunWith(AndroidJUnit4ClassRunner::class) -class FirebaseAppCheckTests : BaseTestCase() { - @Test - fun appCheck_default_callsDefaultGetInstance() { - assertThat(Firebase.appCheck).isSameInstanceAs(FirebaseAppCheck.getInstance()) - } - - @Test - fun appCheck_with_custom_firebaseapp_calls_GetInstance() { - val app = Firebase.app(EXISTING_APP) - assertThat(Firebase.appCheck(app)).isSameInstanceAs(FirebaseAppCheck.getInstance(app)) - } - - @Test - fun appCheckToken_destructuring_declaration_works() { - val mockAppCheckToken = - object : AppCheckToken() { - override fun getToken(): String = "randomToken" - - override fun getExpireTimeMillis(): Long = 23121997 - } - - val (token, expiration) = mockAppCheckToken - - assertThat(token).isEqualTo(mockAppCheckToken.token) - assertThat(expiration).isEqualTo(mockAppCheckToken.expireTimeMillis) - } -} - -internal const val LIBRARY_NAME: String = "fire-app-check-ktx" - -@RunWith(AndroidJUnit4ClassRunner::class) -class LibraryVersionTest : BaseTestCase() { - @Test - fun libraryRegistrationAtRuntime() { - val publisher = Firebase.app.get(UserAgentPublisher::class.java) - assertThat(publisher.userAgent).contains(LIBRARY_NAME) - } -} diff --git a/appcheck/firebase-appcheck/ktx/src/main/AndroidManifest.xml b/appcheck/firebase-appcheck/ktx/src/main/AndroidManifest.xml deleted file mode 100644 index e2af9507263..00000000000 --- a/appcheck/firebase-appcheck/ktx/src/main/AndroidManifest.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/appcheck/firebase-appcheck/ktx/src/main/kotlin/com/google/firebase/appcheck/ktx/Logging.kt b/appcheck/firebase-appcheck/ktx/src/main/kotlin/com/google/firebase/appcheck/ktx/Logging.kt deleted file mode 100644 index 56050655f1f..00000000000 --- a/appcheck/firebase-appcheck/ktx/src/main/kotlin/com/google/firebase/appcheck/ktx/Logging.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2023 Google LLC - * - * 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.google.firebase.appcheck.ktx - -import androidx.annotation.Keep -import com.google.firebase.appcheck.BuildConfig -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.platforminfo.LibraryVersionComponent - -internal const val LIBRARY_NAME: String = "fire-app-check-ktx" - -/** @suppress */ -@Keep -class FirebaseAppcheckLegacyRegistrar : ComponentRegistrar { - override fun getComponents(): List> { - return listOf(LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME)) - } -} diff --git a/appcheck/firebase-appcheck/src/androidTest/java/com/google/firebase/appcheck/ktx/FirebaseAppCheckTests.kt b/appcheck/firebase-appcheck/src/androidTest/java/com/google/firebase/appcheck/ktx/FirebaseAppCheckTests.kt deleted file mode 100644 index 969b0230ed5..00000000000 --- a/appcheck/firebase-appcheck/src/androidTest/java/com/google/firebase/appcheck/ktx/FirebaseAppCheckTests.kt +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2022 Google LLC - * - * 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.google.firebase.appcheck.ktx - -import androidx.test.core.app.ApplicationProvider -import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner -import com.google.common.truth.Truth.assertThat -import com.google.firebase.FirebaseApp -import com.google.firebase.FirebaseOptions -import com.google.firebase.appcheck.AppCheckToken -import com.google.firebase.appcheck.FirebaseAppCheck -import com.google.firebase.ktx.Firebase -import com.google.firebase.ktx.app -import com.google.firebase.ktx.initialize -import com.google.firebase.platforminfo.UserAgentPublisher -import org.junit.After -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith - -const val APP_ID = "APP_ID" -const val API_KEY = "API_KEY" - -const val EXISTING_APP = "existing" - -@RunWith(AndroidJUnit4ClassRunner::class) -abstract class BaseTestCase { - @Before - fun setUp() { - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build() - ) - - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build(), - EXISTING_APP - ) - } - - @After - fun cleanUp() { - FirebaseApp.clearInstancesForTest() - } -} - -@RunWith(AndroidJUnit4ClassRunner::class) -class FirebaseAppCheckTests : BaseTestCase() { - @Test - fun appCheck_default_callsDefaultGetInstance() { - assertThat(Firebase.appCheck).isSameInstanceAs(FirebaseAppCheck.getInstance()) - } - - @Test - fun appCheck_with_custom_firebaseapp_calls_GetInstance() { - val app = Firebase.app(EXISTING_APP) - assertThat(Firebase.appCheck(app)).isSameInstanceAs(FirebaseAppCheck.getInstance(app)) - } - - @Test - fun appCheckToken_destructuring_declaration_works() { - val mockAppCheckToken = - object : AppCheckToken() { - override fun getToken(): String = "randomToken" - - override fun getExpireTimeMillis(): Long = 23121997 - } - - val (token, expiration) = mockAppCheckToken - - assertThat(token).isEqualTo(mockAppCheckToken.token) - assertThat(expiration).isEqualTo(mockAppCheckToken.expireTimeMillis) - } -} - -@RunWith(AndroidJUnit4ClassRunner::class) -class LibraryVersionTest : BaseTestCase() { - @Test - fun libraryRegistrationAtRuntime() { - val publisher = Firebase.app.get(UserAgentPublisher::class.java) - } -} diff --git a/appcheck/firebase-appcheck/src/main/java/com/google/firebase/appcheck/ktx/FirebaseAppCheck.kt b/appcheck/firebase-appcheck/src/main/java/com/google/firebase/appcheck/ktx/FirebaseAppCheck.kt deleted file mode 100644 index 15e1f5b2189..00000000000 --- a/appcheck/firebase-appcheck/src/main/java/com/google/firebase/appcheck/ktx/FirebaseAppCheck.kt +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2022 Google LLC - * - * 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.google.firebase.appcheck.ktx - -import com.google.firebase.FirebaseApp -import com.google.firebase.appcheck.AppCheckToken -import com.google.firebase.appcheck.FirebaseAppCheck -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.ktx.Firebase -import com.google.firebase.ktx.app - -/** - * Accessing this object for Kotlin apps has changed; see the - * [migration guide](https://firebase.google.com/docs/android/kotlin-migration). - * - * Returns the [FirebaseAppCheck] instance of the default [FirebaseApp]. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-appcheck-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -val Firebase.appCheck: FirebaseAppCheck - get() = FirebaseAppCheck.getInstance() - -/** - * Accessing this object for Kotlin apps has changed; see the - * [migration guide](https://firebase.google.com/docs/android/kotlin-migration). - * - * Returns the [FirebaseAppCheck] instance of a given [FirebaseApp]. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-appcheck-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -fun Firebase.appCheck(app: FirebaseApp) = FirebaseAppCheck.getInstance(app) - -/** - * Destructuring declaration for [AppCheckToken] to provide token. - * - * @return the token of the [AppCheckToken] - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-appcheck-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -operator fun AppCheckToken.component1() = token - -/** - * Destructuring declaration for [AppCheckToken] to provide expireTimeMillis. - * - * @return the expireTimeMillis of the [AppCheckToken] - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-appcheck-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -operator fun AppCheckToken.component2() = expireTimeMillis - -/** - * @suppress - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-appcheck-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -class FirebaseAppCheckKtxRegistrar : ComponentRegistrar { - override fun getComponents(): List> = listOf() -} diff --git a/docs/ktx/common.md b/docs/ktx/common.md deleted file mode 100644 index 3935c9e1b9c..00000000000 --- a/docs/ktx/common.md +++ /dev/null @@ -1,42 +0,0 @@ -# Firebase Common Kotlin Extensions - -## Getting Started - -To use the Firebase Common Android SDK with Kotlin Extensions, add the following -to your app's `build.gradle` file: - -```groovy -// See maven.google.com for the latest versions -// This library transitively includes the firebase-common library -implementation 'com.google.firebase:firebase-common-ktx:$VERSION' -``` - -## Features - -### Get the default FirebaseApp and FirebaseOptions - -**Kotlin** -```kotlin -val defaultApp = FirebaseApp.getInstance() -val defaultOptions = defaultApp.options -``` - -**Kotlin + KTX** -```kotlin -val defaultApp = Firebase.app -val defaultOptions = Firebase.options -``` - -### Initialize a FirebaseApp - -**Kotlin** -```kotlin -val options = FirebaseApp.getInstance().options -val anotherApp = FirebaseApp.initializeApp(context, options, "myApp") -``` - -**Kotlin + KTX** -```kotlin -var anotherApp = Firebase.initialize(context, Firebase.options, "myApp") -``` - diff --git a/docs/ktx/crashlytics.md b/docs/ktx/crashlytics.md deleted file mode 100644 index 687944ba2e4..00000000000 --- a/docs/ktx/crashlytics.md +++ /dev/null @@ -1,50 +0,0 @@ -# Crashlytics Kotlin Extensions - -## Getting Started - -To use the Firebase Crashlytics Android SDK with Kotlin Extensions, add the following -to your app's `build.gradle` file: - -```groovy -// See maven.google.com for the latest versions -// This library transitively includes the firebase-crashlytics library -implementation 'com.google.firebase:firebase-crashlytics-ktx:$VERSION' -``` - -## Features - -### Get an instance of FirebaseCrashlytics - -**Kotlin** -```kotlin -val crashlytics = FirebaseCrashlytics.getInstance() -``` - -**Kotlin + KTX** -```kotlin -val crashlytics = Firebase.crashlytics -``` - -### Set custom keys - -**Kotlin** -```kotlin -crashlytics.setCustomKey("str_key", "hello") -crashlytics.setCustomKey("bool_key", true) -crashlytics.setCustomKey("int_key", 1) -crashlytics.setCustomKey("long_key", 1L) -crashlytics.setCustomKey("float_key", 1.0f) -crashlytics.setCustomKey("double_key", 1.0) -``` - -**Kotlin + KTX** -```kotlin -crashlytics.setCustomKeys { - key("str_key", "hello") - key("bool_key", true) - key("int_key", 1) - key("long_key", 1L) - key("float_key", 1.0f) - key("double_key", 1.0) -} -``` diff --git a/docs/ktx/database.md b/docs/ktx/database.md deleted file mode 100644 index d54d3497c84..00000000000 --- a/docs/ktx/database.md +++ /dev/null @@ -1,100 +0,0 @@ -# Realtime Database Kotlin Extensions - -## Getting Started - -To use the Firebase Realtime Database Android SDK with Kotlin Extensions, add the following -to your app's `build.gradle` file: - -```groovy -// See maven.google.com for the latest versions -// This library transitively includes the firebase-database library -implementation 'com.google.firebase:firebase-database-ktx:$VERSION' -``` - -## Features - -### Get an instance of FirebaseDatabase - -**Kotlin** -```kotlin -val database = FirebaseDatabase.getInstance() -val anotherDatabase = FirebaseDatabase.getInstance(FirebaseApp.getInstance("myApp")) -``` - -**Kotlin + KTX** -```kotlin -val database = Firebase.database -val anotherDatabase = Firebase.database(Firebase.app("myApp")) -``` - -### Get the FirebaseDatabase for the specified url - -**Kotlin** -```kotlin -val database = FirebaseDatabase.getInstance(url) -``` - -**Kotlin + KTX** -```kotlin -val database = Firebase.database(url) -``` - - -### Get the FirebaseDatabase of the given FirebaseApp and url - -**Kotlin** -```kotlin -val database = FirebaseDatabase.getInstance(app, url) -``` - -**Kotlin + KTX** -```kotlin -val database = Firebase.database(app, url) -``` - -### Convert a DataSnapshot to a POJO - -**Kotlin** -```kotlin -val snapshot: DataSnapshot = ... -val myObject = snapshot.getValue(MyClass::class.java) -``` - -**Kotlin + KTX** -```kotlin -val snapshot: DocumentSnapshot = ... -val myObject = snapshot.getValue() -``` - -### Convert a DataSnapshot to generic types such as List or Map - -**Kotlin** -```kotlin -val snapshot: DataSnapshot = ... -val typeIndicator = object : GenericTypeIndicator>() {} -val messages: List = snapshot.getValue(typeIndicator) -``` - -**Kotlin + KTX** -```kotlin -val snapshot: DocumentSnapshot = ... -val messages: List = snapshot.getValue>() -``` - -### Convert a MutableData to a POJO in a Transaction - -**Kotlin** -```kotlin -override fun doTransaction(mutableData: MutableData): Transaction.Result { - val post = mutableData.getValue(Post::class.java) - // ... -} -``` - -**Kotlin + KTX** -```kotlin -override fun doTransaction(mutableData: MutableData): Transaction.Result { - val post = mutableData.getValue() - // ... -} -``` diff --git a/docs/ktx/firestore.md b/docs/ktx/firestore.md deleted file mode 100644 index 276f6bc0820..00000000000 --- a/docs/ktx/firestore.md +++ /dev/null @@ -1,150 +0,0 @@ -# Firestore Kotlin Extensions - -## Getting Started - -To use the Cloud Firestore Android SDK with Kotlin Extensions, add the following -to your app's `build.gradle` file: - -```groovy -// See maven.google.com for the latest versions -// This library transitively includes the firebase-firestore library -implementation 'com.google.firebase:firebase-firestore-ktx:$VERSION' -``` - -## Features - -### Get an instance of FirebaseFirestore - -**Kotlin** -```kotlin -val firestore = FirebaseFirestore.getInstance() -val anotherFirestore = FirebaseFirestore.getInstance(FirebaseApp.getInstance("myApp")) -``` - -**Kotlin + KTX** -```kotlin -val firestore = Firebase.firestore -val anotherFirestore = Firebase.firestore(Firebase.app("myApp")) -``` - -### Get a document - -**Kotlin** -```kotlin -firestore.collection("cities") - .document("LON") - .addSnapshotListener { document: DocumentSnapshot?, error: -> - if (error != null) { - // Handle error - return@addSnapshotListener - } - if (document != null) { - // Use document - } - } -``` - -**Kotlin + KTX** -```kotlin -firestore.collection("cities") - .document("LON") - .snapshots() - .collect { document: DocumentSnapshot -> - // Use document - } -``` - -### Query documents - -**Kotlin** -```kotlin -firestore.collection("cities") - .whereEqualTo("capital", true) - .addSnapshotListener { documents: QuerySnapshot?, error -> - if (error != null) { - // Handle error - return@addSnapshotListener - } - if (documents != null) { - for (document in documents) { - // Use document - } - } - } -``` - -**Kotlin + KTX** -```kotlin -firestore.collection("cities") - .whereEqualTo("capital", true) - .snapshots() - .collect { documents: QuerySnapshot -> - for (document in documents) { - // Use document - } - } -``` - -### Convert a DocumentSnapshot field to a POJO - -**Kotlin** -```kotlin -val snapshot: DocumentSnapshot = ... -val myObject = snapshot.get("fieldPath", MyClass::class.java) -``` - -**Kotlin + KTX** -```kotlin -val snapshot: DocumentSnapshot = ... -val myObject = snapshot.get("fieldPath") -``` - -### Convert a DocumentSnapshot to a POJO - -**Kotlin** -```kotlin -val snapshot: DocumentSnapshot = ... -val myObject = snapshot.toObject(MyClass::class.java) -``` - -**Kotlin + KTX** -```kotlin -val snapshot: DocumentSnapshot = ... -val myObject = snapshot.toObject() -``` - -### Convert a QuerySnapshot to a list of POJOs - -**Kotlin** -```kotlin -val snapshot: QuerySnapshot = ... -val objectList = snapshot.toObjects(MyClass::class.java) -``` - -**Kotlin + KTX** -```kotlin -val snapshot: QuerySnapshot = ... -val objectList = snapshot.toObjects() -``` - -### Setup Firestore with a local emulator - -**Kotlin** -```kotlin -val settings = FirebaseFirestoreSettings.Builder() - .setHost("10.0.2.2:8080") - .setSslEnabled(false) - .setPersistenceEnabled(false) - .build() - -firestore.setFirestoreSettings(settings) -``` - -**Kotlin + KTX** -```kotlin -firestore.firestoreSettings = firestoreSettings { - host = "http://10.0.2.2:8080" - isSslEnabled = false - isPersistenceEnabled = false -} -``` diff --git a/docs/ktx/functions.md b/docs/ktx/functions.md deleted file mode 100644 index 6de19ce53ed..00000000000 --- a/docs/ktx/functions.md +++ /dev/null @@ -1,62 +0,0 @@ -# Cloud Functions Kotlin Extensions - -## Getting Started - -To use the Cloud Functions Android SDK with Kotlin Extensions, add the following -to your app's `build.gradle` file: - -```groovy -// See maven.google.com for the latest versions -// This library transitively includes the firebase-functions library -implementation 'com.google.firebase:firebase-functions-ktx:$VERSION' -``` - -## Features - -### Get the FirebaseFunctions instance of the default app - -**Kotlin** -```kotlin -val functions = FirebaseFunctions.getInstance() -``` - -**Kotlin + KTX** -```kotlin -val functions = Firebase.functions -``` - -### Get the FirebaseFunctions of a given region - -**Kotlin** -```kotlin -val functions = FirebaseFunctions.getInstance(region) -``` - -**Kotlin + KTX** -```kotlin -val functions = Firebase.functions(region) -``` - -### Get the FirebaseFunctions of a given FirebaseApp - -**Kotlin** -```kotlin -val functions = FirebaseFunctions.getInstance(app) -``` - -**Kotlin + KTX** -```kotlin -val functions = Firebase.functions(app) -``` - -### Get the FirebaseFunctions of a given region and FirebaseApp - -**Kotlin** -```kotlin -val functions = FirebaseFunctions.getInstance(app, region) -``` - -**Kotlin + KTX** -```kotlin -val functions = Firebase.functions(app, region) -``` diff --git a/docs/ktx/inappmessaging-display.md b/docs/ktx/inappmessaging-display.md deleted file mode 100644 index 82a6d3702cc..00000000000 --- a/docs/ktx/inappmessaging-display.md +++ /dev/null @@ -1,26 +0,0 @@ -# In-App Messaging Display Kotlin Extensions - -## Getting Started - -To use the Firebase In-App Messaging Display Android SDK with Kotlin Extensions, add the following -to your app's `build.gradle` file: - -```groovy -// See maven.google.com for the latest versions -// This library transitively includes the firebase-inappmessaging-display library -implementation 'com.google.firebase:firebase-inappmessaging-display-ktx:$VERSION' -``` - -## Features - -### Get an instance of FirebaseInAppMessagingDisplay - -**Kotlin** -```kotlin -val fiamUI = FirebaseInAppMessagingDisplay.getInstance() -``` - -**Kotlin + KTX** -```kotlin -val fiamUI = Firebase.inAppMessagingDisplay -``` diff --git a/docs/ktx/inappmessaging.md b/docs/ktx/inappmessaging.md deleted file mode 100644 index 13f90d7d84f..00000000000 --- a/docs/ktx/inappmessaging.md +++ /dev/null @@ -1,26 +0,0 @@ -# In-App Messaging Kotlin Extensions - -## Getting Started - -To use the Firebase In-App Messaging Android SDK with Kotlin Extensions, add the following -to your app's `build.gradle` file: - -```groovy -// See maven.google.com for the latest versions -// This library transitively includes the firebase-inappmessaging library -implementation 'com.google.firebase:firebase-inappmessaging-ktx:$VERSION' -``` - -## Features - -### Get an instance of FirebaseInAppMessaging - -**Kotlin** -```kotlin -val fiamUI = FirebaseInAppMessaging.getInstance() -``` - -**Kotlin + KTX** -```kotlin -val fiamUI = Firebase.inAppMessaging -``` diff --git a/docs/ktx/remote-config.md b/docs/ktx/remote-config.md deleted file mode 100644 index 4f685cea793..00000000000 --- a/docs/ktx/remote-config.md +++ /dev/null @@ -1,86 +0,0 @@ -# Remote Config Kotlin Extensions - -## Getting Started - -To use the Firebase Remote Config Android SDK with Kotlin Extensions, add the following -to your app's `build.gradle` file: - -```groovy -// See maven.google.com for the latest versions -// This library transitively includes the firebase-config library -implementation 'com.google.firebase:firebase-config-ktx:$VERSION' -``` - -## Features - -### Get the FirebaseRemoteConfig instance of the default app - -**Kotlin** -```kotlin -val remoteConfig = FirebaseRemoteConfig.getInstance() -``` - -**Kotlin + KTX** -```kotlin -val remoteConfig = Firebase.remoteConfig -``` - -### Get the FirebaseRemoteConfig of a given FirebaseApp - -**Kotlin** -```kotlin -val remoteConfig = FirebaseRemoteConfig.getInstance(app) -``` - -**Kotlin + KTX** -```kotlin -val remoteConfig = Firebase.remoteConfig(app) -``` - -### Get parameter values from FirebaseRemoteConfig - -**Kotlin** -```kotlin -val isEnabled = remoteConfig.getBoolean("is_enabled") - -val fileBytes = remoteConfig.getByteArray("file_bytes") - -val audioVolume = remoteConfig.getDouble("audio_volume") - -val maxCharacters = remoteConfig.getLong("max_characters") - -val accessKey = remoteConfig.getString("access_key") -``` - -**Kotlin + KTX** -```kotlin -val isEnabled = remoteConfig["is_enabled"].asBoolean() - -val fileBytes = remoteConfig["file_bytes"].asByteArray() - -val audioVolume = remoteConfig["audio_volume"].asDouble() - -val maxCharacters = remoteConfig["max_characters"].asLong() - -val accessKey = remoteConfig["access_key"].asString() -``` - -### Set Remote Config Settings - -**Kotlin** -```kotlin -val configSettings = FirebaseRemoteConfigSettings.Builder() - .setMinimumFetchIntervalInSeconds(3600) - .setFetchTimeoutInSeconds(60) - .build() -remoteConfig.setConfigSettingsAsync(configSettings) -``` - -**Kotlin + KTX** -```kotlin -val configSettings = remoteConfigSettings { - minimumFetchIntervalInSeconds = 3600 - fetchTimeoutInSeconds = 60 -} -remoteConfig.setConfigSettingsAsync(configSettings) -``` \ No newline at end of file diff --git a/docs/ktx/storage.md b/docs/ktx/storage.md deleted file mode 100644 index 5854723fe6e..00000000000 --- a/docs/ktx/storage.md +++ /dev/null @@ -1,62 +0,0 @@ -# Storage Kotlin Extensions - -## Getting Started - -To use the Cloud Storage Android SDK with Kotlin Extensions, add the following -to your app's `build.gradle` file: - -```groovy -// See maven.google.com for the latest versions -// This library transitively includes the firebase-storage library -implementation 'com.google.firebase:firebase-storage-ktx:$VERSION' -``` - -## Features - -### Get an instance of FirebaseStorage - -**Kotlin** -```kotlin -val storage = FirebaseStorage.getInstance() -val anotherStorage = FirebaseStorage.getInstance(FirebaseApp.getInstance("myApp")) -``` - -**Kotlin + KTX** -```kotlin -val storage = Firebase.storage -val anotherStorage = Firebase.storage(Firebase.app("myApp")) -``` - -### Get the FirebaseStorage for a custom storage bucket url - -**Kotlin** -```kotlin -val storage = FirebaseStorage.getInstance("gs://my-custom-bucket") -val anotherStorage = FirebaseStorage.getInstance(FirebaseApp.getInstance("myApp"), "gs://my-custom-bucket") -``` - -**Kotlin + KTX** -```kotlin -val storage = Firebase.storage("gs://my-custom-bucket") -val anotherStorage = Firebase.storage(Firebase.app("myApp"), "gs://my-custom-bucket") -``` - -### Create file metadata - -**Kotlin** -```kotlin -val metadata = StorageMetadata.Builder() - .setContentType("image/jpg") - .setContentDisposition("attachment") - .setCustomMetadata("location", "Maputo, MOZ") - .build() -``` - -**Kotlin + KTX** -```kotlin -val metadata = storageMetadata { - contentType = "image/jpg" - contentDisposition = "attachment" - setCustomMetadata("location", "Maputo, MOZ") -} -``` diff --git a/firebase-appdistribution-api/api.txt b/firebase-appdistribution-api/api.txt index 4e823a730f8..94c06f1068f 100644 --- a/firebase-appdistribution-api/api.txt +++ b/firebase-appdistribution-api/api.txt @@ -99,18 +99,3 @@ package com.google.firebase.appdistribution { } -package com.google.firebase.appdistribution.ktx { - - public final class FirebaseAppDistributionKt { - method @Deprecated public static operator com.google.firebase.appdistribution.BinaryType component1(com.google.firebase.appdistribution.AppDistributionRelease); - method @Deprecated public static operator long component1(com.google.firebase.appdistribution.UpdateProgress); - method @Deprecated public static operator String component2(com.google.firebase.appdistribution.AppDistributionRelease); - method @Deprecated public static operator long component2(com.google.firebase.appdistribution.UpdateProgress); - method @Deprecated public static operator long component3(com.google.firebase.appdistribution.AppDistributionRelease); - method @Deprecated public static operator com.google.firebase.appdistribution.UpdateStatus component3(com.google.firebase.appdistribution.UpdateProgress); - method @Deprecated public static operator String? component4(com.google.firebase.appdistribution.AppDistributionRelease); - method @Deprecated public static com.google.firebase.appdistribution.FirebaseAppDistribution getAppDistribution(com.google.firebase.ktx.Firebase); - } - -} - diff --git a/firebase-appdistribution-api/firebase-appdistribution-api.gradle b/firebase-appdistribution-api/firebase-appdistribution-api.gradle index 71416c85e58..c3959df12db 100644 --- a/firebase-appdistribution-api/firebase-appdistribution-api.gradle +++ b/firebase-appdistribution-api/firebase-appdistribution-api.gradle @@ -54,7 +54,6 @@ android { dependencies { api libs.playservices.tasks api("com.google.firebase:firebase-common:21.0.0") - api("com.google.firebase:firebase-common-ktx:21.0.0") api("com.google.firebase:firebase-components:18.0.0") implementation libs.androidx.annotation diff --git a/firebase-appdistribution-api/ktx/api.txt b/firebase-appdistribution-api/ktx/api.txt deleted file mode 100644 index da4f6cc18fe..00000000000 --- a/firebase-appdistribution-api/ktx/api.txt +++ /dev/null @@ -1 +0,0 @@ -// Signature format: 3.0 diff --git a/firebase-appdistribution-api/ktx/gradle.properties b/firebase-appdistribution-api/ktx/gradle.properties deleted file mode 100644 index 9eff84e6c72..00000000000 --- a/firebase-appdistribution-api/ktx/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -android.enableUnitTestBinaryResources=true diff --git a/firebase-appdistribution-api/ktx/ktx.gradle b/firebase-appdistribution-api/ktx/ktx.gradle deleted file mode 100644 index 12398b0347c..00000000000 --- a/firebase-appdistribution-api/ktx/ktx.gradle +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2021 Google LLC -// -// 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. - -plugins { - id 'firebase-library' - id("kotlin-android") -} - -firebaseLibrary { - libraryGroup = "appdistribution" - testLab.enabled = true - publishJavadoc = false - releaseNotes { - enabled.set(false) - } - previewMode = "beta" -} - -android { - namespace "com.google.firebase.appdistribution.ktx" - compileSdkVersion project.compileSdkVersion - defaultConfig { - minSdkVersion project.minSdkVersion - multiDexEnabled true - targetSdkVersion project.targetSdkVersion - versionName version - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - test.java { - srcDir 'src/test/kotlin' - } - androidTest.java.srcDirs += 'src/androidTest/kotlin' - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = '1.8' - } - testOptions.unitTests.includeAndroidResources = true -} - -dependencies { - api(project(":firebase-appdistribution-api")) - api("com.google.firebase:firebase-common:21.0.0") - api("com.google.firebase:firebase-common-ktx:21.0.0") - - implementation("com.google.firebase:firebase-components:18.0.0") - - testImplementation libs.truth - testImplementation 'junit:junit:4.12' - testImplementation 'org.mockito:mockito-core:2.25.0' - testImplementation libs.robolectric - - androidTestImplementation libs.androidx.test.core - androidTestImplementation 'androidx.test:runner:1.2.0' - androidTestImplementation libs.truth - androidTestImplementation 'junit:junit:4.12' -} diff --git a/firebase-appdistribution-api/ktx/src/androidTest/AndroidManifest.xml b/firebase-appdistribution-api/ktx/src/androidTest/AndroidManifest.xml deleted file mode 100644 index b8b4e405e38..00000000000 --- a/firebase-appdistribution-api/ktx/src/androidTest/AndroidManifest.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - diff --git a/firebase-appdistribution-api/ktx/src/androidTest/kotlin/com/google/firebase/app/distribution/ktx/FirebaseAppDistributionTests.kt b/firebase-appdistribution-api/ktx/src/androidTest/kotlin/com/google/firebase/app/distribution/ktx/FirebaseAppDistributionTests.kt deleted file mode 100644 index a818396f7c6..00000000000 --- a/firebase-appdistribution-api/ktx/src/androidTest/kotlin/com/google/firebase/app/distribution/ktx/FirebaseAppDistributionTests.kt +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright 2021 Google LLC - * - * 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.google.firebase.appdistribution.ktx - -import androidx.test.core.app.ApplicationProvider -import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner -import com.google.common.truth.Truth.assertThat -import com.google.firebase.FirebaseApp -import com.google.firebase.FirebaseOptions -import com.google.firebase.appdistribution.AppDistributionRelease -import com.google.firebase.appdistribution.BinaryType -import com.google.firebase.appdistribution.FirebaseAppDistribution -import com.google.firebase.appdistribution.UpdateProgress -import com.google.firebase.appdistribution.UpdateStatus -import com.google.firebase.ktx.Firebase -import com.google.firebase.ktx.app -import com.google.firebase.ktx.initialize -import com.google.firebase.platforminfo.UserAgentPublisher -import org.junit.After -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith - -const val APP_ID = "APP_ID" -const val API_KEY = "API_KEY" - -const val EXISTING_APP = "existing" - -@RunWith(AndroidJUnit4ClassRunner::class) -abstract class BaseTestCase { - @Before - fun setUp() { - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build() - ) - - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build(), - EXISTING_APP - ) - } - - @After - fun cleanUp() { - FirebaseApp.clearInstancesForTest() - } -} - -@RunWith(AndroidJUnit4ClassRunner::class) -class FirebaseAppDistributionTests : BaseTestCase() { - @Test - fun appDistribution_default_callsDefaultGetInstance() { - assertThat(Firebase.appDistribution).isSameInstanceAs(FirebaseAppDistribution.getInstance()) - } - - @Test - fun appDistributionReleaseDestructuringDeclarationsWork() { - val mockAppDistributionRelease = - object : AppDistributionRelease { - override fun getDisplayVersion(): String = "1.0.0" - - override fun getVersionCode(): Long = 1L - - override fun getReleaseNotes(): String = "Changelog..." - - override fun getBinaryType(): BinaryType = BinaryType.AAB - } - - val (type, displayVersion, versionCode, notes) = mockAppDistributionRelease - - assertThat(type).isEqualTo(mockAppDistributionRelease.binaryType) - assertThat(displayVersion).isEqualTo(mockAppDistributionRelease.displayVersion) - assertThat(versionCode).isEqualTo(mockAppDistributionRelease.versionCode) - assertThat(notes).isEqualTo(mockAppDistributionRelease.releaseNotes) - } - - @Test - fun updateProgressDestructuringDeclarationsWork() { - val mockUpdateProgress = - object : UpdateProgress { - override fun getApkBytesDownloaded(): Long = 1200L - - override fun getApkFileTotalBytes(): Long = 9000L - - override fun getUpdateStatus(): UpdateStatus = UpdateStatus.DOWNLOADING - } - - val (downloaded, total, status) = mockUpdateProgress - - assertThat(downloaded).isEqualTo(mockUpdateProgress.apkBytesDownloaded) - assertThat(total).isEqualTo(mockUpdateProgress.apkFileTotalBytes) - assertThat(status).isEqualTo(mockUpdateProgress.updateStatus) - } -} - -internal const val LIBRARY_NAME: String = "fire-appdistribution-ktx" - -@RunWith(AndroidJUnit4ClassRunner::class) -class LibraryVersionTest : BaseTestCase() { - @Test - fun libraryRegistrationAtRuntime() { - val publisher = Firebase.app.get(UserAgentPublisher::class.java) - assertThat(publisher.userAgent).contains(LIBRARY_NAME) - } -} diff --git a/firebase-appdistribution-api/ktx/src/main/AndroidManifest.xml b/firebase-appdistribution-api/ktx/src/main/AndroidManifest.xml deleted file mode 100644 index 45c1bb0580b..00000000000 --- a/firebase-appdistribution-api/ktx/src/main/AndroidManifest.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/firebase-appdistribution-api/ktx/src/main/kotlin/com/google/firebase/appdistribution/ktx/Logging.kt b/firebase-appdistribution-api/ktx/src/main/kotlin/com/google/firebase/appdistribution/ktx/Logging.kt deleted file mode 100644 index e0e7e27519b..00000000000 --- a/firebase-appdistribution-api/ktx/src/main/kotlin/com/google/firebase/appdistribution/ktx/Logging.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2023 Google LLC - * - * 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.google.firebase.appdistribution.ktx - -import androidx.annotation.Keep -import com.google.firebase.appdistribution.BuildConfig -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.platforminfo.LibraryVersionComponent - -internal const val LIBRARY_NAME: String = "fire-appdistribution-ktx" - -/** @suppress */ -@Keep -class FirebaseAppdistributionApiLegacyRegistrar : ComponentRegistrar { - override fun getComponents(): List> { - return listOf(LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME)) - } -} diff --git a/firebase-appdistribution-api/src/main/java/com/google/firebase/appdistribution/ktx/FirebaseAppDistribution.kt b/firebase-appdistribution-api/src/main/java/com/google/firebase/appdistribution/ktx/FirebaseAppDistribution.kt deleted file mode 100644 index ccee214d131..00000000000 --- a/firebase-appdistribution-api/src/main/java/com/google/firebase/appdistribution/ktx/FirebaseAppDistribution.kt +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright 2021 Google LLC - * - * 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.google.firebase.appdistribution.ktx - -import androidx.annotation.Keep -import com.google.firebase.FirebaseApp -import com.google.firebase.appdistribution.AppDistributionRelease -import com.google.firebase.appdistribution.FirebaseAppDistribution -import com.google.firebase.appdistribution.UpdateProgress -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.ktx.Firebase - -/** - * Accessing this object for Kotlin apps has changed; see the - * [migration guide](https://firebase.google.com/docs/android/kotlin-migration). - * - * Returns the [FirebaseAppDistribution] instance of the default [FirebaseApp]. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase:firebase-appdistribution-api-ktx` are now deprecated. As early as April - * 2024, we'll no longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -val Firebase.appDistribution: FirebaseAppDistribution - get() = FirebaseAppDistribution.getInstance() - -/** - * Destructuring declaration for [AppDistributionRelease] to provide binaryType. - * - * @return the binaryType of the [AppDistributionRelease] - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase:firebase-appdistribution-api-ktx` are now deprecated. As early as April - * 2024, we'll no longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -operator fun AppDistributionRelease.component1() = binaryType - -/** - * Destructuring declaration for [AppDistributionRelease] to provide displayVersion. - * - * @return the displayVersion of the [AppDistributionRelease] - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase:firebase-appdistribution-api-ktx` are now deprecated. As early as April - * 2024, we'll no longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -operator fun AppDistributionRelease.component2() = displayVersion - -/** - * Destructuring declaration for [AppDistributionRelease] to provide versionCode. - * - * @return the versionCode of the [AppDistributionRelease] - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase:firebase-appdistribution-api-ktx` are now deprecated. As early as April - * 2024, we'll no longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -operator fun AppDistributionRelease.component3() = versionCode - -/** - * Destructuring declaration for [AppDistributionRelease] to provide releaseNotes. - * - * @return the releaseNotes of the [AppDistributionRelease] - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase:firebase-appdistribution-api-ktx` are now deprecated. As early as April - * 2024, we'll no longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -operator fun AppDistributionRelease.component4() = releaseNotes - -/** - * Destructuring declaration for [UpdateProgress] to provide apkBytesDownloaded. - * - * @return the apkBytesDownloaded of the [UpdateProgress] - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase:firebase-appdistribution-api-ktx` are now deprecated. As early as April - * 2024, we'll no longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -operator fun UpdateProgress.component1() = apkBytesDownloaded - -/** - * Destructuring declaration for [UpdateProgress] to provide apkFileTotalBytes. - * - * @return the apkFileTotalBytes of the [UpdateProgress] - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase:firebase-appdistribution-api-ktx` are now deprecated. As early as April - * 2024, we'll no longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -operator fun UpdateProgress.component2() = apkFileTotalBytes - -/** - * Destructuring declaration for [UpdateProgress] to provide updateStatus. - * - * @return the updateStatus of the [UpdateProgress] - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase:firebase-appdistribution-api-ktx` are now deprecated. As early as April - * 2024, we'll no longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -operator fun UpdateProgress.component3() = updateStatus - -/** - * @suppress - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase:firebase-appdistribution-api-ktx` are now deprecated. As early as April - * 2024, we'll no longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -@Keep -class FirebaseAppDistributionKtxRegistrar : ComponentRegistrar { - override fun getComponents(): List> = listOf() -} diff --git a/firebase-appdistribution/test-app/src/main/kotlin/com/googletest/firebase/appdistribution/testapp/CustomNotificationFeedbackTrigger.kt b/firebase-appdistribution/test-app/src/main/kotlin/com/googletest/firebase/appdistribution/testapp/CustomNotificationFeedbackTrigger.kt index d8690b2e73b..02d6921d3d2 100644 --- a/firebase-appdistribution/test-app/src/main/kotlin/com/googletest/firebase/appdistribution/testapp/CustomNotificationFeedbackTrigger.kt +++ b/firebase-appdistribution/test-app/src/main/kotlin/com/googletest/firebase/appdistribution/testapp/CustomNotificationFeedbackTrigger.kt @@ -31,8 +31,8 @@ import android.util.Log import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat import androidx.core.content.ContextCompat -import com.google.firebase.appdistribution.ktx.appDistribution -import com.google.firebase.ktx.Firebase +import com.google.firebase.appdistribution.appDistribution +import com.google.firebase.Firebase import java.io.IOException import com.google.firebase.appdistribution.testapp.R diff --git a/firebase-appdistribution/test-app/src/main/kotlin/com/googletest/firebase/appdistribution/testapp/MainActivity.kt b/firebase-appdistribution/test-app/src/main/kotlin/com/googletest/firebase/appdistribution/testapp/MainActivity.kt index 279361a0d47..9e63c387eac 100644 --- a/firebase-appdistribution/test-app/src/main/kotlin/com/googletest/firebase/appdistribution/testapp/MainActivity.kt +++ b/firebase-appdistribution/test-app/src/main/kotlin/com/googletest/firebase/appdistribution/testapp/MainActivity.kt @@ -42,9 +42,9 @@ import com.google.android.material.textfield.TextInputLayout import com.google.firebase.appdistribution.AppDistributionRelease import com.google.firebase.appdistribution.InterruptionLevel import com.google.firebase.appdistribution.UpdateProgress -import com.google.firebase.appdistribution.ktx.appDistribution +import com.google.firebase.appdistribution.appDistribution import com.google.firebase.appdistribution.testapp.BuildConfig -import com.google.firebase.ktx.Firebase +import com.google.firebase.Firebase import java.util.concurrent.ExecutorService import java.util.concurrent.Executors import com.google.firebase.appdistribution.testapp.R diff --git a/firebase-appdistribution/test-app/src/main/kotlin/com/googletest/firebase/appdistribution/testapp/ScreenshotDetectionFeedbackTrigger.kt b/firebase-appdistribution/test-app/src/main/kotlin/com/googletest/firebase/appdistribution/testapp/ScreenshotDetectionFeedbackTrigger.kt index c904ed1e507..1b031306a11 100644 --- a/firebase-appdistribution/test-app/src/main/kotlin/com/googletest/firebase/appdistribution/testapp/ScreenshotDetectionFeedbackTrigger.kt +++ b/firebase-appdistribution/test-app/src/main/kotlin/com/googletest/firebase/appdistribution/testapp/ScreenshotDetectionFeedbackTrigger.kt @@ -28,8 +28,8 @@ import android.provider.MediaStore import android.util.Log import androidx.annotation.RequiresApi import androidx.core.content.ContextCompat -import com.google.firebase.appdistribution.ktx.appDistribution -import com.google.firebase.ktx.Firebase +import com.google.firebase.appdistribution.appDistribution +import com.google.firebase.Firebase import java.util.* class ScreenshotDetectionFeedbackTrigger( diff --git a/firebase-appdistribution/test-app/src/main/kotlin/com/googletest/firebase/appdistribution/testapp/SecondActivity.kt b/firebase-appdistribution/test-app/src/main/kotlin/com/googletest/firebase/appdistribution/testapp/SecondActivity.kt index 950d65b096e..b73845fbd1d 100644 --- a/firebase-appdistribution/test-app/src/main/kotlin/com/googletest/firebase/appdistribution/testapp/SecondActivity.kt +++ b/firebase-appdistribution/test-app/src/main/kotlin/com/googletest/firebase/appdistribution/testapp/SecondActivity.kt @@ -23,8 +23,8 @@ import android.view.MenuInflater import android.view.MenuItem import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.AppCompatButton -import com.google.firebase.appdistribution.ktx.appDistribution -import com.google.firebase.ktx.Firebase +import com.google.firebase.appdistribution.appDistribution +import com.google.firebase.Firebase import com.google.firebase.appdistribution.testapp.R class SecondActivity : AppCompatActivity() { diff --git a/firebase-appdistribution/test-app/src/main/kotlin/com/googletest/firebase/appdistribution/testapp/ShakeDetectionFeedbackTrigger.kt b/firebase-appdistribution/test-app/src/main/kotlin/com/googletest/firebase/appdistribution/testapp/ShakeDetectionFeedbackTrigger.kt index 5481ccd603d..5d0bb7722e5 100644 --- a/firebase-appdistribution/test-app/src/main/kotlin/com/googletest/firebase/appdistribution/testapp/ShakeDetectionFeedbackTrigger.kt +++ b/firebase-appdistribution/test-app/src/main/kotlin/com/googletest/firebase/appdistribution/testapp/ShakeDetectionFeedbackTrigger.kt @@ -21,8 +21,8 @@ import android.app.Application import android.hardware.SensorManager import android.os.Bundle import android.util.Log -import com.google.firebase.appdistribution.ktx.appDistribution -import com.google.firebase.ktx.Firebase +import com.google.firebase.appdistribution.appDistribution +import com.google.firebase.Firebase import com.squareup.seismic.ShakeDetector import com.google.firebase.appdistribution.testapp.R diff --git a/firebase-appdistribution/test-app/test-app.gradle b/firebase-appdistribution/test-app/test-app.gradle index 420224b9e78..5af5540892f 100644 --- a/firebase-appdistribution/test-app/test-app.gradle +++ b/firebase-appdistribution/test-app/test-app.gradle @@ -82,7 +82,6 @@ dependencies { // In this test project we also need to explicitly declare these dependencies implementation project(':firebase-appdistribution-api') // All variants use the API - implementation project(':firebase-appdistribution-api:ktx') implementation "androidx.activity:activity-ktx:1.6.0" implementation 'androidx.appcompat:appcompat:1.5.1' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' @@ -91,7 +90,6 @@ dependencies { implementation "androidx.fragment:fragment-ktx:1.5.3" implementation "com.google.android.gms:play-services-tasks:18.0.2" implementation 'com.google.android.material:material:1.6.1' - implementation 'com.google.firebase:firebase-common-ktx:21.0.0' // Shake detection implementation 'com.squareup:seismic:1.0.3' // Other dependencies diff --git a/firebase-common/api.txt b/firebase-common/api.txt index 57f4f898a25..4da45aa2621 100644 --- a/firebase-common/api.txt +++ b/firebase-common/api.txt @@ -82,23 +82,6 @@ package com.google.firebase { } -package com.google.firebase.ktx { - - @Deprecated public final class Firebase { - field @Deprecated public static final com.google.firebase.ktx.Firebase INSTANCE; - } - - public final class FirebaseKt { - method @Deprecated public static com.google.firebase.FirebaseApp app(com.google.firebase.ktx.Firebase, String name); - method @Deprecated public static com.google.firebase.FirebaseApp getApp(com.google.firebase.ktx.Firebase); - method @Deprecated public static com.google.firebase.FirebaseOptions getOptions(com.google.firebase.ktx.Firebase); - method @Deprecated public static com.google.firebase.FirebaseApp? initialize(com.google.firebase.ktx.Firebase, android.content.Context context); - method @Deprecated public static com.google.firebase.FirebaseApp initialize(com.google.firebase.ktx.Firebase, android.content.Context context, com.google.firebase.FirebaseOptions options); - method @Deprecated public static com.google.firebase.FirebaseApp initialize(com.google.firebase.ktx.Firebase, android.content.Context context, com.google.firebase.FirebaseOptions options, String name); - } - -} - package com.google.firebase.provider { public class FirebaseInitProvider extends android.content.ContentProvider { diff --git a/firebase-common/firebase-common.gradle.kts b/firebase-common/firebase-common.gradle.kts index 52114f82558..7d576425b10 100644 --- a/firebase-common/firebase-common.gradle.kts +++ b/firebase-common/firebase-common.gradle.kts @@ -83,7 +83,6 @@ dependencies { androidTestImplementation(project(":integ-testing")) { exclude("com.google.firebase", "firebase-common") - exclude("com.google.firebase", "firebase-common-ktx") } // TODO(Remove when FirbaseAppTest has been modernized to use LiveData) diff --git a/firebase-common/ktx/api.txt b/firebase-common/ktx/api.txt deleted file mode 100644 index da4f6cc18fe..00000000000 --- a/firebase-common/ktx/api.txt +++ /dev/null @@ -1 +0,0 @@ -// Signature format: 3.0 diff --git a/firebase-common/ktx/gradle.properties b/firebase-common/ktx/gradle.properties deleted file mode 100644 index 9eff84e6c72..00000000000 --- a/firebase-common/ktx/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -android.enableUnitTestBinaryResources=true diff --git a/firebase-common/ktx/ktx.gradle.kts b/firebase-common/ktx/ktx.gradle.kts deleted file mode 100644 index 61553f0adeb..00000000000 --- a/firebase-common/ktx/ktx.gradle.kts +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2022 Google LLC -// -// 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. - -plugins { - id("firebase-library") - id("kotlin-android") -} - -firebaseLibrary { - libraryGroup = "common" - publishJavadoc = false - releaseNotes { enabled.set(false) } -} - -android { - val compileSdkVersion: Int by rootProject - val targetSdkVersion: Int by rootProject - val minSdkVersion: Int by rootProject - compileSdk = compileSdkVersion - namespace = "com.google.firebase.ktx" - defaultConfig { - minSdk = minSdkVersion - targetSdk = targetSdkVersion - } - sourceSets { - getByName("main") { java.srcDirs("src/main/kotlin") } - getByName("test") { java.srcDirs("src/test/kotlin") } - } - kotlinOptions { jvmTarget = "1.8" } - testOptions.unitTests.isIncludeAndroidResources = true -} - -dependencies { - api(project(":firebase-common")) - implementation("com.google.firebase:firebase-components:18.0.0") - implementation("com.google.firebase:firebase-annotations:16.2.0") - testImplementation(libs.androidx.test.core) - testImplementation(libs.junit) - testImplementation(libs.kotlin.coroutines.test) - testImplementation(libs.robolectric) - testImplementation(libs.truth) -} diff --git a/firebase-common/ktx/src/main/AndroidManifest.xml b/firebase-common/ktx/src/main/AndroidManifest.xml deleted file mode 100644 index 4e04e3fece4..00000000000 --- a/firebase-common/ktx/src/main/AndroidManifest.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - diff --git a/firebase-common/ktx/src/main/kotlin/com/google/firebase/ktx/Logging.kt b/firebase-common/ktx/src/main/kotlin/com/google/firebase/ktx/Logging.kt deleted file mode 100644 index 5ba2cf4d54c..00000000000 --- a/firebase-common/ktx/src/main/kotlin/com/google/firebase/ktx/Logging.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2023 Google LLC - * - * 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.google.firebase.ktx - -import androidx.annotation.Keep -import com.google.firebase.BuildConfig -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.platforminfo.LibraryVersionComponent - -internal const val LIBRARY_NAME: String = "fire-core-ktx" - -/** @suppress */ -@Keep -class FirebaseCommonLegacyRegistrar : ComponentRegistrar { - override fun getComponents(): List> { - return listOf(LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME)) - } -} diff --git a/firebase-common/ktx/src/test/kotlin/com/google/firebase/ktx/Tests.kt b/firebase-common/ktx/src/test/kotlin/com/google/firebase/ktx/Tests.kt deleted file mode 100644 index bc3eeb54cd5..00000000000 --- a/firebase-common/ktx/src/test/kotlin/com/google/firebase/ktx/Tests.kt +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * 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.google.firebase.ktx - -import androidx.test.core.app.ApplicationProvider -import com.google.android.gms.tasks.Tasks -import com.google.common.truth.Truth.assertThat -import com.google.firebase.FirebaseApp -import com.google.firebase.FirebaseOptions -import com.google.firebase.platforminfo.UserAgentPublisher -import kotlinx.coroutines.tasks.await -import kotlinx.coroutines.test.runTest -import org.junit.Assert.fail -import org.junit.Test -import org.junit.runner.RunWith -import org.robolectric.RobolectricTestRunner - -fun withApp(name: String, block: FirebaseApp.() -> Unit) { - val app = - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder().setApplicationId("appId").build(), - name - ) - try { - block(app) - } finally { - app.delete() - } -} - -class TestException(message: String) : Exception(message) - -@RunWith(RobolectricTestRunner::class) -class VersionTests { - @Test - fun libraryVersions_shouldBeRegisteredWithRuntime() { - withApp("ktxTestApp") { - val uaPublisher = get(UserAgentPublisher::class.java) - assertThat(uaPublisher.userAgent).contains("kotlin") - assertThat(uaPublisher.userAgent).contains(LIBRARY_NAME) - } - } -} - -@RunWith(RobolectricTestRunner::class) -class KtxTests { - @Test - fun `Firebase#app should delegate to FirebaseApp#getInstance()`() { - withApp(FirebaseApp.DEFAULT_APP_NAME) { - assertThat(Firebase.app).isSameInstanceAs(FirebaseApp.getInstance()) - } - } - - @Test - fun `Firebase#app(String) should delegate to FirebaseApp#getInstance(String)`() { - val appName = "testApp" - withApp(appName) { - assertThat(Firebase.app(appName)).isSameInstanceAs(FirebaseApp.getInstance(appName)) - } - } - - @Test - fun `Firebase#options should delegate to FirebaseApp#getInstance()#options`() { - withApp(FirebaseApp.DEFAULT_APP_NAME) { - assertThat(Firebase.options).isSameInstanceAs(FirebaseApp.getInstance().options) - } - } - - @Test - fun `Firebase#initialize(Context, FirebaseOptions) should initialize the app correctly`() { - val options = FirebaseOptions.Builder().setApplicationId("appId").build() - val app = Firebase.initialize(ApplicationProvider.getApplicationContext(), options) - try { - assertThat(app).isNotNull() - assertThat(app.name).isEqualTo(FirebaseApp.DEFAULT_APP_NAME) - assertThat(app.options).isSameInstanceAs(options) - assertThat(app.applicationContext) - .isSameInstanceAs(ApplicationProvider.getApplicationContext()) - } finally { - app.delete() - } - } - - @Test - fun `Firebase#initialize(Context, FirebaseOptions, String) should initialize the app correctly`() { - val options = FirebaseOptions.Builder().setApplicationId("appId").build() - val name = "appName" - val app = Firebase.initialize(ApplicationProvider.getApplicationContext(), options, name) - try { - assertThat(app).isNotNull() - assertThat(app.name).isEqualTo(name) - assertThat(app.options).isSameInstanceAs(options) - assertThat(app.applicationContext) - .isSameInstanceAs(ApplicationProvider.getApplicationContext()) - } finally { - app.delete() - } - } -} - -class CoroutinesPlayServicesTests { - // We are only interested in the await() function offered by kotlinx-coroutines-play-services - // So we're not testing the other functions provided by that library. - - @Test - fun `Task#await() resolves to the same result as Task#getResult()`() = runTest { - val task = Tasks.forResult(21) - - val expected = task.result - val actual = task.await() - - assertThat(actual).isEqualTo(expected) - assertThat(task.isSuccessful).isTrue() - assertThat(task.exception).isNull() - } - - @Test - fun `Task#await() throws an Exception for failing Tasks`() = runTest { - val task = Tasks.forException(TestException("some error happened")) - - try { - task.await() - fail("Task#await should throw an Exception") - } catch (e: Exception) { - assertThat(e).isInstanceOf(TestException::class.java) - assertThat(task.isSuccessful).isFalse() - } - } -} diff --git a/firebase-common/src/main/java/com/google/firebase/ktx/Firebase.kt b/firebase-common/src/main/java/com/google/firebase/ktx/Firebase.kt deleted file mode 100644 index c126b285c99..00000000000 --- a/firebase-common/src/main/java/com/google/firebase/ktx/Firebase.kt +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * 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.google.firebase.ktx - -import android.content.Context -import androidx.annotation.Keep -import com.google.firebase.FirebaseApp -import com.google.firebase.FirebaseOptions -import com.google.firebase.annotations.concurrent.Background -import com.google.firebase.annotations.concurrent.Blocking -import com.google.firebase.annotations.concurrent.Lightweight -import com.google.firebase.annotations.concurrent.UiThread -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.components.Dependency -import com.google.firebase.components.Qualified -import java.util.concurrent.Executor -import kotlinx.coroutines.CoroutineDispatcher -import kotlinx.coroutines.asCoroutineDispatcher - -/** - * All fields in this object are deprecated; Use `com.google.firebase.Firebase` instead. - * - * Single access point to all firebase SDKs from Kotlin. Acts as a target for extension methods - * provided by sdks. - * - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-common-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -object Firebase - -/** - * Accessing this object for Kotlin apps has changed; see the migration guide: - * https://firebase.google.com/docs/android/kotlin-migration. - * - * Returns the default firebase app instance. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-common-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration). - */ -val Firebase.app: FirebaseApp - get() = FirebaseApp.getInstance() - -/** - * Accessing this object for Kotlin apps has changed; see the migration guide: - * https://firebase.google.com/docs/android/kotlin-migration. - * - * Returns a named firebase app instance. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-common-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration). - */ -fun Firebase.app(name: String): FirebaseApp = FirebaseApp.getInstance(name) - -/** - * Initializes and returns a FirebaseApp. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-common-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -fun Firebase.initialize(context: Context): FirebaseApp? = FirebaseApp.initializeApp(context) - -/** - * Initializes and returns a FirebaseApp. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-common-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -fun Firebase.initialize(context: Context, options: FirebaseOptions): FirebaseApp = - FirebaseApp.initializeApp(context, options) - -/** - * Initializes and returns a FirebaseApp. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-common-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -fun Firebase.initialize(context: Context, options: FirebaseOptions, name: String): FirebaseApp = - FirebaseApp.initializeApp(context, options, name) - -/** - * Accessing this object for Kotlin apps has changed; see the migration guide: - * https://firebase.google.com/docs/android/kotlin-migration. - * - * Returns options of default FirebaseApp - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-common-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -val Firebase.options: FirebaseOptions - get() = Firebase.app.options - -/** @suppress */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -@Keep -class FirebaseCommonKtxRegistrar : ComponentRegistrar { - override fun getComponents(): List> { - return listOf( - coroutineDispatcher(), - coroutineDispatcher(), - coroutineDispatcher(), - coroutineDispatcher() - ) - } -} - -private inline fun coroutineDispatcher(): Component = - Component.builder(Qualified.qualified(T::class.java, CoroutineDispatcher::class.java)) - .add(Dependency.required(Qualified.qualified(T::class.java, Executor::class.java))) - .factory { c -> - c.get(Qualified.qualified(T::class.java, Executor::class.java)).asCoroutineDispatcher() - } - .build() diff --git a/firebase-common/src/test/java/com/google/firebase/ktx/Tests.kt b/firebase-common/src/test/java/com/google/firebase/ktx/Tests.kt deleted file mode 100644 index 4adc1167dbc..00000000000 --- a/firebase-common/src/test/java/com/google/firebase/ktx/Tests.kt +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * 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.google.firebase.ktx - -import androidx.test.core.app.ApplicationProvider -import com.google.android.gms.tasks.Tasks -import com.google.common.truth.Truth.assertThat -import com.google.firebase.FirebaseApp -import com.google.firebase.FirebaseOptions -import com.google.firebase.platforminfo.UserAgentPublisher -import kotlinx.coroutines.tasks.await -import kotlinx.coroutines.test.runTest -import org.junit.Assert.fail -import org.junit.Test -import org.junit.runner.RunWith -import org.robolectric.RobolectricTestRunner - -fun withApp(name: String, block: FirebaseApp.() -> Unit) { - val app = - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder().setApplicationId("appId").build(), - name - ) - try { - block(app) - } finally { - app.delete() - } -} - -class TestException(message: String) : Exception(message) - -@RunWith(RobolectricTestRunner::class) -class VersionTests { - @Test - fun libraryVersions_shouldBeRegisteredWithRuntime() { - withApp("ktxTestApp") { - val uaPublisher = get(UserAgentPublisher::class.java) - assertThat(uaPublisher.userAgent).contains("kotlin") - } - } -} - -@RunWith(RobolectricTestRunner::class) -class KtxTests { - @Test - fun `Firebase#app should delegate to FirebaseApp#getInstance()`() { - withApp(FirebaseApp.DEFAULT_APP_NAME) { - assertThat(Firebase.app).isSameInstanceAs(FirebaseApp.getInstance()) - } - } - - @Test - fun `Firebase#app(String) should delegate to FirebaseApp#getInstance(String)`() { - val appName = "testApp" - withApp(appName) { - assertThat(Firebase.app(appName)).isSameInstanceAs(FirebaseApp.getInstance(appName)) - } - } - - @Test - fun `Firebase#options should delegate to FirebaseApp#getInstance()#options`() { - withApp(FirebaseApp.DEFAULT_APP_NAME) { - assertThat(Firebase.options).isSameInstanceAs(FirebaseApp.getInstance().options) - } - } - - @Test - fun `Firebase#initialize(Context, FirebaseOptions) should initialize the app correctly`() { - val options = FirebaseOptions.Builder().setApplicationId("appId").build() - val app = Firebase.initialize(ApplicationProvider.getApplicationContext(), options) - try { - assertThat(app).isNotNull() - assertThat(app.name).isEqualTo(FirebaseApp.DEFAULT_APP_NAME) - assertThat(app.options).isSameInstanceAs(options) - assertThat(app.applicationContext) - .isSameInstanceAs(ApplicationProvider.getApplicationContext()) - } finally { - app.delete() - } - } - - @Test - fun `Firebase#initialize(Context, FirebaseOptions, String) should initialize the app correctly`() { - val options = FirebaseOptions.Builder().setApplicationId("appId").build() - val name = "appName" - val app = Firebase.initialize(ApplicationProvider.getApplicationContext(), options, name) - try { - assertThat(app).isNotNull() - assertThat(app.name).isEqualTo(name) - assertThat(app.options).isSameInstanceAs(options) - assertThat(app.applicationContext) - .isSameInstanceAs(ApplicationProvider.getApplicationContext()) - } finally { - app.delete() - } - } -} - -class CoroutinesPlayServicesTests { - // We are only interested in the await() function offered by kotlinx-coroutines-play-services - // So we're not testing the other functions provided by that library. - - @Test - fun `Task#await() resolves to the same result as Task#getResult()`() = runTest { - val task = Tasks.forResult(21) - - val expected = task.result - val actual = task.await() - - assertThat(actual).isEqualTo(expected) - assertThat(task.isSuccessful).isTrue() - assertThat(task.exception).isNull() - } - - @Test - fun `Task#await() throws an Exception for failing Tasks`() = runTest { - val task = Tasks.forException(TestException("some error happened")) - - try { - task.await() - fail("Task#await should throw an Exception") - } catch (e: Exception) { - assertThat(e).isInstanceOf(TestException::class.java) - assertThat(task.isSuccessful).isFalse() - } - } -} diff --git a/firebase-config/api.txt b/firebase-config/api.txt index 77efe522e60..05a10cad518 100644 --- a/firebase-config/api.txt +++ b/firebase-config/api.txt @@ -143,15 +143,3 @@ package com.google.firebase.remoteconfig { } -package com.google.firebase.remoteconfig.ktx { - - public final class RemoteConfigKt { - method @Deprecated public static operator com.google.firebase.remoteconfig.FirebaseRemoteConfigValue get(com.google.firebase.remoteconfig.FirebaseRemoteConfig, String key); - method @Deprecated public static kotlinx.coroutines.flow.Flow getConfigUpdates(com.google.firebase.remoteconfig.FirebaseRemoteConfig); - method @Deprecated public static com.google.firebase.remoteconfig.FirebaseRemoteConfig getRemoteConfig(com.google.firebase.ktx.Firebase); - method @Deprecated public static com.google.firebase.remoteconfig.FirebaseRemoteConfig remoteConfig(com.google.firebase.ktx.Firebase, com.google.firebase.FirebaseApp app); - method public static com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings remoteConfigSettings(kotlin.jvm.functions.Function1 init); - } - -} - diff --git a/firebase-config/bandwagoner/bandwagoner.gradle b/firebase-config/bandwagoner/bandwagoner.gradle index 12c0ac1d508..8435bb3aab2 100644 --- a/firebase-config/bandwagoner/bandwagoner.gradle +++ b/firebase-config/bandwagoner/bandwagoner.gradle @@ -75,10 +75,6 @@ dependencies { exclude group: 'com.google.firebase', module: 'firebase-common' exclude group: 'com.google.firebase', module: 'firebase-components' } - implementation(project(":firebase-config:ktx")) { - exclude group: 'com.google.firebase', module: 'firebase-common' - exclude group: 'com.google.firebase', module: 'firebase-components' - } implementation(project(":firebase-installations")) { exclude group: 'com.google.firebase', module: 'firebase-common' exclude group: 'com.google.firebase', module: 'firebase-components' @@ -96,7 +92,6 @@ dependencies { // Released artifacts don't need these dependencies since they don't use `project` to refer // to Remote Config. implementation("com.google.firebase:firebase-common:21.0.0") - implementation("com.google.firebase:firebase-common-ktx:21.0.0") implementation("com.google.firebase:firebase-components:18.0.0") implementation("com.google.firebase:firebase-installations-interop:17.1.1") { exclude group: 'com.google.firebase', module: 'firebase-common' diff --git a/firebase-config/bandwagoner/src/main/java/com/googletest/firebase/remoteconfig/bandwagoner/RealtimeKtListener.kt b/firebase-config/bandwagoner/src/main/java/com/googletest/firebase/remoteconfig/bandwagoner/RealtimeKtListener.kt index 5e77119b443..63b42954c4c 100644 --- a/firebase-config/bandwagoner/src/main/java/com/googletest/firebase/remoteconfig/bandwagoner/RealtimeKtListener.kt +++ b/firebase-config/bandwagoner/src/main/java/com/googletest/firebase/remoteconfig/bandwagoner/RealtimeKtListener.kt @@ -17,9 +17,9 @@ package com.googletest.firebase.remoteconfig.bandwagoner import android.util.Log -import com.google.firebase.ktx.Firebase -import com.google.firebase.remoteconfig.ktx.configUpdates -import com.google.firebase.remoteconfig.ktx.remoteConfig +import com.google.firebase.Firebase +import com.google.firebase.remoteconfig.configUpdates +import com.google.firebase.remoteconfig.remoteConfig import java.util.concurrent.CompletableFuture import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.flow.catch diff --git a/firebase-config/firebase-config.gradle.kts b/firebase-config/firebase-config.gradle.kts index 63bec363d14..e689ead214d 100644 --- a/firebase-config/firebase-config.gradle.kts +++ b/firebase-config/firebase-config.gradle.kts @@ -72,7 +72,6 @@ dependencies { exclude(group = "com.google.firebase", module = "firebase-components") } api("com.google.firebase:firebase-common:21.0.0") - api("com.google.firebase:firebase-common-ktx:21.0.0") api("com.google.firebase:firebase-components:18.0.0") api("com.google.firebase:firebase-installations:17.2.0") diff --git a/firebase-config/ktx/api.txt b/firebase-config/ktx/api.txt deleted file mode 100644 index da4f6cc18fe..00000000000 --- a/firebase-config/ktx/api.txt +++ /dev/null @@ -1 +0,0 @@ -// Signature format: 3.0 diff --git a/firebase-config/ktx/gradle.properties b/firebase-config/ktx/gradle.properties deleted file mode 100644 index 016fa887bc0..00000000000 --- a/firebase-config/ktx/gradle.properties +++ /dev/null @@ -1,2 +0,0 @@ -android.enableUnitTestBinaryResources=true - diff --git a/firebase-config/ktx/ktx.gradle b/firebase-config/ktx/ktx.gradle deleted file mode 100644 index 64da37d23fe..00000000000 --- a/firebase-config/ktx/ktx.gradle +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2019 Google LLC -// -// 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. - -plugins { - id 'firebase-library' - id("kotlin-android") -} - -firebaseLibrary { - libraryGroup = "config" - publishJavadoc = false - releaseNotes { - enabled.set(false) - } -} - -android { - namespace "com.google.firebase.remoteconfig.ktx" - compileSdkVersion project.compileSdkVersion - defaultConfig { - minSdkVersion project.minSdkVersion - multiDexEnabled true - targetSdkVersion project.targetSdkVersion - versionName version - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - test.java { - srcDir 'src/test/kotlin' - } - } - kotlinOptions { - jvmTarget = '1.8' - } - testOptions.unitTests.includeAndroidResources = true -} - -dependencies { - api(project(":firebase-config")) - api("com.google.firebase:firebase-common:21.0.0") - api("com.google.firebase:firebase-common-ktx:21.0.0") - api("com.google.firebase:firebase-installations:17.2.0") - - implementation('com.google.firebase:firebase-abt:21.1.1') { - exclude group: 'com.google.firebase', module: 'firebase-common' - exclude group: 'com.google.firebase', module: 'firebase-components' - } - implementation("com.google.firebase:firebase-components:18.0.0") - implementation 'com.google.firebase:firebase-installations-interop:17.1.0' - - testImplementation libs.androidx.test.core - testImplementation libs.truth - testImplementation 'junit:junit:4.12' - testImplementation 'org.mockito:mockito-core:2.25.0' - testImplementation libs.robolectric -} diff --git a/firebase-config/ktx/src/main/AndroidManifest.xml b/firebase-config/ktx/src/main/AndroidManifest.xml deleted file mode 100644 index 9df18d6857b..00000000000 --- a/firebase-config/ktx/src/main/AndroidManifest.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - diff --git a/firebase-config/ktx/src/main/kotlin/com/google/firebase/remoteconfig/ktx/Logging.kt b/firebase-config/ktx/src/main/kotlin/com/google/firebase/remoteconfig/ktx/Logging.kt deleted file mode 100644 index b13c960807c..00000000000 --- a/firebase-config/ktx/src/main/kotlin/com/google/firebase/remoteconfig/ktx/Logging.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2023 Google LLC - * - * 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.google.firebase.remoteconfig.ktx - -import androidx.annotation.Keep -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.platforminfo.LibraryVersionComponent -import com.google.firebase.remoteconfig.BuildConfig - -internal const val LIBRARY_NAME: String = "fire-cfg-ktx" - -/** @suppress */ -@Keep -class FirebaseConfigLegacyRegistrar : ComponentRegistrar { - override fun getComponents(): List> { - return listOf(LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME)) - } -} diff --git a/firebase-config/ktx/src/test/kotlin/com/google/firebase/remoteconfig/TestConstructorUtil.kt b/firebase-config/ktx/src/test/kotlin/com/google/firebase/remoteconfig/TestConstructorUtil.kt deleted file mode 100644 index 4c153bff1e3..00000000000 --- a/firebase-config/ktx/src/test/kotlin/com/google/firebase/remoteconfig/TestConstructorUtil.kt +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * 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.google.firebase.remoteconfig - -import android.content.Context -import com.google.firebase.FirebaseApp -import com.google.firebase.abt.FirebaseABTesting -import com.google.firebase.installations.FirebaseInstallationsApi -import com.google.firebase.remoteconfig.internal.ConfigCacheClient -import com.google.firebase.remoteconfig.internal.ConfigFetchHandler -import com.google.firebase.remoteconfig.internal.ConfigGetParameterHandler -import com.google.firebase.remoteconfig.internal.ConfigRealtimeHandler -import com.google.firebase.remoteconfig.internal.ConfigSharedPrefsClient -import com.google.firebase.remoteconfig.internal.rollouts.RolloutsStateSubscriptionsHandler -import java.util.concurrent.Executor - -// This method is a workaround for testing. It enable us to create a FirebaseRemoteConfig object -// with mocks using the package-private constructor. -fun createRemoteConfig( - context: Context?, - firebaseApp: FirebaseApp, - firebaseInstallations: FirebaseInstallationsApi, - firebaseAbt: FirebaseABTesting?, - executor: Executor, - fetchedConfigsCache: ConfigCacheClient, - activatedConfigsCache: ConfigCacheClient, - defaultConfigsCache: ConfigCacheClient, - fetchHandler: ConfigFetchHandler, - getHandler: ConfigGetParameterHandler, - frcSharedPrefs: ConfigSharedPrefsClient, - realtimeHandler: ConfigRealtimeHandler, - rolloutsStateSubscriptionsHandler: RolloutsStateSubscriptionsHandler -): FirebaseRemoteConfig { - return FirebaseRemoteConfig( - context, - firebaseApp, - firebaseInstallations, - firebaseAbt, - executor, - fetchedConfigsCache, - activatedConfigsCache, - defaultConfigsCache, - fetchHandler, - getHandler, - frcSharedPrefs, - realtimeHandler, - rolloutsStateSubscriptionsHandler - ) -} diff --git a/firebase-config/ktx/src/test/kotlin/com/google/firebase/remoteconfig/ktx/RemoteConfigTests.kt b/firebase-config/ktx/src/test/kotlin/com/google/firebase/remoteconfig/ktx/RemoteConfigTests.kt deleted file mode 100644 index d3e7d10e725..00000000000 --- a/firebase-config/ktx/src/test/kotlin/com/google/firebase/remoteconfig/ktx/RemoteConfigTests.kt +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * 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.google.firebase.remoteconfig.ktx - -import androidx.test.core.app.ApplicationProvider -import com.google.common.truth.Truth.assertThat -import com.google.common.util.concurrent.MoreExecutors -import com.google.firebase.FirebaseApp -import com.google.firebase.FirebaseOptions -import com.google.firebase.installations.FirebaseInstallationsApi -import com.google.firebase.ktx.Firebase -import com.google.firebase.ktx.app -import com.google.firebase.ktx.initialize -import com.google.firebase.platforminfo.UserAgentPublisher -import com.google.firebase.remoteconfig.FirebaseRemoteConfig -import com.google.firebase.remoteconfig.FirebaseRemoteConfigValue -import com.google.firebase.remoteconfig.createRemoteConfig -import com.google.firebase.remoteconfig.internal.ConfigCacheClient -import com.google.firebase.remoteconfig.internal.ConfigFetchHandler -import com.google.firebase.remoteconfig.internal.ConfigGetParameterHandler -import com.google.firebase.remoteconfig.internal.ConfigRealtimeHandler -import com.google.firebase.remoteconfig.internal.ConfigSharedPrefsClient -import com.google.firebase.remoteconfig.internal.rollouts.RolloutsStateSubscriptionsHandler -import org.junit.After -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.Mockito.mock -import org.mockito.Mockito.`when` -import org.robolectric.RobolectricTestRunner - -const val APP_ID = "1:14368190084:android:09cb977358c6f241" -const val API_KEY = "AIzaSyabcdefghijklmnopqrstuvwxyz1234567" - -const val EXISTING_APP = "existing" - -open class DefaultFirebaseRemoteConfigValue : FirebaseRemoteConfigValue { - override fun asLong(): Long = TODO("Unimplementend") - override fun asDouble(): Double = TODO("Unimplementend") - override fun asString(): String = TODO("Unimplementend") - override fun asByteArray(): ByteArray = TODO("Unimplementend") - override fun asBoolean(): Boolean = TODO("Unimplementend") - override fun getSource(): Int = TODO("Unimplementend") -} - -class StringRemoteConfigValue(val value: String) : DefaultFirebaseRemoteConfigValue() { - override fun asString() = value -} - -abstract class BaseTestCase { - @Before - fun setUp() { - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build() - ) - - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build(), - EXISTING_APP - ) - } - - @After - fun cleanUp() { - FirebaseApp.clearInstancesForTest() - } -} - -@RunWith(RobolectricTestRunner::class) -class ConfigTests : BaseTestCase() { - - @Test - fun `Firebase#remoteConfig should delegate to FirebaseRemoteConfig#getInstance()`() { - assertThat(Firebase.remoteConfig).isSameInstanceAs(FirebaseRemoteConfig.getInstance()) - } - - @Test - fun `Firebase#remoteConfig should delegate to FirebaseRemoteConfig#getInstance(FirebaseApp, region)`() { - val app = Firebase.app(EXISTING_APP) - assertThat(Firebase.remoteConfig(app)).isSameInstanceAs(FirebaseRemoteConfig.getInstance(app)) - } - - @Test - fun `Overloaded get() operator returns default value when key doesn't exist`() { - val remoteConfig = Firebase.remoteConfig - assertThat(remoteConfig["non_existing_key"].asString()) - .isEqualTo(FirebaseRemoteConfig.DEFAULT_VALUE_FOR_STRING) - assertThat(remoteConfig["another_non_exisiting_key"].asDouble()) - .isEqualTo(FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE) - } - - @Test - fun `FirebaseRemoteConfigSettings builder works`() { - val minFetchInterval = 3600L - val fetchTimeout = 60L - val configSettings = remoteConfigSettings { - minimumFetchIntervalInSeconds = minFetchInterval - fetchTimeoutInSeconds = fetchTimeout - } - assertThat(configSettings.minimumFetchIntervalInSeconds).isEqualTo(minFetchInterval) - assertThat(configSettings.fetchTimeoutInSeconds).isEqualTo(fetchTimeout) - } - - @Test - fun `Overloaded get() operator returns value when key exists`() { - val mockGetHandler = mock(ConfigGetParameterHandler::class.java) - val directExecutor = MoreExecutors.directExecutor() - - val remoteConfig = - createRemoteConfig( - context = null, - firebaseApp = Firebase.app(EXISTING_APP), - firebaseInstallations = mock(FirebaseInstallationsApi::class.java), - firebaseAbt = null, - executor = directExecutor, - fetchedConfigsCache = mock(ConfigCacheClient::class.java), - activatedConfigsCache = mock(ConfigCacheClient::class.java), - defaultConfigsCache = mock(ConfigCacheClient::class.java), - fetchHandler = mock(ConfigFetchHandler::class.java), - getHandler = mockGetHandler, - frcSharedPrefs = mock(ConfigSharedPrefsClient::class.java), - realtimeHandler = mock(ConfigRealtimeHandler::class.java), - rolloutsStateSubscriptionsHandler = mock(RolloutsStateSubscriptionsHandler::class.java) - ) - - `when`(mockGetHandler.getValue("KEY")).thenReturn(StringRemoteConfigValue("non default value")) - assertThat(remoteConfig["KEY"].asString()).isEqualTo("non default value") - } -} - -@RunWith(RobolectricTestRunner::class) -class LibraryVersionTest : BaseTestCase() { - @Test - fun `library version should be registered with runtime`() { - val publisher = Firebase.app.get(UserAgentPublisher::class.java) - assertThat(publisher.userAgent).contains(LIBRARY_NAME) - } -} diff --git a/firebase-config/src/main/java/com/google/firebase/remoteconfig/ktx/RemoteConfig.kt b/firebase-config/src/main/java/com/google/firebase/remoteconfig/ktx/RemoteConfig.kt deleted file mode 100644 index 899381a6515..00000000000 --- a/firebase-config/src/main/java/com/google/firebase/remoteconfig/ktx/RemoteConfig.kt +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * 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.google.firebase.remoteconfig.ktx - -import androidx.annotation.Keep -import com.google.firebase.FirebaseApp -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.ktx.Firebase -import com.google.firebase.remoteconfig.ConfigUpdate -import com.google.firebase.remoteconfig.ConfigUpdateListener -import com.google.firebase.remoteconfig.FirebaseRemoteConfig -import com.google.firebase.remoteconfig.FirebaseRemoteConfigException -import com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings -import com.google.firebase.remoteconfig.FirebaseRemoteConfigValue -import kotlinx.coroutines.cancel -import kotlinx.coroutines.channels.awaitClose -import kotlinx.coroutines.channels.trySendBlocking -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.callbackFlow - -/** - * Accessing this object for Kotlin apps has changed; see the - * [migration guide](https://firebase.google.com/docs/android/kotlin-migration). - * - * Returns the [FirebaseRemoteConfig] instance of the default [FirebaseApp]. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase:firebase-config-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -val Firebase.remoteConfig: FirebaseRemoteConfig - get() = FirebaseRemoteConfig.getInstance() - -/** - * Accessing this object for Kotlin apps has changed; see the - * [migration guide](https://firebase.google.com/docs/android/kotlin-migration). - * - * Returns the [FirebaseRemoteConfig] instance of a given [FirebaseApp]. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase:firebase-config-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -fun Firebase.remoteConfig(app: FirebaseApp): FirebaseRemoteConfig = - FirebaseRemoteConfig.getInstance(app) - -/** - * See [FirebaseRemoteConfig#getValue] - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase:firebase-config-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -operator fun FirebaseRemoteConfig.get(key: String): FirebaseRemoteConfigValue { - return this.getValue(key) -} - -fun remoteConfigSettings( - init: FirebaseRemoteConfigSettings.Builder.() -> Unit -): FirebaseRemoteConfigSettings { - val builder = FirebaseRemoteConfigSettings.Builder() - builder.init() - return builder.build() -} - -/** - * Starts listening for config updates from the Remote Config backend and emits [ConfigUpdate]s via - * a [Flow]. See [FirebaseRemoteConfig.addOnConfigUpdateListener] for more information. - * - * - When the returned flow starts being collected, an [ConfigUpdateListener] will be attached. - * - When the flow completes, the listener will be removed. If there are no attached listeners, the - * connection to the Remote Config backend will be closed. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase:firebase-config-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -val FirebaseRemoteConfig.configUpdates - get() = callbackFlow { - val registration = - addOnConfigUpdateListener( - object : ConfigUpdateListener { - override fun onUpdate(configUpdate: ConfigUpdate) { - schedule { trySendBlocking(configUpdate) } - } - - override fun onError(error: FirebaseRemoteConfigException) { - cancel(message = "Error listening for config updates.", cause = error) - } - } - ) - awaitClose { registration.remove() } - } - -/** - * @suppress - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase:firebase-config-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -@Keep -class FirebaseRemoteConfigKtxRegistrar : ComponentRegistrar { - override fun getComponents(): List> = listOf() -} diff --git a/firebase-config/src/test/java/com/google/firebase/remoteconfig/ktx/RemoteConfigTests.kt b/firebase-config/src/test/java/com/google/firebase/remoteconfig/ktx/RemoteConfigTests.kt deleted file mode 100644 index 2a423843a7c..00000000000 --- a/firebase-config/src/test/java/com/google/firebase/remoteconfig/ktx/RemoteConfigTests.kt +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * 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.google.firebase.remoteconfig.ktx - -import androidx.test.core.app.ApplicationProvider -import com.google.common.truth.Truth.assertThat -import com.google.common.util.concurrent.MoreExecutors -import com.google.firebase.FirebaseApp -import com.google.firebase.FirebaseOptions -import com.google.firebase.installations.FirebaseInstallationsApi -import com.google.firebase.ktx.Firebase -import com.google.firebase.ktx.app -import com.google.firebase.ktx.initialize -import com.google.firebase.platforminfo.UserAgentPublisher -import com.google.firebase.remoteconfig.FirebaseRemoteConfig -import com.google.firebase.remoteconfig.FirebaseRemoteConfigValue -import com.google.firebase.remoteconfig.createRemoteConfig -import com.google.firebase.remoteconfig.internal.ConfigCacheClient -import com.google.firebase.remoteconfig.internal.ConfigFetchHandler -import com.google.firebase.remoteconfig.internal.ConfigGetParameterHandler -import com.google.firebase.remoteconfig.internal.ConfigRealtimeHandler -import com.google.firebase.remoteconfig.internal.ConfigSharedPrefsClient -import com.google.firebase.remoteconfig.internal.rollouts.RolloutsStateSubscriptionsHandler -import org.junit.After -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.Mockito.mock -import org.mockito.Mockito.`when` -import org.robolectric.RobolectricTestRunner - -const val APP_ID = "1:14368190084:android:09cb977358c6f241" -const val API_KEY = "AIzaSyabcdefghijklmnopqrstuvwxyz1234567" - -const val EXISTING_APP = "existing" - -open class DefaultFirebaseRemoteConfigValue : FirebaseRemoteConfigValue { - override fun asLong(): Long = TODO("Unimplementend") - override fun asDouble(): Double = TODO("Unimplementend") - override fun asString(): String = TODO("Unimplementend") - override fun asByteArray(): ByteArray = TODO("Unimplementend") - override fun asBoolean(): Boolean = TODO("Unimplementend") - override fun getSource(): Int = TODO("Unimplementend") -} - -class StringRemoteConfigValue(val value: String) : DefaultFirebaseRemoteConfigValue() { - override fun asString() = value -} - -abstract class BaseTestCase { - @Before - fun setUp() { - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build() - ) - - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build(), - EXISTING_APP - ) - } - - @After - fun cleanUp() { - FirebaseApp.clearInstancesForTest() - } -} - -@RunWith(RobolectricTestRunner::class) -class ConfigTests : BaseTestCase() { - - @Test - fun `Firebase#remoteConfig should delegate to FirebaseRemoteConfig#getInstance()`() { - assertThat(Firebase.remoteConfig).isSameInstanceAs(FirebaseRemoteConfig.getInstance()) - } - - @Test - fun `Firebase#remoteConfig should delegate to FirebaseRemoteConfig#getInstance(FirebaseApp, region)`() { - val app = Firebase.app(EXISTING_APP) - assertThat(Firebase.remoteConfig(app)).isSameInstanceAs(FirebaseRemoteConfig.getInstance(app)) - } - - @Test - fun `Overloaded get() operator returns default value when key doesn't exist`() { - val remoteConfig = Firebase.remoteConfig - assertThat(remoteConfig["non_existing_key"].asString()) - .isEqualTo(FirebaseRemoteConfig.DEFAULT_VALUE_FOR_STRING) - assertThat(remoteConfig["another_non_exisiting_key"].asDouble()) - .isEqualTo(FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE) - } - - @Test - fun `FirebaseRemoteConfigSettings builder works`() { - val minFetchInterval = 3600L - val fetchTimeout = 60L - val configSettings = remoteConfigSettings { - minimumFetchIntervalInSeconds = minFetchInterval - fetchTimeoutInSeconds = fetchTimeout - } - assertThat(configSettings.minimumFetchIntervalInSeconds).isEqualTo(minFetchInterval) - assertThat(configSettings.fetchTimeoutInSeconds).isEqualTo(fetchTimeout) - } - - @Test - fun `Overloaded get() operator returns value when key exists`() { - val mockGetHandler = mock(ConfigGetParameterHandler::class.java) - val directExecutor = MoreExecutors.directExecutor() - - val remoteConfig = - createRemoteConfig( - context = null, - firebaseApp = Firebase.app(EXISTING_APP), - firebaseInstallations = mock(FirebaseInstallationsApi::class.java), - firebaseAbt = null, - executor = directExecutor, - fetchedConfigsCache = mock(ConfigCacheClient::class.java), - activatedConfigsCache = mock(ConfigCacheClient::class.java), - defaultConfigsCache = mock(ConfigCacheClient::class.java), - fetchHandler = mock(ConfigFetchHandler::class.java), - getHandler = mockGetHandler, - frcSharedPrefs = mock(ConfigSharedPrefsClient::class.java), - realtimeHandler = mock(ConfigRealtimeHandler::class.java), - rolloutsStateSubscriptionsHandler = mock(RolloutsStateSubscriptionsHandler::class.java) - ) - - `when`(mockGetHandler.getValue("KEY")).thenReturn(StringRemoteConfigValue("non default value")) - assertThat(remoteConfig["KEY"].asString()).isEqualTo("non default value") - } -} - -@RunWith(RobolectricTestRunner::class) -class LibraryVersionTest : BaseTestCase() { - @Test - fun `library version should be registered with runtime`() { - val publisher = Firebase.app.get(UserAgentPublisher::class.java) - } -} diff --git a/firebase-config/test-app/src/androidTest/kotlin/com/google/firebase/testing/config/FirebaseConfigTest.kt b/firebase-config/test-app/src/androidTest/kotlin/com/google/firebase/testing/config/FirebaseConfigTest.kt index d8b05fac481..3d0234c8895 100644 --- a/firebase-config/test-app/src/androidTest/kotlin/com/google/firebase/testing/config/FirebaseConfigTest.kt +++ b/firebase-config/test-app/src/androidTest/kotlin/com/google/firebase/testing/config/FirebaseConfigTest.kt @@ -18,9 +18,9 @@ package com.google.firebase.testing.config import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 +import com.google.firebase.Firebase import com.google.firebase.FirebaseApp -import com.google.firebase.ktx.Firebase -import com.google.firebase.ktx.initialize +import com.google.firebase.initialize import org.junit.After import org.junit.Before import org.junit.Test diff --git a/firebase-config/test-app/test-app.gradle.kts b/firebase-config/test-app/test-app.gradle.kts index 0c91cd21fc3..b9354a59646 100644 --- a/firebase-config/test-app/test-app.gradle.kts +++ b/firebase-config/test-app/test-app.gradle.kts @@ -57,7 +57,6 @@ dependencies { implementation(project(":firebase-config")) { exclude(group = "com.google.firebase", module = "firebase-config-interop") } - implementation(project(":firebase-config:ktx")) // This is required since a `project` dependency on frc does not expose the APIs of its // "implementation" dependencies. The alternative would be to make common an "api" dep of @@ -65,7 +64,6 @@ dependencies { // Released artifacts don't need these dependencies since they don't use `project` to refer // to Remote Config. implementation("com.google.firebase:firebase-common:21.0.0") - implementation("com.google.firebase:firebase-common-ktx:21.0.0") implementation("com.google.firebase:firebase-components:18.0.0") implementation("com.google.firebase:firebase-installations-interop:17.1.0") @@ -80,7 +78,6 @@ dependencies { implementation("androidx.core:core-ktx:1.9.0") implementation("com.google.android.material:material:1.8.0") - androidTestImplementation("com.google.firebase:firebase-common-ktx:21.0.0") androidTestImplementation(libs.androidx.test.junit) androidTestImplementation(libs.androidx.test.runner) androidTestImplementation(libs.truth) diff --git a/firebase-crashlytics-ndk/firebase-crashlytics-ndk.gradle b/firebase-crashlytics-ndk/firebase-crashlytics-ndk.gradle index 4cf82e95069..4198cdc64f6 100644 --- a/firebase-crashlytics-ndk/firebase-crashlytics-ndk.gradle +++ b/firebase-crashlytics-ndk/firebase-crashlytics-ndk.gradle @@ -112,7 +112,6 @@ thirdPartyLicenses { dependencies { api project(':firebase-crashlytics') api "com.google.firebase:firebase-common:21.0.0" - api "com.google.firebase:firebase-common-ktx:21.0.0" api "com.google.firebase:firebase-components:18.0.0" implementation libs.playservices.basement diff --git a/firebase-crashlytics/api.txt b/firebase-crashlytics/api.txt index 1112c32d2e8..900b32020a0 100644 --- a/firebase-crashlytics/api.txt +++ b/firebase-crashlytics/api.txt @@ -54,22 +54,3 @@ package com.google.firebase.crashlytics { } -package com.google.firebase.crashlytics.ktx { - - public final class FirebaseCrashlyticsKt { - method @Deprecated public static com.google.firebase.crashlytics.FirebaseCrashlytics getCrashlytics(com.google.firebase.ktx.Firebase); - method @Deprecated public static void setCustomKeys(com.google.firebase.crashlytics.FirebaseCrashlytics, kotlin.jvm.functions.Function1 init); - } - - @Deprecated public final class KeyValueBuilder { - ctor @Deprecated public KeyValueBuilder(com.google.firebase.crashlytics.FirebaseCrashlytics crashlytics); - method @Deprecated public void key(String key, boolean value); - method @Deprecated public void key(String key, double value); - method @Deprecated public void key(String key, float value); - method @Deprecated public void key(String key, int value); - method @Deprecated public void key(String key, String value); - method @Deprecated public void key(String key, long value); - } - -} - diff --git a/firebase-crashlytics/firebase-crashlytics.gradle b/firebase-crashlytics/firebase-crashlytics.gradle index 63b9da33040..0fcf2a0ef39 100644 --- a/firebase-crashlytics/firebase-crashlytics.gradle +++ b/firebase-crashlytics/firebase-crashlytics.gradle @@ -72,7 +72,6 @@ dependencies { api(libs.playservices.tasks) api("com.google.firebase:firebase-annotations:16.2.0") api("com.google.firebase:firebase-common:21.0.0") - api("com.google.firebase:firebase-common-ktx:21.0.0") api("com.google.firebase:firebase-components:18.0.0") api("com.google.firebase:firebase-config-interop:16.0.1") api("com.google.firebase:firebase-encoders:17.0.0") diff --git a/firebase-crashlytics/ktx/api.txt b/firebase-crashlytics/ktx/api.txt deleted file mode 100644 index da4f6cc18fe..00000000000 --- a/firebase-crashlytics/ktx/api.txt +++ /dev/null @@ -1 +0,0 @@ -// Signature format: 3.0 diff --git a/firebase-crashlytics/ktx/gradle.properties b/firebase-crashlytics/ktx/gradle.properties deleted file mode 100644 index 9eff84e6c72..00000000000 --- a/firebase-crashlytics/ktx/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -android.enableUnitTestBinaryResources=true diff --git a/firebase-crashlytics/ktx/ktx.gradle b/firebase-crashlytics/ktx/ktx.gradle deleted file mode 100644 index ba14b9037c8..00000000000 --- a/firebase-crashlytics/ktx/ktx.gradle +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2020 Google LLC -// -// 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. - -plugins { - id "firebase-library" - id "kotlin-android" -} - -firebaseLibrary { - libraryGroup = "crashlytics" - testLab.enabled = true - publishJavadoc = false - releaseNotes { - enabled.set(false) -} -} - -android { - namespace "com.google.firebase.crashlytics.ktx" - compileSdk project.compileSdkVersion - defaultConfig { - minSdk project.minSdkVersion - multiDexEnabled true - targetSdk project.targetSdkVersion - versionName version - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = '1.8' - } - testOptions.unitTests.includeAndroidResources = true -} - -dependencies { - api(project(":firebase-crashlytics")) - api("com.google.firebase:firebase-common:21.0.0") - api("com.google.firebase:firebase-common-ktx:21.0.0") - - implementation("com.google.firebase:firebase-components:18.0.0") - - androidTestImplementation(libs.androidx.test.junit) - androidTestImplementation(libs.androidx.test.runner) - androidTestImplementation(libs.truth) -} diff --git a/firebase-crashlytics/ktx/src/androidTest/AndroidManifest.xml b/firebase-crashlytics/ktx/src/androidTest/AndroidManifest.xml deleted file mode 100644 index f6c54a6adb5..00000000000 --- a/firebase-crashlytics/ktx/src/androidTest/AndroidManifest.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - diff --git a/firebase-crashlytics/ktx/src/androidTest/kotlin/com/google/firebase/crashlytics/ktx/CrashlyticsTests.kt b/firebase-crashlytics/ktx/src/androidTest/kotlin/com/google/firebase/crashlytics/ktx/CrashlyticsTests.kt deleted file mode 100644 index 8015b7c3a91..00000000000 --- a/firebase-crashlytics/ktx/src/androidTest/kotlin/com/google/firebase/crashlytics/ktx/CrashlyticsTests.kt +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * 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.google.firebase.crashlytics.ktx - -import androidx.test.core.app.ApplicationProvider -import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.google.common.truth.Truth.assertThat -import com.google.firebase.FirebaseApp -import com.google.firebase.FirebaseOptions -import com.google.firebase.crashlytics.FirebaseCrashlytics -import com.google.firebase.ktx.Firebase -import com.google.firebase.ktx.app -import com.google.firebase.ktx.initialize -import com.google.firebase.platforminfo.UserAgentPublisher -import org.junit.After -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -class CrashlyticsTests { - @Before - fun setUp() { - @Suppress("DEPRECATION") - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId(PROJECT_ID) - .build(), - ) - } - - @After - fun cleanUp() { - FirebaseApp.clearInstancesForTest() - } - - @Test - fun firebaseCrashlyticsDelegates() { - assertThat(Firebase.crashlytics).isSameInstanceAs(FirebaseCrashlytics.getInstance()) - } - - @Test - fun libraryRegistrationAtRuntime() { - Firebase.app.get(UserAgentPublisher::class.java) - } - - companion object { - private const val APP_ID = "1:1:android:1a" - private const val API_KEY = "API-KEY-API-KEY-API-KEY-API-KEY-API-KEY" - private const val PROJECT_ID = "PROJECT-ID" - } -} diff --git a/firebase-crashlytics/ktx/src/androidTest/res/values/strings.xml b/firebase-crashlytics/ktx/src/androidTest/res/values/strings.xml deleted file mode 100644 index 3f3b1aca4ce..00000000000 --- a/firebase-crashlytics/ktx/src/androidTest/res/values/strings.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - false - - - diff --git a/firebase-crashlytics/ktx/src/main/AndroidManifest.xml b/firebase-crashlytics/ktx/src/main/AndroidManifest.xml deleted file mode 100644 index 9a3f53960e1..00000000000 --- a/firebase-crashlytics/ktx/src/main/AndroidManifest.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/firebase-crashlytics/ktx/src/main/kotlin/com/google/firebase/crashlytics/ktx/Logging.kt b/firebase-crashlytics/ktx/src/main/kotlin/com/google/firebase/crashlytics/ktx/Logging.kt deleted file mode 100644 index e45aed4b682..00000000000 --- a/firebase-crashlytics/ktx/src/main/kotlin/com/google/firebase/crashlytics/ktx/Logging.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2023 Google LLC - * - * 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.google.firebase.crashlytics.ktx - -import androidx.annotation.Keep -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.crashlytics.BuildConfig -import com.google.firebase.platforminfo.LibraryVersionComponent - -internal const val LIBRARY_NAME: String = "fire-cls-ktx" - -/** @suppress */ -@Keep -class FirebaseCrashlyticsLegacyRegistrar : ComponentRegistrar { - override fun getComponents(): List> { - return listOf(LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME)) - } -} diff --git a/firebase-crashlytics/src/androidTest/java/com/google/firebase/crashlytics/ktx/CrashlyticsTests.kt b/firebase-crashlytics/src/androidTest/java/com/google/firebase/crashlytics/ktx/CrashlyticsTests.kt deleted file mode 100644 index 8015b7c3a91..00000000000 --- a/firebase-crashlytics/src/androidTest/java/com/google/firebase/crashlytics/ktx/CrashlyticsTests.kt +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * 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.google.firebase.crashlytics.ktx - -import androidx.test.core.app.ApplicationProvider -import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.google.common.truth.Truth.assertThat -import com.google.firebase.FirebaseApp -import com.google.firebase.FirebaseOptions -import com.google.firebase.crashlytics.FirebaseCrashlytics -import com.google.firebase.ktx.Firebase -import com.google.firebase.ktx.app -import com.google.firebase.ktx.initialize -import com.google.firebase.platforminfo.UserAgentPublisher -import org.junit.After -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -class CrashlyticsTests { - @Before - fun setUp() { - @Suppress("DEPRECATION") - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId(PROJECT_ID) - .build(), - ) - } - - @After - fun cleanUp() { - FirebaseApp.clearInstancesForTest() - } - - @Test - fun firebaseCrashlyticsDelegates() { - assertThat(Firebase.crashlytics).isSameInstanceAs(FirebaseCrashlytics.getInstance()) - } - - @Test - fun libraryRegistrationAtRuntime() { - Firebase.app.get(UserAgentPublisher::class.java) - } - - companion object { - private const val APP_ID = "1:1:android:1a" - private const val API_KEY = "API-KEY-API-KEY-API-KEY-API-KEY-API-KEY" - private const val PROJECT_ID = "PROJECT-ID" - } -} diff --git a/firebase-crashlytics/src/main/java/com/google/firebase/crashlytics/ktx/FirebaseCrashlytics.kt b/firebase-crashlytics/src/main/java/com/google/firebase/crashlytics/ktx/FirebaseCrashlytics.kt deleted file mode 100644 index 84b64d8ecee..00000000000 --- a/firebase-crashlytics/src/main/java/com/google/firebase/crashlytics/ktx/FirebaseCrashlytics.kt +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * 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.google.firebase.crashlytics.ktx - -import androidx.annotation.Keep -import com.google.firebase.FirebaseApp -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.crashlytics.FirebaseCrashlytics -import com.google.firebase.ktx.Firebase - -/** - * Accessing this object for Kotlin apps has changed; see the - * [migration guide](https://firebase.google.com/docs/android/kotlin-migration). - * - * Returns the [FirebaseCrashlytics] instance of the default [FirebaseApp]. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase:firebase-crashlytics-ktx` are now deprecated. As early as April 2024, we'll - * no longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -val Firebase.crashlytics: FirebaseCrashlytics - get() = FirebaseCrashlytics.getInstance() - -/** - * Associates all key-value parameters with the reports - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase:firebase-crashlytics-ktx` are now deprecated. As early as April 2024, we'll - * no longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -fun FirebaseCrashlytics.setCustomKeys(init: KeyValueBuilder.() -> Unit) { - val builder = KeyValueBuilder(this) - builder.init() -} - -/** - * @suppress - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase:firebase-crashlytics-ktx` are now deprecated. As early as April 2024, we'll - * no longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -@Keep -internal class FirebaseCrashlyticsKtxRegistrar : ComponentRegistrar { - override fun getComponents(): List> = listOf() - - companion object {} -} diff --git a/firebase-crashlytics/src/main/java/com/google/firebase/crashlytics/ktx/KeyValueBuilder.kt b/firebase-crashlytics/src/main/java/com/google/firebase/crashlytics/ktx/KeyValueBuilder.kt deleted file mode 100644 index d24cdf1de93..00000000000 --- a/firebase-crashlytics/src/main/java/com/google/firebase/crashlytics/ktx/KeyValueBuilder.kt +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * 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.google.firebase.crashlytics.ktx - -import com.google.firebase.crashlytics.FirebaseCrashlytics - -/** Helper class to enable fluent syntax in [setCustomKeys] */ -@Deprecated( - "Use `com.google.firebase.crashlytics.KeyValueBuilder` from the main module.", -) -class KeyValueBuilder(private val crashlytics: FirebaseCrashlytics) { - - /** - * Sets a custom key and value that are associated with reports. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase:firebase-crashlytics-ktx` are now deprecated. As early as April 2024, - * we'll no longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ - @Deprecated( - "Use `com.google.firebase.crashlytics.KeyValueBuilder.key(key, value)` from the main module.", - ReplaceWith("") - ) - fun key(key: String, value: Boolean) = crashlytics.setCustomKey(key, value) - - /** - * Sets a custom key and value that are associated with reports. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase:firebase-crashlytics-ktx` are now deprecated. As early as April 2024, - * we'll no longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ - @Deprecated( - "Use `com.google.firebase.crashlytics.KeyValueBuilder.key(key, value)` from the main module.", - ReplaceWith("") - ) - fun key(key: String, value: Double) = crashlytics.setCustomKey(key, value) - - /** - * Sets a custom key and value that are associated with reports. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase:firebase-crashlytics-ktx` are now deprecated. As early as April 2024, - * we'll no longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ - @Deprecated( - "Use `com.google.firebase.crashlytics.KeyValueBuilder.key(key, value)` from the main module.", - ReplaceWith("") - ) - fun key(key: String, value: Float) = crashlytics.setCustomKey(key, value) - - /** - * Sets a custom key and value that are associated with reports. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase:firebase-crashlytics-ktx` are now deprecated. As early as April 2024, - * we'll no longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ - @Deprecated( - "Use `com.google.firebase.crashlytics.KeyValueBuilder.key(key, value)` from the main module.", - ReplaceWith("") - ) - fun key(key: String, value: Int) = crashlytics.setCustomKey(key, value) - - /** - * Sets a custom key and value that are associated with reports. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase:firebase-crashlytics-ktx` are now deprecated. As early as April 2024, - * we'll no longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ - @Deprecated( - "Use `com.google.firebase.crashlytics.KeyValueBuilder.key(key, value)` from the main module.", - ReplaceWith("") - ) - fun key(key: String, value: Long) = crashlytics.setCustomKey(key, value) - - /** - * Sets a custom key and value that are associated with reports. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase:firebase-crashlytics-ktx` are now deprecated. As early as April 2024, - * we'll no longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ - @Deprecated( - "Use `com.google.firebase.crashlytics.KeyValueBuilder.key(key, value)` from the main module.", - ReplaceWith("") - ) - fun key(key: String, value: String) = crashlytics.setCustomKey(key, value) -} diff --git a/firebase-database/api.txt b/firebase-database/api.txt index 9c1929bdba5..909def2f1cc 100644 --- a/firebase-database/api.txt +++ b/firebase-database/api.txt @@ -287,63 +287,3 @@ package com.google.firebase.database { } -package com.google.firebase.database.ktx { - - @Deprecated public abstract sealed class ChildEvent { - } - - @Deprecated public static final class ChildEvent.Added extends com.google.firebase.database.ktx.ChildEvent { - ctor @Deprecated public ChildEvent.Added(com.google.firebase.database.DataSnapshot snapshot, String? previousChildName); - method @Deprecated public com.google.firebase.database.DataSnapshot component1(); - method @Deprecated public String? component2(); - method @Deprecated public com.google.firebase.database.ktx.ChildEvent.Added copy(com.google.firebase.database.DataSnapshot snapshot, String? previousChildName); - method @Deprecated public String? getPreviousChildName(); - method @Deprecated public com.google.firebase.database.DataSnapshot getSnapshot(); - property @Deprecated public final String? previousChildName; - property @Deprecated public final com.google.firebase.database.DataSnapshot snapshot; - } - - @Deprecated public static final class ChildEvent.Changed extends com.google.firebase.database.ktx.ChildEvent { - ctor @Deprecated public ChildEvent.Changed(com.google.firebase.database.DataSnapshot snapshot, String? previousChildName); - method @Deprecated public com.google.firebase.database.DataSnapshot component1(); - method @Deprecated public String? component2(); - method @Deprecated public com.google.firebase.database.ktx.ChildEvent.Changed copy(com.google.firebase.database.DataSnapshot snapshot, String? previousChildName); - method @Deprecated public String? getPreviousChildName(); - method @Deprecated public com.google.firebase.database.DataSnapshot getSnapshot(); - property @Deprecated public final String? previousChildName; - property @Deprecated public final com.google.firebase.database.DataSnapshot snapshot; - } - - @Deprecated public static final class ChildEvent.Moved extends com.google.firebase.database.ktx.ChildEvent { - ctor @Deprecated public ChildEvent.Moved(com.google.firebase.database.DataSnapshot snapshot, String? previousChildName); - method @Deprecated public com.google.firebase.database.DataSnapshot component1(); - method @Deprecated public String? component2(); - method @Deprecated public com.google.firebase.database.ktx.ChildEvent.Moved copy(com.google.firebase.database.DataSnapshot snapshot, String? previousChildName); - method @Deprecated public String? getPreviousChildName(); - method @Deprecated public com.google.firebase.database.DataSnapshot getSnapshot(); - property @Deprecated public final String? previousChildName; - property @Deprecated public final com.google.firebase.database.DataSnapshot snapshot; - } - - @Deprecated public static final class ChildEvent.Removed extends com.google.firebase.database.ktx.ChildEvent { - ctor @Deprecated public ChildEvent.Removed(com.google.firebase.database.DataSnapshot snapshot); - method @Deprecated public com.google.firebase.database.DataSnapshot component1(); - method @Deprecated public com.google.firebase.database.ktx.ChildEvent.Removed copy(com.google.firebase.database.DataSnapshot snapshot); - method @Deprecated public com.google.firebase.database.DataSnapshot getSnapshot(); - property @Deprecated public final com.google.firebase.database.DataSnapshot snapshot; - } - - public final class DatabaseKt { - method @Deprecated public static com.google.firebase.database.FirebaseDatabase database(com.google.firebase.ktx.Firebase, com.google.firebase.FirebaseApp app); - method @Deprecated public static com.google.firebase.database.FirebaseDatabase database(com.google.firebase.ktx.Firebase, com.google.firebase.FirebaseApp app, String url); - method @Deprecated public static com.google.firebase.database.FirebaseDatabase database(com.google.firebase.ktx.Firebase, String url); - method @Deprecated public static kotlinx.coroutines.flow.Flow getChildEvents(com.google.firebase.database.Query); - method @Deprecated public static com.google.firebase.database.FirebaseDatabase getDatabase(com.google.firebase.ktx.Firebase); - method @Deprecated public static kotlinx.coroutines.flow.Flow getSnapshots(com.google.firebase.database.Query); - method @Deprecated public static inline T? getValue(com.google.firebase.database.DataSnapshot); - method @Deprecated public static inline T? getValue(com.google.firebase.database.MutableData); - method @Deprecated public static inline kotlinx.coroutines.flow.Flow values(com.google.firebase.database.Query); - } - -} - diff --git a/firebase-database/firebase-database.gradle.kts b/firebase-database/firebase-database.gradle.kts index 038992487b8..796fd4f81c3 100644 --- a/firebase-database/firebase-database.gradle.kts +++ b/firebase-database/firebase-database.gradle.kts @@ -67,7 +67,6 @@ android { dependencies { api("com.google.firebase:firebase-appcheck-interop:17.1.0") api("com.google.firebase:firebase-common:21.0.0") - api("com.google.firebase:firebase-common-ktx:21.0.0") api("com.google.firebase:firebase-components:18.0.0") api("com.google.firebase:firebase-auth-interop:20.0.0") { exclude(group = "com.google.firebase", module = "firebase-common") diff --git a/firebase-database/ktx/api.txt b/firebase-database/ktx/api.txt deleted file mode 100644 index da4f6cc18fe..00000000000 --- a/firebase-database/ktx/api.txt +++ /dev/null @@ -1 +0,0 @@ -// Signature format: 3.0 diff --git a/firebase-database/ktx/gradle.properties b/firebase-database/ktx/gradle.properties deleted file mode 100644 index 9eff84e6c72..00000000000 --- a/firebase-database/ktx/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -android.enableUnitTestBinaryResources=true diff --git a/firebase-database/ktx/ktx.gradle.kts b/firebase-database/ktx/ktx.gradle.kts deleted file mode 100644 index 23372ca79ef..00000000000 --- a/firebase-database/ktx/ktx.gradle.kts +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 Google LLC -// -// 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. - -plugins { - id("firebase-library") - id("kotlin-android") - kotlin("android") -} - -group = "com.google.firebase" - -firebaseLibrary { - libraryGroup = "database" - publishJavadoc = false - releaseNotes { enabled.set(false) } -} - -android { - val compileSdkVersion: Int by rootProject - val targetSdkVersion: Int by rootProject - val minSdkVersion: Int by rootProject - - compileSdk = compileSdkVersion - - namespace = "com.google.firebase.database.ktx" - defaultConfig { - minSdk = minSdkVersion - targetSdk = targetSdkVersion - multiDexEnabled = true - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - sourceSets { - named("main") { java.srcDir("src/main/kotlin") } - named("test") { java.srcDir("src/test/kotlin") } - } - - testOptions.unitTests.isIncludeAndroidResources = true -} - -dependencies { - api("com.google.firebase:firebase-common:21.0.0") - api("com.google.firebase:firebase-common-ktx:21.0.0") - api(project(":firebase-database")) - - implementation("com.google.firebase:firebase-components:18.0.0") - - testImplementation(libs.androidx.test.core) - testImplementation(libs.junit) - testImplementation(libs.robolectric) - testImplementation(libs.truth) -} diff --git a/firebase-database/ktx/src/main/AndroidManifest.xml b/firebase-database/ktx/src/main/AndroidManifest.xml deleted file mode 100644 index 1d98a5ed1e0..00000000000 --- a/firebase-database/ktx/src/main/AndroidManifest.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - diff --git a/firebase-database/ktx/src/main/kotlin/com/google/firebase/database/ktx/Logging.kt b/firebase-database/ktx/src/main/kotlin/com/google/firebase/database/ktx/Logging.kt deleted file mode 100644 index 6f42bad09df..00000000000 --- a/firebase-database/ktx/src/main/kotlin/com/google/firebase/database/ktx/Logging.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2023 Google LLC - * - * 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.google.firebase.database.ktx - -import androidx.annotation.Keep -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.database.BuildConfig -import com.google.firebase.platforminfo.LibraryVersionComponent - -internal const val LIBRARY_NAME: String = "fire-db-ktx" - -/** @suppress */ -@Keep -class FirebaseDatabaseLegacyRegistrar : ComponentRegistrar { - override fun getComponents(): List> { - return listOf(LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME)) - } -} diff --git a/firebase-database/ktx/src/test/kotlin/com/google/firebase/database/DataSnapshotUtil.kt b/firebase-database/ktx/src/test/kotlin/com/google/firebase/database/DataSnapshotUtil.kt deleted file mode 100644 index a2e8d1451b4..00000000000 --- a/firebase-database/ktx/src/test/kotlin/com/google/firebase/database/DataSnapshotUtil.kt +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * 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.google.firebase.database - -import com.google.firebase.database.snapshot.IndexedNode -import com.google.firebase.database.snapshot.NodeUtilities - -/** - * Creates a custom DataSnapshot. - * - * This method is a workaround that enables the creation of a custom DataSnapshot using - * package-private methods. - */ -fun createDataSnapshot(data: Any?, db: FirebaseDatabase): DataSnapshot { - var ref = DatabaseReference("https://test.firebaseio.com", db.config) - val node = NodeUtilities.NodeFromJSON(data) - return DataSnapshot(ref, IndexedNode.from(node)) -} - -/** - * Creates a custom MutableData. - * - * This method is a workaround that enables the creation of a custom MutableData using - * package-private methods. - */ -fun createMutableData(data: Any?): MutableData { - val node = NodeUtilities.NodeFromJSON(data) - return MutableData(node) -} diff --git a/firebase-database/ktx/src/test/kotlin/com/google/firebase/database/ktx/DatabaseTests.kt b/firebase-database/ktx/src/test/kotlin/com/google/firebase/database/ktx/DatabaseTests.kt deleted file mode 100644 index 5ba53fa7edf..00000000000 --- a/firebase-database/ktx/src/test/kotlin/com/google/firebase/database/ktx/DatabaseTests.kt +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * 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.google.firebase.database.ktx - -import androidx.test.core.app.ApplicationProvider -import com.google.common.truth.Truth.assertThat -import com.google.firebase.FirebaseApp -import com.google.firebase.FirebaseOptions -import com.google.firebase.database.Exclude -import com.google.firebase.database.FirebaseDatabase -import com.google.firebase.database.IgnoreExtraProperties -import com.google.firebase.database.createDataSnapshot -import com.google.firebase.database.createMutableData -import com.google.firebase.ktx.Firebase -import com.google.firebase.ktx.app -import com.google.firebase.ktx.initialize -import com.google.firebase.platforminfo.UserAgentPublisher -import org.junit.After -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.robolectric.RobolectricTestRunner - -const val APP_ID = "APP_ID" -const val API_KEY = "API_KEY" - -const val EXISTING_APP = "existing" - -@IgnoreExtraProperties -data class Player( - var name: String? = "", - var jersey: Int? = -1, - var goalkeeper: Boolean? = false, - var avg_goals_per_game: Double? = 0.0 -) { - @Exclude - fun toMap(): Map { - return mapOf( - "name" to name, - "jersey" to jersey, - "goalkeeper" to goalkeeper, - "avg_goals_per_game" to avg_goals_per_game - ) - } -} - -abstract class BaseTestCase { - @Before - fun setUp() { - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .setDatabaseUrl("http://tests.fblocal.com:9000") - .build() - ) - - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .setDatabaseUrl("http://tests.fblocal.com:9000") - .build(), - EXISTING_APP - ) - } - - @After - fun cleanUp() { - FirebaseApp.clearInstancesForTest() - } -} - -@RunWith(RobolectricTestRunner::class) -class DatabaseTests : BaseTestCase() { - @Test - fun `database should delegate to FirebaseDatabase#getInstance()`() { - assertThat(Firebase.database).isSameInstanceAs(FirebaseDatabase.getInstance()) - } - - @Test - fun `FirebaseApp#database should delegate to FirebaseDatabase#getInstance(FirebaseApp)`() { - val app = Firebase.app(EXISTING_APP) - assertThat(Firebase.database(app)).isSameInstanceAs(FirebaseDatabase.getInstance(app)) - } - - @Test - fun `Firebase#database should delegate to FirebaseDatabase#getInstance(url)`() { - val url = "http://tests.fblocal.com:9000" - assertThat(Firebase.database(url)).isSameInstanceAs(FirebaseDatabase.getInstance(url)) - } - - @Test - fun `Firebase#database should delegate to FirebaseDatabase#getInstance(FirebaseApp, url)`() { - val app = Firebase.app(EXISTING_APP) - val url = "http://tests.fblocal.com:9000" - assertThat(Firebase.database(app, url)).isSameInstanceAs(FirebaseDatabase.getInstance(app, url)) - } -} - -@RunWith(RobolectricTestRunner::class) -class DataSnapshotTests : BaseTestCase() { - @Test - fun `reified getValue works with basic types`() { - val data = - mapOf( - "name" to "John Doe", - "jersey" to 35L, - "goalkeeper" to false, - "avg_goals_per_game" to 0.35 - ) - val dataSnapshot = createDataSnapshot(data, Firebase.database) - assertThat(dataSnapshot.child("name").getValue()).isEqualTo("John Doe") - assertThat(dataSnapshot.child("jersey").getValue()).isEqualTo(35L) - assertThat(dataSnapshot.child("goalkeeper").getValue()).isEqualTo(false) - assertThat(dataSnapshot.child("avg_goals_per_game").getValue()).isEqualTo(0.35) - } - - @Test - fun `reified getValue works with maps`() { - val data = - mapOf( - "name" to "John Doe", - "jersey" to 35L, - "goalkeeper" to false, - "avg_goals_per_game" to 0.35 - ) - val dataSnapshot = createDataSnapshot(data, Firebase.database) - assertThat(dataSnapshot.getValue>()).isEqualTo(data) - } - - @Test - fun `reified getValue works with lists types`() { - val data = listOf("George", "John", "Paul", "Ringo") - val dataSnapshot = createDataSnapshot(data, Firebase.database) - assertThat(dataSnapshot.getValue>()).isEqualTo(data) - } - - @Test - fun `reified getValue works with custom types`() { - val data = Player(name = "John Doe", jersey = 35, goalkeeper = false, avg_goals_per_game = 0.35) - val dataSnapshot = createDataSnapshot(data.toMap(), Firebase.database) - assertThat(dataSnapshot.getValue()).isEqualTo(data) - } -} - -@RunWith(RobolectricTestRunner::class) -class MutableDataTests : BaseTestCase() { - @Test - fun `reified getValue works with basic types`() { - val data = - mapOf( - "name" to "John Doe", - "jersey" to 35L, - "goalkeeper" to false, - "avg_goals_per_game" to 0.35 - ) - val mutableData = createMutableData(data) - - assertThat(mutableData.child("name").getValue()).isEqualTo("John Doe") - assertThat(mutableData.child("jersey").getValue()).isEqualTo(35L) - assertThat(mutableData.child("goalkeeper").getValue()).isEqualTo(false) - assertThat(mutableData.child("avg_goals_per_game").getValue()).isEqualTo(0.35) - } - - @Test - fun `reified getValue works with maps`() { - val data = - mapOf( - "name" to "John Doe", - "jersey" to 35L, - "goalkeeper" to false, - "avg_goals_per_game" to 0.35 - ) - val mutableData = createMutableData(data) - assertThat(mutableData.getValue>()).isEqualTo(data) - } - - @Test - fun `reified getValue works with lists types`() { - val data = listOf("George", "John", "Paul", "Ringo") - val mutableData = createMutableData(data) - assertThat(mutableData.getValue>()).isEqualTo(data) - } - - @Test - fun `reified getValue works with custom types`() { - val data = Player(name = "John Doe", jersey = 35, goalkeeper = false, avg_goals_per_game = 0.35) - val mutableData = createMutableData(data.toMap()) - assertThat(mutableData.getValue()).isEqualTo(data) - } -} - -@RunWith(RobolectricTestRunner::class) -class LibraryVersionTest : BaseTestCase() { - @Test - fun `library version should be registered with runtime`() { - val publisher = Firebase.app.get(UserAgentPublisher::class.java) - assertThat(publisher.userAgent).contains(LIBRARY_NAME) - } -} diff --git a/firebase-database/src/main/java/com/google/firebase/database/ktx/ChildEvent.kt b/firebase-database/src/main/java/com/google/firebase/database/ktx/ChildEvent.kt deleted file mode 100644 index 79fb9db7c16..00000000000 --- a/firebase-database/src/main/java/com/google/firebase/database/ktx/ChildEvent.kt +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2022 Google LLC - * - * 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.google.firebase.database.ktx - -import com.google.firebase.database.DataSnapshot - -/** - * Used to emit events about changes in the child locations of a given [Query] when using the - * [childEvents] Flow. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -sealed class ChildEvent { - /** - * Emitted when a new child is added to the location. - * - * @param snapshot An immutable snapshot of the data at the new child location - * @param previousChildName The key name of sibling location ordered before the new child. This - * ``` - * will be null for the first child node of a location. - * ``` - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll - * no longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ - @Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") - ) - data class Added(val snapshot: DataSnapshot, val previousChildName: String?) : ChildEvent() - - /** - * Emitted when the data at a child location has changed. - * - * @param snapshot An immutable snapshot of the data at the new data at the child location - * @param previousChildName The key name of sibling location ordered before the child. This will - * ``` - * be null for the first child node of a location. - * ``` - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll - * no longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ - @Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") - ) - data class Changed(val snapshot: DataSnapshot, val previousChildName: String?) : ChildEvent() - - /** - * Emitted when a child is removed from the location. - * - * @param snapshot An immutable snapshot of the data at the child that was removed. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll - * no longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ - @Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") - ) - data class Removed(val snapshot: DataSnapshot) : ChildEvent() - - /** - * Emitted when a child location's priority changes. - * - * @param snapshot An immutable snapshot of the data at the location that moved. - * @param previousChildName The key name of the sibling location ordered before the child - * ``` - * location. This will be null if this location is ordered first. - * ``` - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll - * no longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ - @Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") - ) - data class Moved(val snapshot: DataSnapshot, val previousChildName: String?) : ChildEvent() -} diff --git a/firebase-database/src/main/java/com/google/firebase/database/ktx/Database.kt b/firebase-database/src/main/java/com/google/firebase/database/ktx/Database.kt deleted file mode 100644 index 684dc9ebd37..00000000000 --- a/firebase-database/src/main/java/com/google/firebase/database/ktx/Database.kt +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * 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.google.firebase.database.ktx - -import androidx.annotation.Keep -import com.google.firebase.FirebaseApp -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.database.ChildEventListener -import com.google.firebase.database.DataSnapshot -import com.google.firebase.database.DatabaseError -import com.google.firebase.database.FirebaseDatabase -import com.google.firebase.database.GenericTypeIndicator -import com.google.firebase.database.MutableData -import com.google.firebase.database.Query -import com.google.firebase.database.ValueEventListener -import com.google.firebase.ktx.Firebase -import kotlinx.coroutines.cancel -import kotlinx.coroutines.channels.awaitClose -import kotlinx.coroutines.channels.trySendBlocking -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.callbackFlow -import kotlinx.coroutines.flow.map - -/** - * Accessing this object for Kotlin apps has changed; see the - * [migration guide](https://firebase.google.com/docs/android/kotlin-migration). - * - * Returns the [FirebaseDatabase] instance of the default [FirebaseApp]. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -val Firebase.database: FirebaseDatabase - get() = FirebaseDatabase.getInstance() - -/** - * Accessing this object for Kotlin apps has changed; see the - * [migration guide](https://firebase.google.com/docs/android/kotlin-migration). - * - * Returns the [FirebaseDatabase] instance for the specified [url]. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -fun Firebase.database(url: String): FirebaseDatabase = FirebaseDatabase.getInstance(url) - -/** - * Accessing this object for Kotlin apps has changed; see the - * [migration guide](https://firebase.google.com/docs/android/kotlin-migration). - * - * Returns the [FirebaseDatabase] instance of the given [FirebaseApp]. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -fun Firebase.database(app: FirebaseApp): FirebaseDatabase = FirebaseDatabase.getInstance(app) - -/** - * Accessing this object for Kotlin apps has changed; see the - * [migration guide](https://firebase.google.com/docs/android/kotlin-migration). - * - * Returns the [FirebaseDatabase] instance of the given [FirebaseApp] and [url]. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -fun Firebase.database(app: FirebaseApp, url: String): FirebaseDatabase = - FirebaseDatabase.getInstance(app, url) - -/** - * Returns the content of the DataSnapshot converted to a POJO. - * - * Supports generics like List<> or Map<>. Use @JvmSuppressWildcards to force the compiler to use - * the type `T`, and not `? extends T`. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -inline fun DataSnapshot.getValue(): T? { - return getValue(object : GenericTypeIndicator() {}) -} - -/** - * Returns the content of the MutableData converted to a POJO. - * - * Supports generics like List<> or Map<>. Use @JvmSuppressWildcards to force the compiler to use - * the type `T`, and not `? extends T`. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -inline fun MutableData.getValue(): T? { - return getValue(object : GenericTypeIndicator() {}) -} - -/** - * Starts listening to this query and emits its values via a [Flow]. - * - * - When the returned flow starts being collected, a [ValueEventListener] will be attached. - * - When the flow completes, the listener will be removed. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -val Query.snapshots - get() = - callbackFlow { - val listener = - addValueEventListener( - object : ValueEventListener { - override fun onDataChange(snapshot: DataSnapshot) { - repo.scheduleNow { trySendBlocking(snapshot) } - } - - override fun onCancelled(error: DatabaseError) { - cancel(message = "Error getting Query snapshot", cause = error.toException()) - } - } - ) - awaitClose { removeEventListener(listener) } - } -/** - * Starts listening to this query's child events and emits its values via a [Flow]. - * - * - When the returned flow starts being collected, a [ChildEventListener] will be attached. - * - When the flow completes, the listener will be removed. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -val Query.childEvents - get() = - callbackFlow { - val listener = - addChildEventListener( - object : ChildEventListener { - override fun onChildAdded(snapshot: DataSnapshot, previousChildName: String?) { - repo.scheduleNow { trySendBlocking(ChildEvent.Added(snapshot, previousChildName)) } - } - - override fun onChildChanged(snapshot: DataSnapshot, previousChildName: String?) { - repo.scheduleNow { trySendBlocking(ChildEvent.Changed(snapshot, previousChildName)) } - } - - override fun onChildRemoved(snapshot: DataSnapshot) { - repo.scheduleNow { trySendBlocking(ChildEvent.Removed(snapshot)) } - } - - override fun onChildMoved(snapshot: DataSnapshot, previousChildName: String?) { - repo.scheduleNow { trySendBlocking(ChildEvent.Moved(snapshot, previousChildName)) } - } - - override fun onCancelled(error: DatabaseError) { - cancel(message = "Error getting Query childEvent", cause = error.toException()) - } - } - ) - awaitClose { removeEventListener(listener) } - } - -/** - * Starts listening to this query and emits its values converted to a POJO via a [Flow]. - * - * - When the returned flow starts being collected, a [ValueEventListener] will be attached. - * - When the flow completes, the listener will be removed. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -inline fun Query.values(): Flow { - return snapshots.map { it.getValue(T::class.java) } -} - -/** - * @suppress - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -@Keep -class FirebaseDatabaseKtxRegistrar : ComponentRegistrar { - override fun getComponents(): List> = listOf() -} diff --git a/firebase-database/src/test/java/com/google/firebase/database/ktx/DatabaseTests.kt b/firebase-database/src/test/java/com/google/firebase/database/ktx/DatabaseTests.kt deleted file mode 100644 index d5859df5751..00000000000 --- a/firebase-database/src/test/java/com/google/firebase/database/ktx/DatabaseTests.kt +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * 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.google.firebase.database.ktx - -import androidx.test.core.app.ApplicationProvider -import com.google.common.truth.Truth.assertThat -import com.google.firebase.FirebaseApp -import com.google.firebase.FirebaseOptions -import com.google.firebase.database.Exclude -import com.google.firebase.database.FirebaseDatabase -import com.google.firebase.database.IgnoreExtraProperties -import com.google.firebase.database.createDataSnapshot -import com.google.firebase.database.createMutableData -import com.google.firebase.ktx.Firebase -import com.google.firebase.ktx.app -import com.google.firebase.ktx.initialize -import com.google.firebase.platforminfo.UserAgentPublisher -import org.junit.After -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.robolectric.RobolectricTestRunner - -const val APP_ID = "APP_ID" -const val API_KEY = "API_KEY" - -const val EXISTING_APP = "existing" - -@IgnoreExtraProperties -data class Player( - var name: String? = "", - var jersey: Int? = -1, - var goalkeeper: Boolean? = false, - var avg_goals_per_game: Double? = 0.0 -) { - @Exclude - fun toMap(): Map { - return mapOf( - "name" to name, - "jersey" to jersey, - "goalkeeper" to goalkeeper, - "avg_goals_per_game" to avg_goals_per_game - ) - } -} - -abstract class BaseTestCase { - @Before - fun setUp() { - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .setDatabaseUrl("http://tests.fblocal.com:9000") - .build() - ) - - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .setDatabaseUrl("http://tests.fblocal.com:9000") - .build(), - EXISTING_APP - ) - } - - @After - fun cleanUp() { - FirebaseApp.clearInstancesForTest() - } -} - -@RunWith(RobolectricTestRunner::class) -class DatabaseTests : BaseTestCase() { - @Test - fun `database should delegate to FirebaseDatabase#getInstance()`() { - assertThat(Firebase.database).isSameInstanceAs(FirebaseDatabase.getInstance()) - } - - @Test - fun `FirebaseApp#database should delegate to FirebaseDatabase#getInstance(FirebaseApp)`() { - val app = Firebase.app(EXISTING_APP) - assertThat(Firebase.database(app)).isSameInstanceAs(FirebaseDatabase.getInstance(app)) - } - - @Test - fun `Firebase#database should delegate to FirebaseDatabase#getInstance(url)`() { - val url = "http://tests.fblocal.com:9000" - assertThat(Firebase.database(url)).isSameInstanceAs(FirebaseDatabase.getInstance(url)) - } - - @Test - fun `Firebase#database should delegate to FirebaseDatabase#getInstance(FirebaseApp, url)`() { - val app = Firebase.app(EXISTING_APP) - val url = "http://tests.fblocal.com:9000" - assertThat(Firebase.database(app, url)).isSameInstanceAs(FirebaseDatabase.getInstance(app, url)) - } -} - -@RunWith(RobolectricTestRunner::class) -class DataSnapshotTests : BaseTestCase() { - @Test - fun `reified getValue works with basic types`() { - val data = - mapOf( - "name" to "John Doe", - "jersey" to 35L, - "goalkeeper" to false, - "avg_goals_per_game" to 0.35 - ) - val dataSnapshot = createDataSnapshot(data, Firebase.database) - assertThat(dataSnapshot.child("name").getValue()).isEqualTo("John Doe") - assertThat(dataSnapshot.child("jersey").getValue()).isEqualTo(35L) - assertThat(dataSnapshot.child("goalkeeper").getValue()).isEqualTo(false) - assertThat(dataSnapshot.child("avg_goals_per_game").getValue()).isEqualTo(0.35) - } - - @Test - fun `reified getValue works with maps`() { - val data = - mapOf( - "name" to "John Doe", - "jersey" to 35L, - "goalkeeper" to false, - "avg_goals_per_game" to 0.35 - ) - val dataSnapshot = createDataSnapshot(data, Firebase.database) - assertThat(dataSnapshot.getValue>()).isEqualTo(data) - } - - @Test - fun `reified getValue works with lists types`() { - val data = listOf("George", "John", "Paul", "Ringo") - val dataSnapshot = createDataSnapshot(data, Firebase.database) - assertThat(dataSnapshot.getValue>()).isEqualTo(data) - } - - @Test - fun `reified getValue works with custom types`() { - val data = Player(name = "John Doe", jersey = 35, goalkeeper = false, avg_goals_per_game = 0.35) - val dataSnapshot = createDataSnapshot(data.toMap(), Firebase.database) - assertThat(dataSnapshot.getValue()).isEqualTo(data) - } -} - -@RunWith(RobolectricTestRunner::class) -class MutableDataTests : BaseTestCase() { - @Test - fun `reified getValue works with basic types`() { - val data = - mapOf( - "name" to "John Doe", - "jersey" to 35L, - "goalkeeper" to false, - "avg_goals_per_game" to 0.35 - ) - val mutableData = createMutableData(data) - - assertThat(mutableData.child("name").getValue()).isEqualTo("John Doe") - assertThat(mutableData.child("jersey").getValue()).isEqualTo(35L) - assertThat(mutableData.child("goalkeeper").getValue()).isEqualTo(false) - assertThat(mutableData.child("avg_goals_per_game").getValue()).isEqualTo(0.35) - } - - @Test - fun `reified getValue works with maps`() { - val data = - mapOf( - "name" to "John Doe", - "jersey" to 35L, - "goalkeeper" to false, - "avg_goals_per_game" to 0.35 - ) - val mutableData = createMutableData(data) - assertThat(mutableData.getValue>()).isEqualTo(data) - } - - @Test - fun `reified getValue works with lists types`() { - val data = listOf("George", "John", "Paul", "Ringo") - val mutableData = createMutableData(data) - assertThat(mutableData.getValue>()).isEqualTo(data) - } - - @Test - fun `reified getValue works with custom types`() { - val data = Player(name = "John Doe", jersey = 35, goalkeeper = false, avg_goals_per_game = 0.35) - val mutableData = createMutableData(data.toMap()) - assertThat(mutableData.getValue()).isEqualTo(data) - } -} - -@RunWith(RobolectricTestRunner::class) -class LibraryVersionTest : BaseTestCase() { - @Test - fun `library version should be registered with runtime`() { - val publisher = Firebase.app.get(UserAgentPublisher::class.java) - } -} diff --git a/firebase-dataconnect/google-services.json b/firebase-dataconnect/google-services.json new file mode 100644 index 00000000000..717e93f77c9 --- /dev/null +++ b/firebase-dataconnect/google-services.json @@ -0,0 +1,29 @@ +{ + "project_info": { + "project_number": "799816452297", + "project_id": "fir-functions-test-4d8fd", + "storage_bucket": "fir-functions-test-4d8fd.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:799816452297:android:bbab11092dd3b71d8ae518", + "android_client_info": { + "package_name": "com.google.firebase.dataconnect" + } + }, + "oauth_client": [], + "api_key": [ + { + "current_key": "AIzaSyDX-ZDDmrNo4zqnKs48-VvrZUePM2udbL4" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [] + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/firebase-dynamic-links/firebase-dynamic-links.gradle b/firebase-dynamic-links/firebase-dynamic-links.gradle new file mode 100644 index 00000000000..4e0cd7cd716 --- /dev/null +++ b/firebase-dynamic-links/firebase-dynamic-links.gradle @@ -0,0 +1,99 @@ +// Copyright 2018 Google LLC +// +// 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. + +plugins { + id 'firebase-library' + id("kotlin-android") +} + +firebaseLibrary { + libraryGroup = "dynamic-links" + testLab.enabled = false + releaseNotes { + name.set("{{ddls}}") + versionName.set("dynamic-links") + } +} + +android { + adbOptions { + timeOutInMs 60 * 1000 + } + + buildFeatures { + aidl true + } + + namespace "com.google.firebase.dynamiclinks" + compileSdkVersion project.compileSdkVersion + defaultConfig { + targetSdkVersion project.targetSdkVersion + minSdkVersion project.minSdkVersion + versionName version + multiDexEnabled true + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + kotlinOptions { jvmTarget = "1.8" } + + packagingOptions { + exclude 'META-INF/DEPENDENCIES' + } + + testOptions.unitTests.includeAndroidResources = true +} + +dependencies { + javadocClasspath libs.autovalue.annotations + javadocClasspath libs.findbugs.jsr305 + javadocClasspath libs.checker.qual + + api libs.playservices.tasks + api('com.google.firebase:firebase-auth-interop:20.0.0') { + exclude group: "com.google.firebase", module: "firebase-common" + } + api("com.google.firebase:firebase-common:21.0.0") + api("com.google.firebase:firebase-components:18.0.0") + api('com.google.firebase:firebase-measurement-connector:19.0.0') { + exclude group: 'com.google.firebase', module: 'firebase-common' + } + + implementation libs.androidx.annotation + implementation libs.playservices.base + implementation libs.playservices.basement + implementation libs.kotlin.stdlib + + testAnnotationProcessor libs.autovalue + + testImplementation libs.androidx.test.core + testImplementation libs.runner + testImplementation libs.jackson.databind + testImplementation('com.google.android.gms:play-services-appinvite:18.0.0') { + exclude group: 'com.google.firebase', module: 'firebase-common' + exclude group: 'com.google.firebase', module: 'firebase-dynamic-links' + } + testImplementation 'com.google.guava:guava-testlib:12.0-rc2' + testImplementation libs.truth + testImplementation libs.junit + testImplementation libs.junit + testImplementation libs.mockito.core + testImplementation libs.mockito.core + testImplementation libs.robolectric + + testCompileOnly libs.autovalue.annotations +} diff --git a/firebase-firestore/api.txt b/firebase-firestore/api.txt index e3a55cf729c..baa44a204b1 100644 --- a/firebase-firestore/api.txt +++ b/firebase-firestore/api.txt @@ -576,33 +576,3 @@ package com.google.firebase.firestore { } -package com.google.firebase.firestore.ktx { - - public final class FirestoreKt { - method @Deprecated public static inline kotlinx.coroutines.flow.Flow dataObjects(com.google.firebase.firestore.DocumentReference, com.google.firebase.firestore.MetadataChanges metadataChanges = com.google.firebase.firestore.MetadataChanges.EXCLUDE); - method @Deprecated public static inline kotlinx.coroutines.flow.Flow> dataObjects(com.google.firebase.firestore.Query, com.google.firebase.firestore.MetadataChanges metadataChanges = com.google.firebase.firestore.MetadataChanges.EXCLUDE); - method @Deprecated public static com.google.firebase.firestore.FirebaseFirestore firestore(com.google.firebase.ktx.Firebase, com.google.firebase.FirebaseApp app); - method @Deprecated public static com.google.firebase.firestore.FirebaseFirestore firestore(com.google.firebase.ktx.Firebase, com.google.firebase.FirebaseApp app, String database); - method @Deprecated public static com.google.firebase.firestore.FirebaseFirestore firestore(com.google.firebase.ktx.Firebase, String database); - method @Deprecated public static com.google.firebase.firestore.FirebaseFirestoreSettings firestoreSettings(kotlin.jvm.functions.Function1 init); - method @Deprecated public static inline T? getField(com.google.firebase.firestore.DocumentSnapshot, com.google.firebase.firestore.FieldPath fieldPath); - method @Deprecated public static inline T? getField(com.google.firebase.firestore.DocumentSnapshot, com.google.firebase.firestore.FieldPath fieldPath, com.google.firebase.firestore.DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior); - method @Deprecated public static inline T? getField(com.google.firebase.firestore.DocumentSnapshot, String field); - method @Deprecated public static inline T? getField(com.google.firebase.firestore.DocumentSnapshot, String field, com.google.firebase.firestore.DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior); - method @Deprecated public static com.google.firebase.firestore.FirebaseFirestore getFirestore(com.google.firebase.ktx.Firebase); - method public static com.google.firebase.firestore.MemoryCacheSettings memoryCacheSettings(kotlin.jvm.functions.Function1 init); - method public static com.google.firebase.firestore.MemoryEagerGcSettings memoryEagerGcSettings(kotlin.jvm.functions.Function1 init); - method public static com.google.firebase.firestore.MemoryLruGcSettings memoryLruGcSettings(kotlin.jvm.functions.Function1 init); - method public static com.google.firebase.firestore.PersistentCacheSettings persistentCacheSettings(kotlin.jvm.functions.Function1 init); - method @Deprecated public static kotlinx.coroutines.flow.Flow snapshots(com.google.firebase.firestore.DocumentReference, com.google.firebase.firestore.MetadataChanges metadataChanges = com.google.firebase.firestore.MetadataChanges.EXCLUDE); - method @Deprecated public static kotlinx.coroutines.flow.Flow snapshots(com.google.firebase.firestore.Query, com.google.firebase.firestore.MetadataChanges metadataChanges = com.google.firebase.firestore.MetadataChanges.EXCLUDE); - method @Deprecated public static inline T? toObject(com.google.firebase.firestore.DocumentSnapshot); - method @Deprecated public static inline T? toObject(com.google.firebase.firestore.DocumentSnapshot, com.google.firebase.firestore.DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior); - method @Deprecated public static inline T toObject(com.google.firebase.firestore.QueryDocumentSnapshot); - method @Deprecated public static inline T toObject(com.google.firebase.firestore.QueryDocumentSnapshot, com.google.firebase.firestore.DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior); - method @Deprecated public static inline java.util.List toObjects(com.google.firebase.firestore.QuerySnapshot); - method @Deprecated public static inline java.util.List toObjects(com.google.firebase.firestore.QuerySnapshot, com.google.firebase.firestore.DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior); - } - -} - diff --git a/firebase-firestore/firebase-firestore.gradle b/firebase-firestore/firebase-firestore.gradle index 806babf6236..299ad8c95f9 100644 --- a/firebase-firestore/firebase-firestore.gradle +++ b/firebase-firestore/firebase-firestore.gradle @@ -129,7 +129,6 @@ dependencies { } api("com.google.firebase:firebase-common:21.0.0") - api("com.google.firebase:firebase-common-ktx:21.0.0") api("com.google.firebase:firebase-components:18.0.0") api('com.google.firebase:firebase-database-collection:18.0.1') diff --git a/firebase-firestore/ktx/api.txt b/firebase-firestore/ktx/api.txt deleted file mode 100644 index da4f6cc18fe..00000000000 --- a/firebase-firestore/ktx/api.txt +++ /dev/null @@ -1 +0,0 @@ -// Signature format: 3.0 diff --git a/firebase-firestore/ktx/gradle.properties b/firebase-firestore/ktx/gradle.properties deleted file mode 100644 index 016fa887bc0..00000000000 --- a/firebase-firestore/ktx/gradle.properties +++ /dev/null @@ -1,2 +0,0 @@ -android.enableUnitTestBinaryResources=true - diff --git a/firebase-firestore/ktx/ktx.gradle b/firebase-firestore/ktx/ktx.gradle deleted file mode 100644 index 88a1e83be26..00000000000 --- a/firebase-firestore/ktx/ktx.gradle +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2019 Google LLC -// -// 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. - -plugins { - id 'firebase-library' - id("kotlin-android") -} - -group = "com.google.firebase" - -firebaseLibrary { - libraryGroup = "firestore" - publishJavadoc = false - releaseNotes { - enabled.set(false) - } -} - -android { - namespace "com.google.firebase.firestore.ktx" - compileSdkVersion project.compileSdkVersion - defaultConfig { - minSdkVersion project.minSdkVersion - multiDexEnabled true - targetSdkVersion project.targetSdkVersion - versionName version - } - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - test.java { - srcDir 'src/test/kotlin' - srcDir 'src/test/java' - } - } - testOptions.unitTests.includeAndroidResources = true - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } -} - -tasks.withType(Test) { - maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1 -} - -dependencies { - api(project(":firebase-firestore")) - api("com.google.firebase:firebase-common:21.0.0") - api("com.google.firebase:firebase-common-ktx:21.0.0") - - implementation("com.google.firebase:firebase-components:18.0.0") - - testImplementation project(':firebase-database-collection') - testImplementation libs.androidx.test.core - testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.9.8' - testImplementation 'com.google.android.gms:play-services-tasks:18.0.1' - testImplementation libs.truth - testImplementation 'junit:junit:4.12' - testImplementation 'org.mockito:mockito-core:2.25.0' - testImplementation libs.robolectric - - testCompileOnly libs.protobuf.java -} diff --git a/firebase-firestore/ktx/src/main/AndroidManifest.xml b/firebase-firestore/ktx/src/main/AndroidManifest.xml deleted file mode 100644 index 3abf3a2ca90..00000000000 --- a/firebase-firestore/ktx/src/main/AndroidManifest.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - diff --git a/firebase-firestore/ktx/src/main/kotlin/com/google/firebase/firestore/ktx/Logging.kt b/firebase-firestore/ktx/src/main/kotlin/com/google/firebase/firestore/ktx/Logging.kt deleted file mode 100644 index 71af63b65b7..00000000000 --- a/firebase-firestore/ktx/src/main/kotlin/com/google/firebase/firestore/ktx/Logging.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2023 Google LLC - * - * 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.google.firebase.firestore.ktx - -import androidx.annotation.Keep -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.firestore.BuildConfig -import com.google.firebase.platforminfo.LibraryVersionComponent - -internal const val LIBRARY_NAME: String = "fire-fst-ktx" - -/** @suppress */ -@Keep -class FirebaseFirestoreLegacyRegistrar : ComponentRegistrar { - override fun getComponents(): List> { - return listOf(LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME)) - } -} diff --git a/firebase-firestore/ktx/src/test/java/com/google/firebase/firestore/TestUtil.java b/firebase-firestore/ktx/src/test/java/com/google/firebase/firestore/TestUtil.java deleted file mode 100644 index a114acf6a84..00000000000 --- a/firebase-firestore/ktx/src/test/java/com/google/firebase/firestore/TestUtil.java +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright 2019 Google LLC -// -// 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.google.firebase.firestore; - -import static com.google.firebase.firestore.testutil.TestUtil.doc; -import static com.google.firebase.firestore.testutil.TestUtil.docSet; -import static com.google.firebase.firestore.testutil.TestUtil.key; -import static org.mockito.Mockito.mock; - -import com.google.firebase.database.collection.ImmutableSortedSet; -import com.google.firebase.firestore.core.DocumentViewChange; -import com.google.firebase.firestore.core.DocumentViewChange.Type; -import com.google.firebase.firestore.core.ViewSnapshot; -import com.google.firebase.firestore.model.Document; -import com.google.firebase.firestore.model.DocumentKey; -import com.google.firebase.firestore.model.DocumentSet; -import com.google.firebase.firestore.model.MutableDocument; -import com.google.firebase.firestore.model.ObjectValue; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -public class TestUtil { - - private static final FirebaseFirestore FIRESTORE = mock(FirebaseFirestore.class); - - public static FirebaseFirestore firestore() { - return FIRESTORE; - } - - public static DocumentSnapshot documentSnapshot( - String path, Map data, boolean isFromCache) { - if (data == null) { - return DocumentSnapshot.fromNoDocument(FIRESTORE, key(path), isFromCache); - } else { - return DocumentSnapshot.fromDocument( - FIRESTORE, doc(path, 1L, data), isFromCache, /* hasPendingWrites= */ false); - } - } - - public static Query query(String path) { - return new Query(com.google.firebase.firestore.testutil.TestUtil.query(path), FIRESTORE); - } - - /** - * A convenience method for creating a particular query snapshot for tests. - * - * @param path To be used in constructing the query. - * @param oldDocs Provides the prior set of documents in the QuerySnapshot. Each entry maps to a - * document, with the key being the document id, and the value being the document contents. - * @param docsToAdd Specifies data to be added into the query snapshot as of now. Each entry maps - * to a document, with the key being the document id, and the value being the document - * contents. - * @param isFromCache Whether the query snapshot is cache result. - * @return A query snapshot that consists of both sets of documents. - */ - public static QuerySnapshot querySnapshot( - String path, - Map oldDocs, - Map docsToAdd, - boolean hasPendingWrites, - boolean isFromCache) { - DocumentSet oldDocuments = docSet(Document.KEY_COMPARATOR); - ImmutableSortedSet mutatedKeys = DocumentKey.emptyKeySet(); - for (Map.Entry pair : oldDocs.entrySet()) { - String docKey = path + "/" + pair.getKey(); - MutableDocument doc = doc(docKey, 1L, pair.getValue()); - if (hasPendingWrites) doc.setHasLocalMutations(); - oldDocuments = oldDocuments.add(doc); - if (hasPendingWrites) { - mutatedKeys = mutatedKeys.insert(key(docKey)); - } - } - DocumentSet newDocuments = docSet(Document.KEY_COMPARATOR); - List documentChanges = new ArrayList<>(); - for (Map.Entry pair : docsToAdd.entrySet()) { - String docKey = path + "/" + pair.getKey(); - MutableDocument docToAdd = doc(docKey, 1L, pair.getValue()); - if (hasPendingWrites) docToAdd.setHasLocalMutations(); - newDocuments = newDocuments.add(docToAdd); - documentChanges.add(DocumentViewChange.create(Type.ADDED, docToAdd)); - - if (hasPendingWrites) { - mutatedKeys = mutatedKeys.insert(key(docKey)); - } - } - ViewSnapshot viewSnapshot = - new ViewSnapshot( - com.google.firebase.firestore.testutil.TestUtil.query(path), - newDocuments, - oldDocuments, - documentChanges, - isFromCache, - mutatedKeys, - /* didSyncStateChange= */ true, - /* excludesMetadataChanges= */ false, - /* hasCachedResults= */ false); - return new QuerySnapshot(query(path), viewSnapshot, FIRESTORE); - } -} diff --git a/firebase-firestore/ktx/src/test/java/com/google/firebase/firestore/testutil/TestUtil.java b/firebase-firestore/ktx/src/test/java/com/google/firebase/firestore/testutil/TestUtil.java deleted file mode 100644 index 1e778b23acc..00000000000 --- a/firebase-firestore/ktx/src/test/java/com/google/firebase/firestore/testutil/TestUtil.java +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2019 Google LLC -// -// 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.google.firebase.firestore.testutil; - -import com.google.firebase.Timestamp; -import com.google.firebase.firestore.UserDataReader; -import com.google.firebase.firestore.core.Query; -import com.google.firebase.firestore.model.DatabaseId; -import com.google.firebase.firestore.model.Document; -import com.google.firebase.firestore.model.DocumentKey; -import com.google.firebase.firestore.model.DocumentSet; -import com.google.firebase.firestore.model.MutableDocument; -import com.google.firebase.firestore.model.ObjectValue; -import com.google.firebase.firestore.model.ResourcePath; -import com.google.firebase.firestore.model.SnapshotVersion; -import com.google.firestore.v1.Value; -import java.util.Comparator; -import java.util.Map; - -/** A set of utilities for tests */ -public class TestUtil { - - public static Value wrap(Object value) { - DatabaseId databaseId = DatabaseId.forProject("project"); - UserDataReader dataReader = new UserDataReader(databaseId); - // HACK: We use parseQueryValue() since it accepts scalars as well as arrays / objects, and - // our tests currently use wrap() pretty generically so we don't know the intent. - return dataReader.parseQueryValue(value); - } - - public static ObjectValue wrapObject(Map value) { - // Cast is safe here because value passed in is a map - return new ObjectValue(wrap(value)); - } - - public static DocumentKey key(String key) { - return DocumentKey.fromPathString(key); - } - - public static ResourcePath path(String key) { - return ResourcePath.fromString(key); - } - - public static Query query(String path) { - return Query.atPath(path(path)); - } - - public static SnapshotVersion version(long versionMicros) { - long seconds = versionMicros / 1000000; - int nanos = (int) (versionMicros % 1000000L) * 1000; - return new SnapshotVersion(new Timestamp(seconds, nanos)); - } - - public static MutableDocument doc(String key, long version, Map data) { - return doc(key(key), version, wrapObject(data)); - } - - public static MutableDocument doc(DocumentKey key, long version, Map data) { - return doc(key, version, wrapObject(data)); - } - - public static MutableDocument doc(String key, long version, ObjectValue data) { - return doc(key(key), version, data); - } - - public static MutableDocument doc(DocumentKey key, long version, ObjectValue data) { - return MutableDocument.newFoundDocument(key, version(version), data); - } - - public static DocumentSet docSet(Comparator comparator, MutableDocument... documents) { - DocumentSet set = DocumentSet.emptySet(comparator); - for (MutableDocument document : documents) { - set = set.add(document); - } - return set; - } -} diff --git a/firebase-firestore/ktx/src/test/kotlin/com/google/firebase/firestore/ktx/FirestoreTests.kt b/firebase-firestore/ktx/src/test/kotlin/com/google/firebase/firestore/ktx/FirestoreTests.kt deleted file mode 100644 index cb31d0b48cb..00000000000 --- a/firebase-firestore/ktx/src/test/kotlin/com/google/firebase/firestore/ktx/FirestoreTests.kt +++ /dev/null @@ -1,270 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * 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.google.firebase.firestore.ktx - -import androidx.test.core.app.ApplicationProvider -import com.google.common.truth.Truth.assertThat -import com.google.firebase.FirebaseApp -import com.google.firebase.FirebaseOptions -import com.google.firebase.firestore.DocumentSnapshot -import com.google.firebase.firestore.FieldPath -import com.google.firebase.firestore.FirebaseFirestore -import com.google.firebase.firestore.FirebaseFirestoreSettings -import com.google.firebase.firestore.PropertyName -import com.google.firebase.firestore.TestUtil -import com.google.firebase.firestore.model.ObjectValue -import com.google.firebase.firestore.testutil.TestUtil.wrap -import com.google.firebase.ktx.Firebase -import com.google.firebase.ktx.app -import com.google.firebase.ktx.initialize -import com.google.firebase.platforminfo.UserAgentPublisher -import org.junit.After -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.Mockito -import org.robolectric.RobolectricTestRunner - -const val APP_ID = "APP_ID" -const val API_KEY = "API_KEY" - -const val EXISTING_APP = "existing" - -abstract class BaseTestCase { - @Before - fun setUp() { - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build() - ) - - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build(), - EXISTING_APP - ) - } - - @After - fun cleanUp() { - FirebaseApp.clearInstancesForTest() - } -} - -@RunWith(RobolectricTestRunner::class) -class FirestoreTests : BaseTestCase() { - - @Test - fun `firestore should delegate to FirebaseFirestore#getInstance()`() { - assertThat(Firebase.firestore).isSameInstanceAs(FirebaseFirestore.getInstance()) - } - - @Test - fun `Database#firestore should delegate to FirebaseFirestore#getInstance(Database)`() { - assertThat(Firebase.firestore("name")).isSameInstanceAs(FirebaseFirestore.getInstance("name")) - } - - @Test - fun `FirebaseApp#firestore should delegate to FirebaseFirestore#getInstance(FirebaseApp)`() { - val app = Firebase.app(EXISTING_APP) - assertThat(Firebase.firestore(app)).isSameInstanceAs(FirebaseFirestore.getInstance(app)) - } - - @Test - fun `FirebaseApp#Database#firestore should delegate to FirebaseFirestore#getInstance(FirebaseApp,Database)`() { - val app = Firebase.app(EXISTING_APP) - assertThat(Firebase.firestore(app, "name")) - .isSameInstanceAs(FirebaseFirestore.getInstance(app, "name")) - } - - @Test - fun `FirebaseFirestoreSettings builder works`() { - val host = "http://10.0.2.2:8080" - val isSslEnabled = false - val isPersistenceEnabled = false - - val settings = firestoreSettings { - this.host = host - this.isSslEnabled = isSslEnabled - this.isPersistenceEnabled = isPersistenceEnabled - } - - assertThat(host).isEqualTo(settings.host) - assertThat(isSslEnabled).isEqualTo(settings.isSslEnabled) - assertThat(isPersistenceEnabled).isEqualTo(settings.isPersistenceEnabled) - } - - @Test - fun `LocalCacheSettings builder works`() { - val host = "http://10.0.2.2:8080" - val isSslEnabled = false - - val settings = firestoreSettings { - this.host = host - this.isSslEnabled = isSslEnabled - this.setLocalCacheSettings(persistentCacheSettings { setSizeBytes(1_000_000) }) - } - - assertThat(host).isEqualTo(settings.host) - assertThat(isSslEnabled).isEqualTo(settings.isSslEnabled) - assertThat(settings.isPersistenceEnabled).isTrue() - assertThat(settings.cacheSizeBytes).isEqualTo(1_000_000) - - val otherSettings = firestoreSettings { this.setLocalCacheSettings(memoryCacheSettings {}) } - - assertThat(otherSettings.host).isEqualTo(FirebaseFirestoreSettings.DEFAULT_HOST) - assertThat(otherSettings.isSslEnabled).isEqualTo(true) - assertThat(otherSettings.isPersistenceEnabled).isFalse() - } - - @Test - fun `MemoryCacheSettings Garbage Collector builder works`() { - val host = "http://10.0.2.2:8080" - val isSslEnabled = false - - val settings = firestoreSettings { - this.host = host - this.isSslEnabled = isSslEnabled - this.setLocalCacheSettings(memoryCacheSettings {}) - } - - assertThat(host).isEqualTo(settings.host) - assertThat(isSslEnabled).isEqualTo(settings.isSslEnabled) - assertThat(settings.isPersistenceEnabled).isFalse() - assertThat(settings.cacheSettings) - .isEqualTo(memoryCacheSettings { setGcSettings(memoryEagerGcSettings {}) }) - - val otherSettings = firestoreSettings { - this.setLocalCacheSettings( - memoryCacheSettings { setGcSettings(memoryLruGcSettings { setSizeBytes(1_000) }) } - ) - } - - assertThat(otherSettings.host).isEqualTo(FirebaseFirestoreSettings.DEFAULT_HOST) - assertThat(otherSettings.isPersistenceEnabled).isFalse() - assertThat(otherSettings.cacheSizeBytes).isEqualTo(1_000) - } -} - -@RunWith(RobolectricTestRunner::class) -class LibraryVersionTest : BaseTestCase() { - @Test - fun `library version should be registered with runtime`() { - val publisher = Firebase.app.get(UserAgentPublisher::class.java) - assertThat(publisher.userAgent).contains(LIBRARY_NAME) - } -} - -data class Room(var a: Int = 0, var b: Int = 0) - -// NOTE: When Kotlin properties are annotated with `PropertyName` they need to use @get and @set. -// Also, the properties need to be mutable; that is, declared with `var` and not `val`. -// See https://github.com/firebase/firebase-android-sdk/issues/4822 -data class DataClassWithPropertyName( - @get:PropertyName("dbName") @set:PropertyName("dbName") var objName: String = "DefaultObjName" -) - -@RunWith(RobolectricTestRunner::class) -class DocumentSnapshotTests { - @Before - fun setup() { - Mockito.`when`(TestUtil.firestore().firestoreSettings) - .thenReturn(FirebaseFirestoreSettings.Builder().build()) - } - - @After - fun cleanup() { - Mockito.reset(TestUtil.firestore()) - } - - @Test - fun `reified getField delegates to get()`() { - val ds = TestUtil.documentSnapshot("rooms/foo", mapOf("a" to 1, "b" to 2), false) - - assertThat(ds.getField("a")).isEqualTo(ds.get("a", Int::class.java)) - assertThat(ds.getField(FieldPath.of("a"))) - .isEqualTo(ds.get(FieldPath.of("a"), Int::class.java)) - - assertThat(ds.getField("a", DocumentSnapshot.ServerTimestampBehavior.ESTIMATE)) - .isEqualTo(ds.get("a", Int::class.java, DocumentSnapshot.ServerTimestampBehavior.ESTIMATE)) - assertThat( - ds.getField(FieldPath.of("a"), DocumentSnapshot.ServerTimestampBehavior.ESTIMATE) - ) - .isEqualTo(ds.get(FieldPath.of("a"), Int::class.java)) - } - - @Test - fun `reified toObject delegates to toObject(Class)`() { - val ds = TestUtil.documentSnapshot("rooms/foo", mapOf("a" to 1, "b" to 2), false) - - var room = ds.toObject() - assertThat(room).isEqualTo(Room(1, 2)) - assertThat(room).isEqualTo(ds.toObject(Room::class.java)) - - room = ds.toObject(DocumentSnapshot.ServerTimestampBehavior.ESTIMATE) - assertThat(room).isEqualTo(Room(1, 2)) - assertThat(room) - .isEqualTo(ds.toObject(Room::class.java, DocumentSnapshot.ServerTimestampBehavior.ESTIMATE)) - } - - @Test - fun `PropertyName annotation works on data classes`() { - val ds = TestUtil.documentSnapshot("foo/bar", mapOf("dbName" to "CustomValue"), false) - - val toObjectReturnValue = ds.toObject() - - assertThat(toObjectReturnValue).isEqualTo(DataClassWithPropertyName("CustomValue")) - } -} - -@RunWith(RobolectricTestRunner::class) -class QuerySnapshotTests { - @Before - fun setup() { - Mockito.`when`(TestUtil.firestore().firestoreSettings) - .thenReturn(FirebaseFirestoreSettings.Builder().build()) - } - - @After - fun cleanup() { - Mockito.reset(TestUtil.firestore()) - } - - @Test - fun `reified toObjects delegates to toObjects(Class)`() { - val qs = - TestUtil.querySnapshot( - "rooms", - mapOf(), - mapOf("id" to ObjectValue.fromMap(mapOf("a" to wrap(1), "b" to wrap(2)))), - false, - false - ) - - assertThat(qs.toObjects()).containsExactly(Room(1, 2)) - assertThat(qs.toObjects(DocumentSnapshot.ServerTimestampBehavior.ESTIMATE)) - .containsExactly(Room(1, 2)) - } -} diff --git a/firebase-firestore/src/main/java/com/google/firebase/firestore/ktx/Firestore.kt b/firebase-firestore/src/main/java/com/google/firebase/firestore/ktx/Firestore.kt deleted file mode 100644 index b27ecda6764..00000000000 --- a/firebase-firestore/src/main/java/com/google/firebase/firestore/ktx/Firestore.kt +++ /dev/null @@ -1,493 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * 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.google.firebase.firestore.ktx - -import androidx.annotation.Keep -import com.google.firebase.FirebaseApp -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.firestore.DocumentReference -import com.google.firebase.firestore.DocumentSnapshot -import com.google.firebase.firestore.EventListener -import com.google.firebase.firestore.FieldPath -import com.google.firebase.firestore.FirebaseFirestore -import com.google.firebase.firestore.FirebaseFirestoreSettings -import com.google.firebase.firestore.MemoryCacheSettings -import com.google.firebase.firestore.MemoryEagerGcSettings -import com.google.firebase.firestore.MemoryLruGcSettings -import com.google.firebase.firestore.MetadataChanges -import com.google.firebase.firestore.PersistentCacheSettings -import com.google.firebase.firestore.Query -import com.google.firebase.firestore.QueryDocumentSnapshot -import com.google.firebase.firestore.QuerySnapshot -import com.google.firebase.firestore.util.Executors.BACKGROUND_EXECUTOR -import com.google.firebase.ktx.Firebase -import kotlinx.coroutines.cancel -import kotlinx.coroutines.channels.awaitClose -import kotlinx.coroutines.channels.trySendBlocking -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.callbackFlow -import kotlinx.coroutines.flow.map - -/** - * Accessing this object for Kotlin apps has changed; see the - * [migration guide](https://firebase.google.com/docs/android/kotlin-migration). - * - * Returns the [FirebaseFirestore] instance of the default [FirebaseApp]. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -val Firebase.firestore: FirebaseFirestore - get() = FirebaseFirestore.getInstance() - -/** - * Accessing this object for Kotlin apps has changed; see the - * [migration guide](https://firebase.google.com/docs/android/kotlin-migration). - * - * Returns the [FirebaseFirestore] instance of a given [FirebaseApp]. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -fun Firebase.firestore(app: FirebaseApp): FirebaseFirestore = FirebaseFirestore.getInstance(app) - -/** - * Accessing this object for Kotlin apps has changed; see the - * [migration guide](https://firebase.google.com/docs/android/kotlin-migration). - * - * Returns the [FirebaseFirestore] instance of a given [FirebaseApp] and database name. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -fun Firebase.firestore(app: FirebaseApp, database: String): FirebaseFirestore = - FirebaseFirestore.getInstance(app, database) - -/** - * Accessing this object for Kotlin apps has changed; see the - * [migration guide](https://firebase.google.com/docs/android/kotlin-migration). - * - * Returns the [FirebaseFirestore] instance of the default [FirebaseApp], given the database name. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -fun Firebase.firestore(database: String): FirebaseFirestore = - FirebaseFirestore.getInstance(database) - -/** - * Returns the contents of the document converted to a POJO or null if the document doesn't exist. - * - * @param T The type of the object to create. - * @return The contents of the document in an object of type T or null if the document doesn't - * ``` - * exist. - * ``` - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -inline fun DocumentSnapshot.toObject(): T? = toObject(T::class.java) - -/** - * Returns the contents of the document converted to a POJO or null if the document doesn't exist. - * - * @param T The type of the object to create. - * @param serverTimestampBehavior Configures the behavior for server timestamps that have not yet - * ``` - * been set to their final value. - * @return - * ``` - * The contents of the document in an object of type T or null if the document doesn't - * ``` - * exist. - * ``` - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -inline fun DocumentSnapshot.toObject( - serverTimestampBehavior: DocumentSnapshot.ServerTimestampBehavior -): T? = toObject(T::class.java, serverTimestampBehavior) - -/** - * Returns the value at the field, converted to a POJO, or null if the field or document doesn't - * exist. - * - * @param field The path to the field. - * @param T The type to convert the field value to. - * @return The value at the given field or null. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -inline fun DocumentSnapshot.getField(field: String): T? = get(field, T::class.java) - -/** - * Returns the value at the field, converted to a POJO, or null if the field or document doesn't - * exist. - * - * @param field The path to the field. - * @param T The type to convert the field value to. - * @param serverTimestampBehavior Configures the behavior for server timestamps that have not yet - * ``` - * been set to their final value. - * @return - * ``` - * The value at the given field or null. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -inline fun DocumentSnapshot.getField( - field: String, - serverTimestampBehavior: DocumentSnapshot.ServerTimestampBehavior -): T? = get(field, T::class.java, serverTimestampBehavior) - -/** - * Returns the value at the field, converted to a POJO, or null if the field or document doesn't - * exist. - * - * @param fieldPath The path to the field. - * @param T The type to convert the field value to. - * @return The value at the given field or null. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -inline fun DocumentSnapshot.getField(fieldPath: FieldPath): T? = - get(fieldPath, T::class.java) - -/** - * Returns the value at the field, converted to a POJO, or null if the field or document doesn't - * exist. - * - * @param fieldPath The path to the field. - * @param T The type to convert the field value to. - * @param serverTimestampBehavior Configures the behavior for server timestamps that have not yet - * ``` - * been set to their final value. - * @return - * ``` - * The value at the given field or null. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -inline fun DocumentSnapshot.getField( - fieldPath: FieldPath, - serverTimestampBehavior: DocumentSnapshot.ServerTimestampBehavior -): T? = get(fieldPath, T::class.java, serverTimestampBehavior) - -/** - * Returns the contents of the document converted to a POJO. - * - * @param T The type of the object to create. - * @return The contents of the document in an object of type T. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -inline fun QueryDocumentSnapshot.toObject(): T = toObject(T::class.java) - -/** - * Returns the contents of the document converted to a POJO. - * - * @param T The type of the object to create. - * @param serverTimestampBehavior Configures the behavior for server timestamps that have not yet - * ``` - * been set to their final value. - * @return - * ``` - * The contents of the document in an object of type T. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -inline fun QueryDocumentSnapshot.toObject( - serverTimestampBehavior: DocumentSnapshot.ServerTimestampBehavior -): T = toObject(T::class.java, serverTimestampBehavior) - -/** - * Returns the contents of the documents in the QuerySnapshot, converted to the provided class, as a - * list. - * - * @param T The POJO type used to convert the documents in the list. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -inline fun QuerySnapshot.toObjects(): List = toObjects(T::class.java) - -/** - * Returns the contents of the documents in the QuerySnapshot, converted to the provided class, as a - * list. - * - * @param T The POJO type used to convert the documents in the list. - * @param serverTimestampBehavior Configures the behavior for server timestamps that have not yet - * ``` - * been set to their final value. - * ``` - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -inline fun QuerySnapshot.toObjects( - serverTimestampBehavior: DocumentSnapshot.ServerTimestampBehavior -): List = toObjects(T::class.java, serverTimestampBehavior) - -/** - * Returns a [FirebaseFirestoreSettings] instance initialized using the [init] function. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -fun firestoreSettings( - init: FirebaseFirestoreSettings.Builder.() -> Unit -): FirebaseFirestoreSettings { - val builder = FirebaseFirestoreSettings.Builder() - builder.init() - return builder.build() -} - -fun memoryCacheSettings(init: MemoryCacheSettings.Builder.() -> Unit): MemoryCacheSettings { - val builder = MemoryCacheSettings.newBuilder() - builder.init() - return builder.build() -} - -fun memoryEagerGcSettings(init: MemoryEagerGcSettings.Builder.() -> Unit): MemoryEagerGcSettings { - val builder = MemoryEagerGcSettings.newBuilder() - builder.init() - return builder.build() -} - -fun memoryLruGcSettings(init: MemoryLruGcSettings.Builder.() -> Unit): MemoryLruGcSettings { - val builder = MemoryLruGcSettings.newBuilder() - builder.init() - return builder.build() -} - -fun persistentCacheSettings( - init: PersistentCacheSettings.Builder.() -> Unit -): PersistentCacheSettings { - val builder = PersistentCacheSettings.newBuilder() - builder.init() - return builder.build() -} - -/** - * @suppress - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -@Keep -class FirebaseFirestoreKtxRegistrar : ComponentRegistrar { - override fun getComponents(): List> = listOf() -} - -/** - * Starts listening to the document referenced by this `DocumentReference` with the given options - * and emits its values via a [Flow]. - * - * - When the returned flow starts being collected, an [EventListener] will be attached. - * - When the flow completes, the listener will be removed. - * - * @param metadataChanges controls metadata-only changes. Default: [MetadataChanges.EXCLUDE] - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated("com.google.firebase.fires", ReplaceWith("")) -fun DocumentReference.snapshots( - metadataChanges: MetadataChanges = MetadataChanges.EXCLUDE -): Flow { - return callbackFlow { - val registration = - addSnapshotListener(BACKGROUND_EXECUTOR, metadataChanges) { snapshot, exception -> - if (exception != null) { - cancel(message = "Error getting DocumentReference snapshot", cause = exception) - } else if (snapshot != null) { - trySendBlocking(snapshot) - } - } - awaitClose { registration.remove() } - } -} - -/** - * Starts listening to this query with the given options and emits its values via a [Flow]. - * - * - When the returned flow starts being collected, an [EventListener] will be attached. - * - When the flow completes, the listener will be removed. - * - * @param metadataChanges controls metadata-only changes. Default: [MetadataChanges.EXCLUDE] - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -fun Query.snapshots( - metadataChanges: MetadataChanges = MetadataChanges.EXCLUDE -): Flow { - return callbackFlow { - val registration = - addSnapshotListener(BACKGROUND_EXECUTOR, metadataChanges) { snapshot, exception -> - if (exception != null) { - cancel(message = "Error getting Query snapshot", cause = exception) - } else if (snapshot != null) { - trySendBlocking(snapshot) - } - } - awaitClose { registration.remove() } - } -} - -/** - * Starts listening to this query with the given options and emits its values converted to a POJO - * via a [Flow]. - * - * - When the returned flow starts being collected, an [EventListener] will be attached. - * - When the flow completes, the listener will be removed. - * - * @param metadataChanges controls metadata-only changes. Default: [MetadataChanges.EXCLUDE] - * @param T The type of the object to convert to. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -inline fun Query.dataObjects( - metadataChanges: MetadataChanges = MetadataChanges.EXCLUDE -): Flow> = snapshots(metadataChanges).map { it.toObjects(T::class.java) } - -/** - * Starts listening to the document referenced by this `DocumentReference` with the given options - * and emits its values converted to a POJO via a [Flow]. - * - * - When the returned flow starts being collected, an [EventListener] will be attached. - * - When the flow completes, the listener will be removed. - * - * @param metadataChanges controls metadata-only changes. Default: [MetadataChanges.EXCLUDE] - * @param T The type of the object to convert to. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-database-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -inline fun DocumentReference.dataObjects( - metadataChanges: MetadataChanges = MetadataChanges.EXCLUDE -): Flow = snapshots(metadataChanges).map { it.toObject(T::class.java) } diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/ktx/FirestoreTests.kt b/firebase-firestore/src/test/java/com/google/firebase/firestore/ktx/FirestoreTests.kt deleted file mode 100644 index 74ea542b22d..00000000000 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/ktx/FirestoreTests.kt +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * 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.google.firebase.firestore.ktx - -import androidx.test.core.app.ApplicationProvider -import com.google.common.truth.Truth.assertThat -import com.google.firebase.FirebaseApp -import com.google.firebase.FirebaseOptions -import com.google.firebase.firestore.DocumentSnapshot -import com.google.firebase.firestore.FieldPath -import com.google.firebase.firestore.FirebaseFirestore -import com.google.firebase.firestore.FirebaseFirestoreSettings -import com.google.firebase.firestore.PropertyName -import com.google.firebase.firestore.TestUtilKtx -import com.google.firebase.firestore.model.ObjectValue -import com.google.firebase.firestore.testutil.TestUtilKtx.wrap -import com.google.firebase.ktx.Firebase -import com.google.firebase.ktx.app -import com.google.firebase.ktx.initialize -import com.google.firebase.platforminfo.UserAgentPublisher -import org.junit.After -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.Mockito -import org.robolectric.RobolectricTestRunner - -const val APP_ID = "APP_ID" -const val API_KEY = "API_KEY" - -const val EXISTING_APP = "existing" - -abstract class BaseTestCase { - @Before - fun setUp() { - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build() - ) - - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build(), - EXISTING_APP - ) - } - - @After - fun cleanUp() { - FirebaseApp.clearInstancesForTest() - } -} - -@RunWith(RobolectricTestRunner::class) -class FirestoreTests : BaseTestCase() { - - @Test - fun `firestore should delegate to FirebaseFirestore#getInstance()`() { - assertThat(Firebase.firestore).isSameInstanceAs(FirebaseFirestore.getInstance()) - } - - @Test - fun `Database#firestore should delegate to FirebaseFirestore#getInstance(Database)`() { - assertThat(Firebase.firestore("name")).isSameInstanceAs(FirebaseFirestore.getInstance("name")) - } - - @Test - fun `FirebaseApp#firestore should delegate to FirebaseFirestore#getInstance(FirebaseApp)`() { - val app = Firebase.app(EXISTING_APP) - assertThat(Firebase.firestore(app)).isSameInstanceAs(FirebaseFirestore.getInstance(app)) - } - - @Test - fun `FirebaseApp#Database#firestore should delegate to FirebaseFirestore#getInstance(FirebaseApp,Database)`() { - val app = Firebase.app(EXISTING_APP) - assertThat(Firebase.firestore(app, "name")) - .isSameInstanceAs(FirebaseFirestore.getInstance(app, "name")) - } - - @Test - fun `FirebaseFirestoreSettings builder works`() { - val host = "http://10.0.2.2:8080" - val isSslEnabled = false - val isPersistenceEnabled = false - - val settings = firestoreSettings { - this.host = host - this.isSslEnabled = isSslEnabled - this.isPersistenceEnabled = isPersistenceEnabled - } - - assertThat(host).isEqualTo(settings.host) - assertThat(isSslEnabled).isEqualTo(settings.isSslEnabled) - assertThat(isPersistenceEnabled).isEqualTo(settings.isPersistenceEnabled) - } - - @Test - fun `LocalCacheSettings builder works`() { - val host = "http://10.0.2.2:8080" - val isSslEnabled = false - - val settings = firestoreSettings { - this.host = host - this.isSslEnabled = isSslEnabled - this.setLocalCacheSettings(persistentCacheSettings { setSizeBytes(1_000_000) }) - } - - assertThat(host).isEqualTo(settings.host) - assertThat(isSslEnabled).isEqualTo(settings.isSslEnabled) - assertThat(settings.isPersistenceEnabled).isTrue() - assertThat(settings.cacheSizeBytes).isEqualTo(1_000_000) - - val otherSettings = firestoreSettings { this.setLocalCacheSettings(memoryCacheSettings {}) } - - assertThat(otherSettings.host).isEqualTo(FirebaseFirestoreSettings.DEFAULT_HOST) - assertThat(otherSettings.isSslEnabled).isEqualTo(true) - assertThat(otherSettings.isPersistenceEnabled).isFalse() - } - - @Test - fun `MemoryCacheSettings Garbage Collector builder works`() { - val host = "http://10.0.2.2:8080" - val isSslEnabled = false - - val settings = firestoreSettings { - this.host = host - this.isSslEnabled = isSslEnabled - this.setLocalCacheSettings(memoryCacheSettings {}) - } - - assertThat(host).isEqualTo(settings.host) - assertThat(isSslEnabled).isEqualTo(settings.isSslEnabled) - assertThat(settings.isPersistenceEnabled).isFalse() - assertThat(settings.cacheSettings) - .isEqualTo(memoryCacheSettings { setGcSettings(memoryEagerGcSettings {}) }) - - val otherSettings = firestoreSettings { - this.setLocalCacheSettings( - memoryCacheSettings { setGcSettings(memoryLruGcSettings { setSizeBytes(1_000) }) } - ) - } - - assertThat(otherSettings.host).isEqualTo(FirebaseFirestoreSettings.DEFAULT_HOST) - assertThat(otherSettings.isPersistenceEnabled).isFalse() - assertThat(otherSettings.cacheSizeBytes).isEqualTo(1_000) - } -} - -@RunWith(RobolectricTestRunner::class) -class LibraryVersionTest : BaseTestCase() { - @Test - fun `library version should be registered with runtime`() { - val publisher = Firebase.app.get(UserAgentPublisher::class.java) - } -} - -data class Room(var a: Int = 0, var b: Int = 0) - -// NOTE: When Kotlin properties are annotated with `PropertyName` they need to use @get and @set. -// Also, the properties need to be mutable; that is, declared with `var` and not `val`. -// See https://github.com/firebase/firebase-android-sdk/issues/4822 -data class DataClassWithPropertyName( - @get:PropertyName("dbName") @set:PropertyName("dbName") var objName: String = "DefaultObjName" -) - -@RunWith(RobolectricTestRunner::class) -class DocumentSnapshotTests { - @Before - fun setup() { - Mockito.`when`(TestUtilKtx.firestore().firestoreSettings) - .thenReturn(FirebaseFirestoreSettings.Builder().build()) - } - - @After - fun cleanup() { - Mockito.reset(TestUtilKtx.firestore()) - } - - @Test - fun `reified getField delegates to get()`() { - val ds = TestUtilKtx.documentSnapshot("rooms/foo", mapOf("a" to 1, "b" to 2), false) - - assertThat(ds.getField("a")).isEqualTo(ds.get("a", Int::class.java)) - assertThat(ds.getField(FieldPath.of("a"))) - .isEqualTo(ds.get(FieldPath.of("a"), Int::class.java)) - - assertThat(ds.getField("a", DocumentSnapshot.ServerTimestampBehavior.ESTIMATE)) - .isEqualTo(ds.get("a", Int::class.java, DocumentSnapshot.ServerTimestampBehavior.ESTIMATE)) - assertThat( - ds.getField(FieldPath.of("a"), DocumentSnapshot.ServerTimestampBehavior.ESTIMATE) - ) - .isEqualTo(ds.get(FieldPath.of("a"), Int::class.java)) - } - - @Test - fun `reified toObject delegates to toObject(Class)`() { - val ds = TestUtilKtx.documentSnapshot("rooms/foo", mapOf("a" to 1, "b" to 2), false) - - var room = ds.toObject() - assertThat(room).isEqualTo(Room(1, 2)) - assertThat(room).isEqualTo(ds.toObject(Room::class.java)) - - room = ds.toObject(DocumentSnapshot.ServerTimestampBehavior.ESTIMATE) - assertThat(room).isEqualTo(Room(1, 2)) - assertThat(room) - .isEqualTo(ds.toObject(Room::class.java, DocumentSnapshot.ServerTimestampBehavior.ESTIMATE)) - } - - @Test - fun `PropertyName annotation works on data classes`() { - val ds = TestUtilKtx.documentSnapshot("foo/bar", mapOf("dbName" to "CustomValue"), false) - - val toObjectReturnValue = ds.toObject() - - assertThat(toObjectReturnValue).isEqualTo(DataClassWithPropertyName("CustomValue")) - } -} - -@RunWith(RobolectricTestRunner::class) -class QuerySnapshotTests { - @Before - fun setup() { - Mockito.`when`(TestUtilKtx.firestore().firestoreSettings) - .thenReturn(FirebaseFirestoreSettings.Builder().build()) - } - - @After - fun cleanup() { - Mockito.reset(TestUtilKtx.firestore()) - } - - @Test - fun `reified toObjects delegates to toObjects(Class)`() { - val qs = - TestUtilKtx.querySnapshot( - "rooms", - mapOf(), - mapOf("id" to ObjectValue.fromMap(mapOf("a" to wrap(1), "b" to wrap(2)))), - false, - false - ) - - assertThat(qs.toObjects()).containsExactly(Room(1, 2)) - assertThat(qs.toObjects(DocumentSnapshot.ServerTimestampBehavior.ESTIMATE)) - .containsExactly(Room(1, 2)) - } -} diff --git a/firebase-functions/api.txt b/firebase-functions/api.txt index 1a12a250b35..8d7c2ffa995 100644 --- a/firebase-functions/api.txt +++ b/firebase-functions/api.txt @@ -112,16 +112,3 @@ package com.google.firebase.functions { } -package com.google.firebase.functions.ktx { - - public final class FunctionsKt { - method @Deprecated public static com.google.firebase.functions.FirebaseFunctions functions(com.google.firebase.ktx.Firebase, com.google.firebase.FirebaseApp app); - method @Deprecated public static com.google.firebase.functions.FirebaseFunctions functions(com.google.firebase.ktx.Firebase, com.google.firebase.FirebaseApp app, String regionOrCustomDomain); - method @Deprecated public static com.google.firebase.functions.FirebaseFunctions functions(com.google.firebase.ktx.Firebase, String regionOrCustomDomain); - method @Deprecated public static com.google.firebase.functions.FirebaseFunctions getFunctions(com.google.firebase.ktx.Firebase); - method @Deprecated public static com.google.firebase.functions.HttpsCallableReference getHttpsCallable(com.google.firebase.functions.FirebaseFunctions, String name, kotlin.jvm.functions.Function1 init); - method @Deprecated public static com.google.firebase.functions.HttpsCallableReference getHttpsCallableFromUrl(com.google.firebase.functions.FirebaseFunctions, java.net.URL url, kotlin.jvm.functions.Function1 init); - } - -} - diff --git a/firebase-functions/firebase-functions.gradle.kts b/firebase-functions/firebase-functions.gradle.kts index b1c220a6594..39168076e03 100644 --- a/firebase-functions/firebase-functions.gradle.kts +++ b/firebase-functions/firebase-functions.gradle.kts @@ -95,7 +95,6 @@ dependencies { api("com.google.firebase:firebase-appcheck-interop:17.1.0") api("com.google.firebase:firebase-common:21.0.0") - api("com.google.firebase:firebase-common-ktx:21.0.0") api("com.google.firebase:firebase-components:18.0.0") api("com.google.firebase:firebase-annotations:16.2.0") api("com.google.firebase:firebase-auth-interop:18.0.0") { diff --git a/firebase-functions/ktx/api.txt b/firebase-functions/ktx/api.txt deleted file mode 100644 index da4f6cc18fe..00000000000 --- a/firebase-functions/ktx/api.txt +++ /dev/null @@ -1 +0,0 @@ -// Signature format: 3.0 diff --git a/firebase-functions/ktx/gradle.properties b/firebase-functions/ktx/gradle.properties deleted file mode 100644 index 016fa887bc0..00000000000 --- a/firebase-functions/ktx/gradle.properties +++ /dev/null @@ -1,2 +0,0 @@ -android.enableUnitTestBinaryResources=true - diff --git a/firebase-functions/ktx/ktx.gradle.kts b/firebase-functions/ktx/ktx.gradle.kts deleted file mode 100644 index a40052eb371..00000000000 --- a/firebase-functions/ktx/ktx.gradle.kts +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// 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. - -plugins { - id("firebase-library") - id("kotlin-android") -} - -firebaseLibrary { - libraryGroup = "functions" - publishJavadoc = false - releaseNotes { enabled.set(false) } - testLab.enabled = true -} - -android { - val compileSdkVersion: Int by rootProject - val targetSdkVersion: Int by rootProject - val minSdkVersion: Int by rootProject - - namespace = "com.google.firebase.functions.ktx" - compileSdk = compileSdkVersion - defaultConfig { - minSdk = minSdkVersion - targetSdk = targetSdkVersion - multiDexEnabled = true - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - sourceSets { - getByName("main").java.srcDirs("src/main/kotlin") - getByName("test").java.srcDirs("src/test/kotlin") - getByName("androidTest").java.srcDirs("src/androidTest/kotlin") - } - testOptions.unitTests.isIncludeAndroidResources = true -} - -dependencies { - api("com.google.firebase:firebase-common:21.0.0") - api("com.google.firebase:firebase-common-ktx:21.0.0") - api(project(":firebase-functions")) - - implementation("com.google.firebase:firebase-components:18.0.0") - - testImplementation(libs.androidx.test.core) - testImplementation(libs.junit) - testImplementation(libs.robolectric) - testImplementation(libs.truth) - - androidTestImplementation(libs.androidx.test.runner) - androidTestImplementation(libs.junit) - androidTestImplementation(libs.truth) -} diff --git a/firebase-functions/ktx/src/androidTest/AndroidManifest.xml b/firebase-functions/ktx/src/androidTest/AndroidManifest.xml deleted file mode 100644 index d5b1f2e017a..00000000000 --- a/firebase-functions/ktx/src/androidTest/AndroidManifest.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - diff --git a/firebase-functions/ktx/src/androidTest/README.md b/firebase-functions/ktx/src/androidTest/README.md deleted file mode 100644 index 4f233c0f377..00000000000 --- a/firebase-functions/ktx/src/androidTest/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Running integration tests - -To run these integration tests, please deploy the required functions as -described in `../../../src/androidTest/backend/README.md` diff --git a/firebase-functions/ktx/src/main/AndroidManifest.xml b/firebase-functions/ktx/src/main/AndroidManifest.xml deleted file mode 100644 index 336b52fc894..00000000000 --- a/firebase-functions/ktx/src/main/AndroidManifest.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - diff --git a/firebase-functions/ktx/src/main/kotlin/com/google/firebase/functions/ktx/Logging.kt b/firebase-functions/ktx/src/main/kotlin/com/google/firebase/functions/ktx/Logging.kt deleted file mode 100644 index f5661d4caaf..00000000000 --- a/firebase-functions/ktx/src/main/kotlin/com/google/firebase/functions/ktx/Logging.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2023 Google LLC - * - * 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.google.firebase.functions.ktx - -import androidx.annotation.Keep -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.functions.BuildConfig -import com.google.firebase.platforminfo.LibraryVersionComponent - -internal const val LIBRARY_NAME: String = "fire-fun-ktx" - -/** @suppress */ -@Keep -class FirebaseFunctionsLegacyRegistrar : ComponentRegistrar { - override fun getComponents(): List> { - return listOf(LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME)) - } -} diff --git a/firebase-functions/src/androidTest/java/com/google/firebase/functions/ktx/CallTests.kt b/firebase-functions/src/androidTest/java/com/google/firebase/functions/ktx/CallTests.kt deleted file mode 100644 index dae8690718d..00000000000 --- a/firebase-functions/src/androidTest/java/com/google/firebase/functions/ktx/CallTests.kt +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * 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.google.firebase.functions.ktx - -import androidx.test.InstrumentationRegistry -import androidx.test.runner.AndroidJUnit4 -import com.google.android.gms.tasks.Tasks -import com.google.common.truth.Truth.assertThat -import com.google.firebase.FirebaseApp -import com.google.firebase.ktx.Firebase -import com.google.firebase.ktx.app -import com.google.firebase.ktx.initialize -import org.junit.AfterClass -import org.junit.BeforeClass -import org.junit.Test -import org.junit.runner.RunWith - -const val APP_ID = "APP_ID" -const val API_KEY = "API_KEY" - -@RunWith(AndroidJUnit4::class) -class CallTests { - companion object { - lateinit var app: FirebaseApp - - @BeforeClass - @JvmStatic - fun setup() { - app = Firebase.initialize(InstrumentationRegistry.getContext())!! - } - - @AfterClass - @JvmStatic - fun cleanup() { - app.delete() - } - } - - @Test - fun testDataCall() { - val functions = Firebase.functions(app) - val input = - hashMapOf( - "bool" to true, - "int" to 2, - "long" to 3L, - "string" to "four", - "array" to listOf(5, 6), - "null" to null - ) - - var function = functions.getHttpsCallable("dataTest") - val actual = Tasks.await(function.call(input)).data - - assertThat(actual).isInstanceOf(Map::class.java) - @Suppress("UNCHECKED_CAST") val map = actual as Map - assertThat(map["message"]).isEqualTo("stub response") - assertThat(map["code"]).isEqualTo(42) - assertThat(map["long"]).isEqualTo(420L) - } - - @Test - fun testNullDataCall() { - val functions = Firebase.functions(app) - var function = functions.getHttpsCallable("nullTest") - val actual = Tasks.await(function.call(null)).data - - assertThat(actual).isNull() - } - - @Test - fun testEmptyDataCall() { - val functions = Firebase.functions(app) - var function = functions.getHttpsCallable("nullTest") - val actual = Tasks.await(function.call()).data - - assertThat(actual).isNull() - } -} diff --git a/firebase-functions/src/main/java/com/google/firebase/functions/ktx/Functions.kt b/firebase-functions/src/main/java/com/google/firebase/functions/ktx/Functions.kt deleted file mode 100644 index c69d487ba05..00000000000 --- a/firebase-functions/src/main/java/com/google/firebase/functions/ktx/Functions.kt +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * 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.google.firebase.functions.ktx - -import androidx.annotation.Keep -import com.google.firebase.FirebaseApp -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.functions.FirebaseFunctions -import com.google.firebase.functions.HttpsCallableOptions -import com.google.firebase.functions.HttpsCallableReference -import com.google.firebase.ktx.Firebase -import java.net.URL - -/** - * Accessing this object for Kotlin apps has changed; see the - * [migration guide](https://firebase.google.com/docs/android/kotlin-migration). - * - * Returns the [FirebaseFunctions] instance of the default [FirebaseApp]. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-functions-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -public val Firebase.functions: FirebaseFunctions - get() = FirebaseFunctions.getInstance() - -/** - * Accessing this object for Kotlin apps has changed; see the - * [migration guide](https://firebase.google.com/docs/android/kotlin-migration). - * - * Returns the [FirebaseFunctions] instance of a given [regionOrCustomDomain]. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-functions-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -public fun Firebase.functions(regionOrCustomDomain: String): FirebaseFunctions = - FirebaseFunctions.getInstance(regionOrCustomDomain) - -/** - * Accessing this object for Kotlin apps has changed; see the - * [migration guide](https://firebase.google.com/docs/android/kotlin-migration). - * - * Returns the [FirebaseFunctions] instance of a given [FirebaseApp]. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-functions-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -public fun Firebase.functions(app: FirebaseApp): FirebaseFunctions = - FirebaseFunctions.getInstance(app) - -/** - * Accessing this object for Kotlin apps has changed; see the - * [migration guide](https://firebase.google.com/docs/android/kotlin-migration). - * - * Returns the [FirebaseFunctions] instance of a given [FirebaseApp] and [regionOrCustomDomain]. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-functions-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -public fun Firebase.functions(app: FirebaseApp, regionOrCustomDomain: String): FirebaseFunctions = - FirebaseFunctions.getInstance(app, regionOrCustomDomain) - -/** - * @suppress - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-functions-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -@Keep -public class FirebaseFunctionsKtxRegistrar : ComponentRegistrar { - override fun getComponents(): List> = listOf() -} - -/** - * Returns a reference to the Callable HTTPS trigger with the given name and call options. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-functions-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -public fun FirebaseFunctions.getHttpsCallable( - name: String, - init: HttpsCallableOptions.Builder.() -> Unit -): HttpsCallableReference { - val builder = HttpsCallableOptions.Builder() - builder.init() - return getHttpsCallable(name, builder.build()) -} - -/** - * Returns a reference to the Callable HTTPS trigger with the given URL and call options. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-functions-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -public fun FirebaseFunctions.getHttpsCallableFromUrl( - url: URL, - init: HttpsCallableOptions.Builder.() -> Unit -): HttpsCallableReference { - val builder = HttpsCallableOptions.Builder() - builder.init() - return getHttpsCallableFromUrl(url, builder.build()) -} diff --git a/firebase-functions/src/test/java/com/google/firebase/functions/ktx/FunctionsTests.kt b/firebase-functions/src/test/java/com/google/firebase/functions/ktx/FunctionsTests.kt deleted file mode 100644 index 78a9fd8022d..00000000000 --- a/firebase-functions/src/test/java/com/google/firebase/functions/ktx/FunctionsTests.kt +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * 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.google.firebase.functions.ktx - -import androidx.test.core.app.ApplicationProvider -import com.google.common.truth.Truth.assertThat -import com.google.firebase.FirebaseApp -import com.google.firebase.FirebaseOptions -import com.google.firebase.functions.FirebaseFunctions -import com.google.firebase.functions.usesLimitedUseFacTokens -import com.google.firebase.ktx.Firebase -import com.google.firebase.ktx.app -import com.google.firebase.ktx.initialize -import com.google.firebase.platforminfo.UserAgentPublisher -import java.net.URL -import org.junit.After -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.robolectric.RobolectricTestRunner - -const val APP_ID = "APP_ID" -const val API_KEY = "API_KEY" - -const val EXISTING_APP = "existing" - -abstract class BaseTestCase { - @Before - fun setUp() { - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build() - ) - - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build(), - EXISTING_APP - ) - } - - @After - fun cleanUp() { - FirebaseApp.clearInstancesForTest() - } -} - -@RunWith(RobolectricTestRunner::class) -class FunctionsTests : BaseTestCase() { - - @Test - fun `functions should delegate to FirebaseFunctions#getInstance()`() { - assertThat(Firebase.functions).isSameInstanceAs(FirebaseFunctions.getInstance()) - } - - @Test - fun `FirebaseApp#functions should delegate to FirebaseFunctions#getInstance(FirebaseApp)`() { - val app = Firebase.app(EXISTING_APP) - assertThat(Firebase.functions(app)).isSameInstanceAs(FirebaseFunctions.getInstance(app)) - } - - @Test - fun `Firebase#functions should delegate to FirebaseFunctions#getInstance(region)`() { - val region = "valid_region" - assertThat(Firebase.functions(region)).isSameInstanceAs(FirebaseFunctions.getInstance(region)) - } - - @Test - fun `Firebase#functions should delegate to FirebaseFunctions#getInstance(FirebaseApp, region)`() { - val app = Firebase.app(EXISTING_APP) - val region = "valid_region" - assertThat(Firebase.functions(app, region)) - .isSameInstanceAs(FirebaseFunctions.getInstance(app, region)) - } -} - -@RunWith(RobolectricTestRunner::class) -class LibraryVersionTest : BaseTestCase() { - @Test - fun `library version should be registered with runtime`() { - val publisher = Firebase.app.get(UserAgentPublisher::class.java) - } -} - -@RunWith(RobolectricTestRunner::class) -class AppCheckLimitedUseTest : BaseTestCase() { - @Test - fun `FirebaseFunctions#getHttpsCallable should not use limited-use tokens by default`() { - val callable = Firebase.functions.getHttpsCallable("function") - assertThat(callable.usesLimitedUseFacTokens()).isFalse() - } - - @Test - fun `FirebaseFunctions#getHttpsCallable should build callable with FAC settings (when true)`() { - val callable = - Firebase.functions.getHttpsCallable("function") { limitedUseAppCheckTokens = true } - assertThat(callable.usesLimitedUseFacTokens()).isTrue() - } - - @Test - fun `FirebaseFunctions#getHttpsCallable should build callable with FAC settings (when false)`() { - val callable = - Firebase.functions.getHttpsCallable("function") { limitedUseAppCheckTokens = false } - assertThat(callable.usesLimitedUseFacTokens()).isFalse() - } - - @Test - fun `FirebaseFunctions#getHttpsCallableFromUrl should not use limited-use tokens by default`() { - val callable = Firebase.functions.getHttpsCallableFromUrl(URL("https://functions.test")) - assertThat(callable.usesLimitedUseFacTokens()).isFalse() - } - - @Test - fun `FirebaseFunctions#getHttpsCallableFromUrl callable with FAC settings (when true)`() { - val callable = - Firebase.functions.getHttpsCallableFromUrl(URL("https://functions.test")) { - limitedUseAppCheckTokens = true - } - assertThat(callable.usesLimitedUseFacTokens()).isTrue() - } - - @Test - fun `FirebaseFunctions#getHttpsCallableFromUrl callable with FAC settings (when false)`() { - val callable = - Firebase.functions.getHttpsCallableFromUrl(URL("https://functions.test")) { - limitedUseAppCheckTokens = false - } - assertThat(callable.usesLimitedUseFacTokens()).isFalse() - } -} diff --git a/firebase-inappmessaging-display/api.txt b/firebase-inappmessaging-display/api.txt index 4243fd46210..ad308036b5e 100644 --- a/firebase-inappmessaging-display/api.txt +++ b/firebase-inappmessaging-display/api.txt @@ -19,11 +19,3 @@ package com.google.firebase.inappmessaging.display { } -package com.google.firebase.inappmessaging.display.ktx { - - public final class InAppMessagingDisplayKt { - method @Deprecated public static com.google.firebase.inappmessaging.display.FirebaseInAppMessagingDisplay getInAppMessagingDisplay(com.google.firebase.ktx.Firebase); - } - -} - diff --git a/firebase-inappmessaging-display/firebase-inappmessaging-display.gradle b/firebase-inappmessaging-display/firebase-inappmessaging-display.gradle index 0a3dd479326..fb5e28afc86 100644 --- a/firebase-inappmessaging-display/firebase-inappmessaging-display.gradle +++ b/firebase-inappmessaging-display/firebase-inappmessaging-display.gradle @@ -89,7 +89,6 @@ dependencies { api(project(":firebase-inappmessaging")) api("com.google.firebase:firebase-common:21.0.0") - api("com.google.firebase:firebase-common-ktx:21.0.0") api("com.google.firebase:firebase-components:18.0.0") implementation libs.androidx.annotation diff --git a/firebase-inappmessaging-display/ktx/api.txt b/firebase-inappmessaging-display/ktx/api.txt deleted file mode 100644 index da4f6cc18fe..00000000000 --- a/firebase-inappmessaging-display/ktx/api.txt +++ /dev/null @@ -1 +0,0 @@ -// Signature format: 3.0 diff --git a/firebase-inappmessaging-display/ktx/gradle.properties b/firebase-inappmessaging-display/ktx/gradle.properties deleted file mode 100644 index 016fa887bc0..00000000000 --- a/firebase-inappmessaging-display/ktx/gradle.properties +++ /dev/null @@ -1,2 +0,0 @@ -android.enableUnitTestBinaryResources=true - diff --git a/firebase-inappmessaging-display/ktx/ktx.gradle b/firebase-inappmessaging-display/ktx/ktx.gradle deleted file mode 100644 index 72002f1114b..00000000000 --- a/firebase-inappmessaging-display/ktx/ktx.gradle +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2019 Google LLC -// -// 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. - -plugins { - id 'firebase-library' - id("kotlin-android") -} - -firebaseLibrary { - libraryGroup = "inappmessaging" - publishJavadoc = false - releaseNotes { - enabled.set(false) - } -} - -android { - namespace "com.google.firebase.inappmessaging.display.ktx" - compileSdkVersion project.compileSdkVersion - defaultConfig { - minSdkVersion project.minSdkVersion - multiDexEnabled true - targetSdkVersion project.targetSdkVersion - versionName version - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - test.java { - srcDir 'src/test/kotlin' - } - } - kotlinOptions { - jvmTarget = '1.8' - } - testOptions.unitTests.includeAndroidResources = true -} - -dependencies { - api(project(":firebase-inappmessaging")) - api(project(":firebase-inappmessaging-display")) - api("com.google.firebase:firebase-common:21.0.0") - api("com.google.firebase:firebase-common-ktx:21.0.0") - - implementation("com.google.firebase:firebase-components:18.0.0") - - testImplementation libs.androidx.test.core - testImplementation ("com.google.firebase:firebase-analytics:17.0.0") { - exclude group: "com.google.firebase", module: "firebase-common" - } - testImplementation libs.truth - testImplementation 'junit:junit:4.12' - testImplementation libs.robolectric -} diff --git a/firebase-inappmessaging-display/ktx/src/main/AndroidManifest.xml b/firebase-inappmessaging-display/ktx/src/main/AndroidManifest.xml deleted file mode 100644 index 1e87b15152b..00000000000 --- a/firebase-inappmessaging-display/ktx/src/main/AndroidManifest.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - diff --git a/firebase-inappmessaging-display/ktx/src/main/kotlin/com/google/firebase/inappmessaging/display/ktx/Logging.kt b/firebase-inappmessaging-display/ktx/src/main/kotlin/com/google/firebase/inappmessaging/display/ktx/Logging.kt deleted file mode 100644 index df3354bc713..00000000000 --- a/firebase-inappmessaging-display/ktx/src/main/kotlin/com/google/firebase/inappmessaging/display/ktx/Logging.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2023 Google LLC - * - * 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.google.firebase.inappmessaging.display.ktx - -import androidx.annotation.Keep -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.inappmessaging.display.BuildConfig -import com.google.firebase.platforminfo.LibraryVersionComponent - -internal const val LIBRARY_NAME: String = "fire-iamd-ktx" - -/** @suppress */ -@Keep -class FirebaseInappmessagingDisplayLegacyRegistrar : ComponentRegistrar { - override fun getComponents(): List> { - return listOf(LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME)) - } -} diff --git a/firebase-inappmessaging-display/ktx/src/test/kotlin/com/google/firebase/inappmessaging/display/ktx/InAppMessagingDisplayTests.kt b/firebase-inappmessaging-display/ktx/src/test/kotlin/com/google/firebase/inappmessaging/display/ktx/InAppMessagingDisplayTests.kt deleted file mode 100644 index ce14d51baed..00000000000 --- a/firebase-inappmessaging-display/ktx/src/test/kotlin/com/google/firebase/inappmessaging/display/ktx/InAppMessagingDisplayTests.kt +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * 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.google.firebase.inappmessaging.display.ktx - -import androidx.test.core.app.ApplicationProvider -import com.google.common.truth.Truth.assertThat -import com.google.firebase.FirebaseApp -import com.google.firebase.FirebaseOptions -import com.google.firebase.inappmessaging.display.FirebaseInAppMessagingDisplay -import com.google.firebase.ktx.Firebase -import com.google.firebase.ktx.app -import com.google.firebase.ktx.initialize -import com.google.firebase.platforminfo.UserAgentPublisher -import java.util.UUID -import org.junit.After -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.robolectric.RobolectricTestRunner - -internal const val APP_ID = "APP:ID" -internal val API_KEY = "ABC" + UUID.randomUUID().toString() - -const val EXISTING_APP = "existing" - -abstract class BaseTestCase { - @Before - fun setUp() { - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build() - ) - - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build(), - EXISTING_APP - ) - } - - @After - fun cleanUp() { - FirebaseApp.clearInstancesForTest() - } -} - -@RunWith(RobolectricTestRunner::class) -class InAppMessagingDisplayTests : BaseTestCase() { - - @Test - fun `inAppMessagingDisplay should delegate to FirebaseInAppMessagingDisplay#getInstance()`() { - assertThat(Firebase.inAppMessagingDisplay) - .isSameInstanceAs(FirebaseInAppMessagingDisplay.getInstance()) - } -} - -@RunWith(RobolectricTestRunner::class) -class LibraryVersionTest : BaseTestCase() { - @Test - fun `library version should be registered with runtime`() { - val publisher = Firebase.app.get(UserAgentPublisher::class.java) - assertThat(publisher.userAgent).contains(LIBRARY_NAME) - } -} diff --git a/firebase-inappmessaging-display/src/main/java/com/google/firebase/inappmessaging/display/ktx/InAppMessagingDisplay.kt b/firebase-inappmessaging-display/src/main/java/com/google/firebase/inappmessaging/display/ktx/InAppMessagingDisplay.kt deleted file mode 100644 index 1abec0f0aa7..00000000000 --- a/firebase-inappmessaging-display/src/main/java/com/google/firebase/inappmessaging/display/ktx/InAppMessagingDisplay.kt +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * 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.google.firebase.inappmessaging.display.ktx - -import androidx.annotation.Keep -import com.google.firebase.FirebaseApp -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.inappmessaging.display.FirebaseInAppMessagingDisplay -import com.google.firebase.ktx.Firebase - -/** - * Accessing this object for Kotlin apps has changed; see the - * [migration guide](https://firebase.google.com/docs/android/kotlin-migration). - * - * Returns the [FirebaseInAppMessagingDisplay] instance of the default [FirebaseApp]. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-inappmessaging-display-ktx` are now deprecated. As early as April - * 2024, we'll no longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -val Firebase.inAppMessagingDisplay: FirebaseInAppMessagingDisplay - get() = FirebaseInAppMessagingDisplay.getInstance() - -/** - * @suppress - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-inappmessaging-display-ktx` are now deprecated. As early as April - * 2024, we'll no longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -@Keep -class FirebaseInAppMessagingDisplayKtxRegistrar : ComponentRegistrar { - override fun getComponents(): List> = listOf() -} diff --git a/firebase-inappmessaging-display/src/test/java/com/google/firebase/inappmessaging/display/ktx/InAppMessagingDisplayTests.kt b/firebase-inappmessaging-display/src/test/java/com/google/firebase/inappmessaging/display/ktx/InAppMessagingDisplayTests.kt deleted file mode 100644 index d04f0e94892..00000000000 --- a/firebase-inappmessaging-display/src/test/java/com/google/firebase/inappmessaging/display/ktx/InAppMessagingDisplayTests.kt +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * 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.google.firebase.inappmessaging.display.ktx - -import androidx.test.core.app.ApplicationProvider -import com.google.common.truth.Truth.assertThat -import com.google.firebase.FirebaseApp -import com.google.firebase.FirebaseOptions -import com.google.firebase.inappmessaging.display.FirebaseInAppMessagingDisplay -import com.google.firebase.ktx.Firebase -import com.google.firebase.ktx.app -import com.google.firebase.ktx.initialize -import com.google.firebase.platforminfo.UserAgentPublisher -import java.util.UUID -import org.junit.After -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.robolectric.RobolectricTestRunner - -internal const val APP_ID = "APP:ID" -internal val API_KEY = "ABC" + UUID.randomUUID().toString() - -const val EXISTING_APP = "existing" - -abstract class BaseTestCase { - @Before - fun setUp() { - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build() - ) - - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build(), - EXISTING_APP - ) - } - - @After - fun cleanUp() { - FirebaseApp.clearInstancesForTest() - } -} - -@RunWith(RobolectricTestRunner::class) -class InAppMessagingDisplayTests : BaseTestCase() { - - @Test - fun `inAppMessagingDisplay should delegate to FirebaseInAppMessagingDisplay#getInstance()`() { - assertThat(Firebase.inAppMessagingDisplay) - .isSameInstanceAs(FirebaseInAppMessagingDisplay.getInstance()) - } -} - -@RunWith(RobolectricTestRunner::class) -class LibraryVersionTest : BaseTestCase() { - @Test - fun `library version should be registered with runtime`() { - val publisher = Firebase.app.get(UserAgentPublisher::class.java) - } -} diff --git a/firebase-inappmessaging/api.txt b/firebase-inappmessaging/api.txt index e3c0d64be59..cf5b72d9fe5 100644 --- a/firebase-inappmessaging/api.txt +++ b/firebase-inappmessaging/api.txt @@ -76,14 +76,6 @@ package com.google.firebase.inappmessaging { } -package com.google.firebase.inappmessaging.ktx { - - public final class InAppMessagingKt { - method @Deprecated public static com.google.firebase.inappmessaging.FirebaseInAppMessaging getInAppMessaging(com.google.firebase.ktx.Firebase); - } - -} - package com.google.firebase.inappmessaging.model { public class Action { diff --git a/firebase-inappmessaging/firebase-inappmessaging.gradle b/firebase-inappmessaging/firebase-inappmessaging.gradle index d979b13fcc7..35da1a0eb6e 100644 --- a/firebase-inappmessaging/firebase-inappmessaging.gradle +++ b/firebase-inappmessaging/firebase-inappmessaging.gradle @@ -118,7 +118,6 @@ dependencies { exclude group: 'com.google.firebase', module: 'firebase-components' } api("com.google.firebase:firebase-common:21.0.0") - api("com.google.firebase:firebase-common-ktx:21.0.0") api("com.google.firebase:firebase-components:18.0.0") api("com.google.firebase:firebase-datatransport:18.2.0"){ exclude group: 'com.google.firebase', module: 'firebase-common' diff --git a/firebase-inappmessaging/ktx/api.txt b/firebase-inappmessaging/ktx/api.txt deleted file mode 100644 index da4f6cc18fe..00000000000 --- a/firebase-inappmessaging/ktx/api.txt +++ /dev/null @@ -1 +0,0 @@ -// Signature format: 3.0 diff --git a/firebase-inappmessaging/ktx/gradle.properties b/firebase-inappmessaging/ktx/gradle.properties deleted file mode 100644 index 016fa887bc0..00000000000 --- a/firebase-inappmessaging/ktx/gradle.properties +++ /dev/null @@ -1,2 +0,0 @@ -android.enableUnitTestBinaryResources=true - diff --git a/firebase-inappmessaging/ktx/ktx.gradle b/firebase-inappmessaging/ktx/ktx.gradle deleted file mode 100644 index 0a240351423..00000000000 --- a/firebase-inappmessaging/ktx/ktx.gradle +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2019 Google LLC -// -// 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. - -plugins { - id 'firebase-library' - id("kotlin-android") -} - -firebaseLibrary { - libraryGroup = "inappmessaging" - publishJavadoc = false - releaseNotes { - enabled.set(false) - } -} - -android { - namespace "com.google.firebase.inappmessaging.ktx" - compileSdkVersion project.compileSdkVersion - defaultConfig { - minSdkVersion project.minSdkVersion - multiDexEnabled true - targetSdkVersion project.targetSdkVersion - versionName version - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - test.java { - srcDir 'src/test/kotlin' - } - } - kotlinOptions { - jvmTarget = '1.8' - } - testOptions.unitTests.includeAndroidResources = true -} - -dependencies { - api(project(":firebase-inappmessaging")) - api("com.google.firebase:firebase-common:21.0.0") - api("com.google.firebase:firebase-common-ktx:21.0.0") - - implementation("com.google.firebase:firebase-components:18.0.0") - - testImplementation libs.androidx.test.core - testImplementation libs.truth - testImplementation 'junit:junit:4.12' - testImplementation libs.robolectric -} diff --git a/firebase-inappmessaging/ktx/src/main/AndroidManifest.xml b/firebase-inappmessaging/ktx/src/main/AndroidManifest.xml deleted file mode 100644 index d22f9fafcf3..00000000000 --- a/firebase-inappmessaging/ktx/src/main/AndroidManifest.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - diff --git a/firebase-inappmessaging/ktx/src/main/kotlin/com/google/firebase/inappmessaging/ktx/Logging.kt b/firebase-inappmessaging/ktx/src/main/kotlin/com/google/firebase/inappmessaging/ktx/Logging.kt deleted file mode 100644 index 41f3dc79e46..00000000000 --- a/firebase-inappmessaging/ktx/src/main/kotlin/com/google/firebase/inappmessaging/ktx/Logging.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2023 Google LLC - * - * 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.google.firebase.inappmessaging.ktx - -import androidx.annotation.Keep -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.inappmessaging.BuildConfig -import com.google.firebase.platforminfo.LibraryVersionComponent - -internal const val LIBRARY_NAME: String = "fire-iam-ktx" - -/** @suppress */ -@Keep -class FirebaseInappmessagingLegacyRegistrar : ComponentRegistrar { - override fun getComponents(): List> { - return listOf(LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME)) - } -} diff --git a/firebase-inappmessaging/ktx/src/test/kotlin/com/google/firebase/inappmessagging/ktx/InAppMessaggingTests.kt b/firebase-inappmessaging/ktx/src/test/kotlin/com/google/firebase/inappmessagging/ktx/InAppMessaggingTests.kt deleted file mode 100644 index b98aa269269..00000000000 --- a/firebase-inappmessaging/ktx/src/test/kotlin/com/google/firebase/inappmessagging/ktx/InAppMessaggingTests.kt +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * 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.google.firebase.inappmessaging.ktx - -import androidx.test.core.app.ApplicationProvider -import com.google.common.truth.Truth.assertThat -import com.google.firebase.FirebaseApp -import com.google.firebase.FirebaseOptions -import com.google.firebase.inappmessaging.FirebaseInAppMessaging -import com.google.firebase.ktx.Firebase -import com.google.firebase.ktx.app -import com.google.firebase.ktx.initialize -import com.google.firebase.platforminfo.UserAgentPublisher -import java.util.UUID -import org.junit.After -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.robolectric.RobolectricTestRunner - -internal const val APP_ID = "APP:ID" -internal val API_KEY = "ABC" + UUID.randomUUID().toString() - -const val EXISTING_APP = "existing" - -abstract class BaseTestCase { - @Before - fun setUp() { - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setGcmSenderId("ic") - .setApiKey(API_KEY) - .setProjectId("123") - .build() - ) - - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build(), - EXISTING_APP - ) - } - - @After - fun cleanUp() { - FirebaseApp.clearInstancesForTest() - } -} - -@RunWith(RobolectricTestRunner::class) -class FirebaseInAppMessagingTests : BaseTestCase() { - - @Test - fun `inappmessaging should delegate to FirebaseInAppMessaging#getInstance()`() { - assertThat(Firebase.inAppMessaging).isSameInstanceAs(FirebaseInAppMessaging.getInstance()) - } -} - -@RunWith(RobolectricTestRunner::class) -class LibraryVersionTest : BaseTestCase() { - @Test - fun `library version should be registered with runtime`() { - val publisher = Firebase.app.get(UserAgentPublisher::class.java) - assertThat(publisher.userAgent).contains(LIBRARY_NAME) - } -} diff --git a/firebase-inappmessaging/src/main/java/com/google/firebase/inappmessaging/ktx/InAppMessaging.kt b/firebase-inappmessaging/src/main/java/com/google/firebase/inappmessaging/ktx/InAppMessaging.kt deleted file mode 100644 index 82dce304852..00000000000 --- a/firebase-inappmessaging/src/main/java/com/google/firebase/inappmessaging/ktx/InAppMessaging.kt +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * 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.google.firebase.inappmessaging.ktx - -import androidx.annotation.Keep -import com.google.firebase.FirebaseApp -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.inappmessaging.FirebaseInAppMessaging -import com.google.firebase.ktx.Firebase - -/** - * Accessing this object for Kotlin apps has changed; see the - * [migration guide](https://firebase.google.com/docs/android/kotlin-migration). - * - * Returns the [FirebaseInAppMessaging] instance of the default [FirebaseApp]. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-inappmessaging-ktx` are now deprecated. As early as April 2024, - * we'll no longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -val Firebase.inAppMessaging: FirebaseInAppMessaging - get() = FirebaseInAppMessaging.getInstance() - -/** - * @suppress - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-inappmessaging-ktx` are now deprecated. As early as April 2024, - * we'll no longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -@Keep -class FirebaseInAppMessagingKtxRegistrar : ComponentRegistrar { - override fun getComponents(): List> = listOf() -} diff --git a/firebase-installations/api.txt b/firebase-installations/api.txt index 71de29c094f..644203b7640 100644 --- a/firebase-installations/api.txt +++ b/firebase-installations/api.txt @@ -17,12 +17,3 @@ package com.google.firebase.installations { } -package com.google.firebase.installations.ktx { - - public final class InstallationsKt { - method @Deprecated public static com.google.firebase.installations.FirebaseInstallations getInstallations(com.google.firebase.ktx.Firebase); - method @Deprecated public static com.google.firebase.installations.FirebaseInstallations installations(com.google.firebase.ktx.Firebase, com.google.firebase.FirebaseApp app); - } - -} - diff --git a/firebase-installations/firebase-installations.gradle b/firebase-installations/firebase-installations.gradle index 47d5ee852ea..50178124f74 100644 --- a/firebase-installations/firebase-installations.gradle +++ b/firebase-installations/firebase-installations.gradle @@ -54,7 +54,6 @@ dependencies { api libs.playservices.tasks api 'com.google.firebase:firebase-annotations:16.2.0' api("com.google.firebase:firebase-common:21.0.0") - api("com.google.firebase:firebase-common-ktx:21.0.0") api("com.google.firebase:firebase-components:18.0.0") api 'com.google.firebase:firebase-installations-interop:17.1.0' api("com.google.firebase:firebase-installations-interop:17.1.1") diff --git a/firebase-installations/ktx/api.txt b/firebase-installations/ktx/api.txt deleted file mode 100644 index da4f6cc18fe..00000000000 --- a/firebase-installations/ktx/api.txt +++ /dev/null @@ -1 +0,0 @@ -// Signature format: 3.0 diff --git a/firebase-installations/ktx/gradle.properties b/firebase-installations/ktx/gradle.properties deleted file mode 100644 index 9eff84e6c72..00000000000 --- a/firebase-installations/ktx/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -android.enableUnitTestBinaryResources=true diff --git a/firebase-installations/ktx/ktx.gradle b/firebase-installations/ktx/ktx.gradle deleted file mode 100644 index 841651f8e0f..00000000000 --- a/firebase-installations/ktx/ktx.gradle +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2020 Google LLC -// -// 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. - -plugins { - id 'firebase-library' - id("kotlin-android") -} - -firebaseLibrary { - libraryGroup = "installations" - publishJavadoc = false - releaseNotes { - enabled.set(false) - } -} - -android { - namespace "com.google.firebase.installations.ktx" - compileSdkVersion project.compileSdkVersion - defaultConfig { - minSdkVersion project.minSdkVersion - multiDexEnabled true - targetSdkVersion project.targetSdkVersion - versionName version - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - test.java.srcDirs += 'src/test/kotlin' - androidTest.java.srcDirs += 'src/androidTest/kotlin' - } - kotlinOptions { - jvmTarget = '1.8' - } - testOptions.unitTests.includeAndroidResources = true -} - -dependencies { - api(project(":firebase-installations")) - api("com.google.firebase:firebase-common:21.0.0") - api("com.google.firebase:firebase-common-ktx:21.0.0") - api("com.google.firebase:firebase-installations-interop:17.1.1") - - implementation("com.google.firebase:firebase-components:18.0.0") - - testImplementation libs.androidx.test.core - testImplementation libs.truth - testImplementation 'junit:junit:4.13' - testImplementation libs.robolectric -} diff --git a/firebase-installations/ktx/src/main/AndroidManifest.xml b/firebase-installations/ktx/src/main/AndroidManifest.xml deleted file mode 100644 index 477db160ce1..00000000000 --- a/firebase-installations/ktx/src/main/AndroidManifest.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/firebase-installations/ktx/src/main/kotlin/com/google/firebase/installations/ktx/Logging.kt b/firebase-installations/ktx/src/main/kotlin/com/google/firebase/installations/ktx/Logging.kt deleted file mode 100644 index d746430fb6e..00000000000 --- a/firebase-installations/ktx/src/main/kotlin/com/google/firebase/installations/ktx/Logging.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2023 Google LLC - * - * 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.google.firebase.installations.ktx - -import androidx.annotation.Keep -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.installations.BuildConfig -import com.google.firebase.platforminfo.LibraryVersionComponent - -internal const val LIBRARY_NAME: String = "fire-installations-ktx" - -/** @suppress */ -@Keep -class FirebaseInstallationsLegacyRegistrar : ComponentRegistrar { - override fun getComponents(): List> { - return listOf(LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME)) - } -} diff --git a/firebase-installations/ktx/src/test/kotlin/com/google/firebase/installations/ktx/InstallationsTests.kt b/firebase-installations/ktx/src/test/kotlin/com/google/firebase/installations/ktx/InstallationsTests.kt deleted file mode 100644 index 4d169997ae7..00000000000 --- a/firebase-installations/ktx/src/test/kotlin/com/google/firebase/installations/ktx/InstallationsTests.kt +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * 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.google.firebase.installations.ktx - -import androidx.test.core.app.ApplicationProvider -import com.google.common.truth.Truth -import com.google.firebase.FirebaseApp -import com.google.firebase.FirebaseOptions -import com.google.firebase.installations.FirebaseInstallations -import com.google.firebase.ktx.Firebase -import com.google.firebase.ktx.app -import com.google.firebase.ktx.initialize -import com.google.firebase.platforminfo.UserAgentPublisher -import org.junit.After -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.robolectric.RobolectricTestRunner - -const val APP_ID = "APP_ID" -const val API_KEY = "API_KEY" - -const val EXISTING_APP = "existing" - -abstract class BaseTestCase { - @Before - fun setUp() { - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build() - ) - - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build(), - EXISTING_APP - ) - } - - @After - fun cleanUp() { - FirebaseApp.clearInstancesForTest() - } -} - -@RunWith(RobolectricTestRunner::class) -class InstallationsTests : BaseTestCase() { - @Test - fun `installations should delegate to FirebaseInstallations#getInstance()`() { - Truth.assertThat(Firebase.installations).isSameInstanceAs(FirebaseInstallations.getInstance()) - } - - @Test - fun `installations(app) should delegate to FirebaseInstallations#getInstance(FirebaseApp)`() { - val app = Firebase.app(EXISTING_APP) - Truth.assertThat(Firebase.installations(app)) - .isSameInstanceAs(FirebaseInstallations.getInstance(app)) - } -} - -@RunWith(RobolectricTestRunner::class) -class LibraryVersionTest : BaseTestCase() { - @Test - fun `library version should be registered with runtime`() { - val publisher = Firebase.app.get(UserAgentPublisher::class.java) - Truth.assertThat(publisher.userAgent).contains(LIBRARY_NAME) - } -} diff --git a/firebase-installations/src/main/java/com/google/firebase/installations/ktx/Installations.kt b/firebase-installations/src/main/java/com/google/firebase/installations/ktx/Installations.kt deleted file mode 100644 index 3ab350e5e9e..00000000000 --- a/firebase-installations/src/main/java/com/google/firebase/installations/ktx/Installations.kt +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * 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.google.firebase.installations.ktx - -import com.google.firebase.FirebaseApp -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.installations.FirebaseInstallations -import com.google.firebase.ktx.Firebase - -/** - * Accessing this object for Kotlin apps has changed; see the - * [migration guide](https://firebase.google.com/docs/android/kotlin-migration). - * - * Returns the [FirebaseInstallations] instance of the default [FirebaseApp]. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-storage-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -val Firebase.installations: FirebaseInstallations - get() = FirebaseInstallations.getInstance() - -/** - * Accessing this object for Kotlin apps has changed; see the - * [migration guide](https://firebase.google.com/docs/android/kotlin-migration). - * - * Returns the [FirebaseInstallations] instance of a given [FirebaseApp]. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-storage-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -fun Firebase.installations(app: FirebaseApp): FirebaseInstallations = - FirebaseInstallations.getInstance(app) - -/** @suppress */ -@Deprecated( - "com.google.firebase.installations.FirebaseInstallationsKtxRegistrar has been deprecated. Use `com.google.firebase.installationsFirebaseInstallationsKtxRegistrar` instead.", - ReplaceWith("") -) -class FirebaseInstallationsKtxRegistrar : ComponentRegistrar { - override fun getComponents(): List> = listOf() -} diff --git a/firebase-installations/src/test/java/com/google/firebase/installations/ktx/InstallationsTests.kt b/firebase-installations/src/test/java/com/google/firebase/installations/ktx/InstallationsTests.kt deleted file mode 100644 index 796e78a56ae..00000000000 --- a/firebase-installations/src/test/java/com/google/firebase/installations/ktx/InstallationsTests.kt +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * 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.google.firebase.installations.ktx - -import androidx.test.core.app.ApplicationProvider -import com.google.common.truth.Truth -import com.google.firebase.FirebaseApp -import com.google.firebase.FirebaseOptions -import com.google.firebase.installations.FirebaseInstallations -import com.google.firebase.ktx.Firebase -import com.google.firebase.ktx.app -import com.google.firebase.ktx.initialize -import com.google.firebase.platforminfo.UserAgentPublisher -import org.junit.After -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.robolectric.RobolectricTestRunner - -const val APP_ID = "APP_ID" -const val API_KEY = "API_KEY" - -const val EXISTING_APP = "existing" - -abstract class BaseTestCase { - @Before - fun setUp() { - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build() - ) - - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build(), - EXISTING_APP - ) - } - - @After - fun cleanUp() { - FirebaseApp.clearInstancesForTest() - } -} - -@RunWith(RobolectricTestRunner::class) -class InstallationsTests : BaseTestCase() { - @Test - fun `installations should delegate to FirebaseInstallations#getInstance()`() { - Truth.assertThat(Firebase.installations).isSameInstanceAs(FirebaseInstallations.getInstance()) - } - - @Test - fun `installations(app) should delegate to FirebaseInstallations#getInstance(FirebaseApp)`() { - val app = Firebase.app(EXISTING_APP) - Truth.assertThat(Firebase.installations(app)) - .isSameInstanceAs(FirebaseInstallations.getInstance(app)) - } -} - -@RunWith(RobolectricTestRunner::class) -class LibraryVersionTest : BaseTestCase() { - @Test - fun `library version should be registered with runtime`() { - val publisher = Firebase.app.get(UserAgentPublisher::class.java) - } -} diff --git a/firebase-messaging/api.txt b/firebase-messaging/api.txt index 1cb7cd1e4c9..e6528a2cff4 100644 --- a/firebase-messaging/api.txt +++ b/firebase-messaging/api.txt @@ -107,12 +107,3 @@ package com.google.firebase.messaging { } -package com.google.firebase.messaging.ktx { - - public final class MessagingKt { - method @Deprecated public static com.google.firebase.messaging.FirebaseMessaging getMessaging(com.google.firebase.ktx.Firebase); - method @Deprecated public static inline com.google.firebase.messaging.RemoteMessage remoteMessage(String to, kotlin.jvm.functions.Function1 init); - } - -} - diff --git a/firebase-messaging/firebase-messaging.gradle b/firebase-messaging/firebase-messaging.gradle index 4321ffc653d..c6158eb9bc9 100644 --- a/firebase-messaging/firebase-messaging.gradle +++ b/firebase-messaging/firebase-messaging.gradle @@ -90,7 +90,6 @@ dependencies { javadocClasspath libs.autovalue.annotations api("com.google.firebase:firebase-common:21.0.0") - api("com.google.firebase:firebase-common-ktx:21.0.0") api("com.google.firebase:firebase-components:18.0.0") api('com.google.firebase:firebase-datatransport:18.2.0') { exclude group: 'com.google.firebase', module: 'firebase-common' diff --git a/firebase-messaging/ktx/api.txt b/firebase-messaging/ktx/api.txt deleted file mode 100644 index da4f6cc18fe..00000000000 --- a/firebase-messaging/ktx/api.txt +++ /dev/null @@ -1 +0,0 @@ -// Signature format: 3.0 diff --git a/firebase-messaging/ktx/gradle.properties b/firebase-messaging/ktx/gradle.properties deleted file mode 100644 index 016fa887bc0..00000000000 --- a/firebase-messaging/ktx/gradle.properties +++ /dev/null @@ -1,2 +0,0 @@ -android.enableUnitTestBinaryResources=true - diff --git a/firebase-messaging/ktx/ktx.gradle b/firebase-messaging/ktx/ktx.gradle deleted file mode 100644 index 175566afe92..00000000000 --- a/firebase-messaging/ktx/ktx.gradle +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2020 Google LLC -// -// 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. - -plugins { - id 'firebase-library' - id("kotlin-android") -} - -firebaseLibrary { - libraryGroup = "messaging" - publishJavadoc = false - releaseNotes { - enabled.set(false) - } -} - -android { - namespace "com.google.firebase.messaging.ktx" - compileSdkVersion project.compileSdkVersion - defaultConfig { - minSdkVersion project.minSdkVersion - multiDexEnabled true - targetSdkVersion project.targetSdkVersion - versionName version - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - test.java.srcDirs += 'src/test/kotlin' - androidTest.java.srcDirs += 'src/androidTest/kotlin' - } - kotlinOptions { - jvmTarget = '1.8' - } - testOptions.unitTests.includeAndroidResources = true -} - -dependencies { - api(project(":firebase-messaging")) - api("com.google.firebase:firebase-common:21.0.0") - api("com.google.firebase:firebase-common-ktx:21.0.0") - - implementation("com.google.firebase:firebase-components:18.0.0") - - testImplementation libs.androidx.test.core - testImplementation libs.truth - testImplementation 'junit:junit:4.12' - testImplementation libs.robolectric -} diff --git a/firebase-messaging/ktx/src/main/AndroidManifest.xml b/firebase-messaging/ktx/src/main/AndroidManifest.xml deleted file mode 100644 index 26423f637af..00000000000 --- a/firebase-messaging/ktx/src/main/AndroidManifest.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - diff --git a/firebase-messaging/ktx/src/main/kotlin/com/google/firebase/messaging/ktx/Logging.kt b/firebase-messaging/ktx/src/main/kotlin/com/google/firebase/messaging/ktx/Logging.kt deleted file mode 100644 index 3e3a591947a..00000000000 --- a/firebase-messaging/ktx/src/main/kotlin/com/google/firebase/messaging/ktx/Logging.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2023 Google LLC - * - * 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.google.firebase.messaging.ktx - -import androidx.annotation.Keep -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.messaging.BuildConfig -import com.google.firebase.platforminfo.LibraryVersionComponent - -internal const val LIBRARY_NAME: String = "fire-fcm-ktx" - -/** @suppress */ -@Keep -class FirebaseMessagingLegacyRegistrar : ComponentRegistrar { - override fun getComponents(): List> { - return listOf(LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME)) - } -} diff --git a/firebase-messaging/ktx/src/test/kotlin/com/google/firebase/messaging/ktx/MessagingTests.kt b/firebase-messaging/ktx/src/test/kotlin/com/google/firebase/messaging/ktx/MessagingTests.kt deleted file mode 100644 index ce40403254f..00000000000 --- a/firebase-messaging/ktx/src/test/kotlin/com/google/firebase/messaging/ktx/MessagingTests.kt +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * 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.google.firebase.messaging.ktx - -import androidx.test.core.app.ApplicationProvider -import com.google.common.truth.Truth.assertThat -import com.google.firebase.FirebaseApp -import com.google.firebase.FirebaseOptions -import com.google.firebase.ktx.Firebase -import com.google.firebase.ktx.app -import com.google.firebase.ktx.initialize -import com.google.firebase.messaging.FirebaseMessaging -import com.google.firebase.platforminfo.UserAgentPublisher -import org.junit.After -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.robolectric.RobolectricTestRunner - -const val APP_ID = "APP_ID" -const val API_KEY = "API_KEY" - -abstract class BaseTestCase { - @Before - fun setUp() { - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build() - ) - } - - @After - fun cleanUp() { - FirebaseApp.clearInstancesForTest() - } -} - -@RunWith(RobolectricTestRunner::class) -class MessagingTests : BaseTestCase() { - - @Test - fun `messaging should delegate to FirebaseMessaging#getInstance()`() { - assertThat(Firebase.messaging).isSameInstanceAs(FirebaseMessaging.getInstance()) - } - - @Test - fun `remoteMessage() should produce correct RemoteMessages`() { - val recipient = "recipient" - val expectedCollapseKey = "collapse" - val msgId = "id" - val msgType = "type" - val timeToLive = 100 - val remoteMessage = - remoteMessage(recipient) { - collapseKey = expectedCollapseKey - messageId = msgId - messageType = msgType - ttl = timeToLive - addData("hello", "world") - } - assertThat(remoteMessage.to).isEqualTo(recipient) - assertThat(remoteMessage.collapseKey).isEqualTo(expectedCollapseKey) - assertThat(remoteMessage.messageId).isEqualTo(msgId) - assertThat(remoteMessage.messageType).isEqualTo(msgType) - assertThat(remoteMessage.data).isEqualTo(mapOf("hello" to "world")) - } -} - -@RunWith(RobolectricTestRunner::class) -class LibraryVersionTest : BaseTestCase() { - @Test - fun `library version should be registered with runtime`() { - val publisher = Firebase.app.get(UserAgentPublisher::class.java) - assertThat(publisher.userAgent).contains(LIBRARY_NAME) - } -} diff --git a/firebase-messaging/src/main/java/com/google/firebase/messaging/ktx/Messaging.kt b/firebase-messaging/src/main/java/com/google/firebase/messaging/ktx/Messaging.kt deleted file mode 100644 index d0035e605a0..00000000000 --- a/firebase-messaging/src/main/java/com/google/firebase/messaging/ktx/Messaging.kt +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * 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.google.firebase.messaging.ktx - -import com.google.firebase.FirebaseApp -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.ktx.Firebase -import com.google.firebase.messaging.FirebaseMessaging -import com.google.firebase.messaging.RemoteMessage - -/** - * Accessing this object for Kotlin apps has changed; see the - * [migration guide](https://firebase.google.com/docs/android/kotlin-migration). - * - * Returns the [FirebaseMessaging] instance of the default [FirebaseApp]. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-messaging-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -val Firebase.messaging: FirebaseMessaging - get() = FirebaseMessaging.getInstance() - -/** - * Returns a [RemoteMessage] instance initialized using the [init] function. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-messaging-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -inline fun remoteMessage( - to: String, - crossinline init: RemoteMessage.Builder.() -> Unit -): RemoteMessage { - val builder = RemoteMessage.Builder(to) - builder.init() - return builder.build() -} - -/** - * @suppress - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-messaging-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -class FirebaseMessagingKtxRegistrar : ComponentRegistrar { - override fun getComponents(): List> = listOf() -} diff --git a/firebase-messaging/src/test/java/com/google/firebase/messaging/ktx/MessagingTests.kt b/firebase-messaging/src/test/java/com/google/firebase/messaging/ktx/MessagingTests.kt deleted file mode 100644 index 66f105ed7be..00000000000 --- a/firebase-messaging/src/test/java/com/google/firebase/messaging/ktx/MessagingTests.kt +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * 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.google.firebase.messaging.ktx - -import androidx.test.core.app.ApplicationProvider -import com.google.common.truth.Truth.assertThat -import com.google.firebase.FirebaseApp -import com.google.firebase.FirebaseOptions -import com.google.firebase.ktx.Firebase -import com.google.firebase.ktx.app -import com.google.firebase.ktx.initialize -import com.google.firebase.messaging.FirebaseMessaging -import com.google.firebase.platforminfo.UserAgentPublisher -import org.junit.After -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.robolectric.RobolectricTestRunner - -const val APP_ID = "APP_ID" -const val API_KEY = "API_KEY" - -abstract class BaseTestCase { - @Before - fun setUp() { - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build() - ) - } - - @After - fun cleanUp() { - FirebaseApp.clearInstancesForTest() - } -} - -@RunWith(RobolectricTestRunner::class) -class MessagingTests : BaseTestCase() { - - @Test - fun `messaging should delegate to FirebaseMessaging#getInstance()`() { - assertThat(Firebase.messaging).isSameInstanceAs(FirebaseMessaging.getInstance()) - } - - @Test - fun `remoteMessage() should produce correct RemoteMessages`() { - val recipient = "recipient" - val expectedCollapseKey = "collapse" - val msgId = "id" - val msgType = "type" - val timeToLive = 100 - val remoteMessage = - remoteMessage(recipient) { - collapseKey = expectedCollapseKey - messageId = msgId - messageType = msgType - ttl = timeToLive - addData("hello", "world") - } - assertThat(remoteMessage.to).isEqualTo(recipient) - assertThat(remoteMessage.collapseKey).isEqualTo(expectedCollapseKey) - assertThat(remoteMessage.messageId).isEqualTo(msgId) - assertThat(remoteMessage.messageType).isEqualTo(msgType) - assertThat(remoteMessage.data).isEqualTo(mapOf("hello" to "world")) - } -} - -@RunWith(RobolectricTestRunner::class) -class LibraryVersionTest : BaseTestCase() { - @Test - fun `library version should be registered with runtime`() { - val publisher = Firebase.app.get(UserAgentPublisher::class.java) - } -} diff --git a/firebase-ml-modeldownloader/api.txt b/firebase-ml-modeldownloader/api.txt index 647ca614142..f693f42c9f7 100644 --- a/firebase-ml-modeldownloader/api.txt +++ b/firebase-ml-modeldownloader/api.txt @@ -78,18 +78,3 @@ package com.google.firebase.ml.modeldownloader { } -package com.google.firebase.ml.modeldownloader.ktx { - - public final class ModelDownloaderKt { - method public static operator java.io.File? component1(com.google.firebase.ml.modeldownloader.CustomModel); - method public static operator long component2(com.google.firebase.ml.modeldownloader.CustomModel); - method public static operator long component3(com.google.firebase.ml.modeldownloader.CustomModel); - method public static operator String component4(com.google.firebase.ml.modeldownloader.CustomModel); - method public static operator String component5(com.google.firebase.ml.modeldownloader.CustomModel); - method @Deprecated public static com.google.firebase.ml.modeldownloader.CustomModelDownloadConditions customModelDownloadConditions(kotlin.jvm.functions.Function1 init); - method @Deprecated public static com.google.firebase.ml.modeldownloader.FirebaseModelDownloader getModelDownloader(com.google.firebase.ktx.Firebase); - method @Deprecated public static com.google.firebase.ml.modeldownloader.FirebaseModelDownloader modelDownloader(com.google.firebase.ktx.Firebase, com.google.firebase.FirebaseApp app); - } - -} - diff --git a/firebase-ml-modeldownloader/firebase-ml-modeldownloader.gradle b/firebase-ml-modeldownloader/firebase-ml-modeldownloader.gradle index 2e709015da1..5eea0c3fd85 100644 --- a/firebase-ml-modeldownloader/firebase-ml-modeldownloader.gradle +++ b/firebase-ml-modeldownloader/firebase-ml-modeldownloader.gradle @@ -89,7 +89,6 @@ dependencies { api libs.playservices.tasks api 'com.google.firebase:firebase-annotations:16.2.0' api("com.google.firebase:firebase-common:21.0.0") - api("com.google.firebase:firebase-common-ktx:21.0.0") api("com.google.firebase:firebase-components:18.0.0") api('com.google.firebase:firebase-datatransport:18.2.0'){ exclude group: 'com.google.firebase', module: 'firebase-common' diff --git a/firebase-ml-modeldownloader/ktx/api.txt b/firebase-ml-modeldownloader/ktx/api.txt deleted file mode 100644 index da4f6cc18fe..00000000000 --- a/firebase-ml-modeldownloader/ktx/api.txt +++ /dev/null @@ -1 +0,0 @@ -// Signature format: 3.0 diff --git a/firebase-ml-modeldownloader/ktx/gradle.properties b/firebase-ml-modeldownloader/ktx/gradle.properties deleted file mode 100644 index 016fa887bc0..00000000000 --- a/firebase-ml-modeldownloader/ktx/gradle.properties +++ /dev/null @@ -1,2 +0,0 @@ -android.enableUnitTestBinaryResources=true - diff --git a/firebase-ml-modeldownloader/ktx/ktx.gradle b/firebase-ml-modeldownloader/ktx/ktx.gradle deleted file mode 100644 index 9b182097594..00000000000 --- a/firebase-ml-modeldownloader/ktx/ktx.gradle +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2021 Google LLC -// -// 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. - -plugins { - id 'firebase-library' - id("kotlin-android") -} - -firebaseLibrary { - libraryGroup = "ml-modeldownloader" - publishJavadoc = false - releaseNotes { - enabled.set(false) - } - testLab.enabled = false -} - -android { - namespace "com.google.firebase.ml.modeldownloader.ktx" - compileSdkVersion project.compileSdkVersion - defaultConfig { - minSdkVersion project.minSdkVersion - multiDexEnabled true - targetSdkVersion project.targetSdkVersion - versionName version - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - test.java.srcDirs += 'src/test/kotlin' - } - testOptions.unitTests.includeAndroidResources = true -} - -dependencies { - api(project(":firebase-ml-modeldownloader")) - api("com.google.firebase:firebase-common:21.0.0") - api("com.google.firebase:firebase-common-ktx:21.0.0") - - implementation("com.google.firebase:firebase-components:18.0.0") - - testImplementation 'androidx.test:runner:1.5.1' - testImplementation libs.androidx.test.junit - testImplementation libs.truth - testImplementation libs.junit - testImplementation 'org.mockito:mockito-core:3.6.0' - testImplementation libs.robolectric -} diff --git a/firebase-ml-modeldownloader/ktx/src/main/AndroidManifest.xml b/firebase-ml-modeldownloader/ktx/src/main/AndroidManifest.xml deleted file mode 100644 index 105842d8ac4..00000000000 --- a/firebase-ml-modeldownloader/ktx/src/main/AndroidManifest.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/firebase-ml-modeldownloader/ktx/src/main/kotlin/com/google/firebase/ml/modeldownloader/ktx/Logging.kt b/firebase-ml-modeldownloader/ktx/src/main/kotlin/com/google/firebase/ml/modeldownloader/ktx/Logging.kt deleted file mode 100644 index faaace93f22..00000000000 --- a/firebase-ml-modeldownloader/ktx/src/main/kotlin/com/google/firebase/ml/modeldownloader/ktx/Logging.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2023 Google LLC - * - * 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.google.firebase.ml.modeldownloader.ktx - -import androidx.annotation.Keep -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.ml.modeldownloader.BuildConfig -import com.google.firebase.platforminfo.LibraryVersionComponent - -internal const val LIBRARY_NAME: String = "firebase-ml-modeldownloader-ktx" - -/** @suppress */ -@Keep -class FirebaseMlModeldownloaderLegacyRegistrar : ComponentRegistrar { - override fun getComponents(): List> { - return listOf(LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME)) - } -} diff --git a/firebase-ml-modeldownloader/ktx/src/test/kotlin/com/google/firebase/ml/modeldownloader/ktx/ModelDownloaderTests.kt b/firebase-ml-modeldownloader/ktx/src/test/kotlin/com/google/firebase/ml/modeldownloader/ktx/ModelDownloaderTests.kt deleted file mode 100644 index 775d599b106..00000000000 --- a/firebase-ml-modeldownloader/ktx/src/test/kotlin/com/google/firebase/ml/modeldownloader/ktx/ModelDownloaderTests.kt +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright 2021 Google LLC - * - * 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.google.firebase.ml.modeldownloader.ktx - -import androidx.test.core.app.ApplicationProvider -import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.google.common.truth.Truth.assertThat -import com.google.firebase.FirebaseApp -import com.google.firebase.FirebaseOptions -import com.google.firebase.ktx.Firebase -import com.google.firebase.ktx.app -import com.google.firebase.ktx.initialize -import com.google.firebase.ml.modeldownloader.FirebaseModelDownloader -import com.google.firebase.platforminfo.UserAgentPublisher -import org.junit.After -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.robolectric.RobolectricTestRunner - -const val APP_ID = "1:1234567890:android:321abc456def7890" -const val API_KEY = "AIzaSyDOCAbC123dEf456GhI789jKl012-MnO" - -const val EXISTING_APP = "existing" - -abstract class BaseTestCase { - @Before - fun setUp() { - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build() - ) - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build(), - EXISTING_APP - ) - } - - @After - fun cleanUp() { - FirebaseApp.clearInstancesForTest() - } -} - -@RunWith(AndroidJUnit4::class) -class ModelDownloaderTests : BaseTestCase() { - - @Test - fun `modelDownloader should delegate to FirebaseModelDownloader#getInstance()`() { - assertThat(Firebase.modelDownloader).isSameInstanceAs(FirebaseModelDownloader.getInstance()) - } - - @Test - fun `Firebase#modelDownloader(FirebaseApp) should delegate to FirebaseModelDownloader#getInstance(FirebaseApp)`() { - val app = Firebase.app(EXISTING_APP) - assertThat(Firebase.modelDownloader(app)) - .isSameInstanceAs(FirebaseModelDownloader.getInstance(app)) - } - - @Test - fun `CustomModelDownloadConditions builder works`() { - val conditions = customModelDownloadConditions { - requireCharging() - requireDeviceIdle() - } - - assertThat(conditions.isChargingRequired).isEqualTo(true) - assertThat(conditions.isWifiRequired).isEqualTo(false) - assertThat(conditions.isDeviceIdleRequired).isEqualTo(true) - } - - @Test - fun `CustomModel destructuring declarations work`() { - val app = Firebase.app(EXISTING_APP) - - val modelName = "myModel" - val modelHash = "someHash" - val fileSize = 200L - val downloadId = 258L - - val customModel = - Firebase.modelDownloader(app).modelFactory.create(modelName, modelHash, fileSize, downloadId) - - val (_, size, id, hash, name) = customModel - - assertThat(name).isEqualTo(customModel.name) - assertThat(hash).isEqualTo(customModel.modelHash) - assertThat(size).isEqualTo(customModel.size) - assertThat(id).isEqualTo(customModel.downloadId) - } -} - -@RunWith(RobolectricTestRunner::class) -class LibraryVersionTest : BaseTestCase() { - @Test - fun `library version should be registered with runtime`() { - val publisher = Firebase.app.get(UserAgentPublisher::class.java) - assertThat(publisher.userAgent).contains(LIBRARY_NAME) - } -} diff --git a/firebase-ml-modeldownloader/ml-data-collection-tests/ml-data-collection-tests.gradle b/firebase-ml-modeldownloader/ml-data-collection-tests/ml-data-collection-tests.gradle index ef073266edd..16fcbc987ea 100644 --- a/firebase-ml-modeldownloader/ml-data-collection-tests/ml-data-collection-tests.gradle +++ b/firebase-ml-modeldownloader/ml-data-collection-tests/ml-data-collection-tests.gradle @@ -45,7 +45,6 @@ dependencies { implementation project(':firebase-ml-modeldownloader') implementation libs.androidx.core implementation 'com.google.firebase:firebase-common:21.0.0' - implementation 'com.google.firebase:firebase-common-ktx:21.0.0' testImplementation libs.androidx.test.runner testImplementation libs.androidx.test.junit diff --git a/firebase-ml-modeldownloader/src/main/java/com/google/firebase/ml/modeldownloader/ktx/ModelDownloader.kt b/firebase-ml-modeldownloader/src/main/java/com/google/firebase/ml/modeldownloader/ktx/ModelDownloader.kt deleted file mode 100644 index 89b34d9053a..00000000000 --- a/firebase-ml-modeldownloader/src/main/java/com/google/firebase/ml/modeldownloader/ktx/ModelDownloader.kt +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2021 Google LLC - * - * 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.google.firebase.ml.modeldownloader.ktx - -import com.google.firebase.FirebaseApp -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.ktx.Firebase -import com.google.firebase.ml.modeldownloader.CustomModel -import com.google.firebase.ml.modeldownloader.CustomModelDownloadConditions -import com.google.firebase.ml.modeldownloader.FirebaseModelDownloader -import java.io.File - -/** - * Accessing this object for Kotlin apps has changed; see the - * [migration guide](https://firebase.google.com/docs/android/kotlin-migration). - * - * Returns the [FirebaseModelDownloader] instance of the default [FirebaseApp]. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-ml-modeldownloade-ktx` are now deprecated. As early as April 2024, - * we'll no longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -val Firebase.modelDownloader: FirebaseModelDownloader - get() = FirebaseModelDownloader.getInstance() - -/** - * Accessing this object for Kotlin apps has changed; see the - * [migration guide](https://firebase.google.com/docs/android/kotlin-migration). - * - * Returns the [FirebaseModelDownloader] instance of a given [FirebaseApp]. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-ml-modeldownloade-ktx` are now deprecated. As early as April 2024, - * we'll no longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -fun Firebase.modelDownloader(app: FirebaseApp) = FirebaseModelDownloader.getInstance(app) - -/** - * Returns a [CustomModelDownloadConditions] initialized using the [init] function. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-ml-modeldownloade-ktx` are now deprecated. As early as April 2024, - * we'll no longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -fun customModelDownloadConditions( - init: CustomModelDownloadConditions.Builder.() -> Unit -): CustomModelDownloadConditions { - val builder = CustomModelDownloadConditions.Builder() - builder.init() - return builder.build() -} - -operator fun CustomModel.component1(): File? = file - -operator fun CustomModel.component2() = size - -operator fun CustomModel.component3() = downloadId - -operator fun CustomModel.component4() = modelHash - -operator fun CustomModel.component5() = name - -/** - * @suppress - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-ml-modeldownloade-ktx` are now deprecated. As early as April 2024, - * we'll no longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -class FirebaseMlModelDownloaderKtxRegistrar : ComponentRegistrar { - override fun getComponents(): List> = listOf() -} diff --git a/firebase-ml-modeldownloader/src/test/java/com/google/firebase/ml/modeldownloader/ktx/ModelDownloaderTests.kt b/firebase-ml-modeldownloader/src/test/java/com/google/firebase/ml/modeldownloader/ktx/ModelDownloaderTests.kt deleted file mode 100644 index e88df2d6946..00000000000 --- a/firebase-ml-modeldownloader/src/test/java/com/google/firebase/ml/modeldownloader/ktx/ModelDownloaderTests.kt +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright 2021 Google LLC - * - * 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.google.firebase.ml.modeldownloader.ktx - -import androidx.test.core.app.ApplicationProvider -import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.google.common.truth.Truth.assertThat -import com.google.firebase.FirebaseApp -import com.google.firebase.FirebaseOptions -import com.google.firebase.ktx.Firebase -import com.google.firebase.ktx.app -import com.google.firebase.ktx.initialize -import com.google.firebase.ml.modeldownloader.FirebaseModelDownloader -import com.google.firebase.platforminfo.UserAgentPublisher -import org.junit.After -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.robolectric.RobolectricTestRunner - -const val APP_ID = "1:1234567890:android:321abc456def7890" -const val API_KEY = "AIzaSyDOCAbC123dEf456GhI789jKl012-MnO" - -const val EXISTING_APP = "existing" - -abstract class BaseTestCase { - @Before - fun setUp() { - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build() - ) - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build(), - EXISTING_APP - ) - } - - @After - fun cleanUp() { - FirebaseApp.clearInstancesForTest() - } -} - -@RunWith(AndroidJUnit4::class) -class ModelDownloaderTests : BaseTestCase() { - - @Test - fun `modelDownloader should delegate to FirebaseModelDownloader#getInstance()`() { - assertThat(Firebase.modelDownloader).isSameInstanceAs(FirebaseModelDownloader.getInstance()) - } - - @Test - fun `Firebase#modelDownloader(FirebaseApp) should delegate to FirebaseModelDownloader#getInstance(FirebaseApp)`() { - val app = Firebase.app(EXISTING_APP) - assertThat(Firebase.modelDownloader(app)) - .isSameInstanceAs(FirebaseModelDownloader.getInstance(app)) - } - - @Test - fun `CustomModelDownloadConditions builder works`() { - val conditions = customModelDownloadConditions { - requireCharging() - requireDeviceIdle() - } - - assertThat(conditions.isChargingRequired).isEqualTo(true) - assertThat(conditions.isWifiRequired).isEqualTo(false) - assertThat(conditions.isDeviceIdleRequired).isEqualTo(true) - } - - @Test - fun `CustomModel destructuring declarations work`() { - val app = Firebase.app(EXISTING_APP) - - val modelName = "myModel" - val modelHash = "someHash" - val fileSize = 200L - val downloadId = 258L - - val customModel = - Firebase.modelDownloader(app).modelFactory.create(modelName, modelHash, fileSize, downloadId) - - val (_, size, id, hash, name) = customModel - - assertThat(name).isEqualTo(customModel.name) - assertThat(hash).isEqualTo(customModel.modelHash) - assertThat(size).isEqualTo(customModel.size) - assertThat(id).isEqualTo(customModel.downloadId) - } -} - -@RunWith(RobolectricTestRunner::class) -class LibraryVersionTest : BaseTestCase() { - @Test - fun `library version should be registered with runtime`() { - val publisher = Firebase.app.get(UserAgentPublisher::class.java) - } -} diff --git a/firebase-perf/api.txt b/firebase-perf/api.txt index 2352c0de69f..13dfb7dcbea 100644 --- a/firebase-perf/api.txt +++ b/firebase-perf/api.txt @@ -36,17 +36,6 @@ package com.google.firebase.perf { } -package com.google.firebase.perf.ktx { - - public final class PerformanceKt { - method @Deprecated public static com.google.firebase.perf.FirebasePerformance getPerformance(com.google.firebase.ktx.Firebase); - method @Deprecated public static inline void trace(com.google.firebase.perf.metrics.HttpMetric, kotlin.jvm.functions.Function1 block); - method @Deprecated public static inline T trace(com.google.firebase.perf.metrics.Trace, kotlin.jvm.functions.Function1 block); - method @Deprecated public static inline T trace(String name, kotlin.jvm.functions.Function1 block); - } - -} - package com.google.firebase.perf.metrics { @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) public @interface AddTrace { diff --git a/firebase-perf/dev-app/dev-app.gradle b/firebase-perf/dev-app/dev-app.gradle index 41b7a98e48e..49cad609c98 100644 --- a/firebase-perf/dev-app/dev-app.gradle +++ b/firebase-perf/dev-app/dev-app.gradle @@ -88,7 +88,6 @@ dependencies { println("Building with HEAD version ':firebase-perf' of SDK") implementation project(":firebase-perf") implementation "com.google.firebase:firebase-common:21.0.0" - implementation "com.google.firebase:firebase-common-ktx:21.0.0" implementation project(":firebase-config") } else { diff --git a/firebase-perf/firebase-perf.gradle b/firebase-perf/firebase-perf.gradle index 4c49ed6aad6..121e31d47b2 100644 --- a/firebase-perf/firebase-perf.gradle +++ b/firebase-perf/firebase-perf.gradle @@ -114,7 +114,6 @@ dependencies { api project(":protolite-well-known-types") implementation libs.okhttp api("com.google.firebase:firebase-common:21.0.0") - api("com.google.firebase:firebase-common-ktx:21.0.0") api("com.google.firebase:firebase-components:18.0.0") api("com.google.firebase:firebase-config:21.5.0") api("com.google.firebase:firebase-installations:17.2.0") diff --git a/firebase-perf/ktx/api.txt b/firebase-perf/ktx/api.txt deleted file mode 100644 index da4f6cc18fe..00000000000 --- a/firebase-perf/ktx/api.txt +++ /dev/null @@ -1 +0,0 @@ -// Signature format: 3.0 diff --git a/firebase-perf/ktx/gradle.properties b/firebase-perf/ktx/gradle.properties deleted file mode 100644 index 016fa887bc0..00000000000 --- a/firebase-perf/ktx/gradle.properties +++ /dev/null @@ -1,2 +0,0 @@ -android.enableUnitTestBinaryResources=true - diff --git a/firebase-perf/ktx/ktx.gradle b/firebase-perf/ktx/ktx.gradle deleted file mode 100644 index c028b48fa49..00000000000 --- a/firebase-perf/ktx/ktx.gradle +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2020 Google LLC -// -// 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. - -plugins { - id 'firebase-library' - id("kotlin-android") -} - -firebaseLibrary { - libraryGroup = "perf" - publishJavadoc = false - releaseNotes { - enabled.set(false) - } -} - -android { - namespace "com.google.firebase.perf.ktx" - compileSdk project.compileSdkVersion - defaultConfig { - minSdkVersion project.minSdkVersion - multiDexEnabled true - targetSdkVersion project.targetSdkVersion - versionName version - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - test.java { - srcDir 'src/test/kotlin' - } - } - kotlinOptions.jvmTarget = "1.8" - testOptions.unitTests.includeAndroidResources = true -} - -dependencies { - api(project(":firebase-perf")) - api("com.google.firebase:firebase-common:21.0.0") - api("com.google.firebase:firebase-common-ktx:21.0.0") - - implementation("com.google.firebase:firebase-components:18.0.0") - - testImplementation libs.androidx.test.core - testImplementation libs.truth - testImplementation 'junit:junit:4.12' - testImplementation 'org.mockito:mockito-core:2.25.0' - testImplementation libs.robolectric - - testCompileOnly libs.protobuf.java -} diff --git a/firebase-perf/ktx/src/main/AndroidManifest.xml b/firebase-perf/ktx/src/main/AndroidManifest.xml deleted file mode 100644 index ddafad4d174..00000000000 --- a/firebase-perf/ktx/src/main/AndroidManifest.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - diff --git a/firebase-perf/ktx/src/main/kotlin/com/google/firebase/perf/ktx/Logging.kt b/firebase-perf/ktx/src/main/kotlin/com/google/firebase/perf/ktx/Logging.kt deleted file mode 100644 index b9f8fba664c..00000000000 --- a/firebase-perf/ktx/src/main/kotlin/com/google/firebase/perf/ktx/Logging.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2023 Google LLC - * - * 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.google.firebase.perf.ktx - -import androidx.annotation.Keep -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.perf.BuildConfig -import com.google.firebase.platforminfo.LibraryVersionComponent - -internal const val LIBRARY_NAME: String = "fire-perf-ktx" - -/** @suppress */ -@Keep -class FirebasePerfLegacyRegistrar : ComponentRegistrar { - override fun getComponents(): List> { - return listOf(LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME)) - } -} diff --git a/firebase-perf/ktx/src/test/kotlin/com/google/firebase/perf/ktx/PerformanceTests.kt b/firebase-perf/ktx/src/test/kotlin/com/google/firebase/perf/ktx/PerformanceTests.kt deleted file mode 100644 index 2a477986908..00000000000 --- a/firebase-perf/ktx/src/test/kotlin/com/google/firebase/perf/ktx/PerformanceTests.kt +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * 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.google.firebase.perf.ktx - -import android.content.Context -import androidx.test.core.app.ApplicationProvider -import com.google.common.truth.Truth.assertThat -import com.google.firebase.FirebaseApp -import com.google.firebase.FirebaseOptions -import com.google.firebase.ktx.Firebase -import com.google.firebase.ktx.app -import com.google.firebase.ktx.initialize -import com.google.firebase.perf.FirebasePerformance -import com.google.firebase.perf.FirebasePerformance.HttpMethod -import com.google.firebase.perf.application.AppStateMonitor -import com.google.firebase.perf.metrics.HttpMetric -import com.google.firebase.perf.metrics.Trace -import com.google.firebase.perf.metrics.getTraceCounter -import com.google.firebase.perf.metrics.getTraceCounterCount -import com.google.firebase.perf.transport.TransportManager -import com.google.firebase.perf.util.Clock -import com.google.firebase.perf.util.Timer -import com.google.firebase.perf.v1.ApplicationProcessState -import com.google.firebase.perf.v1.NetworkRequestMetric -import com.google.firebase.perf.v1.TraceMetric -import com.google.firebase.platforminfo.UserAgentPublisher -import org.junit.After -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.ArgumentCaptor -import org.mockito.ArgumentMatchers -import org.mockito.ArgumentMatchers.nullable -import org.mockito.Captor -import org.mockito.Mock -import org.mockito.Mockito.doAnswer -import org.mockito.Mockito.verify -import org.mockito.Mockito.`when` -import org.mockito.MockitoAnnotations.initMocks -import org.robolectric.RobolectricTestRunner -import org.robolectric.Shadows - -const val APP_ID = "1:149208680807:android:0000000000000000" -const val API_KEY = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" - -const val EXISTING_APP = "existing" - -abstract class BaseTestCase { - @Before - open fun setUp() { - val context = ApplicationProvider.getApplicationContext() - val shadowPackageManager = Shadows.shadowOf(context.packageManager) - val packageInfo = shadowPackageManager.getInternalMutablePackageInfo(context.packageName) - packageInfo.versionName = "1.0.0" - - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build() - ) - - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build(), - EXISTING_APP - ) - } - - @After - fun cleanUp() { - FirebaseApp.clearInstancesForTest() - } -} - -@RunWith(RobolectricTestRunner::class) -class PerformanceTests : BaseTestCase() { - - @Mock lateinit var transportManagerMock: TransportManager - - @Mock lateinit var timerMock: Timer - - @Mock lateinit var mockTransportManager: TransportManager - - @Mock lateinit var mockClock: Clock - - @Mock lateinit var mockAppStateMonitor: AppStateMonitor - - @Captor lateinit var argMetricCaptor: ArgumentCaptor - - @Captor lateinit var argumentsCaptor: ArgumentCaptor - - var currentTime: Long = 1 - - @Before - override fun setUp() { - super.setUp() - initMocks(this) - - `when`(timerMock.getMicros()).thenReturn(1000L) - `when`(timerMock.getDurationMicros()).thenReturn(2000L).thenReturn(3000L) - doAnswer { Timer(currentTime) }.`when`(mockClock).getTime() - } - - @Test - fun `performance should delegate to FirebasePerformance#getInstance()`() { - assertThat(Firebase.performance).isSameInstanceAs(FirebasePerformance.getInstance()) - } - - @Test - fun `httpMetric wrapper test `() { - val metric = - HttpMetric("https://www.google.com/", HttpMethod.GET, transportManagerMock, timerMock) - metric.trace { setHttpResponseCode(200) } - - verify(transportManagerMock) - .log( - argMetricCaptor.capture(), - ArgumentMatchers.nullable(ApplicationProcessState::class.java) - ) - - val metricValue = argMetricCaptor.getValue() - assertThat(metricValue.getHttpResponseCode()).isEqualTo(200) - } - - @Test - fun `trace wrapper test`() { - val trace = Trace("trace_1", mockTransportManager, mockClock, mockAppStateMonitor) - trace.trace { incrementMetric("metric_1", 5) } - - assertThat(getTraceCounter(trace)).hasSize(1) - assertThat(getTraceCounterCount(trace, "metric_1")).isEqualTo(5) - verify(mockTransportManager) - .log(argumentsCaptor.capture(), nullable(ApplicationProcessState::class.java)) - } -} - -@RunWith(RobolectricTestRunner::class) -class LibraryVersionTest : BaseTestCase() { - @Test - fun `library version should be registered with runtime`() { - val publisher = Firebase.app.get(UserAgentPublisher::class.java) - assertThat(publisher.userAgent).contains(LIBRARY_NAME) - } -} diff --git a/firebase-perf/ktx/src/test/kotlin/com/google/firebase/perf/metrics/TestUtil.kt b/firebase-perf/ktx/src/test/kotlin/com/google/firebase/perf/metrics/TestUtil.kt deleted file mode 100644 index 88c5890f9bf..00000000000 --- a/firebase-perf/ktx/src/test/kotlin/com/google/firebase/perf/metrics/TestUtil.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * 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.google.firebase.perf.metrics - -fun getTraceCounter(trace: Trace): Map { - return trace.getCounters() -} - -fun getTraceCounterCount(trace: Trace, counterName: String): Long { - return trace.getCounters().get(counterName)!!.getCount() -} diff --git a/firebase-perf/src/main/java/com/google/firebase/perf/ktx/Performance.kt b/firebase-perf/src/main/java/com/google/firebase/perf/ktx/Performance.kt deleted file mode 100644 index 21d0fde9fe9..00000000000 --- a/firebase-perf/src/main/java/com/google/firebase/perf/ktx/Performance.kt +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * 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.google.firebase.perf.ktx - -import androidx.annotation.Keep -import com.google.firebase.FirebaseApp -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.ktx.Firebase -import com.google.firebase.perf.FirebasePerformance -import com.google.firebase.perf.metrics.HttpMetric -import com.google.firebase.perf.metrics.Trace - -/** - * Accessing this object for Kotlin apps has changed; see the - * [migration guide](https://firebase.google.com/docs/android/kotlin-migration). - * - * Returns the [FirebasePerformance] instance of the default [FirebaseApp]. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-perf-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -val Firebase.performance: FirebasePerformance - get() = FirebasePerformance.getInstance() - -/** - * Measures the time it takes to run the [block] wrapped by calls to [start] and [stop] using - * [HttpMetric]. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-perf-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -inline fun HttpMetric.trace(block: HttpMetric.() -> Unit) { - start() - try { - block() - } finally { - stop() - } -} - -/** - * Measures the time it takes to run the [block] wrapped by calls to [start] and [stop] using - * [Trace]. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-perf-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -inline fun Trace.trace(block: Trace.() -> T): T { - start() - try { - return block() - } finally { - stop() - } -} - -/** - * Creates a [Trace] object with given [name] and measures the time it takes to run the [block] - * wrapped by calls to [start] and [stop]. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-perf-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -inline fun trace(name: String, block: Trace.() -> T): T = Trace.create(name).trace(block) - -/** - * @suppress - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-perf-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -@Keep -class FirebasePerfKtxRegistrar : ComponentRegistrar { - override fun getComponents(): List> = listOf() -} diff --git a/firebase-perf/src/test/java/com/google/firebase/perf/ktx/PerformanceTests.kt b/firebase-perf/src/test/java/com/google/firebase/perf/ktx/PerformanceTests.kt deleted file mode 100644 index f5d02ea6b35..00000000000 --- a/firebase-perf/src/test/java/com/google/firebase/perf/ktx/PerformanceTests.kt +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * 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.google.firebase.perf.ktx - -import android.content.Context -import androidx.test.core.app.ApplicationProvider -import com.google.common.truth.Truth.assertThat -import com.google.firebase.FirebaseApp -import com.google.firebase.FirebaseOptions -import com.google.firebase.ktx.Firebase -import com.google.firebase.ktx.app -import com.google.firebase.ktx.initialize -import com.google.firebase.perf.FirebasePerformance -import com.google.firebase.perf.FirebasePerformance.HttpMethod -import com.google.firebase.perf.application.AppStateMonitor -import com.google.firebase.perf.metrics.HttpMetric -import com.google.firebase.perf.metrics.Trace -import com.google.firebase.perf.metrics.getTraceCounter -import com.google.firebase.perf.metrics.getTraceCounterCount -import com.google.firebase.perf.transport.TransportManager -import com.google.firebase.perf.util.Clock -import com.google.firebase.perf.util.Timer -import com.google.firebase.perf.v1.ApplicationProcessState -import com.google.firebase.perf.v1.NetworkRequestMetric -import com.google.firebase.perf.v1.TraceMetric -import com.google.firebase.platforminfo.UserAgentPublisher -import org.junit.After -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.ArgumentCaptor -import org.mockito.ArgumentMatchers -import org.mockito.ArgumentMatchers.nullable -import org.mockito.Captor -import org.mockito.Mock -import org.mockito.Mockito.doAnswer -import org.mockito.Mockito.verify -import org.mockito.Mockito.`when` -import org.mockito.MockitoAnnotations.initMocks -import org.robolectric.RobolectricTestRunner -import org.robolectric.Shadows - -const val APP_ID = "1:149208680807:android:0000000000000000" -const val API_KEY = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" - -const val EXISTING_APP = "existing" - -abstract class BaseTestCase { - @Before - open fun setUp() { - val context = ApplicationProvider.getApplicationContext() - val shadowPackageManager = Shadows.shadowOf(context.packageManager) - val packageInfo = shadowPackageManager.getInternalMutablePackageInfo(context.packageName) - packageInfo.versionName = "1.0.0" - - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build() - ) - - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build(), - EXISTING_APP - ) - } - - @After - fun cleanUp() { - FirebaseApp.clearInstancesForTest() - } -} - -@RunWith(RobolectricTestRunner::class) -class PerformanceTests : BaseTestCase() { - - @Mock lateinit var transportManagerMock: TransportManager - - @Mock lateinit var timerMock: Timer - - @Mock lateinit var mockTransportManager: TransportManager - - @Mock lateinit var mockClock: Clock - - @Mock lateinit var mockAppStateMonitor: AppStateMonitor - - @Captor lateinit var argMetricCaptor: ArgumentCaptor - - @Captor lateinit var argumentsCaptor: ArgumentCaptor - - var currentTime: Long = 1 - - @Before - override fun setUp() { - super.setUp() - initMocks(this) - - `when`(timerMock.getMicros()).thenReturn(1000L) - `when`(timerMock.getDurationMicros()).thenReturn(2000L).thenReturn(3000L) - doAnswer { Timer(currentTime) }.`when`(mockClock).getTime() - } - - @Test - fun `performance should delegate to FirebasePerformance#getInstance()`() { - assertThat(Firebase.performance).isSameInstanceAs(FirebasePerformance.getInstance()) - } - - @Test - fun `httpMetric wrapper test `() { - val metric = - HttpMetric("https://www.google.com/", HttpMethod.GET, transportManagerMock, timerMock) - metric.trace { setHttpResponseCode(200) } - - verify(transportManagerMock) - .log( - argMetricCaptor.capture(), - ArgumentMatchers.nullable(ApplicationProcessState::class.java) - ) - - val metricValue = argMetricCaptor.getValue() - assertThat(metricValue.getHttpResponseCode()).isEqualTo(200) - } - - @Test - fun `trace wrapper test`() { - val trace = Trace("trace_1", mockTransportManager, mockClock, mockAppStateMonitor) - trace.trace { incrementMetric("metric_1", 5) } - - assertThat(getTraceCounter(trace)).hasSize(1) - assertThat(getTraceCounterCount(trace, "metric_1")).isEqualTo(5) - verify(mockTransportManager) - .log(argumentsCaptor.capture(), nullable(ApplicationProcessState::class.java)) - } -} - -@RunWith(RobolectricTestRunner::class) -class LibraryVersionTest : BaseTestCase() { - @Test - fun `library version should be registered with runtime`() { - val publisher = Firebase.app.get(UserAgentPublisher::class.java) - } -} diff --git a/firebase-sessions/firebase-sessions.gradle.kts b/firebase-sessions/firebase-sessions.gradle.kts index 83ab6fe940b..6ae1a53efa5 100644 --- a/firebase-sessions/firebase-sessions.gradle.kts +++ b/firebase-sessions/firebase-sessions.gradle.kts @@ -69,7 +69,6 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KaptGenerateStubs::class.java). dependencies { api("com.google.firebase:firebase-common:21.0.0") - api("com.google.firebase:firebase-common-ktx:21.0.0") api("com.google.firebase:firebase-components:18.0.0") api("com.google.firebase:firebase-installations-interop:17.2.0") { diff --git a/firebase-storage/api.txt b/firebase-storage/api.txt index 38c099acdac..db77e0966b0 100644 --- a/firebase-storage/api.txt +++ b/firebase-storage/api.txt @@ -281,43 +281,3 @@ package com.google.firebase.storage { } -package com.google.firebase.storage.ktx { - - public final class StorageKt { - method @Deprecated public static operator long component1(com.google.firebase.storage.FileDownloadTask.TaskSnapshot); - method @Deprecated public static operator java.util.List component1(com.google.firebase.storage.ListResult); - method @Deprecated public static operator long component1(com.google.firebase.storage.StreamDownloadTask.TaskSnapshot); - method @Deprecated public static operator long component1(com.google.firebase.storage.UploadTask.TaskSnapshot); - method @Deprecated public static operator long component2(com.google.firebase.storage.FileDownloadTask.TaskSnapshot); - method @Deprecated public static operator java.util.List component2(com.google.firebase.storage.ListResult); - method @Deprecated public static operator long component2(com.google.firebase.storage.StreamDownloadTask.TaskSnapshot); - method @Deprecated public static operator long component2(com.google.firebase.storage.UploadTask.TaskSnapshot); - method @Deprecated public static operator String? component3(com.google.firebase.storage.ListResult); - method @Deprecated public static operator java.io.InputStream component3(com.google.firebase.storage.StreamDownloadTask.TaskSnapshot); - method @Deprecated public static operator com.google.firebase.storage.StorageMetadata? component3(com.google.firebase.storage.UploadTask.TaskSnapshot); - method @Deprecated public static operator android.net.Uri? component4(com.google.firebase.storage.UploadTask.TaskSnapshot); - method @Deprecated public static com.google.firebase.storage.FirebaseStorage getStorage(com.google.firebase.ktx.Firebase); - method @Deprecated public static .SnapshotBase> kotlinx.coroutines.flow.Flow> getTaskState(com.google.firebase.storage.StorageTask); - method @Deprecated public static com.google.firebase.storage.FirebaseStorage storage(com.google.firebase.ktx.Firebase, com.google.firebase.FirebaseApp app); - method @Deprecated public static com.google.firebase.storage.FirebaseStorage storage(com.google.firebase.ktx.Firebase, com.google.firebase.FirebaseApp app, String url); - method @Deprecated public static com.google.firebase.storage.FirebaseStorage storage(com.google.firebase.ktx.Firebase, String url); - method @Deprecated public static com.google.firebase.storage.StorageMetadata storageMetadata(kotlin.jvm.functions.Function1 init); - } - - @Deprecated public abstract class TaskState { - } - - @Deprecated public static final class TaskState.InProgress extends com.google.firebase.storage.ktx.TaskState { - ctor @Deprecated public TaskState.InProgress(T snapshot); - method @Deprecated public T getSnapshot(); - property @Deprecated public final T snapshot; - } - - @Deprecated public static final class TaskState.Paused extends com.google.firebase.storage.ktx.TaskState { - ctor @Deprecated public TaskState.Paused(T snapshot); - method @Deprecated public T getSnapshot(); - property @Deprecated public final T snapshot; - } - -} - diff --git a/firebase-storage/firebase-storage.gradle b/firebase-storage/firebase-storage.gradle index efb892570db..49db50a98ab 100644 --- a/firebase-storage/firebase-storage.gradle +++ b/firebase-storage/firebase-storage.gradle @@ -99,7 +99,6 @@ dependencies { exclude group: "com.google.firebase", module: "firebase-annotations" } api("com.google.firebase:firebase-common:21.0.0") - api("com.google.firebase:firebase-common-ktx:21.0.0") api("com.google.firebase:firebase-components:18.0.0") implementation libs.androidx.annotation diff --git a/firebase-storage/ktx/api.txt b/firebase-storage/ktx/api.txt deleted file mode 100644 index da4f6cc18fe..00000000000 --- a/firebase-storage/ktx/api.txt +++ /dev/null @@ -1 +0,0 @@ -// Signature format: 3.0 diff --git a/firebase-storage/ktx/gradle.properties b/firebase-storage/ktx/gradle.properties deleted file mode 100644 index 016fa887bc0..00000000000 --- a/firebase-storage/ktx/gradle.properties +++ /dev/null @@ -1,2 +0,0 @@ -android.enableUnitTestBinaryResources=true - diff --git a/firebase-storage/ktx/ktx.gradle b/firebase-storage/ktx/ktx.gradle deleted file mode 100644 index c0ad95e7382..00000000000 --- a/firebase-storage/ktx/ktx.gradle +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2019 Google LLC -// -// 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. - -plugins { - id 'firebase-library' - id("kotlin-android") -} - -group = "com.google.firebase" - -firebaseLibrary { - libraryGroup = "storage" - publishJavadoc = false - releaseNotes { - enabled.set(false) - } -} - -android { - namespace "com.google.firebase.storage.ktx" - compileSdkVersion project.compileSdkVersion - defaultConfig { - minSdkVersion project.minSdkVersion - multiDexEnabled true - targetSdkVersion project.targetSdkVersion - versionName version - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - test.java { - srcDir 'src/test/kotlin' - srcDir '../src/testUtil/java' - } - androidTest.java.srcDirs += 'src/androidTest/kotlin' - } - testOptions.unitTests.includeAndroidResources = true - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - - kotlinOptions { - jvmTarget = "1.8" - } -} - -dependencies { - api(project(":firebase-storage")) - api("com.google.firebase:firebase-common:21.0.0") - api("com.google.firebase:firebase-common-ktx:21.0.0") - - implementation("com.google.firebase:firebase-components:18.0.0") - - testImplementation libs.androidx.test.core - testImplementation libs.truth - testImplementation 'junit:junit:4.12' - testImplementation 'org.mockito:mockito-core:3.3.3' - testImplementation libs.robolectric - - androidTestImplementation 'androidx.test:runner:1.2.0' - androidTestImplementation libs.truth - androidTestImplementation 'junit:junit:4.12' -} diff --git a/firebase-storage/ktx/src/main/AndroidManifest.xml b/firebase-storage/ktx/src/main/AndroidManifest.xml deleted file mode 100644 index 3a78c5134c7..00000000000 --- a/firebase-storage/ktx/src/main/AndroidManifest.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - diff --git a/firebase-storage/ktx/src/main/kotlin/com/google/firebase/storage/ktx/Logging.kt b/firebase-storage/ktx/src/main/kotlin/com/google/firebase/storage/ktx/Logging.kt deleted file mode 100644 index 32d28146f10..00000000000 --- a/firebase-storage/ktx/src/main/kotlin/com/google/firebase/storage/ktx/Logging.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2023 Google LLC - * - * 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.google.firebase.storage.ktx - -import androidx.annotation.Keep -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.platforminfo.LibraryVersionComponent -import com.google.firebase.storage.BuildConfig - -internal const val LIBRARY_NAME: String = "fire-stg-ktx" - -/** @suppress */ -@Keep -class FirebaseStorageLegacyRegistrar : ComponentRegistrar { - override fun getComponents(): List> { - return listOf(LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME)) - } -} diff --git a/firebase-storage/ktx/src/test/kotlin/com/google/firebase/storage/ktx/StorageTest.kt b/firebase-storage/ktx/src/test/kotlin/com/google/firebase/storage/ktx/StorageTest.kt deleted file mode 100644 index 5dfa0d7c8d1..00000000000 --- a/firebase-storage/ktx/src/test/kotlin/com/google/firebase/storage/ktx/StorageTest.kt +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * 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.google.firebase.storage.ktx - -import android.net.Uri -import androidx.test.core.app.ApplicationProvider -import com.google.common.truth.Truth.assertThat -import com.google.firebase.FirebaseApp -import com.google.firebase.FirebaseOptions -import com.google.firebase.ktx.Firebase -import com.google.firebase.ktx.app -import com.google.firebase.ktx.initialize -import com.google.firebase.platforminfo.UserAgentPublisher -import com.google.firebase.storage.FileDownloadTask -import com.google.firebase.storage.FirebaseStorage -import com.google.firebase.storage.KtxTestUtil -import com.google.firebase.storage.StorageMetadata -import com.google.firebase.storage.StorageReference -import com.google.firebase.storage.StreamDownloadTask -import com.google.firebase.storage.UploadTask -import java.io.ByteArrayInputStream -import org.junit.After -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.Mockito -import org.mockito.Mockito.`when` -import org.robolectric.RobolectricTestRunner - -const val APP_ID = "APP_ID" -const val API_KEY = "API_KEY" - -const val EXISTING_APP = "existing" - -abstract class BaseTestCase { - @Before - fun setUp() { - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build() - ) - - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build(), - EXISTING_APP - ) - } - - @After - fun cleanUp() { - FirebaseApp.clearInstancesForTest() - } -} - -@RunWith(RobolectricTestRunner::class) -class StorageTests : BaseTestCase() { - - @Test - fun `storage should delegate to FirebaseStorage#getInstance()`() { - assertThat(Firebase.storage).isSameInstanceAs(FirebaseStorage.getInstance()) - } - - @Test - fun `FirebaseApp#storage should delegate to FirebaseStorage#getInstance(FirebaseApp)`() { - val app = Firebase.app(EXISTING_APP) - assertThat(Firebase.storage(app)).isSameInstanceAs(FirebaseStorage.getInstance(app)) - } - - @Test - fun `Firebase#storage should delegate to FirebaseStorage#getInstance(url)`() { - val url = "gs://valid.url" - assertThat(Firebase.storage(url)).isSameInstanceAs(FirebaseStorage.getInstance(url)) - } - - @Test - fun `Firebase#storage should delegate to FirebaseStorage#getInstance(FirebaseApp, url)`() { - val app = Firebase.app(EXISTING_APP) - val url = "gs://valid.url" - assertThat(Firebase.storage(app, url)).isSameInstanceAs(FirebaseStorage.getInstance(app, url)) - } - - @Test - fun `storageMetadata type-safe builder extension works`() { - val storage = Firebase.storage - val metadata: StorageMetadata = storageMetadata { - contentLanguage = "en_us" - contentType = "text/html" - contentEncoding = "utf-8" - cacheControl = "no-cache" - contentDisposition = "attachment" - } - - assertThat(metadata.getContentType()).isEqualTo("text/html") - assertThat(metadata.getCacheControl()).isEqualTo("no-cache") - } - - @Test - fun `ListResult destructuring declarations work`() { - val mockListResult = - KtxTestUtil.listResult(listOf(), listOf(), null) - - val (items, prefixes, pageToken) = mockListResult - assertThat(items).isSameInstanceAs(mockListResult.items) - assertThat(prefixes).isSameInstanceAs(mockListResult.prefixes) - assertThat(pageToken).isSameInstanceAs(mockListResult.pageToken) - } - - @Test - fun `UploadTask#TaskSnapshot destructuring declarations work`() { - val mockTaskSnapshot = Mockito.mock(UploadTask.TaskSnapshot::class.java) - `when`(mockTaskSnapshot.bytesTransferred).thenReturn(50) - `when`(mockTaskSnapshot.totalByteCount).thenReturn(100) - `when`(mockTaskSnapshot.metadata) - .thenReturn( - storageMetadata { - contentType = "image/png" - contentEncoding = "utf-8" - } - ) - `when`(mockTaskSnapshot.uploadSessionUri).thenReturn(Uri.parse("https://test.com")) - - val (bytesTransferred, totalByteCount, metadata, sessionUri) = mockTaskSnapshot - - assertThat(bytesTransferred).isSameInstanceAs(mockTaskSnapshot.bytesTransferred) - assertThat(totalByteCount).isSameInstanceAs(mockTaskSnapshot.totalByteCount) - assertThat(metadata).isSameInstanceAs(mockTaskSnapshot.metadata) - assertThat(sessionUri).isSameInstanceAs(mockTaskSnapshot.uploadSessionUri) - } - - @Test - fun `StreamDownloadTask#TaskSnapshot destructuring declarations work`() { - val mockTaskSnapshot = Mockito.mock(StreamDownloadTask.TaskSnapshot::class.java) - `when`(mockTaskSnapshot.bytesTransferred).thenReturn(50) - `when`(mockTaskSnapshot.totalByteCount).thenReturn(100) - `when`(mockTaskSnapshot.stream).thenReturn(ByteArrayInputStream("test".toByteArray())) - - val (bytesTransferred, totalByteCount, stream) = mockTaskSnapshot - - assertThat(bytesTransferred).isSameInstanceAs(mockTaskSnapshot.bytesTransferred) - assertThat(totalByteCount).isSameInstanceAs(mockTaskSnapshot.totalByteCount) - assertThat(stream).isSameInstanceAs(mockTaskSnapshot.stream) - } - - @Test - fun `FileDownloadTask#TaskSnapshot destructuring declarations work`() { - val mockTaskSnapshot = Mockito.mock(FileDownloadTask.TaskSnapshot::class.java) - `when`(mockTaskSnapshot.bytesTransferred).thenReturn(50) - `when`(mockTaskSnapshot.totalByteCount).thenReturn(100) - - val (bytesTransferred, totalByteCount) = mockTaskSnapshot - - assertThat(bytesTransferred).isSameInstanceAs(mockTaskSnapshot.bytesTransferred) - assertThat(totalByteCount).isSameInstanceAs(mockTaskSnapshot.totalByteCount) - } -} - -@RunWith(RobolectricTestRunner::class) -class LibraryVersionTest : BaseTestCase() { - @Test - fun `library version should be registered with runtime`() { - val publisher = Firebase.app.get(UserAgentPublisher::class.java) - assertThat(publisher.userAgent).contains(LIBRARY_NAME) - } -} diff --git a/firebase-storage/src/main/java/com/google/firebase/storage/ktx/Storage.kt b/firebase-storage/src/main/java/com/google/firebase/storage/ktx/Storage.kt deleted file mode 100644 index fc94cdc8ef3..00000000000 --- a/firebase-storage/src/main/java/com/google/firebase/storage/ktx/Storage.kt +++ /dev/null @@ -1,374 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * 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.google.firebase.storage.ktx - -import androidx.annotation.Keep -import com.google.android.gms.tasks.OnCompleteListener -import com.google.firebase.FirebaseApp -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.ktx.Firebase -import com.google.firebase.storage.FileDownloadTask -import com.google.firebase.storage.FirebaseStorage -import com.google.firebase.storage.ListResult -import com.google.firebase.storage.OnPausedListener -import com.google.firebase.storage.OnProgressListener -import com.google.firebase.storage.StorageMetadata -import com.google.firebase.storage.StorageReference -import com.google.firebase.storage.StorageTask -import com.google.firebase.storage.StorageTaskScheduler -import com.google.firebase.storage.StreamDownloadTask -import com.google.firebase.storage.UploadTask -import kotlinx.coroutines.cancel -import kotlinx.coroutines.channels.awaitClose -import kotlinx.coroutines.channels.trySendBlocking -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.callbackFlow - -/** - * Accessing this object for Kotlin apps has changed; see the - * [migration guide](https://firebase.google.com/docs/android/kotlin-migration). - * - * Returns the [FirebaseStorage] instance of the default [FirebaseApp]. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-storage-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -val Firebase.storage: FirebaseStorage - get() = FirebaseStorage.getInstance() - -/** - * Accessing this object for Kotlin apps has changed; see the - * [migration guide](https://firebase.google.com/docs/android/kotlin-migration). - * - * Returns the [FirebaseStorage] instance for a custom storage bucket at [url]. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-storage-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -fun Firebase.storage(url: String): FirebaseStorage = FirebaseStorage.getInstance(url) - -/** - * Accessing this object for Kotlin apps has changed; see the - * [migration guide](https://firebase.google.com/docs/android/kotlin-migration). - * - * Returns the [FirebaseStorage] instance of a given [FirebaseApp]. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-storage-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -fun Firebase.storage(app: FirebaseApp): FirebaseStorage = FirebaseStorage.getInstance(app) - -/** - * Accessing this object for Kotlin apps has changed; see the - * [migration guide](https://firebase.google.com/docs/android/kotlin-migration). - * - * Returns the [FirebaseStorage] instance of a given [FirebaseApp] and storage bucket [url]. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-storage-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -fun Firebase.storage(app: FirebaseApp, url: String): FirebaseStorage = - FirebaseStorage.getInstance(app, url) - -/** - * Returns a [StorageMetadata] object initialized using the [init] function. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-storage-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -fun storageMetadata(init: StorageMetadata.Builder.() -> Unit): StorageMetadata { - val builder = StorageMetadata.Builder() - builder.init() - return builder.build() -} - -/** - * Destructuring declaration for [UploadTask.TaskSnapshot] to provide bytesTransferred. - * - * @return the bytesTransferred of the [UploadTask.TaskSnapshot] - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-storage-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -operator fun UploadTask.TaskSnapshot.component1() = bytesTransferred - -/** - * Destructuring declaration for [UploadTask.TaskSnapshot] to provide totalByteCount. - * - * @return the totalByteCount of the [UploadTask.TaskSnapshot] - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-storage-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -operator fun UploadTask.TaskSnapshot.component2() = totalByteCount - -/** - * Destructuring declaration for [UploadTask.TaskSnapshot] to provide its metadata. - * - * @return the metadata of the [UploadTask.TaskSnapshot] - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-storage-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -operator fun UploadTask.TaskSnapshot.component3() = metadata - -/** - * Destructuring declaration for [UploadTask.TaskSnapshot] to provide its uploadSessionUri. - * - * @return the uploadSessionUri of the [UploadTask.TaskSnapshot] - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-storage-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -operator fun UploadTask.TaskSnapshot.component4() = uploadSessionUri - -/** - * Destructuring declaration for [StreamDownloadTask.TaskSnapshot] to provide bytesTransferred. - * - * @return the bytesTransferred of the [StreamDownloadTask.TaskSnapshot] - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-storage-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -operator fun StreamDownloadTask.TaskSnapshot.component1() = bytesTransferred - -/** - * Destructuring declaration for [StreamDownloadTask.TaskSnapshot] to provide totalByteCount. - * - * @return the totalByteCount of the [StreamDownloadTask.TaskSnapshot] - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-storage-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -operator fun StreamDownloadTask.TaskSnapshot.component2() = totalByteCount - -/** - * Destructuring declaration for [StreamDownloadTask.TaskSnapshot] to provide its stream. - * - * @return the stream of the [StreamDownloadTask.TaskSnapshot] - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-storage-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -operator fun StreamDownloadTask.TaskSnapshot.component3() = stream - -/** - * Destructuring declaration for [FileDownloadTask.TaskSnapshot] to provide bytesTransferred. - * - * @return the bytesTransferred of the [FileDownloadTask.TaskSnapshot] - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-storage-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -operator fun FileDownloadTask.TaskSnapshot.component1() = bytesTransferred - -/** - * Destructuring declaration for [FileDownloadTask.TaskSnapshot] to provide totalByteCount. - * - * @return the totalByteCount of the [FileDownloadTask.TaskSnapshot] - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-storage-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -operator fun FileDownloadTask.TaskSnapshot.component2() = totalByteCount - -/** - * Destructuring declaration for [ListResult] to provide its items. - * - * @return the items of the [ListResult] - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-storage-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -operator fun ListResult.component1(): List = items - -/** - * Destructuring declaration for [ListResult] to provide its prefixes. - * - * @return the prefixes of the [ListResult] - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-storage-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -operator fun ListResult.component2(): List = prefixes - -/** - * Destructuring declaration for [ListResult] to provide its pageToken. - * - * @return the pageToken of the [ListResult] - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-storage-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -operator fun ListResult.component3(): String? = pageToken - -/** - * Starts listening to this task's progress and emits its values via a [Flow]. - * - * - When the returned flow starts being collected, it attaches the following listeners: - * [OnProgressListener], [OnPausedListener], [OnCompleteListener]. - * - When the flow completes the listeners will be removed. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-storage-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -val .SnapshotBase> StorageTask.taskState: Flow> - get() = callbackFlow { - val progressListener = - OnProgressListener { snapshot -> - StorageTaskScheduler.getInstance().scheduleCallback { - trySendBlocking(TaskState.InProgress(snapshot)) - } - } - val pauseListener = - OnPausedListener { snapshot -> - StorageTaskScheduler.getInstance().scheduleCallback { - trySendBlocking(TaskState.Paused(snapshot)) - } - } - - // Only used to close or cancel the Flows, doesn't send any values - val completionListener = - OnCompleteListener { task -> - if (task.isSuccessful) { - close() - } else { - val exception = task.exception - cancel("Error getting the TaskState", exception) - } - } - - addOnProgressListener(progressListener) - addOnPausedListener(pauseListener) - addOnCompleteListener(completionListener) - - awaitClose { - removeOnProgressListener(progressListener) - removeOnPausedListener(pauseListener) - removeOnCompleteListener(completionListener) - } - } - -/** - * @suppress - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-storage-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -@Keep -class FirebaseStorageKtxRegistrar : ComponentRegistrar { - override fun getComponents(): List> = listOf() -} diff --git a/firebase-storage/src/main/java/com/google/firebase/storage/ktx/TaskState.kt b/firebase-storage/src/main/java/com/google/firebase/storage/ktx/TaskState.kt deleted file mode 100644 index 5c409a163e0..00000000000 --- a/firebase-storage/src/main/java/com/google/firebase/storage/ktx/TaskState.kt +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2022 Google LLC - * - * 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.google.firebase.storage.ktx - -/** - * Used to emit events about the progress of storage tasks. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-storage-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ -@Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") -) -abstract class TaskState private constructor() { - /** - * Called periodically as data is transferred and can be used to populate an upload/download - * indicator. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-storage-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ - @Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") - ) - class InProgress(val snapshot: T) : TaskState() - - /** - * Called any time the upload/download is paused. - * @deprecated **Deprecation Notice:** The Kotlin extensions (KTX) APIs have been added to their - * respective main modules, and the Kotlin extension (KTX) APIs in - * `com.google.firebase.firebase-storage-ktx` are now deprecated. As early as April 2024, we'll no - * longer release KTX modules. For details, see the - * [FAQ about this initiative.](https://firebase.google.com/docs/android/kotlin-migration) - */ - @Deprecated( - "Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.", - ReplaceWith("") - ) - class Paused(val snapshot: T) : TaskState() -} diff --git a/firebase-storage/src/test/java/com/google/firebase/storage/ktx/StorageTest.kt b/firebase-storage/src/test/java/com/google/firebase/storage/ktx/StorageTest.kt deleted file mode 100644 index 0164695e901..00000000000 --- a/firebase-storage/src/test/java/com/google/firebase/storage/ktx/StorageTest.kt +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * 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.google.firebase.storage.ktx - -import android.net.Uri -import androidx.test.core.app.ApplicationProvider -import com.google.common.truth.Truth.assertThat -import com.google.firebase.FirebaseApp -import com.google.firebase.FirebaseOptions -import com.google.firebase.ktx.Firebase -import com.google.firebase.ktx.app -import com.google.firebase.ktx.initialize -import com.google.firebase.platforminfo.UserAgentPublisher -import com.google.firebase.storage.FileDownloadTask -import com.google.firebase.storage.FirebaseStorage -import com.google.firebase.storage.KtxTestUtil -import com.google.firebase.storage.StorageMetadata -import com.google.firebase.storage.StorageReference -import com.google.firebase.storage.StreamDownloadTask -import com.google.firebase.storage.UploadTask -import java.io.ByteArrayInputStream -import org.junit.After -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.Mockito -import org.mockito.Mockito.`when` -import org.robolectric.RobolectricTestRunner - -const val APP_ID = "APP_ID" -const val API_KEY = "API_KEY" - -const val EXISTING_APP = "existing" - -abstract class BaseTestCase { - @Before - fun setUp() { - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build() - ) - - Firebase.initialize( - ApplicationProvider.getApplicationContext(), - FirebaseOptions.Builder() - .setApplicationId(APP_ID) - .setApiKey(API_KEY) - .setProjectId("123") - .build(), - EXISTING_APP - ) - } - - @After - fun cleanUp() { - FirebaseApp.clearInstancesForTest() - } -} - -@RunWith(RobolectricTestRunner::class) -class StorageTests : BaseTestCase() { - - @Test - fun `storage should delegate to FirebaseStorage#getInstance()`() { - assertThat(Firebase.storage).isSameInstanceAs(FirebaseStorage.getInstance()) - } - - @Test - fun `FirebaseApp#storage should delegate to FirebaseStorage#getInstance(FirebaseApp)`() { - val app = Firebase.app(EXISTING_APP) - assertThat(Firebase.storage(app)).isSameInstanceAs(FirebaseStorage.getInstance(app)) - } - - @Test - fun `Firebase#storage should delegate to FirebaseStorage#getInstance(url)`() { - val url = "gs://valid.url" - assertThat(Firebase.storage(url)).isSameInstanceAs(FirebaseStorage.getInstance(url)) - } - - @Test - fun `Firebase#storage should delegate to FirebaseStorage#getInstance(FirebaseApp, url)`() { - val app = Firebase.app(EXISTING_APP) - val url = "gs://valid.url" - assertThat(Firebase.storage(app, url)).isSameInstanceAs(FirebaseStorage.getInstance(app, url)) - } - - @Test - fun `storageMetadata type-safe builder extension works`() { - val storage = Firebase.storage - val metadata: StorageMetadata = storageMetadata { - contentLanguage = "en_us" - contentType = "text/html" - contentEncoding = "utf-8" - cacheControl = "no-cache" - contentDisposition = "attachment" - } - - assertThat(metadata.getContentType()).isEqualTo("text/html") - assertThat(metadata.getCacheControl()).isEqualTo("no-cache") - } - - @Test - fun `ListResult destructuring declarations work`() { - val mockListResult = - KtxTestUtil.listResult(listOf(), listOf(), null) - - val (items, prefixes, pageToken) = mockListResult - assertThat(items).isSameInstanceAs(mockListResult.items) - assertThat(prefixes).isSameInstanceAs(mockListResult.prefixes) - assertThat(pageToken).isSameInstanceAs(mockListResult.pageToken) - } - - @Test - fun `UploadTask#TaskSnapshot destructuring declarations work`() { - val mockTaskSnapshot = Mockito.mock(UploadTask.TaskSnapshot::class.java) - `when`(mockTaskSnapshot.bytesTransferred).thenReturn(50) - `when`(mockTaskSnapshot.totalByteCount).thenReturn(100) - `when`(mockTaskSnapshot.metadata) - .thenReturn( - storageMetadata { - contentType = "image/png" - contentEncoding = "utf-8" - } - ) - `when`(mockTaskSnapshot.uploadSessionUri).thenReturn(Uri.parse("https://test.com")) - - val (bytesTransferred, totalByteCount, metadata, sessionUri) = mockTaskSnapshot - - assertThat(bytesTransferred).isSameInstanceAs(mockTaskSnapshot.bytesTransferred) - assertThat(totalByteCount).isSameInstanceAs(mockTaskSnapshot.totalByteCount) - assertThat(metadata).isSameInstanceAs(mockTaskSnapshot.metadata) - assertThat(sessionUri).isSameInstanceAs(mockTaskSnapshot.uploadSessionUri) - } - - @Test - fun `StreamDownloadTask#TaskSnapshot destructuring declarations work`() { - val mockTaskSnapshot = Mockito.mock(StreamDownloadTask.TaskSnapshot::class.java) - `when`(mockTaskSnapshot.bytesTransferred).thenReturn(50) - `when`(mockTaskSnapshot.totalByteCount).thenReturn(100) - `when`(mockTaskSnapshot.stream).thenReturn(ByteArrayInputStream("test".toByteArray())) - - val (bytesTransferred, totalByteCount, stream) = mockTaskSnapshot - - assertThat(bytesTransferred).isSameInstanceAs(mockTaskSnapshot.bytesTransferred) - assertThat(totalByteCount).isSameInstanceAs(mockTaskSnapshot.totalByteCount) - assertThat(stream).isSameInstanceAs(mockTaskSnapshot.stream) - } - - @Test - fun `FileDownloadTask#TaskSnapshot destructuring declarations work`() { - val mockTaskSnapshot = Mockito.mock(FileDownloadTask.TaskSnapshot::class.java) - `when`(mockTaskSnapshot.bytesTransferred).thenReturn(50) - `when`(mockTaskSnapshot.totalByteCount).thenReturn(100) - - val (bytesTransferred, totalByteCount) = mockTaskSnapshot - - assertThat(bytesTransferred).isSameInstanceAs(mockTaskSnapshot.bytesTransferred) - assertThat(totalByteCount).isSameInstanceAs(mockTaskSnapshot.totalByteCount) - } -} - -@RunWith(RobolectricTestRunner::class) -class LibraryVersionTest : BaseTestCase() { - @Test - fun `library version should be registered with runtime`() { - val publisher = Firebase.app.get(UserAgentPublisher::class.java) - } -} diff --git a/integ-testing/integ-testing.gradle.kts b/integ-testing/integ-testing.gradle.kts index 619e645658c..ef769ba7a9a 100644 --- a/integ-testing/integ-testing.gradle.kts +++ b/integ-testing/integ-testing.gradle.kts @@ -38,7 +38,6 @@ android { } dependencies { - implementation("com.google.firebase:firebase-common-ktx:21.0.0") implementation("com.google.firebase:firebase-common:21.0.0") implementation("com.google.firebase:firebase-components:18.0.0") implementation(libs.androidx.test.runner) diff --git a/plugins/src/main/java/com/google/firebase/gradle/plugins/PublishingPlugin.kt b/plugins/src/main/java/com/google/firebase/gradle/plugins/PublishingPlugin.kt index 9f8e07ca6be..758f592f52d 100644 --- a/plugins/src/main/java/com/google/firebase/gradle/plugins/PublishingPlugin.kt +++ b/plugins/src/main/java/com/google/firebase/gradle/plugins/PublishingPlugin.kt @@ -347,10 +347,8 @@ abstract class PublishingPlugin : Plugin { "com.google.firebase:firebase-database-connection-license", "com.google.firebase:firebase-database-license", "com.google.firebase:firebase-datatransport", - "com.google.firebase:firebase-appdistribution-ktx", "com.google.firebase:firebase-appdistribution", "com.google.firebase:firebase-appdistribution-api", - "com.google.firebase:firebase-appdistribution-api-ktx", "com.google.firebase:firebase-dynamic-module-support", "com.google.firebase:firebase-functions-license", "com.google.firebase:firebase-iid-interop", @@ -774,44 +772,28 @@ abstract class PublishingPlugin : Plugin { val BOM_ARTIFACTS = listOf( "com.google.firebase:firebase-analytics", - "com.google.firebase:firebase-analytics-ktx", "com.google.firebase:firebase-appcheck-debug", "com.google.firebase:firebase-appcheck-debug-testing", - "com.google.firebase:firebase-appcheck-ktx", "com.google.firebase:firebase-appcheck-playintegrity", "com.google.firebase:firebase-appcheck", "com.google.firebase:firebase-auth", - "com.google.firebase:firebase-auth-ktx", "com.google.firebase:firebase-common", - "com.google.firebase:firebase-common-ktx", "com.google.firebase:firebase-config", - "com.google.firebase:firebase-config-ktx", "com.google.firebase:firebase-crashlytics", - "com.google.firebase:firebase-crashlytics-ktx", "com.google.firebase:firebase-crashlytics-ndk", "com.google.firebase:firebase-database", "com.google.firebase:firebase-dataconnect", - "com.google.firebase:firebase-database-ktx", "com.google.firebase:firebase-encoders", "com.google.firebase:firebase-firestore", - "com.google.firebase:firebase-firestore-ktx", "com.google.firebase:firebase-functions", - "com.google.firebase:firebase-functions-ktx", "com.google.firebase:firebase-inappmessaging", "com.google.firebase:firebase-inappmessaging-display", - "com.google.firebase:firebase-inappmessaging-display-ktx", - "com.google.firebase:firebase-inappmessaging-ktx", "com.google.firebase:firebase-installations", - "com.google.firebase:firebase-installations-ktx", "com.google.firebase:firebase-messaging", "com.google.firebase:firebase-messaging-directboot", - "com.google.firebase:firebase-messaging-ktx", "com.google.firebase:firebase-ml-modeldownloader", - "com.google.firebase:firebase-ml-modeldownloader-ktx", "com.google.firebase:firebase-perf", - "com.google.firebase:firebase-perf-ktx", "com.google.firebase:firebase-storage", - "com.google.firebase:firebase-storage-ktx", "com.google.firebase:firebase-vertexai", "com.google.firebase:firebase-ai", ) diff --git a/subprojects.cfg b/subprojects.cfg index 72e06c9248f..a43cf350e91 100644 --- a/subprojects.cfg +++ b/subprojects.cfg @@ -4,29 +4,23 @@ appcheck:firebase-appcheck-debug appcheck:firebase-appcheck-interop appcheck:firebase-appcheck-playintegrity appcheck:firebase-appcheck -appcheck:firebase-appcheck:ktx firebase-abt firebase-ai firebase-annotations firebase-appdistribution firebase-appdistribution-api -firebase-appdistribution-api:ktx firebase-common firebase-common:data-collection-tests -firebase-common:ktx firebase-components firebase-components:firebase-dynamic-module-support firebase-config -firebase-config:ktx firebase-config:bandwagoner firebase-config:test-app firebase-config-interop firebase-crashlytics -firebase-crashlytics:ktx firebase-crashlytics-ndk firebase-database -firebase-database:ktx firebase-database-collection firebase-dataconnect firebase-dataconnect:androidTestutil @@ -34,31 +28,22 @@ firebase-dataconnect:connectors firebase-dataconnect:testutil firebase-datatransport firebase-firestore -firebase-firestore:ktx firebase-functions -firebase-functions:ktx firebase-messaging -firebase-messaging:ktx firebase-messaging-directboot firebase-inappmessaging -firebase-inappmessaging:ktx firebase-inappmessaging-display -firebase-inappmessaging-display:ktx firebase-installations-interop firebase-installations -firebase-installations:ktx firebase-ml-modeldownloader -firebase-ml-modeldownloader:ktx firebase-ml-modeldownloader:ml-data-collection-tests firebase-perf -firebase-perf:ktx firebase-perf:dev-app firebase-perf:e2e-app firebase-sessions firebase-sessions:benchmark firebase-sessions:test-app firebase-storage -firebase-storage:ktx firebase-vertexai protolite-well-known-types From f68c320d07015c7d8de1b30ea9d59c26f9ae776b Mon Sep 17 00:00:00 2001 From: Emily Ploszaj Date: Tue, 8 Jul 2025 17:04:28 -0500 Subject: [PATCH 08/11] Fixes --- firebase-messaging/src/test/AndroidManifest.xml | 2 +- .../firebase/messaging/DisplayNotificationRoboTest.java | 6 +++--- .../scheduling/jobscheduling/AlarmManagerSchedulerTest.java | 4 ++-- .../scheduling/jobscheduling/JobInfoSchedulerTest.java | 4 ++-- .../runtime/scheduling/jobscheduling/UploaderTest.java | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/firebase-messaging/src/test/AndroidManifest.xml b/firebase-messaging/src/test/AndroidManifest.xml index 34d239d4020..9cc3a8ab47e 100644 --- a/firebase-messaging/src/test/AndroidManifest.xml +++ b/firebase-messaging/src/test/AndroidManifest.xml @@ -18,7 +18,7 @@ android:versionCode="1" android:versionName="1"> - + diff --git a/firebase-messaging/src/test/java/com/google/firebase/messaging/DisplayNotificationRoboTest.java b/firebase-messaging/src/test/java/com/google/firebase/messaging/DisplayNotificationRoboTest.java index f3026653ee1..de61071d0e0 100644 --- a/firebase-messaging/src/test/java/com/google/firebase/messaging/DisplayNotificationRoboTest.java +++ b/firebase-messaging/src/test/java/com/google/firebase/messaging/DisplayNotificationRoboTest.java @@ -475,7 +475,7 @@ public void testClickActionAndLink() { /** Test that a valid notification with color is displayed. */ @Test - @Config(sdk = Build.VERSION_CODES.LOLLIPOP) + @Config(sdk = Build.VERSION_CODES.M) public void testColor() { final String color = "#123456"; Bundle data = new Bundle(); @@ -489,7 +489,7 @@ public void testColor() { } @Test - @Config(sdk = Build.VERSION_CODES.LOLLIPOP) + @Config(sdk = Build.VERSION_CODES.M) public void testNoColor() { Bundle data = new Bundle(); data.putString(KEY_TITLE, "title 123"); @@ -503,7 +503,7 @@ public void testNoColor() { /** Test that the user can choose the default color via AndroidManifest metadata. */ @Test - @Config(sdk = Build.VERSION_CODES.LOLLIPOP) + @Config(sdk = Build.VERSION_CODES.M) public void testColorFromMetadata() { Bundle metadata = new Bundle(); metadata.putInt( diff --git a/transport/transport-runtime/src/test/java/com/google/android/datatransport/runtime/scheduling/jobscheduling/AlarmManagerSchedulerTest.java b/transport/transport-runtime/src/test/java/com/google/android/datatransport/runtime/scheduling/jobscheduling/AlarmManagerSchedulerTest.java index ac6293f9de3..4a66fd7e36b 100644 --- a/transport/transport-runtime/src/test/java/com/google/android/datatransport/runtime/scheduling/jobscheduling/AlarmManagerSchedulerTest.java +++ b/transport/transport-runtime/src/test/java/com/google/android/datatransport/runtime/scheduling/jobscheduling/AlarmManagerSchedulerTest.java @@ -14,7 +14,7 @@ package com.google.android.datatransport.runtime.scheduling.jobscheduling; -import static android.os.Build.VERSION_CODES.LOLLIPOP; +import static android.os.Build.VERSION_CODES.M; import static com.google.common.truth.Truth.assertThat; import static org.mockito.AdditionalMatchers.gt; import static org.mockito.ArgumentMatchers.any; @@ -47,7 +47,7 @@ import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; -@Config(sdk = {LOLLIPOP}) +@Config(sdk = {M}) @RunWith(RobolectricTestRunner.class) public class AlarmManagerSchedulerTest { private static final long TWENTY_FOUR_HOURS = 24 * 60 * 60 * 1000; diff --git a/transport/transport-runtime/src/test/java/com/google/android/datatransport/runtime/scheduling/jobscheduling/JobInfoSchedulerTest.java b/transport/transport-runtime/src/test/java/com/google/android/datatransport/runtime/scheduling/jobscheduling/JobInfoSchedulerTest.java index 197daa2747c..693d047d3a8 100644 --- a/transport/transport-runtime/src/test/java/com/google/android/datatransport/runtime/scheduling/jobscheduling/JobInfoSchedulerTest.java +++ b/transport/transport-runtime/src/test/java/com/google/android/datatransport/runtime/scheduling/jobscheduling/JobInfoSchedulerTest.java @@ -14,7 +14,7 @@ package com.google.android.datatransport.runtime.scheduling.jobscheduling; -import static android.os.Build.VERSION_CODES.LOLLIPOP; +import static android.os.Build.VERSION_CODES.M; import static com.google.common.truth.Truth.assertThat; import android.app.job.JobInfo; @@ -37,7 +37,7 @@ import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; -@Config(sdk = {LOLLIPOP}) +@Config(sdk = {M}) @RunWith(RobolectricTestRunner.class) public class JobInfoSchedulerTest { private static final long TWENTY_FOUR_HOURS = 24 * 60 * 60 * 1000; diff --git a/transport/transport-runtime/src/test/java/com/google/android/datatransport/runtime/scheduling/jobscheduling/UploaderTest.java b/transport/transport-runtime/src/test/java/com/google/android/datatransport/runtime/scheduling/jobscheduling/UploaderTest.java index f3b0e999842..25ec6040a7e 100644 --- a/transport/transport-runtime/src/test/java/com/google/android/datatransport/runtime/scheduling/jobscheduling/UploaderTest.java +++ b/transport/transport-runtime/src/test/java/com/google/android/datatransport/runtime/scheduling/jobscheduling/UploaderTest.java @@ -14,7 +14,7 @@ package com.google.android.datatransport.runtime.scheduling.jobscheduling; -import static android.os.Build.VERSION_CODES.LOLLIPOP; +import static android.os.Build.VERSION_CODES.M; import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.argThat; @@ -52,7 +52,7 @@ import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; -@Config(sdk = {LOLLIPOP}) +@Config(sdk = {M}) @RunWith(RobolectricTestRunner.class) public class UploaderTest { private static final SynchronizationGuard guard = From 623bf177d2a9a5429260c68bd4e37bf7a34dd129 Mon Sep 17 00:00:00 2001 From: Emily Ploszaj Date: Tue, 8 Jul 2025 17:38:03 -0500 Subject: [PATCH 09/11] Fix sessions compilation --- .../com/google/firebase/sessions/testing/FakeFirebaseApp.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firebase-sessions/src/test/kotlin/com/google/firebase/sessions/testing/FakeFirebaseApp.kt b/firebase-sessions/src/test/kotlin/com/google/firebase/sessions/testing/FakeFirebaseApp.kt index e934ada6bf0..cd758b8e0b1 100644 --- a/firebase-sessions/src/test/kotlin/com/google/firebase/sessions/testing/FakeFirebaseApp.kt +++ b/firebase-sessions/src/test/kotlin/com/google/firebase/sessions/testing/FakeFirebaseApp.kt @@ -43,7 +43,7 @@ internal class FakeFirebaseApp( val packageInfo = PackageInfoBuilder.newBuilder().setPackageName(context.packageName).build() packageInfo.versionName = MOCK_APP_VERSION - metadata?.let { packageInfo.applicationInfo.metaData = it } + metadata?.let { packageInfo.applicationInfo!!.metaData = it } shadowPackageManager.installPackage(packageInfo) val activityManager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager From 84e69f5e61a30d5200995f67d419a1fa82b35e94 Mon Sep 17 00:00:00 2001 From: Emily Ploszaj Date: Wed, 9 Jul 2025 10:47:55 -0500 Subject: [PATCH 10/11] Revert compilesdk --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 61573c624c3..7aa23171f82 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -31,7 +31,7 @@ plugins { extra["targetSdkVersion"] = 35 -extra["compileSdkVersion"] = 35 +extra["compileSdkVersion"] = 34 extra["minSdkVersion"] = 23 From f2d1ed20db341128cc254d9a4f46b137c5ceb35a Mon Sep 17 00:00:00 2001 From: Emily Ploszaj Date: Wed, 9 Jul 2025 12:28:20 -0500 Subject: [PATCH 11/11] Revert to target sdk 34 --- build.gradle.kts | 2 +- gradle/libs.versions.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 7aa23171f82..ec33368b81e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -29,7 +29,7 @@ plugins { alias(libs.plugins.kotlinx.serialization) apply false } -extra["targetSdkVersion"] = 35 +extra["targetSdkVersion"] = 34 extra["compileSdkVersion"] = 34 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9c5ceb00fd6..544bd51cf69 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -64,7 +64,7 @@ protobufjavautil = "3.25.5" protoc = "3.25.5" quickcheck = "0.6" reactiveStreams = "1.0.4" -robolectric = "4.14" +robolectric = "4.12" runner = "1.0.2" rxandroid = "2.0.2" rxjava = "2.1.14"