Skip to content

Commit b2acdc6

Browse files
committed
Merge remote-tracking branch 'origin/main' into TestModernization3
2 parents 7587b84 + 2d3e414 commit b2acdc6

File tree

5 files changed

+39
-24
lines changed

5 files changed

+39
-24
lines changed

firebase-crashlytics/src/main/java/com/google/firebase/crashlytics/FirebaseCrashlytics.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -441,10 +441,10 @@ public boolean didCrashOnPreviousExecution() {
441441
* @return In order of priority:
442442
* <ul>
443443
* <li>If {@link #setCrashlyticsCollectionEnabled(boolean)} is called with a value, use it.
444-
* <li>If the <b>firebase_crashlytics_collection_enabled</b> key is in your app’s
445-
* AndroidManifest.xml, use it.
444+
* <li>If the <b>firebase_crashlytics_collection_enabled</b> key is in your app’s {@code
445+
* AndroidManifest.xml}, use it.
446446
* <li>Otherwise, use the default {@link FirebaseApp#isDataCollectionDefaultEnabled()} in
447-
* FirebaseApp.
447+
* {@link FirebaseApp}.
448448
* </ul>
449449
*/
450450
public boolean isCrashlyticsCollectionEnabled() {
@@ -454,8 +454,8 @@ public boolean isCrashlyticsCollectionEnabled() {
454454
/**
455455
* Enables or disables the automatic data collection configuration for Crashlytics.
456456
*
457-
* <p>If this is set, it overrides any automatic data collection settings configured in the
458-
* AndroidManifest.xml as well as any Firebase-wide settings.
457+
* <p>If this is set, it overrides any automatic data collection settings configured in the {@code
458+
* AndroidManifest.xml} as well as any Firebase-wide settings.
459459
*
460460
* <p>If automatic data collection is disabled for Crashlytics, crash reports are stored on the
461461
* device. To check for reports, use the {@link #checkForUnsentReports()} method. Use {@link
@@ -466,7 +466,7 @@ public boolean isCrashlyticsCollectionEnabled() {
466466
* @param enabled whether to enable automatic data collection. When set to {@code false}, the new
467467
* value does not apply until the next run of the app. To disable data collection by default
468468
* for all app runs, add the {@code firebase_crashlytics_collection_enabled} flag to your
469-
* app's AndroidManifest.xml.
469+
* app's {@code AndroidManifest.xml}.
470470
*/
471471
public void setCrashlyticsCollectionEnabled(boolean enabled) {
472472
core.setCrashlyticsCollectionEnabled(enabled);
@@ -475,9 +475,9 @@ public void setCrashlyticsCollectionEnabled(boolean enabled) {
475475
/**
476476
* Enables or disables the automatic data collection configuration for Crashlytics.
477477
*
478-
* <p>If this is set, it overrides any automatic data collection settings configured in the
479-
* AndroidManifest.xml as well as any Firebase-wide settings. If set to {@code null}, the override
480-
* is cleared.
478+
* <p>If this is set, it overrides any automatic data collection settings configured in the {@code
479+
* AndroidManifest.xml} as well as any Firebase-wide settings. If set to {@code null}, the
480+
* override is cleared.
481481
*
482482
* <p>If automatic data collection is disabled for Crashlytics, crash reports are stored on the
483483
* device. To check for reports, use the {@link #checkForUnsentReports()} method. Use {@link
@@ -488,7 +488,7 @@ public void setCrashlyticsCollectionEnabled(boolean enabled) {
488488
* @param enabled whether to enable or disable automatic data collection. When set to {@code
489489
* false}, the new value does not apply until the next run of the app. When set to {@code
490490
* null}, the override is cleared and automatic data collection settings are determined by the
491-
* configuration in your AndroidManifest.xml or other Firebase-wide settings.
491+
* configuration in your {@code AndroidManifest.xml} or other Firebase-wide settings.
492492
*/
493493
public void setCrashlyticsCollectionEnabled(@Nullable Boolean enabled) {
494494
core.setCrashlyticsCollectionEnabled(enabled);

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/common/shared/Types.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ internal data class FunctionResponsePart(val functionResponse: FunctionResponse)
6262
@Serializable internal data class FunctionResponse(val name: String, val response: JsonObject)
6363

6464
@Serializable
65-
internal data class FunctionCall(val name: String, val args: Map<String, String?>? = null)
65+
internal data class FunctionCall(val name: String, val args: Map<String, JsonElement?>? = null)
6666

6767
@Serializable
6868
internal data class FileDataPart(@SerialName("file_data") val fileData: FileData) : Part

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/internal/util/conversions.kt

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ import com.google.firebase.vertexai.type.content
5858
import java.io.ByteArrayOutputStream
5959
import java.util.Calendar
6060
import kotlinx.serialization.json.Json
61+
import kotlinx.serialization.json.JsonNull
6162
import kotlinx.serialization.json.JsonObject
62-
import kotlinx.serialization.json.JsonPrimitive
6363
import org.json.JSONObject
6464

6565
private const val BASE_64_FLAGS = Base64.NO_WRAP
@@ -97,10 +97,7 @@ internal fun Part.toInternal(): com.google.firebase.vertexai.common.shared.Part
9797
}
9898

9999
internal fun FunctionCall.toInternal() =
100-
com.google.firebase.vertexai.common.shared.FunctionCall(
101-
name,
102-
args.orEmpty().mapValues { it.value.toString() }
103-
)
100+
com.google.firebase.vertexai.common.shared.FunctionCall(name, args)
104101

105102
internal fun FunctionResponse.toInternal() =
106103
com.google.firebase.vertexai.common.shared.FunctionResponse(name, response)
@@ -237,13 +234,7 @@ internal fun com.google.firebase.vertexai.common.shared.Part.toPublic(): Part {
237234
}
238235

239236
internal fun com.google.firebase.vertexai.common.shared.FunctionCall.toPublic() =
240-
FunctionCall(
241-
name,
242-
args.orEmpty().mapValues {
243-
val argValue = it.value
244-
if (argValue == null) JsonPrimitive(null) else Json.parseToJsonElement(argValue)
245-
}
246-
)
237+
FunctionCall(name, args.orEmpty().mapValues { it.value ?: JsonNull })
247238

248239
internal fun com.google.firebase.vertexai.common.shared.FunctionResponse.toPublic() =
249240
FunctionResponse(

firebase-vertexai/src/test/java/com/google/firebase/vertexai/UnarySnapshotTests.kt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ import io.ktor.http.HttpStatusCode
4545
import kotlin.time.Duration.Companion.seconds
4646
import kotlinx.coroutines.withTimeout
4747
import kotlinx.serialization.json.JsonPrimitive
48+
import kotlinx.serialization.json.jsonObject
49+
import kotlinx.serialization.json.jsonPrimitive
4850
import org.json.JSONArray
4951
import org.junit.Test
5052

@@ -372,6 +374,27 @@ internal class UnarySnapshotTests {
372374
}
373375
}
374376

377+
@Test
378+
fun `function call with complex json literal parses correctly`() =
379+
goldenUnaryFile("unary-success-function-call-complex-json-literal.json") {
380+
withTimeout(testTimeout) {
381+
val response = model.generateContent("prompt")
382+
val content = response.candidates.shouldNotBeNullOrEmpty().first().content
383+
val callPart =
384+
content.let {
385+
it.shouldNotBeNull()
386+
it.parts.shouldNotBeEmpty()
387+
it.parts.first().shouldBeInstanceOf<FunctionCallPart>()
388+
}
389+
390+
callPart.functionCall.args["current"] shouldBe JsonPrimitive(true)
391+
callPart.functionCall.args["testObject"]!!
392+
.jsonObject["testProperty"]!!
393+
.jsonPrimitive
394+
.content shouldBe "string property"
395+
}
396+
}
397+
375398
@Test
376399
fun `function call contains no arguments`() =
377400
goldenUnaryFile("unary-success-function-call-no-arguments.json") {

firebase-vertexai/src/test/java/com/google/firebase/vertexai/common/UnarySnapshotTests.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import io.ktor.http.HttpStatusCode
3636
import kotlin.time.Duration.Companion.seconds
3737
import kotlinx.coroutines.withTimeout
3838
import kotlinx.serialization.Serializable
39+
import kotlinx.serialization.json.JsonPrimitive
3940
import org.junit.Test
4041

4142
@Serializable internal data class MountainColors(val name: String, val colors: List<String>)
@@ -330,7 +331,7 @@ internal class UnarySnapshotTests {
330331
}
331332

332333
callPart.functionCall.args shouldNotBe null
333-
callPart.functionCall.args?.get("current") shouldBe "true"
334+
callPart.functionCall.args?.get("current") shouldBe JsonPrimitive(true)
334335
}
335336
}
336337

0 commit comments

Comments
 (0)