diff --git a/appcheck/firebase-appcheck-debug-testing/firebase-appcheck-debug-testing.gradle b/appcheck/firebase-appcheck-debug-testing/firebase-appcheck-debug-testing.gradle index be44fcf315c..a4f8f20006a 100644 --- a/appcheck/firebase-appcheck-debug-testing/firebase-appcheck-debug-testing.gradle +++ b/appcheck/firebase-appcheck-debug-testing/firebase-appcheck-debug-testing.gradle @@ -52,7 +52,6 @@ dependencies { api project(':appcheck:firebase-appcheck-debug') api 'com.google.firebase:firebase-appcheck-interop:17.0.0' api 'com.google.firebase:firebase-common:20.4.2' - api 'com.google.firebase:firebase-common-ktx:20.4.2' api 'com.google.firebase:firebase-components:17.1.5' implementation "androidx.test:core:$androidxTestCoreVersion" diff --git a/appcheck/firebase-appcheck-debug/firebase-appcheck-debug.gradle b/appcheck/firebase-appcheck-debug/firebase-appcheck-debug.gradle index 1a74fb6b741..142f35c9cee 100644 --- a/appcheck/firebase-appcheck-debug/firebase-appcheck-debug.gradle +++ b/appcheck/firebase-appcheck-debug/firebase-appcheck-debug.gradle @@ -48,7 +48,6 @@ dependencies { api project(':appcheck:firebase-appcheck') api 'com.google.firebase:firebase-annotations:16.2.0' api 'com.google.firebase:firebase-common:20.4.2' - api 'com.google.firebase:firebase-common-ktx:20.4.2' api 'com.google.firebase:firebase-components:17.1.5' implementation 'com.google.android.gms:play-services-base:18.0.1' diff --git a/appcheck/firebase-appcheck-playintegrity/firebase-appcheck-playintegrity.gradle b/appcheck/firebase-appcheck-playintegrity/firebase-appcheck-playintegrity.gradle index 6f6aa933e0b..267216a9c62 100644 --- a/appcheck/firebase-appcheck-playintegrity/firebase-appcheck-playintegrity.gradle +++ b/appcheck/firebase-appcheck-playintegrity/firebase-appcheck-playintegrity.gradle @@ -48,7 +48,6 @@ dependencies { api project(':appcheck:firebase-appcheck') api 'com.google.firebase:firebase-annotations:16.2.0' api 'com.google.firebase:firebase-common:20.4.2' - api 'com.google.firebase:firebase-common-ktx:20.4.2' api 'com.google.firebase:firebase-components:17.1.5' implementation 'com.google.android.gms:play-services-base:18.0.1' diff --git a/appcheck/firebase-appcheck-safetynet/firebase-appcheck-safetynet.gradle b/appcheck/firebase-appcheck-safetynet/firebase-appcheck-safetynet.gradle index a03028f34bb..f8b53577903 100644 --- a/appcheck/firebase-appcheck-safetynet/firebase-appcheck-safetynet.gradle +++ b/appcheck/firebase-appcheck-safetynet/firebase-appcheck-safetynet.gradle @@ -48,7 +48,6 @@ dependencies { api project(':appcheck:firebase-appcheck') api 'com.google.firebase:firebase-annotations:16.2.0' api 'com.google.firebase:firebase-common:20.4.2' - api 'com.google.firebase:firebase-common-ktx:20.4.2' api 'com.google.firebase:firebase-components:17.1.5' implementation 'com.google.android.gms:play-services-base:18.0.1' diff --git a/appcheck/firebase-appcheck/firebase-appcheck.gradle b/appcheck/firebase-appcheck/firebase-appcheck.gradle index 4fb2dbaf93c..d8417b6f9d7 100644 --- a/appcheck/firebase-appcheck/firebase-appcheck.gradle +++ b/appcheck/firebase-appcheck/firebase-appcheck.gradle @@ -51,7 +51,6 @@ dependencies { api 'com.google.firebase:firebase-annotations:16.2.0' api "com.google.firebase:firebase-appcheck-interop:17.1.0" api("com.google.firebase:firebase-common:20.4.2") - api("com.google.firebase:firebase-common-ktx:20.4.2") api("com.google.firebase:firebase-components:17.1.5") implementation 'androidx.annotation:annotation:1.1.0' diff --git a/appcheck/firebase-appcheck/ktx/api.txt b/appcheck/firebase-appcheck/ktx/api.txt deleted file mode 100644 index c951388dd72..00000000000 --- a/appcheck/firebase-appcheck/ktx/api.txt +++ /dev/null @@ -1,8 +0,0 @@ -// Signature format: 2.0 -package com.google.firebase.appcheck.ktx { - - public final class LoggingKt { - } - -} - 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 98333d7b728..00000000000 --- a/appcheck/firebase-appcheck/ktx/ktx.gradle +++ /dev/null @@ -1,72 +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 - publishReleaseNotes = false - publishSources = true -} - -android { - namespace "com.google.firebase.appcheck.ktx" - compileSdkVersion project.targetSdkVersion - defaultConfig { - minSdkVersion 16 - 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:20.4.2") - api("com.google.firebase:firebase-common-ktx:20.4.2") - - implementation("com.google.firebase:firebase-components:17.1.5") - - testImplementation "com.google.truth:truth:$googleTruthVersion" - testImplementation 'junit:junit:4.12' - testImplementation 'org.mockito:mockito-core:2.25.0' - testImplementation "org.robolectric:robolectric:$robolectricVersion" - - androidTestImplementation "androidx.test:core:$androidxTestCoreVersion" - androidTestImplementation 'androidx.test:runner:1.2.0' - androidTestImplementation 'com.google.firebase:firebase-appcheck-interop:17.1.0' - androidTestImplementation "com.google.truth:truth:$googleTruthVersion" - androidTestImplementation 'junit:junit:4.12' -} \ No newline at end of file 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 8e6d8981caa..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 8d144dde780..00000000000 --- a/appcheck/firebase-appcheck/ktx/src/main/AndroidManifest.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file 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/dynamic-links.md b/docs/ktx/dynamic-links.md deleted file mode 100644 index 187dade8b41..00000000000 --- a/docs/ktx/dynamic-links.md +++ /dev/null @@ -1,170 +0,0 @@ -# Dynamic Links Kotlin Extensions - -## Getting Started - -To use the Dynamic Links 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-dynamic-links library -implementation 'com.google.firebase:firebase-dynamic-links-ktx:$VERSION' -``` - -## Features - -### Get an instance of FirebaseDynamicLinks - -**Kotlin** -```kotlin -val dynamicLinks = FirebaseDynamicLinks.getInstance() -val anotherDynamicLinks = FirebaseDynamicLinks.getInstance(FirebaseApp.getInstance("myApp")) -``` - -**Kotlin + KTX** -```kotlin -val dynamicLinks = Firebase.dynamicLinks -val anotherDynamicLinks = Firebase.dynamicLinks(Firebase.app("myApp")) -``` - -### Create a Dynamic Link from parameters - -**Kotlin** -```kotlin -val dynamicLink = FirebaseDynamicLinks.getInstance().createDynamicLink() - .setLink(Uri.parse("https://www.example.com/")) - .setDomainUriPrefix("https://example.page.link") - .setAndroidParameters( - DynamicLink.AndroidParameters.Builder("com.example.android") - .setMinimumVersion(16) - .build()) - .setIosParameters( - DynamicLink.IosParameters.Builder("com.example.ios") - .setAppStoreId("123456789") - .setMinimumVersion("1.0.1") - .build()) - .setGoogleAnalyticsParameters( - DynamicLink.GoogleAnalyticsParameters.Builder() - .setSource("orkut") - .setMedium("social") - .setCampaign("example-promo") - .build()) - .setItunesConnectAnalyticsParameters( - DynamicLink.ItunesConnectAnalyticsParameters.Builder() - .setProviderToken("123456") - .setCampaignToken("example-promo") - .build()) - .setSocialMetaTagParameters( - DynamicLink.SocialMetaTagParameters.Builder() - .setTitle("Example of a Dynamic Link") - .setDescription("This link works whether the app is installed or not!") - .build()) - .buildDynamicLink() -``` - -**Kotlin + KTX** -```kotlin -val dynamicLink = Firebase.dynamicLinks.dynamicLink { - link = Uri.parse("https://www.example.com/") - domainUriPrefix = "https://example.page.link" - androidParameters("com.example.android") { - minimumVersion = 16 - } - iosParameters("com.example.ios") { - appStoreId = "123456789" - minimumVersion = "1.0.1" - } - googleAnalyticsParameters { - source = "orkut" - medium = "social" - campaign = "example-promo" - } - itunesConnectAnalyticsParameters { - providerToken = "123456" - campaignToken = "example-promo" - } - socialMetaTagParameters { - title = "Example of a Dynamic Link" - description = "This link works whether the app is installed or not!" - } -} -``` - -### Shorten a long Dynamic Link - -**Kotlin** -```kotlin -FirebaseDynamicLinks.getInstance().createDynamicLink() - .setLongLink(Uri.parse("https://example.page.link/?link=" + - "https://www.example.com/&apn=com.example.android&ibn=com.example.ios")) - .buildShortDynamicLink() - .addOnSuccessListener { result -> - // Short link created - val shortLink = result.shortLink - val flowchartLink = result.previewLink - val warnings = result.warnings - - // do something with the links and warnings - showLinks(shortLink, flowchartLink) - displayWarnings(warnings) - } - .addOnFailureListener { - // Error - // ... - } -``` - -**Kotlin + KTX** -```kotlin -Firebase.dynamicLinks.shortLinkAsync { - longLink = Uri.parse("https://example.page.link/?link=" + - "https://www.example.com/&apn=com.example.android&ibn=com.example.ios") -}.addOnSuccessListener { (shortLink, flowchartLink, warnings) -> - // do something with the links and warnings - showLinks(shortLink, flowchartLink) - displayWarnings(warnings) -}.addOnFailureListener { - // Error - // ... -} -``` - -### Create a Dynamic Link with a shorter link suffix - -**Kotlin** -```kotlin -val shortLinkTask = FirebaseDynamicLinks.getInstance().createDynamicLink() - // ... - .buildShortDynamicLink(ShortDynamicLink.Suffix.SHORT) -``` - -**Kotlin + KTX** -```kotlin -val shortLinkTask = Firebase.dynamicLinks.shortLinkAsync(ShortDynamicLink.Suffix.SHORT) { - // ... -} -``` - -### Receive deep links - -**Kotlin** -```kotlin -Firebase.dynamicLinks - .getDynamicLink(intent) - .addOnSuccessListener(this) { pendingDynamicLinkData -> - val deepLink = pendingDynamicLinkData.link - val minAppVersion = pendingDynamicLinkData.minimumAppVersion - val clickTimestamp = pendingDynamicLinkData.clickTimestamp - - // TODO(developer): handle the deepLink - }.addOnFailureListener { /* ... */ } -``` - -**Kotlin + KTX** -```kotlin -Firebase.dynamicLinks - .getDynamicLink(intent) - .addOnSuccessListener(this) { (deepLink, minAppVersion, clickTimestamp) -> - // TODO(developer): handle the deepLink - }.addOnFailureListener { /* ... */ } -``` 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/firebase-appdistribution-api.gradle b/firebase-appdistribution-api/firebase-appdistribution-api.gradle index d805e70d6bb..34db30f95d2 100644 --- a/firebase-appdistribution-api/firebase-appdistribution-api.gradle +++ b/firebase-appdistribution-api/firebase-appdistribution-api.gradle @@ -46,7 +46,6 @@ android { dependencies { api 'com.google.android.gms:play-services-tasks:18.0.1' api("com.google.firebase:firebase-common:20.4.2") - api("com.google.firebase:firebase-common-ktx:20.4.2") api("com.google.firebase:firebase-components:17.1.5") implementation 'androidx.annotation:annotation:1.1.0' diff --git a/firebase-appdistribution-api/ktx/api.txt b/firebase-appdistribution-api/ktx/api.txt deleted file mode 100644 index f7139bec523..00000000000 --- a/firebase-appdistribution-api/ktx/api.txt +++ /dev/null @@ -1,8 +0,0 @@ -// Signature format: 2.0 -package com.google.firebase.appdistribution.ktx { - - public final class LoggingKt { - } - -} - 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 b948db63d69..00000000000 --- a/firebase-appdistribution-api/ktx/ktx.gradle +++ /dev/null @@ -1,71 +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 - publishReleaseNotes = false - publishSources = true -} - -android { - namespace "com.google.firebase.appdistribution.ktx" - compileSdkVersion project.targetSdkVersion - defaultConfig { - minSdkVersion 16 - 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:20.4.2") - api("com.google.firebase:firebase-common-ktx:20.4.2") - - implementation("com.google.firebase:firebase-components:17.1.5") - - testImplementation "com.google.truth:truth:$googleTruthVersion" - testImplementation 'junit:junit:4.12' - testImplementation 'org.mockito:mockito-core:2.25.0' - testImplementation "org.robolectric:robolectric:$robolectricVersion" - - androidTestImplementation "androidx.test:core:$androidxTestCoreVersion" - androidTestImplementation 'androidx.test:runner:1.2.0' - androidTestImplementation "com.google.truth:truth:$googleTruthVersion" - androidTestImplementation 'junit:junit:4.12' -} \ No newline at end of file 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 1aeaf991cd6..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 cd959b21770..00000000000 --- a/firebase-appdistribution-api/ktx/src/main/AndroidManifest.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file 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/test-app.gradle b/firebase-appdistribution/test-app/test-app.gradle index 410111af7b7..e667d80eeee 100644 --- a/firebase-appdistribution/test-app/test-app.gradle +++ b/firebase-appdistribution/test-app/test-app.gradle @@ -85,7 +85,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:20.3.1' // Shake detection implementation 'com.squareup:seismic:1.0.3' // Other dependencies diff --git a/firebase-common/ktx/api.txt b/firebase-common/ktx/api.txt deleted file mode 100644 index 13900ee70e6..00000000000 --- a/firebase-common/ktx/api.txt +++ /dev/null @@ -1,8 +0,0 @@ -// Signature format: 2.0 -package com.google.firebase.ktx { - - public final class LoggingKt { - } - -} - 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 2f823bf2283..00000000000 --- a/firebase-common/ktx/ktx.gradle.kts +++ /dev/null @@ -1,55 +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 - publishReleaseNotes = false -} - -android { - val targetSdkVersion : Int by rootProject - val minSdkVersion : Int by rootProject - compileSdk = targetSdkVersion - 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") - } - } - testOptions.unitTests.isIncludeAndroidResources = true -} - -dependencies { - api(project(":firebase-common")) - implementation("com.google.firebase:firebase-components:17.1.5") - 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) -} \ No newline at end of file diff --git a/firebase-common/ktx/src/main/AndroidManifest.xml b/firebase-common/ktx/src/main/AndroidManifest.xml deleted file mode 100644 index 3a2a9b6297f..00000000000 --- a/firebase-common/ktx/src/main/AndroidManifest.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - \ No newline at end of file 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/bandwagoner/bandwagoner.gradle b/firebase-config/bandwagoner/bandwagoner.gradle index a21bd6e9ff0..bd1f48ce1ec 100644 --- a/firebase-config/bandwagoner/bandwagoner.gradle +++ b/firebase-config/bandwagoner/bandwagoner.gradle @@ -71,10 +71,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' @@ -92,7 +88,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:20.4.2") - implementation("com.google.firebase:firebase-common-ktx:20.4.2") implementation("com.google.firebase:firebase-components:17.1.5") implementation("com.google.firebase:firebase-installations-interop:17.1.1") { exclude group: 'com.google.firebase', module: 'firebase-common' diff --git a/firebase-config/firebase-config.gradle.kts b/firebase-config/firebase-config.gradle.kts index 478bfa59550..c5c1d2e4e0c 100644 --- a/firebase-config/firebase-config.gradle.kts +++ b/firebase-config/firebase-config.gradle.kts @@ -65,7 +65,6 @@ dependencies { exclude(group = "com.google.firebase", module = "firebase-components") } api("com.google.firebase:firebase-common:20.4.2") - api("com.google.firebase:firebase-common-ktx:20.4.2") api("com.google.firebase:firebase-components:17.1.5") 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 071387283db..00000000000 --- a/firebase-config/ktx/api.txt +++ /dev/null @@ -1,8 +0,0 @@ -// Signature format: 2.0 -package com.google.firebase.remoteconfig.ktx { - - public final class LoggingKt { - } - -} - 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 424c37e0cc9..00000000000 --- a/firebase-config/ktx/ktx.gradle +++ /dev/null @@ -1,64 +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 - publishReleaseNotes = false - publishSources = true -} - -android { - namespace "com.google.firebase.remoteconfig.ktx" - compileSdkVersion project.targetSdkVersion - defaultConfig { - minSdkVersion 16 - 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' - } - } - testOptions.unitTests.includeAndroidResources = true -} - -dependencies { - api(project(":firebase-config")) - api("com.google.firebase:firebase-common:20.4.2") - api("com.google.firebase:firebase-common-ktx:20.4.2") - 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:17.1.5") - implementation 'com.google.firebase:firebase-installations-interop:17.1.0' - - testImplementation "androidx.test:core:$androidxTestCoreVersion" - testImplementation "com.google.truth:truth:$googleTruthVersion" - testImplementation 'junit:junit:4.12' - testImplementation 'org.mockito:mockito-core:2.25.0' - testImplementation "org.robolectric:robolectric:$robolectricVersion" -} diff --git a/firebase-config/ktx/src/main/AndroidManifest.xml b/firebase-config/ktx/src/main/AndroidManifest.xml deleted file mode 100644 index f39f6b02d1f..00000000000 --- a/firebase-config/ktx/src/main/AndroidManifest.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - \ No newline at end of file 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 e6167b5ab09..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.ConfigMetadataClient -import com.google.firebase.remoteconfig.internal.ConfigRealtimeHandler -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, - frcMetadata: ConfigMetadataClient, - realtimeHandler: ConfigRealtimeHandler, - rolloutsStateSubscriptionsHandler: RolloutsStateSubscriptionsHandler -): FirebaseRemoteConfig { - return FirebaseRemoteConfig( - context, - firebaseApp, - firebaseInstallations, - firebaseAbt, - executor, - fetchedConfigsCache, - activatedConfigsCache, - defaultConfigsCache, - fetchHandler, - getHandler, - frcMetadata, - 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 bb525cf4090..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.ConfigMetadataClient -import com.google.firebase.remoteconfig.internal.ConfigRealtimeHandler -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, - frcMetadata = mock(ConfigMetadataClient::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 c11ea869fbf..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.ConfigMetadataClient -import com.google.firebase.remoteconfig.internal.ConfigRealtimeHandler -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, - frcMetadata = mock(ConfigMetadataClient::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/test-app.gradle.kts b/firebase-config/test-app/test-app.gradle.kts index 1879e5ce6c5..fcc770978db 100644 --- a/firebase-config/test-app/test-app.gradle.kts +++ b/firebase-config/test-app/test-app.gradle.kts @@ -52,14 +52,12 @@ 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 remote-config. // Released artifacts don't need these dependencies since they don't use `project` to refer // to Remote Config. implementation("com.google.firebase:firebase-common:20.3.3") - implementation("com.google.firebase:firebase-common-ktx:20.3.3") implementation("com.google.firebase:firebase-components:17.1.1") implementation("com.google.firebase:firebase-installations-interop:17.1.0") @@ -74,7 +72,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:20.3.2") 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 a6f321f0203..5b4355e2157 100644 --- a/firebase-crashlytics-ndk/firebase-crashlytics-ndk.gradle +++ b/firebase-crashlytics-ndk/firebase-crashlytics-ndk.gradle @@ -107,7 +107,6 @@ thirdPartyLicenses { dependencies { api project(':firebase-crashlytics') api "com.google.firebase:firebase-common:20.4.2" - api "com.google.firebase:firebase-common-ktx:20.4.2" api "com.google.firebase:firebase-components:17.1.5" implementation 'com.google.android.gms:play-services-basement:18.1.0' diff --git a/firebase-crashlytics/firebase-crashlytics.gradle b/firebase-crashlytics/firebase-crashlytics.gradle index b6717425195..db2b59317e2 100644 --- a/firebase-crashlytics/firebase-crashlytics.gradle +++ b/firebase-crashlytics/firebase-crashlytics.gradle @@ -65,7 +65,6 @@ dependencies { api "com.google.android.gms:play-services-tasks:18.0.1" api 'com.google.firebase:firebase-annotations:16.2.0' api("com.google.firebase:firebase-common:20.4.2") - api("com.google.firebase:firebase-common-ktx:20.4.2") api("com.google.firebase:firebase-components:17.1.5") api 'com.google.firebase:firebase-config-interop:16.0.0' 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 fdf9446609e..00000000000 --- a/firebase-crashlytics/ktx/api.txt +++ /dev/null @@ -1,8 +0,0 @@ -// Signature format: 2.0 -package com.google.firebase.crashlytics.ktx { - - public final class LoggingKt { - } - -} - 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 00591434a6d..00000000000 --- a/firebase-crashlytics/ktx/ktx.gradle +++ /dev/null @@ -1,58 +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 - publishReleaseNotes = false - publishSources = true -} - -android { - namespace "com.google.firebase.crashlytics.ktx" - compileSdk 33 - defaultConfig { - minSdk 16 - multiDexEnabled true - targetSdk 33 - 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:20.4.2") - api("com.google.firebase:firebase-common-ktx:20.4.2") - - implementation("com.google.firebase:firebase-components:17.1.5") - - androidTestImplementation(libs.androidx.test.junit) - androidTestImplementation(libs.androidx.test.runner) - androidTestImplementation(libs.truth) -} \ No newline at end of file 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 09fb253d601..00000000000 --- a/firebase-crashlytics/ktx/src/main/AndroidManifest.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file 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/firebase-database.gradle.kts b/firebase-database/firebase-database.gradle.kts index 1c913a06ff9..2eb497e2c81 100644 --- a/firebase-database/firebase-database.gradle.kts +++ b/firebase-database/firebase-database.gradle.kts @@ -57,7 +57,6 @@ android { dependencies { api("com.google.firebase:firebase-appcheck-interop:17.1.0") api("com.google.firebase:firebase-common:20.4.2") - api("com.google.firebase:firebase-common-ktx:20.4.2") api("com.google.firebase:firebase-components:17.1.5") 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 9767e86197c..00000000000 --- a/firebase-database/ktx/api.txt +++ /dev/null @@ -1,8 +0,0 @@ -// Signature format: 2.0 -package com.google.firebase.database.ktx { - - public final class LoggingKt { - } - -} - 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 6add391befd..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 - publishReleaseNotes = false - publishSources = true -} - -android { - val targetSdkVersion: Int by rootProject - val minSdkVersion: Int by rootProject - - compileSdk = targetSdkVersion - - 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:20.4.2") - api("com.google.firebase:firebase-common-ktx:20.4.2") - api(project(":firebase-database")) - - implementation("com.google.firebase:firebase-components:17.1.5") - - testImplementation(libs.androidx.test.core) - testImplementation(libs.junit) - testImplementation(libs.robolectric) - testImplementation(libs.truth) -} \ No newline at end of file diff --git a/firebase-database/ktx/src/main/AndroidManifest.xml b/firebase-database/ktx/src/main/AndroidManifest.xml deleted file mode 100644 index e47f9541b92..00000000000 --- a/firebase-database/ktx/src/main/AndroidManifest.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - \ No newline at end of file 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-dynamic-links/firebase-dynamic-links.gradle b/firebase-dynamic-links/firebase-dynamic-links.gradle index 1b2e6947f8d..0d73181c7d8 100644 --- a/firebase-dynamic-links/firebase-dynamic-links.gradle +++ b/firebase-dynamic-links/firebase-dynamic-links.gradle @@ -60,7 +60,6 @@ dependencies { exclude group: "com.google.firebase", module: "firebase-common" } api("com.google.firebase:firebase-common:20.4.2") - api("com.google.firebase:firebase-common-ktx:20.4.2") api("com.google.firebase:firebase-components:17.1.5") api('com.google.firebase:firebase-measurement-connector:19.0.0') { exclude group: 'com.google.firebase', module: 'firebase-common' diff --git a/firebase-dynamic-links/ktx/api.txt b/firebase-dynamic-links/ktx/api.txt deleted file mode 100644 index 448c591bfb5..00000000000 --- a/firebase-dynamic-links/ktx/api.txt +++ /dev/null @@ -1,8 +0,0 @@ -// Signature format: 2.0 -package com.google.firebase.dynamiclinks.ktx { - - public final class LoggingKt { - } - -} - diff --git a/firebase-dynamic-links/ktx/gradle.properties b/firebase-dynamic-links/ktx/gradle.properties deleted file mode 100644 index 016fa887bc0..00000000000 --- a/firebase-dynamic-links/ktx/gradle.properties +++ /dev/null @@ -1,2 +0,0 @@ -android.enableUnitTestBinaryResources=true - diff --git a/firebase-dynamic-links/ktx/ktx.gradle b/firebase-dynamic-links/ktx/ktx.gradle deleted file mode 100644 index ff76d9c1d0c..00000000000 --- a/firebase-dynamic-links/ktx/ktx.gradle +++ /dev/null @@ -1,58 +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 "dynamic-links" - publishJavadoc = false - publishReleaseNotes = false - publishSources = true -} - -android { - namespace "com.google.firebase.dynamiclinks.ktx" - compileSdkVersion project.targetSdkVersion - defaultConfig { - minSdkVersion 19 - 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' - } - } - testOptions.unitTests.includeAndroidResources = true -} - -dependencies { - api(project(":firebase-dynamic-links")) - api("com.google.firebase:firebase-common:20.4.2") - api("com.google.firebase:firebase-common-ktx:20.4.2") - - implementation("com.google.firebase:firebase-components:17.1.5") - - testImplementation "androidx.test:core:$androidxTestCoreVersion" - testImplementation "com.google.truth:truth:$googleTruthVersion" - testImplementation 'junit:junit:4.12' - testImplementation 'org.mockito:mockito-core:2.25.0' - testImplementation "org.robolectric:robolectric:$robolectricVersion" -} \ No newline at end of file diff --git a/firebase-dynamic-links/ktx/src/main/AndroidManifest.xml b/firebase-dynamic-links/ktx/src/main/AndroidManifest.xml deleted file mode 100644 index 67b8ed2d837..00000000000 --- a/firebase-dynamic-links/ktx/src/main/AndroidManifest.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/firebase-dynamic-links/ktx/src/main/kotlin/com/google/firebase/dynamiclinks/ktx/Logging.kt b/firebase-dynamic-links/ktx/src/main/kotlin/com/google/firebase/dynamiclinks/ktx/Logging.kt deleted file mode 100644 index 37249965572..00000000000 --- a/firebase-dynamic-links/ktx/src/main/kotlin/com/google/firebase/dynamiclinks/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.dynamiclinks.ktx - -import androidx.annotation.Keep -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.dynamiclinks.BuildConfig -import com.google.firebase.platforminfo.LibraryVersionComponent - -internal const val LIBRARY_NAME: String = "fire-dl-ktx" - -/** @suppress */ -@Keep -class FirebaseDynamicLinksLegacyRegistrar : ComponentRegistrar { - override fun getComponents(): List> { - return listOf(LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME)) - } -} diff --git a/firebase-dynamic-links/ktx/src/test/kotlin/com/google/firebase/dynamiclinks/ktx/DynamicLinksTests.kt b/firebase-dynamic-links/ktx/src/test/kotlin/com/google/firebase/dynamiclinks/ktx/DynamicLinksTests.kt deleted file mode 100644 index 48531d72990..00000000000 --- a/firebase-dynamic-links/ktx/src/test/kotlin/com/google/firebase/dynamiclinks/ktx/DynamicLinksTests.kt +++ /dev/null @@ -1,281 +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.dynamiclinks.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.dynamiclinks.FirebaseDynamicLinks -import com.google.firebase.dynamiclinks.PendingDynamicLinkData -import com.google.firebase.dynamiclinks.ShortDynamicLink -import com.google.firebase.ktx.Firebase -import com.google.firebase.ktx.app -import com.google.firebase.ktx.initialize -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 = "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 DynamicLinksTests : BaseTestCase() { - - @Test - fun `Firebase#dynamicLinks should delegate to FirebaseDynamicLinks#getInstance()`() { - assertThat(Firebase.dynamicLinks).isSameInstanceAs(FirebaseDynamicLinks.getInstance()) - } - - @Test - fun `Firebase#dynamicLinks should delegate to FirebaseDynamicLinks#getInstance(FirebaseApp)`() { - val app = Firebase.app(EXISTING_APP) - assertThat(Firebase.dynamicLinks(app)).isSameInstanceAs(FirebaseDynamicLinks.getInstance(app)) - } - - @Test - fun `Firebase#dynamicLinks#createDynamicLink`() { - val exampleLink = "https://example.com" - val exampleDomainUriPrefix = "https://example.page.link" - - val dynamicLinkKtx = - Firebase.dynamicLinks.dynamicLink { - link = Uri.parse(exampleLink) - domainUriPrefix = exampleDomainUriPrefix - } - - val dynamicLink = - FirebaseDynamicLinks.getInstance() - .createDynamicLink() - .setLink(Uri.parse(exampleLink)) - .setDomainUriPrefix(exampleDomainUriPrefix) - .buildDynamicLink() - - assertThat(dynamicLinkKtx.uri).isEqualTo(dynamicLink.uri) - } - - @Test - fun `androidParameters type-safe builder extension works`() { - val fallbackLink = "https://android.com" - val minVersion = 19 - val packageName = "com.example.android" - - val dynamicLink = - Firebase.dynamicLinks.dynamicLink { - link = Uri.parse("https://example.com") - domainUriPrefix = "https://example.page.link" - androidParameters { - minimumVersion = minVersion - fallbackUrl = Uri.parse(fallbackLink) - } - } - - val anotherDynamicLink = - Firebase.dynamicLinks.dynamicLink { - link = Uri.parse("https://example.com") - domainUriPrefix = "https://example.page.link" - androidParameters(packageName) { - minimumVersion = minVersion - fallbackUrl = Uri.parse(fallbackLink) - } - } - - assertThat(dynamicLink.uri.getQueryParameter("amv")?.toInt()).isEqualTo(minVersion) - assertThat(dynamicLink.uri.getQueryParameter("afl")).isEqualTo(fallbackLink) - - assertThat(anotherDynamicLink.uri.getQueryParameter("amv")?.toInt()).isEqualTo(minVersion) - assertThat(anotherDynamicLink.uri.getQueryParameter("afl")).isEqualTo(fallbackLink) - assertThat(anotherDynamicLink.uri.getQueryParameter("apn")).isEqualTo(packageName) - } - - @Test - fun `iosParameters type-safe builder extension works`() { - val iosAppStoreId = "123456789" - val iosMinimumVersion = "1.0.1" - val iosBundleId = "com.example.ios" - - val dynamicLink = - Firebase.dynamicLinks.dynamicLink { - link = Uri.parse("https://example.com") - domainUriPrefix = "https://example.page.link" - iosParameters(iosBundleId) { - appStoreId = iosAppStoreId - minimumVersion = iosMinimumVersion - } - } - - assertThat(dynamicLink.uri.getQueryParameter("ibi")).isEqualTo(iosBundleId) - assertThat(dynamicLink.uri.getQueryParameter("imv")).isEqualTo(iosMinimumVersion) - assertThat(dynamicLink.uri.getQueryParameter("isi")).isEqualTo(iosAppStoreId) - } - - @Test - fun `googleAnalyticsParameters type-safe builder extension works`() { - val campaignTerm = "Example Term" - val campaignContent = "Example Content" - val campaignSource = "Twitter" - val campaignMedium = "Social" - val campaignName = "Example Promo" - - val dynamicLink = - Firebase.dynamicLinks.dynamicLink { - link = Uri.parse("https://example.com") - domainUriPrefix = "https://example.page.link" - googleAnalyticsParameters(campaignSource, campaignMedium, campaignName) { - term = campaignTerm - content = campaignContent - } - } - - assertThat(dynamicLink.uri.getQueryParameter("utm_content")).isEqualTo(campaignContent) - assertThat(dynamicLink.uri.getQueryParameter("utm_term")).isEqualTo(campaignTerm) - assertThat(dynamicLink.uri.getQueryParameter("utm_source")).isEqualTo(campaignSource) - assertThat(dynamicLink.uri.getQueryParameter("utm_medium")).isEqualTo(campaignMedium) - assertThat(dynamicLink.uri.getQueryParameter("utm_campaign")).isEqualTo(campaignName) - } - - @Test - fun `itunesConnectAnalyticsParameters type-safe builder extension works`() { - val ct = "example-campaign" - val pt = "123456" - - val dynamicLink = - Firebase.dynamicLinks.dynamicLink { - link = Uri.parse("https://example.com") - domainUriPrefix = "https://example.page.link" - itunesConnectAnalyticsParameters { - providerToken = pt - campaignToken = ct - } - } - - assertThat(dynamicLink.uri.getQueryParameter("pt")).isEqualTo(pt) - assertThat(dynamicLink.uri.getQueryParameter("ct")).isEqualTo(ct) - } - - @Test - fun `socialMetaTagParameters type-safe builder extension works`() { - val socialTitle = "Example Title" - val socialDescription = "This link works whether the app is installed or not!" - - val dynamicLink = - Firebase.dynamicLinks.dynamicLink { - link = Uri.parse("https://example.com") - domainUriPrefix = "https://example.page.link" - socialMetaTagParameters { - title = socialTitle - description = socialDescription - } - } - - assertThat(dynamicLink.uri.getQueryParameter("st")).isEqualTo(socialTitle) - assertThat(dynamicLink.uri.getQueryParameter("sd")).isEqualTo(socialDescription) - } - - @Test - fun `navigationInfoParameters type-safe builder extension works`() { - val forcedRedirect = true - - val dynamicLink = - Firebase.dynamicLinks.dynamicLink { - link = Uri.parse("https://example.com") - domainUriPrefix = "https://example.page.link" - navigationInfoParameters { forcedRedirectEnabled = true } - } - - val efr = Integer.parseInt(dynamicLink.uri.getQueryParameter("efr")!!) == 1 - assertThat(efr).isEqualTo(forcedRedirect) - } - - @Test - fun `ShortDynamicLink destructure declaration works`() { - val fakeWarning = - object : ShortDynamicLink.Warning { - override fun getMessage() = "Warning" - override fun getCode() = "warning" - } - - val expectedShortLink = Uri.parse("https://example.com") - val expectedPreviewLink = Uri.parse("https://example.com/preview") - val expectedWarnings = mutableListOf(fakeWarning) - - val mockShortDynamicLink = mock(ShortDynamicLink::class.java) - `when`(mockShortDynamicLink.shortLink).thenReturn(expectedShortLink) - `when`(mockShortDynamicLink.previewLink).thenReturn(expectedPreviewLink) - `when`(mockShortDynamicLink.warnings).thenReturn(expectedWarnings) - - val (shortLink, previewLink, warnings) = mockShortDynamicLink - - assertThat(shortLink).isEqualTo(expectedShortLink) - assertThat(previewLink).isEqualTo(expectedPreviewLink) - assertThat(warnings).isEqualTo(expectedWarnings) - } - - @Test - fun `PendingDynamicLinkData destructure declaration works`() { - val expectedLink = Uri.parse("https://example.com") - val expectedMinAppVersion = 30 - val expectedTimestamp = 172947600L - - val mockPendingData = mock(PendingDynamicLinkData::class.java) - `when`(mockPendingData.link).thenReturn(expectedLink) - `when`(mockPendingData.minimumAppVersion).thenReturn(expectedMinAppVersion) - `when`(mockPendingData.clickTimestamp).thenReturn(expectedTimestamp) - - val (link, minAppVersion, timestamp) = mockPendingData - - assertThat(link).isEqualTo(expectedLink) - assertThat(minAppVersion).isEqualTo(expectedMinAppVersion) - assertThat(timestamp).isEqualTo(expectedTimestamp) - } -} diff --git a/firebase-dynamic-links/src/main/java/com/google/firebase/dynamiclinks/ktx/FirebaseDynamicLinks.kt b/firebase-dynamic-links/src/main/java/com/google/firebase/dynamiclinks/ktx/FirebaseDynamicLinks.kt deleted file mode 100644 index b0591e2f082..00000000000 --- a/firebase-dynamic-links/src/main/java/com/google/firebase/dynamiclinks/ktx/FirebaseDynamicLinks.kt +++ /dev/null @@ -1,385 +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.dynamiclinks.ktx - -import androidx.annotation.Keep -import com.google.android.gms.tasks.Task -import com.google.firebase.FirebaseApp -import com.google.firebase.components.Component -import com.google.firebase.components.ComponentRegistrar -import com.google.firebase.dynamiclinks.DynamicLink -import com.google.firebase.dynamiclinks.FirebaseDynamicLinks -import com.google.firebase.dynamiclinks.PendingDynamicLinkData -import com.google.firebase.dynamiclinks.ShortDynamicLink -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 [FirebaseDynamicLinks] 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-dynamic-links-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.dynamicLinks: FirebaseDynamicLinks - get() = FirebaseDynamicLinks.getInstance() - -/** - * Accessing this object for Kotlin apps has changed; see the - * [migration guide](https://firebase.google.com/docs/android/kotlin-migration). - * - * Returns the [FirebaseDynamicLinks] 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-dynamic-links-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.dynamicLinks(app: FirebaseApp): FirebaseDynamicLinks { - return FirebaseDynamicLinks.getInstance(app) -} - -/** - * Creates a [DynamicLink.AndroidParameters] object initialized using the [init] function and sets - * it to the [DynamicLink.Builder] - * @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-dynamic-links-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 DynamicLink.Builder.androidParameters(init: DynamicLink.AndroidParameters.Builder.() -> Unit) { - val builder = DynamicLink.AndroidParameters.Builder() - builder.init() - setAndroidParameters(builder.build()) -} - -/** - * Creates a [DynamicLink.AndroidParameters] object initialized with the specified [packageName] and - * using the [init] function and sets it to the [DynamicLink.Builder] - * @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-dynamic-links-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 DynamicLink.Builder.androidParameters( - packageName: String, - init: DynamicLink.AndroidParameters.Builder.() -> Unit -) { - val builder = DynamicLink.AndroidParameters.Builder(packageName) - builder.init() - setAndroidParameters(builder.build()) -} - -/** - * Creates a [DynamicLink.IosParameters] object initialized with the specified [bundleId] and using - * the [init] function and sets it to the [DynamicLink.Builder] - * @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-dynamic-links-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 DynamicLink.Builder.iosParameters( - bundleId: String, - init: DynamicLink.IosParameters.Builder.() -> Unit -) { - val builder = DynamicLink.IosParameters.Builder(bundleId) - builder.init() - setIosParameters(builder.build()) -} - -/** - * Creates a [DynamicLink.GoogleAnalyticsParameters] object initialized using the [init] function - * and sets it to the [DynamicLink.Builder] - * @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-dynamic-links-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 DynamicLink.Builder.googleAnalyticsParameters( - init: DynamicLink.GoogleAnalyticsParameters.Builder.() -> Unit -) { - val builder = DynamicLink.GoogleAnalyticsParameters.Builder() - builder.init() - setGoogleAnalyticsParameters(builder.build()) -} - -/** - * Creates a [DynamicLink.GoogleAnalyticsParameters] object initialized with the specified [source], - * [medium], [campaign] and using the [init] function and sets it to the [DynamicLink.Builder]. - * @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-dynamic-links-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.dynam", ReplaceWith("")) -fun DynamicLink.Builder.googleAnalyticsParameters( - source: String, - medium: String, - campaign: String, - init: DynamicLink.GoogleAnalyticsParameters.Builder.() -> Unit -) { - val builder = DynamicLink.GoogleAnalyticsParameters.Builder(source, medium, campaign) - builder.init() - setGoogleAnalyticsParameters(builder.build()) -} - -/** - * Creates a [DynamicLink.ItunesConnectAnalyticsParameters] object initialized using the [init] - * function and sets it to the [DynamicLink.Builder] - * @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-dynamic-links-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 DynamicLink.Builder.itunesConnectAnalyticsParameters( - init: DynamicLink.ItunesConnectAnalyticsParameters.Builder.() -> Unit -) { - val builder = DynamicLink.ItunesConnectAnalyticsParameters.Builder() - builder.init() - setItunesConnectAnalyticsParameters(builder.build()) -} - -/** - * Creates a [DynamicLink.SocialMetaTagParameters] object initialized using the [init] function and - * sets it to the [DynamicLink.Builder] - * @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-dynamic-links-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 DynamicLink.Builder.socialMetaTagParameters( - init: DynamicLink.SocialMetaTagParameters.Builder.() -> Unit -) { - val builder = DynamicLink.SocialMetaTagParameters.Builder() - builder.init() - setSocialMetaTagParameters(builder.build()) -} - -/** - * Creates a [DynamicLink.NavigationInfoParameters] object initialized using the [init] function and - * sets it to the [DynamicLink.Builder] - * @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-dynamic-links-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 DynamicLink.Builder.navigationInfoParameters( - init: DynamicLink.NavigationInfoParameters.Builder.() -> Unit -) { - val builder = DynamicLink.NavigationInfoParameters.Builder() - builder.init() - setNavigationInfoParameters(builder.build()) -} - -/** - * Creates a [DynamicLink] 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-dynamic-links-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 FirebaseDynamicLinks.dynamicLink(init: DynamicLink.Builder.() -> Unit): DynamicLink { - val builder = FirebaseDynamicLinks.getInstance().createDynamicLink() - builder.init() - return builder.buildDynamicLink() -} - -/** - * Creates a [ShortDynamicLink] 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-dynamic-links-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 FirebaseDynamicLinks.shortLinkAsync( - init: DynamicLink.Builder.() -> Unit -): Task { - val builder = FirebaseDynamicLinks.getInstance().createDynamicLink() - builder.init() - return builder.buildShortDynamicLink() -} - -/** - * Creates a [ShortDynamicLink] 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-dynamic-links-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 FirebaseDynamicLinks.shortLinkAsync( - suffix: Int, - init: DynamicLink.Builder.() -> Unit -): Task { - val builder = FirebaseDynamicLinks.getInstance().createDynamicLink() - builder.init() - return builder.buildShortDynamicLink(suffix) -} - -/** - * Destructuring declaration for [ShortDynamicLink] to provide shortLink. - * @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-dynamic-links-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 ShortDynamicLink.component1() = shortLink - -/** - * Destructuring declaration for [ShortDynamicLink] to provide previewLink. - * @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-dynamic-links-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 ShortDynamicLink.component2() = previewLink - -/** - * Destructuring declaration for [ShortDynamicLink] to provide warnings. - * @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-dynamic-links-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 ShortDynamicLink.component3(): List = warnings - -/** - * Destructuring declaration for [PendingDynamicLinkData] to provide link. - * @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-dynamic-links-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 PendingDynamicLinkData.component1() = link - -/** - * Destructuring declaration for [PendingDynamicLinkData] to provide minimumAppVersion. - * @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-dynamic-links-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 PendingDynamicLinkData.component2() = minimumAppVersion - -/** - * Destructuring declaration for [PendingDynamicLinkData] to provide clickTimestamp. - * @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-dynamic-links-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 PendingDynamicLinkData.component3() = clickTimestamp - -/** - * @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-dynamic-links-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 FirebaseDynamicLinksKtxRegistrar : ComponentRegistrar { - override fun getComponents(): List> = listOf() -} diff --git a/firebase-dynamic-links/src/test/java/com/google/firebase/dynamiclinks/ktx/DynamicLinksTests.kt b/firebase-dynamic-links/src/test/java/com/google/firebase/dynamiclinks/ktx/DynamicLinksTests.kt deleted file mode 100644 index 48531d72990..00000000000 --- a/firebase-dynamic-links/src/test/java/com/google/firebase/dynamiclinks/ktx/DynamicLinksTests.kt +++ /dev/null @@ -1,281 +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.dynamiclinks.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.dynamiclinks.FirebaseDynamicLinks -import com.google.firebase.dynamiclinks.PendingDynamicLinkData -import com.google.firebase.dynamiclinks.ShortDynamicLink -import com.google.firebase.ktx.Firebase -import com.google.firebase.ktx.app -import com.google.firebase.ktx.initialize -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 = "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 DynamicLinksTests : BaseTestCase() { - - @Test - fun `Firebase#dynamicLinks should delegate to FirebaseDynamicLinks#getInstance()`() { - assertThat(Firebase.dynamicLinks).isSameInstanceAs(FirebaseDynamicLinks.getInstance()) - } - - @Test - fun `Firebase#dynamicLinks should delegate to FirebaseDynamicLinks#getInstance(FirebaseApp)`() { - val app = Firebase.app(EXISTING_APP) - assertThat(Firebase.dynamicLinks(app)).isSameInstanceAs(FirebaseDynamicLinks.getInstance(app)) - } - - @Test - fun `Firebase#dynamicLinks#createDynamicLink`() { - val exampleLink = "https://example.com" - val exampleDomainUriPrefix = "https://example.page.link" - - val dynamicLinkKtx = - Firebase.dynamicLinks.dynamicLink { - link = Uri.parse(exampleLink) - domainUriPrefix = exampleDomainUriPrefix - } - - val dynamicLink = - FirebaseDynamicLinks.getInstance() - .createDynamicLink() - .setLink(Uri.parse(exampleLink)) - .setDomainUriPrefix(exampleDomainUriPrefix) - .buildDynamicLink() - - assertThat(dynamicLinkKtx.uri).isEqualTo(dynamicLink.uri) - } - - @Test - fun `androidParameters type-safe builder extension works`() { - val fallbackLink = "https://android.com" - val minVersion = 19 - val packageName = "com.example.android" - - val dynamicLink = - Firebase.dynamicLinks.dynamicLink { - link = Uri.parse("https://example.com") - domainUriPrefix = "https://example.page.link" - androidParameters { - minimumVersion = minVersion - fallbackUrl = Uri.parse(fallbackLink) - } - } - - val anotherDynamicLink = - Firebase.dynamicLinks.dynamicLink { - link = Uri.parse("https://example.com") - domainUriPrefix = "https://example.page.link" - androidParameters(packageName) { - minimumVersion = minVersion - fallbackUrl = Uri.parse(fallbackLink) - } - } - - assertThat(dynamicLink.uri.getQueryParameter("amv")?.toInt()).isEqualTo(minVersion) - assertThat(dynamicLink.uri.getQueryParameter("afl")).isEqualTo(fallbackLink) - - assertThat(anotherDynamicLink.uri.getQueryParameter("amv")?.toInt()).isEqualTo(minVersion) - assertThat(anotherDynamicLink.uri.getQueryParameter("afl")).isEqualTo(fallbackLink) - assertThat(anotherDynamicLink.uri.getQueryParameter("apn")).isEqualTo(packageName) - } - - @Test - fun `iosParameters type-safe builder extension works`() { - val iosAppStoreId = "123456789" - val iosMinimumVersion = "1.0.1" - val iosBundleId = "com.example.ios" - - val dynamicLink = - Firebase.dynamicLinks.dynamicLink { - link = Uri.parse("https://example.com") - domainUriPrefix = "https://example.page.link" - iosParameters(iosBundleId) { - appStoreId = iosAppStoreId - minimumVersion = iosMinimumVersion - } - } - - assertThat(dynamicLink.uri.getQueryParameter("ibi")).isEqualTo(iosBundleId) - assertThat(dynamicLink.uri.getQueryParameter("imv")).isEqualTo(iosMinimumVersion) - assertThat(dynamicLink.uri.getQueryParameter("isi")).isEqualTo(iosAppStoreId) - } - - @Test - fun `googleAnalyticsParameters type-safe builder extension works`() { - val campaignTerm = "Example Term" - val campaignContent = "Example Content" - val campaignSource = "Twitter" - val campaignMedium = "Social" - val campaignName = "Example Promo" - - val dynamicLink = - Firebase.dynamicLinks.dynamicLink { - link = Uri.parse("https://example.com") - domainUriPrefix = "https://example.page.link" - googleAnalyticsParameters(campaignSource, campaignMedium, campaignName) { - term = campaignTerm - content = campaignContent - } - } - - assertThat(dynamicLink.uri.getQueryParameter("utm_content")).isEqualTo(campaignContent) - assertThat(dynamicLink.uri.getQueryParameter("utm_term")).isEqualTo(campaignTerm) - assertThat(dynamicLink.uri.getQueryParameter("utm_source")).isEqualTo(campaignSource) - assertThat(dynamicLink.uri.getQueryParameter("utm_medium")).isEqualTo(campaignMedium) - assertThat(dynamicLink.uri.getQueryParameter("utm_campaign")).isEqualTo(campaignName) - } - - @Test - fun `itunesConnectAnalyticsParameters type-safe builder extension works`() { - val ct = "example-campaign" - val pt = "123456" - - val dynamicLink = - Firebase.dynamicLinks.dynamicLink { - link = Uri.parse("https://example.com") - domainUriPrefix = "https://example.page.link" - itunesConnectAnalyticsParameters { - providerToken = pt - campaignToken = ct - } - } - - assertThat(dynamicLink.uri.getQueryParameter("pt")).isEqualTo(pt) - assertThat(dynamicLink.uri.getQueryParameter("ct")).isEqualTo(ct) - } - - @Test - fun `socialMetaTagParameters type-safe builder extension works`() { - val socialTitle = "Example Title" - val socialDescription = "This link works whether the app is installed or not!" - - val dynamicLink = - Firebase.dynamicLinks.dynamicLink { - link = Uri.parse("https://example.com") - domainUriPrefix = "https://example.page.link" - socialMetaTagParameters { - title = socialTitle - description = socialDescription - } - } - - assertThat(dynamicLink.uri.getQueryParameter("st")).isEqualTo(socialTitle) - assertThat(dynamicLink.uri.getQueryParameter("sd")).isEqualTo(socialDescription) - } - - @Test - fun `navigationInfoParameters type-safe builder extension works`() { - val forcedRedirect = true - - val dynamicLink = - Firebase.dynamicLinks.dynamicLink { - link = Uri.parse("https://example.com") - domainUriPrefix = "https://example.page.link" - navigationInfoParameters { forcedRedirectEnabled = true } - } - - val efr = Integer.parseInt(dynamicLink.uri.getQueryParameter("efr")!!) == 1 - assertThat(efr).isEqualTo(forcedRedirect) - } - - @Test - fun `ShortDynamicLink destructure declaration works`() { - val fakeWarning = - object : ShortDynamicLink.Warning { - override fun getMessage() = "Warning" - override fun getCode() = "warning" - } - - val expectedShortLink = Uri.parse("https://example.com") - val expectedPreviewLink = Uri.parse("https://example.com/preview") - val expectedWarnings = mutableListOf(fakeWarning) - - val mockShortDynamicLink = mock(ShortDynamicLink::class.java) - `when`(mockShortDynamicLink.shortLink).thenReturn(expectedShortLink) - `when`(mockShortDynamicLink.previewLink).thenReturn(expectedPreviewLink) - `when`(mockShortDynamicLink.warnings).thenReturn(expectedWarnings) - - val (shortLink, previewLink, warnings) = mockShortDynamicLink - - assertThat(shortLink).isEqualTo(expectedShortLink) - assertThat(previewLink).isEqualTo(expectedPreviewLink) - assertThat(warnings).isEqualTo(expectedWarnings) - } - - @Test - fun `PendingDynamicLinkData destructure declaration works`() { - val expectedLink = Uri.parse("https://example.com") - val expectedMinAppVersion = 30 - val expectedTimestamp = 172947600L - - val mockPendingData = mock(PendingDynamicLinkData::class.java) - `when`(mockPendingData.link).thenReturn(expectedLink) - `when`(mockPendingData.minimumAppVersion).thenReturn(expectedMinAppVersion) - `when`(mockPendingData.clickTimestamp).thenReturn(expectedTimestamp) - - val (link, minAppVersion, timestamp) = mockPendingData - - assertThat(link).isEqualTo(expectedLink) - assertThat(minAppVersion).isEqualTo(expectedMinAppVersion) - assertThat(timestamp).isEqualTo(expectedTimestamp) - } -} diff --git a/firebase-firestore/firebase-firestore.gradle b/firebase-firestore/firebase-firestore.gradle index a51f531bbeb..97f66714ce8 100644 --- a/firebase-firestore/firebase-firestore.gradle +++ b/firebase-firestore/firebase-firestore.gradle @@ -128,7 +128,6 @@ dependencies { exclude group: "com.google.firebase", module: "firebase-common" } api(project(":firebase-common")) - api("com.google.firebase:firebase-common-ktx:20.4.2") { exclude group: "com.google.firebase", module: "firebase-common" } api("com.google.firebase:firebase-components:17.1.5") { diff --git a/firebase-firestore/ktx/api.txt b/firebase-firestore/ktx/api.txt deleted file mode 100644 index b8472c410b7..00000000000 --- a/firebase-firestore/ktx/api.txt +++ /dev/null @@ -1,8 +0,0 @@ -// Signature format: 2.0 -package com.google.firebase.firestore.ktx { - - public final class LoggingKt { - } - -} - 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 6b2127d489e..00000000000 --- a/firebase-firestore/ktx/ktx.gradle +++ /dev/null @@ -1,73 +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" - publishSources = true - publishJavadoc = false - publishReleaseNotes = false -} - -android { - namespace "com.google.firebase.firestore.ktx" - compileSdkVersion project.targetSdkVersion - defaultConfig { - minSdkVersion 19 - 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:20.4.2") - api("com.google.firebase:firebase-common-ktx:20.4.2") - - implementation("com.google.firebase:firebase-components:17.1.5") - - testImplementation project(':firebase-database-collection') - testImplementation "androidx.test:core:$androidxTestCoreVersion" - testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.9.8' - testImplementation 'com.google.android.gms:play-services-tasks:18.0.1' - testImplementation "com.google.truth:truth:$googleTruthVersion" - testImplementation 'junit:junit:4.12' - testImplementation 'org.mockito:mockito-core:2.25.0' - testImplementation "org.robolectric:robolectric:$robolectricVersion" - - testCompileOnly "com.google.protobuf:protobuf-java:$protocVersion" -} \ No newline at end of file diff --git a/firebase-firestore/ktx/src/main/AndroidManifest.xml b/firebase-firestore/ktx/src/main/AndroidManifest.xml deleted file mode 100644 index 983da176c92..00000000000 --- a/firebase-firestore/ktx/src/main/AndroidManifest.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - \ No newline at end of file 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 e11c5af1503..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/firebase-functions.gradle.kts b/firebase-functions/firebase-functions.gradle.kts index 6bba36981d1..83aa8cc9cef 100644 --- a/firebase-functions/firebase-functions.gradle.kts +++ b/firebase-functions/firebase-functions.gradle.kts @@ -52,7 +52,6 @@ dependencies { api("com.google.firebase:firebase-appcheck-interop:17.1.0") api("com.google.firebase:firebase-common:20.4.2") - api("com.google.firebase:firebase-common-ktx:20.4.2") api("com.google.firebase:firebase-components:17.1.5") 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 60c7053d554..00000000000 --- a/firebase-functions/ktx/api.txt +++ /dev/null @@ -1,8 +0,0 @@ -// Signature format: 2.0 -package com.google.firebase.functions.ktx { - - public final class LoggingKt { - } - -} - 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 bbf1867afe8..00000000000 --- a/firebase-functions/ktx/ktx.gradle.kts +++ /dev/null @@ -1,62 +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 - publishReleaseNotes = false - publishSources = true - testLab.enabled = true -} - -android { - val targetSdkVersion : Int by rootProject - - namespace = "com.google.firebase.functions.ktx" - compileSdk = targetSdkVersion - defaultConfig { - minSdk = 16 - 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:20.4.2") - api("com.google.firebase:firebase-common-ktx:20.4.2") - api(project(":firebase-functions")) - - implementation("com.google.firebase:firebase-components:17.1.5") - - 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) -} \ No newline at end of file diff --git a/firebase-functions/ktx/src/androidTest/AndroidManifest.xml b/firebase-functions/ktx/src/androidTest/AndroidManifest.xml deleted file mode 100644 index ffd2322e211..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/androidTest/kotlin/com/google/firebase/functions/ktx/CallTests.kt b/firebase-functions/ktx/src/androidTest/kotlin/com/google/firebase/functions/ktx/CallTests.kt deleted file mode 100644 index 87ca19f8348..00000000000 --- a/firebase-functions/ktx/src/androidTest/kotlin/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)).getData() - - 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)).getData() - - assertThat(actual).isNull() - } - - @Test - fun testEmptyDataCall() { - val functions = Firebase.functions(app) - var function = functions.getHttpsCallable("nullTest") - val actual = Tasks.await(function.call()).getData() - - assertThat(actual).isNull() - } -} diff --git a/firebase-functions/ktx/src/main/AndroidManifest.xml b/firebase-functions/ktx/src/main/AndroidManifest.xml deleted file mode 100644 index 4b63c1e7eae..00000000000 --- a/firebase-functions/ktx/src/main/AndroidManifest.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - \ No newline at end of file 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/ktx/src/test/kotlin/com/google/firebase/functions/TestVisibilityUtil.kt b/firebase-functions/ktx/src/test/kotlin/com/google/firebase/functions/TestVisibilityUtil.kt deleted file mode 100644 index 9a8be4b4f9c..00000000000 --- a/firebase-functions/ktx/src/test/kotlin/com/google/firebase/functions/TestVisibilityUtil.kt +++ /dev/null @@ -1,22 +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 - -/** - * Returns true if the {@link HttpsCallableReference} is configured to use FAC limited-use tokens. - */ -fun HttpsCallableReference.usesLimitedUseFacTokens() = options.getLimitedUseAppCheckTokens() diff --git a/firebase-functions/ktx/src/test/kotlin/com/google/firebase/functions/ktx/FunctionsTests.kt b/firebase-functions/ktx/src/test/kotlin/com/google/firebase/functions/ktx/FunctionsTests.kt deleted file mode 100644 index 34e845c7927..00000000000 --- a/firebase-functions/ktx/src/test/kotlin/com/google/firebase/functions/ktx/FunctionsTests.kt +++ /dev/null @@ -1,153 +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) - assertThat(publisher.userAgent).contains(LIBRARY_NAME) - } -} - -@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-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 87ca19f8348..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)).getData() - - 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)).getData() - - assertThat(actual).isNull() - } - - @Test - fun testEmptyDataCall() { - val functions = Firebase.functions(app) - var function = functions.getHttpsCallable("nullTest") - val actual = Tasks.await(function.call()).getData() - - 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 c0a18428f29..00000000000 --- a/firebase-functions/src/main/java/com/google/firebase/functions/ktx/Functions.kt +++ /dev/null @@ -1,141 +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) - */ -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) - */ -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) - */ -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) - */ -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 -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("") -) -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("") -) -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/firebase-inappmessaging-display.gradle b/firebase-inappmessaging-display/firebase-inappmessaging-display.gradle index 2793672fa22..d3f4a05931f 100644 --- a/firebase-inappmessaging-display/firebase-inappmessaging-display.gradle +++ b/firebase-inappmessaging-display/firebase-inappmessaging-display.gradle @@ -84,7 +84,6 @@ dependencies { api(project(":firebase-inappmessaging")) api("com.google.firebase:firebase-common:20.4.2") - api("com.google.firebase:firebase-common-ktx:20.4.2") api("com.google.firebase:firebase-components:17.1.5") implementation 'androidx.annotation:annotation:1.1.0' diff --git a/firebase-inappmessaging-display/ktx/api.txt b/firebase-inappmessaging-display/ktx/api.txt deleted file mode 100644 index 2357649b88d..00000000000 --- a/firebase-inappmessaging-display/ktx/api.txt +++ /dev/null @@ -1,8 +0,0 @@ -// Signature format: 2.0 -package com.google.firebase.inappmessaging.display.ktx { - - public final class LoggingKt { - } - -} - 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 24b3a09c02c..00000000000 --- a/firebase-inappmessaging-display/ktx/ktx.gradle +++ /dev/null @@ -1,62 +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 - publishReleaseNotes = false - publishSources = true -} - -android { - namespace "com.google.firebase.inappmessaging.display.ktx" - compileSdkVersion project.targetSdkVersion - defaultConfig { - minSdkVersion 16 - 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' - } - } - - testOptions.unitTests.includeAndroidResources = true -} - -dependencies { - api(project(":firebase-inappmessaging")) - api(project(":firebase-inappmessaging-display")) - api("com.google.firebase:firebase-common:20.4.2") - api("com.google.firebase:firebase-common-ktx:20.4.2") - - implementation("com.google.firebase:firebase-components:17.1.5") - - testImplementation "androidx.test:core:$androidxTestCoreVersion" - testImplementation ("com.google.firebase:firebase-analytics:17.0.0") { - exclude group: "com.google.firebase", module: "firebase-common" - } - testImplementation "com.google.truth:truth:$googleTruthVersion" - testImplementation 'junit:junit:4.12' - testImplementation "org.robolectric:robolectric:$robolectricVersion" -} \ No newline at end of file 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 b486f17f358..00000000000 --- a/firebase-inappmessaging-display/ktx/src/main/AndroidManifest.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - \ No newline at end of file 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/firebase-inappmessaging.gradle b/firebase-inappmessaging/firebase-inappmessaging.gradle index 0ea9a19753e..82caaf07458 100644 --- a/firebase-inappmessaging/firebase-inappmessaging.gradle +++ b/firebase-inappmessaging/firebase-inappmessaging.gradle @@ -113,7 +113,6 @@ dependencies { exclude group: 'com.google.firebase', module: 'firebase-components' } api("com.google.firebase:firebase-common:20.4.2") - api("com.google.firebase:firebase-common-ktx:20.4.2") api("com.google.firebase:firebase-components:17.1.5") 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 57a96ed4b0a..00000000000 --- a/firebase-inappmessaging/ktx/api.txt +++ /dev/null @@ -1,8 +0,0 @@ -// Signature format: 2.0 -package com.google.firebase.inappmessaging.ktx { - - public final class LoggingKt { - } - -} - 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 5f492ace193..00000000000 --- a/firebase-inappmessaging/ktx/ktx.gradle +++ /dev/null @@ -1,57 +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 - publishReleaseNotes = false - publishSources = true -} - -android { - namespace "com.google.firebase.inappmessaging.ktx" - compileSdkVersion project.targetSdkVersion - defaultConfig { - minSdkVersion 16 - 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' - } - } - testOptions.unitTests.includeAndroidResources = true -} - -dependencies { - api(project(":firebase-inappmessaging")) - api("com.google.firebase:firebase-common:20.4.2") - api("com.google.firebase:firebase-common-ktx:20.4.2") - - implementation("com.google.firebase:firebase-components:17.1.5") - - testImplementation "androidx.test:core:$androidxTestCoreVersion" - testImplementation "com.google.truth:truth:$googleTruthVersion" - testImplementation 'junit:junit:4.12' - testImplementation "org.robolectric:robolectric:$robolectricVersion" -} \ No newline at end of file diff --git a/firebase-inappmessaging/ktx/src/main/AndroidManifest.xml b/firebase-inappmessaging/ktx/src/main/AndroidManifest.xml deleted file mode 100644 index 171608eac4f..00000000000 --- a/firebase-inappmessaging/ktx/src/main/AndroidManifest.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - \ No newline at end of file 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/firebase-installations.gradle b/firebase-installations/firebase-installations.gradle index 60e912d38fc..6f20cc170bf 100644 --- a/firebase-installations/firebase-installations.gradle +++ b/firebase-installations/firebase-installations.gradle @@ -49,7 +49,6 @@ dependencies { api 'com.google.android.gms:play-services-tasks:18.0.1' api 'com.google.firebase:firebase-annotations:16.2.0' api("com.google.firebase:firebase-common:20.4.2") - api("com.google.firebase:firebase-common-ktx:20.4.2") api("com.google.firebase:firebase-components:17.1.5") 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 5e4b3374897..00000000000 --- a/firebase-installations/ktx/api.txt +++ /dev/null @@ -1,8 +0,0 @@ -// Signature format: 2.0 -package com.google.firebase.installations.ktx { - - public final class LoggingKt { - } - -} - 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 578e50f67a4..00000000000 --- a/firebase-installations/ktx/ktx.gradle +++ /dev/null @@ -1,57 +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 - publishReleaseNotes = false - publishSources = true -} - -android { - namespace "com.google.firebase.installations.ktx" - compileSdkVersion project.targetSdkVersion - 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' - } - testOptions.unitTests.includeAndroidResources = true -} - -dependencies { - api(project(":firebase-installations")) - api("com.google.firebase:firebase-common:20.4.2") - api("com.google.firebase:firebase-common-ktx:20.4.2") - api("com.google.firebase:firebase-installations-interop:17.1.1") - - implementation("com.google.firebase:firebase-components:17.1.5") - - testImplementation "androidx.test:core:$androidxTestCoreVersion" - testImplementation "com.google.truth:truth:$googleTruthVersion" - testImplementation 'junit:junit:4.13' - testImplementation "org.robolectric:robolectric:$robolectricVersion" -} 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/firebase-messaging.gradle b/firebase-messaging/firebase-messaging.gradle index c9ed35c51c7..1b41b29e3d5 100644 --- a/firebase-messaging/firebase-messaging.gradle +++ b/firebase-messaging/firebase-messaging.gradle @@ -82,7 +82,6 @@ dependencies { javadocClasspath 'com.google.auto.value:auto-value-annotations:1.6.6' api("com.google.firebase:firebase-common:20.4.2") - api("com.google.firebase:firebase-common-ktx:20.4.2") api("com.google.firebase:firebase-components:17.1.5") api('com.google.firebase:firebase-datatransport:18.1.7') { 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 c0bdbc228e9..00000000000 --- a/firebase-messaging/ktx/api.txt +++ /dev/null @@ -1,8 +0,0 @@ -// Signature format: 2.0 -package com.google.firebase.messaging.ktx { - - public final class LoggingKt { - } - -} - 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 69d9397ed5c..00000000000 --- a/firebase-messaging/ktx/ktx.gradle +++ /dev/null @@ -1,56 +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 - publishReleaseNotes = false - publishSources = true -} - -android { - namespace "com.google.firebase.messaging.ktx" - compileSdkVersion project.targetSdkVersion - defaultConfig { - minSdkVersion 19 - 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' - } - testOptions.unitTests.includeAndroidResources = true -} - -dependencies { - api(project(":firebase-messaging")) - api("com.google.firebase:firebase-common:20.4.2") - api("com.google.firebase:firebase-common-ktx:20.4.2") - - implementation("com.google.firebase:firebase-components:17.1.5") - - testImplementation "androidx.test:core:$androidxTestCoreVersion" - testImplementation "com.google.truth:truth:$googleTruthVersion" - testImplementation 'junit:junit:4.12' - testImplementation "org.robolectric:robolectric:$robolectricVersion" -} \ No newline at end of file diff --git a/firebase-messaging/ktx/src/main/AndroidManifest.xml b/firebase-messaging/ktx/src/main/AndroidManifest.xml deleted file mode 100644 index 9ba6190bd2c..00000000000 --- a/firebase-messaging/ktx/src/main/AndroidManifest.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - \ No newline at end of file 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/firebase-ml-modeldownloader.gradle b/firebase-ml-modeldownloader/firebase-ml-modeldownloader.gradle index 713cbd114bc..650fae1f183 100644 --- a/firebase-ml-modeldownloader/firebase-ml-modeldownloader.gradle +++ b/firebase-ml-modeldownloader/firebase-ml-modeldownloader.gradle @@ -79,7 +79,6 @@ dependencies { api 'com.google.android.gms:play-services-tasks:18.0.1' api 'com.google.firebase:firebase-annotations:16.2.0' api("com.google.firebase:firebase-common:20.4.2") - api("com.google.firebase:firebase-common-ktx:20.4.2") api("com.google.firebase:firebase-components:17.1.5") 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 97f07ed6300..00000000000 --- a/firebase-ml-modeldownloader/ktx/api.txt +++ /dev/null @@ -1,8 +0,0 @@ -// Signature format: 2.0 -package com.google.firebase.ml.modeldownloader.ktx { - - public final class LoggingKt { - } - -} - 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 160fc3409f9..00000000000 --- a/firebase-ml-modeldownloader/ktx/ktx.gradle +++ /dev/null @@ -1,58 +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 - publishReleaseNotes = false - publishSources = true - testLab.enabled = false -} - -android { - namespace "com.google.firebase.ml.modeldownloader.ktx" - compileSdkVersion project.targetSdkVersion - defaultConfig { - minSdkVersion 16 - 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:20.4.2") - api("com.google.firebase:firebase-common-ktx:20.4.2") - - implementation("com.google.firebase:firebase-components:17.1.5") - - testImplementation 'androidx.test:runner:1.5.1' - testImplementation "androidx.test.ext:junit:$androidxTestJUnitVersion" - testImplementation "com.google.truth:truth:$googleTruthVersion" - testImplementation 'junit:junit:4.13.2' - testImplementation 'org.mockito:mockito-core:3.6.0' - testImplementation "org.robolectric:robolectric:$robolectricVersion" -} \ No newline at end of file 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 3f74a6e19b6..3e53e9d50b2 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 'androidx.core:core:1.2.0' implementation 'com.google.firebase:firebase-common:20.4.2' - implementation 'com.google.firebase:firebase-common-ktx:20.4.2' testImplementation 'androidx.test:runner:1.2.0' testImplementation "androidx.test.ext:junit:$androidxTestJUnitVersion" 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/dev-app/dev-app.gradle b/firebase-perf/dev-app/dev-app.gradle index 10dad6e7b20..8a4ee823b97 100644 --- a/firebase-perf/dev-app/dev-app.gradle +++ b/firebase-perf/dev-app/dev-app.gradle @@ -85,7 +85,6 @@ dependencies { println("Building with HEAD version ':firebase-perf' of SDK") implementation project(":firebase-perf") implementation "com.google.firebase:firebase-common:20.4.2" - implementation "com.google.firebase:firebase-common-ktx:20.4.2" implementation project(":firebase-config") } else { diff --git a/firebase-perf/firebase-perf.gradle b/firebase-perf/firebase-perf.gradle index 5649c118a20..794a48dfb55 100644 --- a/firebase-perf/firebase-perf.gradle +++ b/firebase-perf/firebase-perf.gradle @@ -110,7 +110,6 @@ dependencies { api 'com.google.firebase:protolite-well-known-types:18.0.0' implementation 'com.squareup.okhttp3:okhttp:3.12.1' api("com.google.firebase:firebase-common:20.4.2") - api("com.google.firebase:firebase-common-ktx:20.4.2") api("com.google.firebase:firebase-components:17.1.5") 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 5c7be346e10..00000000000 --- a/firebase-perf/ktx/api.txt +++ /dev/null @@ -1,8 +0,0 @@ -// Signature format: 2.0 -package com.google.firebase.perf.ktx { - - public final class LoggingKt { - } - -} - 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 a3c7bea9617..00000000000 --- a/firebase-perf/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 "perf" - publishJavadoc = false - publishReleaseNotes = false - publishSources = true -} - -android { - namespace "com.google.firebase.perf.ktx" - compileSdk 30 - defaultConfig { - minSdkVersion 16 - 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' - } - } - testOptions.unitTests.includeAndroidResources = true -} - -dependencies { - api(project(":firebase-perf")) - api("com.google.firebase:firebase-common:20.4.2") - api("com.google.firebase:firebase-common-ktx:20.4.2") - - implementation("com.google.firebase:firebase-components:17.1.5") - - testImplementation "androidx.test:core:$androidxTestCoreVersion" - testImplementation "com.google.truth:truth:$googleTruthVersion" - testImplementation 'junit:junit:4.12' - testImplementation 'org.mockito:mockito-core:2.25.0' - testImplementation "org.robolectric:robolectric:$robolectricVersion" - - testCompileOnly "com.google.protobuf:protobuf-java:3.21.9" -} \ No newline at end of file diff --git a/firebase-perf/ktx/src/main/AndroidManifest.xml b/firebase-perf/ktx/src/main/AndroidManifest.xml deleted file mode 100644 index 36da1745eb4..00000000000 --- a/firebase-perf/ktx/src/main/AndroidManifest.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - \ No newline at end of file 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 6f9cb45285c..1f8ff4fcd4b 100644 --- a/firebase-sessions/firebase-sessions.gradle.kts +++ b/firebase-sessions/firebase-sessions.gradle.kts @@ -52,7 +52,6 @@ android { dependencies { api("com.google.firebase:firebase-common:20.4.2") - api("com.google.firebase:firebase-common-ktx:20.4.2") api("com.google.firebase:firebase-components:17.1.5") api("com.google.firebase:firebase-installations-interop:17.1.1") { diff --git a/firebase-storage/firebase-storage.gradle b/firebase-storage/firebase-storage.gradle index 5116a7e929e..db7b49b4a85 100644 --- a/firebase-storage/firebase-storage.gradle +++ b/firebase-storage/firebase-storage.gradle @@ -94,7 +94,6 @@ dependencies { exclude group: "com.google.firebase", module: "firebase-annotations" } api("com.google.firebase:firebase-common:20.4.2") - api("com.google.firebase:firebase-common-ktx:20.4.2") api("com.google.firebase:firebase-components:17.1.5") implementation 'androidx.annotation:annotation:1.1.0' diff --git a/firebase-storage/ktx/api.txt b/firebase-storage/ktx/api.txt deleted file mode 100644 index 3d03b63fadb..00000000000 --- a/firebase-storage/ktx/api.txt +++ /dev/null @@ -1,8 +0,0 @@ -// Signature format: 2.0 -package com.google.firebase.storage.ktx { - - public final class LoggingKt { - } - -} - 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 55370877423..00000000000 --- a/firebase-storage/ktx/ktx.gradle +++ /dev/null @@ -1,75 +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 - publishReleaseNotes = false - publishSources = true -} - -android { - namespace "com.google.firebase.storage.ktx" - compileSdkVersion project.targetSdkVersion - defaultConfig { - minSdkVersion 16 - 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:20.4.2") - api("com.google.firebase:firebase-common-ktx:20.4.2") - - implementation("com.google.firebase:firebase-components:17.1.5") - - testImplementation "androidx.test:core:$androidxTestCoreVersion" - testImplementation "com.google.truth:truth:$googleTruthVersion" - testImplementation 'junit:junit:4.12' - testImplementation 'org.mockito:mockito-core:3.3.3' - testImplementation "org.robolectric:robolectric:$robolectricVersion" - - androidTestImplementation 'androidx.test:runner:1.2.0' - androidTestImplementation "com.google.truth:truth:$googleTruthVersion" - androidTestImplementation 'junit:junit:4.12' -} \ No newline at end of file diff --git a/firebase-storage/ktx/src/main/AndroidManifest.xml b/firebase-storage/ktx/src/main/AndroidManifest.xml deleted file mode 100644 index fa696ef053f..00000000000 --- a/firebase-storage/ktx/src/main/AndroidManifest.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - \ No newline at end of file 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 cb80a3ae84f..2f4a9300498 100644 --- a/integ-testing/integ-testing.gradle.kts +++ b/integ-testing/integ-testing.gradle.kts @@ -36,7 +36,6 @@ android { } dependencies { - implementation("com.google.firebase:firebase-common-ktx:20.4.2") implementation("com.google.firebase:firebase-common:20.4.2") implementation("com.google.firebase:firebase-components:17.1.5") implementation(libs.androidx.test.runner) diff --git a/sdkProperties.gradle b/sdkProperties.gradle index 430a032b6af..e69de29bb2d 100644 --- a/sdkProperties.gradle +++ b/sdkProperties.gradle @@ -1,18 +0,0 @@ -// 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. - -ext { - targetSdkVersion = 33 - minSdkVersion = 14 -} \ No newline at end of file diff --git a/subprojects.cfg b/subprojects.cfg index 9ab01abbd88..66cd7d97abf 100644 --- a/subprojects.cfg +++ b/subprojects.cfg @@ -5,58 +5,43 @@ appcheck:firebase-appcheck-interop appcheck:firebase-appcheck-playintegrity appcheck:firebase-appcheck-safetynet appcheck:firebase-appcheck -appcheck:firebase-appcheck:ktx firebase-abt 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-datatransport firebase-dynamic-links -firebase-dynamic-links:ktx 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-segmentation firebase-sessions firebase-sessions:test-app firebase-storage -firebase-storage:ktx protolite-well-known-types encoders