Skip to content

Commit 9652f6e

Browse files
Fix screenshot permission gating by model support
1 parent 1f852ad commit 9652f6e

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

app/src/main/kotlin/com/google/ai/sample/GenerativeAiViewModelFactory.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ enum class ModelOption(
5656
ApiProvider.GOOGLE,
5757
"https://huggingface.co/na5h13/gemma-3n-E4B-it-litert-lm/resolve/main/gemma-3n-E4B-it-int4.litertlm?download=true",
5858
"4.92 GB",
59+
supportsScreenshot = true,
5960
isOfflineModel = true,
6061
offlineModelFilename = "gemma-3n-e4b-it-int4.litertlm",
6162
offlineRequiredFilenames = listOf("gemma-3n-e4b-it-int4.litertlm")

app/src/main/kotlin/com/google/ai/sample/feature/multimodal/PhotoReasoningScreen.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,9 +406,10 @@ fun PhotoReasoningScreen(
406406
return@IconButton
407407
}
408408

409-
// Check MediaProjection for all models except offline and human-expert
410-
// Human Expert uses its own MediaProjection for WebRTC, not ScreenCaptureService
411-
if (!isMediaProjectionPermissionGranted && !com.google.ai.sample.GenerativeAiViewModelFactory.getCurrentModel().isOfflineModel && modelName != "human-expert") {
409+
// Check MediaProjection only for models that support screenshots and are not human-expert.
410+
// Human Expert uses its own MediaProjection for WebRTC, not ScreenCaptureService.
411+
val currentModel = com.google.ai.sample.GenerativeAiViewModelFactory.getCurrentModel()
412+
if (!isMediaProjectionPermissionGranted && currentModel.supportsScreenshot && modelName != "human-expert") {
412413
mainActivity?.requestMediaProjectionPermission {
413414
// This block will be executed after permission is granted
414415
if (userQuestion.isNotBlank()) {

0 commit comments

Comments
 (0)