Skip to content

Commit e587d42

Browse files
committed
update code
1 parent 9130fb1 commit e587d42

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

firebase-ai/api.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ package com.google.firebase.ai.java {
142142
@com.google.firebase.ai.type.PublicPreviewAPI public abstract class LiveSessionFutures {
143143
method public abstract com.google.common.util.concurrent.ListenableFuture<kotlin.Unit> close();
144144
method public static final com.google.firebase.ai.java.LiveSessionFutures from(com.google.firebase.ai.type.LiveSession session);
145+
method public abstract boolean isAudioConversationActive();
146+
method public abstract boolean isClosed();
145147
method public abstract org.reactivestreams.Publisher<com.google.firebase.ai.type.LiveServerMessage> receive();
146148
method public abstract com.google.common.util.concurrent.ListenableFuture<kotlin.Unit> send(com.google.firebase.ai.type.Content content);
147149
method public abstract com.google.common.util.concurrent.ListenableFuture<kotlin.Unit> send(String text);
@@ -879,6 +881,8 @@ package com.google.firebase.ai.type {
879881

880882
@com.google.firebase.ai.type.PublicPreviewAPI public final class LiveSession {
881883
method public suspend Object? close(kotlin.coroutines.Continuation<? super kotlin.Unit>);
884+
method public boolean isAudioConversationActive();
885+
method public boolean isClosed();
882886
method public kotlinx.coroutines.flow.Flow<com.google.firebase.ai.type.LiveServerMessage> receive();
883887
method public suspend Object? send(com.google.firebase.ai.type.Content content, kotlin.coroutines.Continuation<? super kotlin.Unit>);
884888
method public suspend Object? send(String text, kotlin.coroutines.Continuation<? super kotlin.Unit>);
@@ -918,6 +922,10 @@ package com.google.firebase.ai.type {
918922
method public static String? asTextOrNull(com.google.firebase.ai.type.Part);
919923
}
920924

925+
public final class PermissionMissingException extends com.google.firebase.ai.type.FirebaseAIException {
926+
ctor public PermissionMissingException(String message, Throwable? cause = null);
927+
}
928+
921929
public final class PromptBlockedException extends com.google.firebase.ai.type.FirebaseAIException {
922930
method public com.google.firebase.ai.type.GenerateContentResponse? getResponse();
923931
property public final com.google.firebase.ai.type.GenerateContentResponse? response;

firebase-ai/src/main/kotlin/com/google/firebase/ai/java/LiveSessionFutures.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import com.google.firebase.ai.type.MediaData
2929
import com.google.firebase.ai.type.PublicPreviewAPI
3030
import com.google.firebase.ai.type.SessionAlreadyReceivingException
3131
import io.ktor.websocket.close
32-
import kotlinx.coroutines.isActive
3332
import kotlinx.coroutines.reactive.asPublisher
3433
import org.reactivestreams.Publisher
3534

@@ -53,10 +52,10 @@ public abstract class LiveSessionFutures internal constructor() {
5352
): ListenableFuture<Unit>
5453

5554
/** Indicates whether the underlying websocket connection is active. */
56-
public abstract fun isActive(): ListenableFuture<Boolean>
55+
public abstract fun isClosed(): Boolean
5756

5857
/** Indicates whether an audio conversation is being used for this session object. */
59-
public abstract fun isAudioConversationActive(): ListenableFuture<Boolean>
58+
public abstract fun isAudioConversationActive(): Boolean
6059

6160
/**
6261
* Starts an audio conversation with the model, which can only be stopped using
@@ -176,10 +175,9 @@ public abstract class LiveSessionFutures internal constructor() {
176175
override fun startAudioConversation() =
177176
SuspendToFutureAdapter.launchFuture { session.startAudioConversation() }
178177

179-
override fun isActive() = SuspendToFutureAdapter.launchFuture { session.isActive() }
178+
override fun isClosed() = session.isClosed()
180179

181-
override fun isAudioConversationActive() =
182-
SuspendToFutureAdapter.launchFuture { session.isAudioConversationActive() }
180+
override fun isAudioConversationActive() = session.isAudioConversationActive()
183181

184182
override fun stopAudioConversation() =
185183
SuspendToFutureAdapter.launchFuture { session.stopAudioConversation() }

firebase-ai/src/main/kotlin/com/google/firebase/ai/type/LiveSession.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ internal constructor(
144144
}
145145

146146
/** Indicates whether the underlying websocket connection is active. */
147-
public fun isActive(): Boolean = session.isActive
147+
public fun isClosed(): Boolean = !(session.isActive && !session.incoming.tryReceive().isClosed)
148148

149149
/** Indicates whether an audio conversation is being used for this session object. */
150150
public fun isAudioConversationActive(): Boolean = (audioHelper != null)

0 commit comments

Comments
 (0)