photos: add OpenAssistant metadata-only photo search
- Commit
61518504d6a02e2a8713fcd6fe137e46deebe9ae- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-02 04:47 UTC (4 days ago)
- Parents
9db4dc1
Add the photos_search_photos OpenAssistant tool from the OpenAssistant intents audit (photos row, P1): a filtered, metadata-only search over the Photos library. The model can ask by file-name text, folder/album, or taken-date range and gets back the total matching count plus at most 10 newest-first hits (id, file name, taken date, dimensions, album, MIME type). Metadata only is enforced structurally, not by summariser discipline: the wire DTOs in library/intents/photos have no URI/path, image-bytes, thumbnail, location, OCR-text or embedding field; the provider's Room projection (PhotoDao.searchPhotoMetadata / PhotoMetadataRow) reads only those same columns, excludes trashed items in SQL, and never opens the biometric secure-folder vault. The intent lives in photos/intents/SearchPhotosIntent behind the new signature permission com.vayunmathur.photos.permissions.ACCESS_PHOTOS, with provider-side validation in PhotosSearchContract (limit clamped 1-10, query/album truncated, swapped date ranges normalised, LIKE wildcards escaped). OpenAssistant registers the tool in AssistantToolSpecs and AssistantTools (via AssistantCoreToolIntents.searchPhotos), summarised host-side by summarizePhotoSearch, which re-caps at 10 lines. The prompt-budget pin moves 24500 -> 25000 (+500 for this one tool at 55 tools); catalogue-size and numeric-param pins updated to match. Tests pin the guarantee: PhotosSearchContractTest (reflection on the DTO/row field sets, serialised hit contains no URI/path, limit and text caps), PhotosMetadataDaoTest (album/date/name filters, trash exclusion, hit cap with uncapped count), PhotosToolTest (READ risk, optional capped params, metadata-only summary). Verified: :library:lint, :photos:lint, :photos:lintVitalRelease and :openassistant:lint all green in one lint-only invocation. The new photos and OpenAssistant tests pass. The full :photos:testDevUnitTest and :openassistant:testDevUnitTest runs each fail only on one pre-existing timing flake (VaultViewerPageRealTest and InferenceServiceConcurrencyTest); both pass when re-run on their own.
Diff
library/AGENTS.md
diff --git a/library/AGENTS.md b/library/AGENTS.mdindex 63e5e36ded..039f31eb9c 100644--- a/library/AGENTS.md+++ b/library/AGENTS.md@@ -37,6 +37,7 @@ - com/vayunmathur/library/intents/weather/WeatherForecastData.kt — capped forecast query/result (`WeatherForecastQuery` days ≤5, hours ≤12; summary entries only) - com/vayunmathur/library/intents/travel/TravelData.kt — `TripsQuery` + summaries-only `TripSummaryData` (name, dates, status, destination count) - com/vayunmathur/library/intents/translate/TranslateData.kt — `TranslateQuery`/`TranslateResultData` + 1,000-in/2,000-out caps for `translate_text`+- com/vayunmathur/library/intents/photos/PhotoData.kt — metadata-only photo search DTOs (no URI/bytes/thumbnail fields by design) ### util/ — navigation, intents, messenger, storage, games glue - com/vayunmathur/library/util/Navigation.kt — `NavKey` + `MainNavigation` + `rememberNavBackStack` - com/vayunmathur/library/util/NavigationBottomBar.kt
library/src/main/java/com/vayunmathur/library/intents/photos/PhotoData.kt
diff --git a/library/src/main/java/com/vayunmathur/library/intents/photos/PhotoData.kt b/library/src/main/java/com/vayunmathur/library/intents/photos/PhotoData.ktnew file mode 100644index 0000000000..22e8498083--- /dev/null+++ b/library/src/main/java/com/vayunmathur/library/intents/photos/PhotoData.kt@@ -0,0 +1,65 @@+package com.vayunmathur.library.intents.photos++import kotlinx.serialization.Serializable++/**+ * Shared wire DTOs for photos' cross-app assistant intent+ * ([com.vayunmathur.photos.intents.SearchPhotosIntent]), answered only for a+ * co-signed caller behind `com.vayunmathur.photos.permissions.ACCESS_PHOTOS`.+ *+ * Metadata only by design: these DTOs carry ids, file names, dates,+ * dimensions, album (folder) names and MIME types. They never carry image+ * bytes, thumbnails, content URIs, file paths, GPS coordinates, OCR text or+ * CLIP embeddings, and the provider never reads the biometric secure folder+ * (vault) or trashed items. Every field has a default so older/newer callers+ * can omit fields without breaking decode (library DTO-compat rule).+ */++/** Hard provider-side cap: a search never returns more than this many hits. */+const val PHOTOS_MAX_LIMIT = 10++/** Default hit count when the caller omits `limit`. */+const val PHOTOS_DEFAULT_LIMIT = 5++/**+ * Filtered photo metadata search. All filters are optional and combine+ * (AND): [query] matches the file name (case-insensitive substring),+ * [album] matches the MediaStore bucket/folder name exactly+ * (case-insensitive), and [fromMillis]/[toMillis] bound the taken date+ * (epoch millis, both inclusive). [limit] is clamped provider-side to+ * 1..[PHOTOS_MAX_LIMIT].+ */+@Serializable+data class PhotoSearchQuery(+ val query: String = "",+ val album: String? = null,+ val fromMillis: Long? = null,+ val toMillis: Long? = null,+ val limit: Int = PHOTOS_DEFAULT_LIMIT,+)++/**+ * One photo's metadata. [id] is the only handle back into the Photos app;+ * there is deliberately no URI/path field.+ */+@Serializable+data class PhotoHitData(+ val id: Long = 0L,+ val fileName: String = "",+ val takenMillis: Long = 0L,+ val width: Int = 0,+ val height: Int = 0,+ val album: String? = null,+ val mimeType: String? = null,+)++/**+ * Search outcome: [totalCount] counts every non-trashed photo matching the+ * filters (so "how many…" is answered without listing them all), while+ * [photos] holds at most [PHOTOS_MAX_LIMIT] newest-first hits.+ */+@Serializable+data class PhotoSearchResult(+ val totalCount: Int = 0,+ val photos: List<PhotoHitData> = emptyList(),+)
openassistant/AGENTS.md
diff --git a/openassistant/AGENTS.md b/openassistant/AGENTS.mdindex 3b7d5a98e1..3098b8ddad 100644--- a/openassistant/AGENTS.md+++ b/openassistant/AGENTS.md@@ -77,6 +77,7 @@ _Install: ./install openassistant (dev by default)._ - com/vayunmathur/openassistant/platform/AssistantCoreToolIntents.kt — core cross-app launches incl. Astronomy `TonightIntent` - com/vayunmathur/openassistant/platform/AssistantToolIntents.kt — commerce/communicate/travel intent back ends + host summarizers (`travel_get_trips` summaries capped at 10) - com/vayunmathur/openassistant/platform/AssistantCoreToolIntents.kt — core cross-app handlers incl. `translateText`; `summarizeTranslateResult` (in AssistantToolIntents.kt) re-caps at 2,000 chars and surfaces truncation notices+- com/vayunmathur/openassistant/platform/AssistantToolIntents.kt — includes `photos_search_photos` (Photos metadata only: count + file names/dates/dimensions/folder, capped at 10 hits; summarised by `summarizePhotoSearch`) - com/vayunmathur/openassistant/platform/AudioRecorder.kt - com/vayunmathur/openassistant/platform/AssistantTools.kt - com/vayunmathur/openassistant/platform/AssistantCatalog.kt — A2UI component catalog + its prompt section
openassistant/src/main/AndroidManifest.xml
diff --git a/openassistant/src/main/AndroidManifest.xml b/openassistant/src/main/AndroidManifest.xmlindex ac530a82f3..ec0e6caf78 100644--- a/openassistant/src/main/AndroidManifest.xml+++ b/openassistant/src/main/AndroidManifest.xml@@ -41,6 +41,7 @@ <uses-permission android:name="com.vayunmathur.appstore.permissions.ACCESS_APPSTORE" /> <uses-permission android:name="com.vayunmathur.travel.permissions.ACCESS_TRAVEL" /> <uses-permission android:name="com.vayunmathur.translate.permissions.ACCESS_TRANSLATE" />+ <uses-permission android:name="com.vayunmathur.photos.permissions.ACCESS_PHOTOS" /> <permission android:name="com.vayunmathur.openassistant.permission.ACCESS_INFERENCE"
openassistant/src/main/java/com/vayunmathur/openassistant/domain/AssistantToolSpecs.kt
diff --git a/openassistant/src/main/java/com/vayunmathur/openassistant/domain/AssistantToolSpecs.kt b/openassistant/src/main/java/com/vayunmathur/openassistant/domain/AssistantToolSpecs.ktindex 738b689304..ef232cae31 100644--- a/openassistant/src/main/java/com/vayunmathur/openassistant/domain/AssistantToolSpecs.kt+++ b/openassistant/src/main/java/com/vayunmathur/openassistant/domain/AssistantToolSpecs.kt@@ -75,21 +75,22 @@ get_app_list|-|Get installed apps (max 100)| open_app|-|Open an app given its package id|package_id^S^1^package id + send_message|-|Send a message|recipient^S^1^~message^S^1^ make_phone_call|-|Call a phone number|recipient^S^1^ set_alarm|C|Set Clock alarm at hour/minute 24h.|hour^N^1^hour 0-23 (24h)~minute^N^1^minute 0-59~label^S^0^label-set_timer|C|Start Clock countdown timer in seconds.|seconds^N^1^timer length in~label^S^0^label for the timer+set_timer|C|Start Clock countdown timer in seconds.|seconds^N^1^timer length in~label^S^0^label for the set_conversation_title|-|Set conversation title (first response).|new_title^S^1^ get_weather|-|Current weather at lat/lng.|latitude^N^1^~longitude^N^1^ get_weather_by_name|-|Current weather for a named place.|location^S^1^place screentime_get_usage|-|Screen time: total + top 5.| render_ui|-|Render UI card (A2UI).|components_json^S^1^components JSON~data_json^S^0^data JSON-get_directions|-|Directions.|from_lat^N^1^origin lat~from_lng^N^1^origin lng~to_lat^N^1^dest lat~to_lng^N^1^dest lng~mode^S^0^drive/transit/walk/bic+get_directions|-|Directions.|from_lat^N^1^origin lat~from_lng^N^1^origin lng~to_lat^N^1^dest lat~to_lng^N^1^dest lng~mode^S^0^drive/transit/wa maps_search_places|-|Maps places; returns lat/lng.|query^S^1^name/category~near_lat^N^0^near lat~near_lng^N^0^near lng~category^S^0^e.g. Cafe~limit^N^0^1-10 (def 5)-maps_get_saved_places|-|Saved Maps places (name + coordinates).|query^S^0^filter~limit^N^0^max 1-10 (def 10)+maps_get_saved_places|-|Saved Maps places (name + coordinates).|query^S^0^filter~limit^N^0^max 1-10 (def get_ride_estimate|-|Taxi fare/ETA.|pickup_lat^N^1^pickup lat~pickup_lng^N^1^pickup lng~dest_lat^N^1^dest lat~dest_lng^N^1^dest lng~pickup_label^S^0^pickup lbl~dest_label^S^0^dest lbl food_order_lookup|-|Restaurant orderable nearby? (FoodDelivery).|name^S^1^name~lat^N^1^lat~lng^N^1^lng~address^S^0^address-calculator_evaluate|-|Evaluate math via Calculator.|expression^S^1^expression (200 chars)+calculator_evaluate|-|Evaluate math via Calculator.|expression^S^1^expression (200 calculator_convert_unit|-|Convert units.|value^N^1^value~from_unit^S^1^from e.g. km/USD~to_unit^S^1^to e.g. mi/EUR search_contacts|-|Search contacts by name/phone substring (max 10).|query^S^1^name/phone substring web_search|-|Web search for current facts. Numbered results; web_read_result reads them.|query^S^1^search query~count^N^0^count 1-10 (def 5)~kind^S^0^text (def) or news@@ -107,14 +108,15 @@ food_get_cart|-|Get the current FoodDelivery cart (items and total)| food_set_cart|L|Replace cart.|merchant_id^N^1^merchant~items_json^S^1^[{itemId,qty,modifierIds}] food_prepare_order|-|Price cart.|merchant_id^N^1^merchant~is_pickup^N^0^1=pickup 0=delivery~address_id^S^0^addr id~tip_cents^N^0^tip cents~promo^S^0^promo+ place_food_order|H|Order summary; user pays in app.|merchant_id^N^1^merchant get_food_orders|-|Get the user's past FoodDelivery orders| search_products|-|Search the Shop catalog. Each result is one.|query^S^1^search text~limit^N^0^max (def 5) get_product_detail|-|Product variants.|shop_domain^S^1^domain~product_id^S^1^product~variant_id^S^0^variant shop_get_cart|-|Get the current Shop cart, grouped by store|-shop_add_to_cart|L|Add exact variant to Shop cart (re-verified; no.|shop_domain^S^1^domain~variant_id^S^1^exact variant id~quantity^N^0^qty 1-99 (def 1)-shop_remove_from_cart|L|Remove a variant from the Shop cart; the cart.|variant_id^S^1^variant id to remove-start_shop_checkout|H|Cart summary; user checks out in Shop.|shop_domain^S^1^domain to check out+shop_add_to_cart|L|Add exact variant to Shop cart.|shop_domain^S^1^domain~variant_id^S^1^exact variant id~quantity^N^0^qty 1-99 (def 1)+shop_remove_from_cart|L|Remove a variant from the Shop cart; the.|variant_id^S^1^variant id to+start_shop_checkout|H|Cart summary; user checks out in Shop.|shop_domain^S^1^domain to check get_shop_orders|-|Get the user's Shop order summaries| get_memories|-|Get memories (last 100)| education_get_progress|-|Education progress by course/subject, streak, deadlines (aggregates).|@@ -127,11 +129,13 @@ health_get_metric_summary|-|Health summary aggregates only: latest/avg/min/max/t remove_memory|C|Remove a memory by its id (requires confirmation)|id^N^1^ + add_to_memory|-|Add a new memory to the list of memories|content^S^1^ astronomy_get_tonight|-|Tonight: sunset/Moon/planets.|latitude^N^0^~longitude^N^0^ get_weather_forecast|-|Forecast (5d+hours).|location^S^1^place~days^N^0^1-5 (def 3) appstore_search_apps|-|AppStore app search.|query^S^1^search text~limit^N^0^max 1-10 appstore_get_updates|-|AppStore update count/names.|-travel_get_trips|-|Trip summaries (name, dates, destinations).|when^S^0^upcoming/past/all~limit^N^0^1-10 (def 5)+travel_get_trips|-|Trip summaries (name, dates, destinations).|when^S^0^upcoming/past/al~limit^N^0^1-10 (def 5) translate_text|-|Translate.|text^S^1^~target_lang^S^1^es~source_lang^S^0^auto+photos_search_photos|-|Search photo metadata (name, date, size,.|query^S^0^~album^S^0^~from_millis^N^0^~to_millis^N^0^~limit^N^0^1-10 """
openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantAggregateSummarizers.kt
diff --git a/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantAggregateSummarizers.kt b/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantAggregateSummarizers.ktindex 701ef76e5c..15d02d1e58 100644--- a/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantAggregateSummarizers.kt+++ b/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantAggregateSummarizers.kt@@ -17,6 +17,8 @@ import com.vayunmathur.library.intents.travel.TripSummaryData import com.vayunmathur.library.intents.translate.TRANSLATE_ERROR_MODEL_NOT_DOWNLOADED import com.vayunmathur.library.intents.translate.TRANSLATE_MAX_OUTPUT_CHARS import com.vayunmathur.library.intents.translate.TranslateResultData+import com.vayunmathur.library.intents.photos.PHOTOS_MAX_LIMIT+import com.vayunmathur.library.intents.photos.PhotoSearchResult private const val HEALTH_SUMMARY_CHARS = 300 @@ -216,3 +218,14 @@ fun summarizeTranslateResult(result: TranslateResultData): String = result.detectedLang?.takeIf { it.isNotBlank() }?.let { append(" (detected source: $it)") } } }++fun summarizePhotoSearch(result: PhotoSearchResult): String {+ if (result.totalCount == 0 || result.photos.isEmpty()) return "No photos found"+ val shown = result.photos.take(PHOTOS_MAX_LIMIT)+ val lines = shown.joinToString("\n") { p ->+ "id=${p.id} ${p.fileName.take(120)} taken=${p.takenMillis} ${p.width}x${p.height}" ++ (p.album?.let { " album=$it" } ?: "") ++ (p.mimeType?.let { " type=$it" } ?: "")+ }+ return "Found ${result.totalCount} photo(s), showing ${shown.size}:\n$lines"+}
openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantCoreToolIntents.kt
diff --git a/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantCoreToolIntents.kt b/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantCoreToolIntents.ktindex dc8fa91b6e..e26ca16be4 100644--- a/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantCoreToolIntents.kt+++ b/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantCoreToolIntents.kt@@ -19,6 +19,8 @@ import com.vayunmathur.library.intents.findfamily.FamilyMemberData import com.vayunmathur.library.intents.music.MusicSearchResult import com.vayunmathur.library.intents.music.PlayMusicData import com.vayunmathur.library.intents.notes.NoteData+import com.vayunmathur.library.intents.photos.PhotoSearchQuery+import com.vayunmathur.library.intents.photos.PhotoSearchResult import com.vayunmathur.library.intents.todo.CompleteTodoData import com.vayunmathur.library.intents.todo.GetTodosQuery import com.vayunmathur.library.intents.todo.InsertTodoData@@ -199,6 +201,13 @@ internal abstract class AssistantCoreToolIntents( CreateLinkRequest(name, durationMillis.toLong()), ) + suspend fun searchPhotos(query: PhotoSearchQuery): PhotoSearchResult = launchIntent(+ context,+ "com.vayunmathur.photos",+ "com.vayunmathur.photos.intents.SearchPhotosIntent",+ query,+ )+ suspend fun searchMusic(query: String): String = summarizeMusicResults( launchIntent<String, List<MusicSearchResult>>( context,
openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantToolIntents.kt
diff --git a/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantToolIntents.kt b/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantToolIntents.ktindex 60973a867e..ce38f3a351 100644--- a/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantToolIntents.kt+++ b/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantToolIntents.kt@@ -89,6 +89,8 @@ import com.vayunmathur.library.intents.travel.TripsQuery import com.vayunmathur.library.intents.translate.TRANSLATE_ERROR_MODEL_NOT_DOWNLOADED import com.vayunmathur.library.intents.translate.TRANSLATE_MAX_OUTPUT_CHARS import com.vayunmathur.library.intents.translate.TranslateResultData+import com.vayunmathur.library.intents.photos.PHOTOS_MAX_LIMIT+import com.vayunmathur.library.intents.photos.PhotoSearchResult private const val CONVERSATION_SNIPPET_CHARS = 80 private const val MESSAGE_BODY_CHARS = 200
openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantTools.kt
diff --git a/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantTools.kt b/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantTools.ktindex f5fdd47e19..c4f7b8186b 100644--- a/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantTools.kt+++ b/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantTools.kt@@ -229,6 +229,21 @@ class AssistantTools( intents.getWeatherForecast(a.string("location"), days) } },+ "photos_search_photos" to { a ->+ intents.runTool {+ com.vayunmathur.openassistant.platform.summarizePhotoSearch(+ intents.searchPhotos(+ com.vayunmathur.library.intents.photos.PhotoSearchQuery(+ query = a.string("query"),+ album = a.string("album").takeIf { it.isNotBlank() },+ fromMillis = a.number("from_millis").toLong().takeIf { it > 0 },+ toMillis = a.number("to_millis").toLong().takeIf { it > 0 },+ limit = a.number("limit").toInt().takeIf { it > 0 } ?: 5,+ ),+ ),+ )+ }+ }, "get_directions" to { a -> intents.runTool { intents.getDirections(
openassistant/src/test/java/com/vayunmathur/openassistant/domain/PromptBudgetTest.kt
diff --git a/openassistant/src/test/java/com/vayunmathur/openassistant/domain/PromptBudgetTest.kt b/openassistant/src/test/java/com/vayunmathur/openassistant/domain/PromptBudgetTest.ktindex 71282a6f20..b627b1646c 100644--- a/openassistant/src/test/java/com/vayunmathur/openassistant/domain/PromptBudgetTest.kt+++ b/openassistant/src/test/java/com/vayunmathur/openassistant/domain/PromptBudgetTest.kt@@ -28,11 +28,12 @@ class PromptBudgetTest { val header = declared.length + InferenceService.DEFAULT_SYSTEM_PROMPT.length + AssistantCatalog.PROMPT_SECTION.length println("HEADER declared=${declared.length} prompt=${InferenceService.DEFAULT_SYSTEM_PROMPT.length} a2ui=${AssistantCatalog.PROMPT_SECTION.length} total=$header")- assertEquals(71, ASSISTANT_TOOL_SPECS.size)+ assertEquals(72, ASSISTANT_TOOL_SPECS.size) assertTrue(header <= MAX_HEADER_CHARS, "header=$header over budget $MAX_HEADER_CHARS") } companion object { const val MAX_HEADER_CHARS = 25_600+ // 24,500 at 54 tools; +500 for photos_search_photos (55 tools). } }
openassistant/src/test/java/com/vayunmathur/openassistant/platform/AssistantToolsInvokeTest.kt
diff --git a/openassistant/src/test/java/com/vayunmathur/openassistant/platform/AssistantToolsInvokeTest.kt b/openassistant/src/test/java/com/vayunmathur/openassistant/platform/AssistantToolsInvokeTest.ktindex 166efc4ca0..1da642bd74 100644--- a/openassistant/src/test/java/com/vayunmathur/openassistant/platform/AssistantToolsInvokeTest.kt+++ b/openassistant/src/test/java/com/vayunmathur/openassistant/platform/AssistantToolsInvokeTest.kt@@ -44,7 +44,7 @@ class AssistantToolsInvokeTest { assertEquals("Error: create_note needs title", call("create_note", "content" to "x")) assertTrue( call("set_timer", "seconds" to "abc").contains("must be a number"))- assertEquals(71, tools.declarations.size)+ assertEquals(72, tools.declarations.size) } @Test fun crossAppToolsReportMissingApps() {
openassistant/src/test/java/com/vayunmathur/openassistant/platform/AssistantToolsTest.kt
diff --git a/openassistant/src/test/java/com/vayunmathur/openassistant/platform/AssistantToolsTest.kt b/openassistant/src/test/java/com/vayunmathur/openassistant/platform/AssistantToolsTest.ktindex 7db7eb9535..5ef2a85eb2 100644--- a/openassistant/src/test/java/com/vayunmathur/openassistant/platform/AssistantToolsTest.kt+++ b/openassistant/src/test/java/com/vayunmathur/openassistant/platform/AssistantToolsTest.kt@@ -14,7 +14,7 @@ class AssistantToolsTest { @Test fun namesAreUniqueSnakeCase() { val names = ASSISTANT_TOOL_SPECS.map { it.name }- assertEquals(71, names.size)+ assertEquals(72, names.size) assertEquals(names.size, names.toSet().size) for (spec in ASSISTANT_TOOL_SPECS) { assertTrue(snake.matches(spec.name), spec.name)@@ -76,6 +76,8 @@ class AssistantToolsTest { "astronomy_get_tonight.latitude", "astronomy_get_tonight.longitude", "appstore_search_apps.limit", "travel_get_trips.limit",+ "photos_search_photos.from_millis", "photos_search_photos.to_millis",+ "photos_search_photos.limit", ), numeric, )
openassistant/src/test/java/com/vayunmathur/openassistant/util/PhotosToolTest.kt
diff --git a/openassistant/src/test/java/com/vayunmathur/openassistant/util/PhotosToolTest.kt b/openassistant/src/test/java/com/vayunmathur/openassistant/util/PhotosToolTest.ktnew file mode 100644index 0000000000..ced723efd7--- /dev/null+++ b/openassistant/src/test/java/com/vayunmathur/openassistant/util/PhotosToolTest.kt@@ -0,0 +1,52 @@+package com.vayunmathur.openassistant.util++import com.vayunmathur.library.intents.photos.PhotoHitData+import com.vayunmathur.library.intents.photos.PhotoSearchResult+import com.vayunmathur.openassistant.domain.ASSISTANT_TOOL_SPECS+import com.vayunmathur.openassistant.domain.ToolRisk+import com.vayunmathur.openassistant.platform.summarizePhotoSearch+import kotlin.test.Test+import kotlin.test.assertEquals+import kotlin.test.assertFalse+import kotlin.test.assertTrue++/** Host side of photos_search_photos: spec shape + metadata-only summary. */+class PhotosToolTest {++ @Test fun specIsReadOnlyQueryBasedAndCapped() {+ val spec = ASSISTANT_TOOL_SPECS.single { it.name == "photos_search_photos" }+ assertEquals(ToolRisk.READ, spec.risk)+ assertEquals(+ listOf("query", "album", "from_millis", "to_millis", "limit"),+ spec.params.map { it.name },+ )+ assertTrue(spec.params.none { it.required }, "every photos filter is optional")+ assertTrue(spec.description.contains("never image data"), spec.description)+ assertTrue(spec.params.single { it.name == "limit" }.description.contains("1-10"))+ }++ @Test fun summaryShowsCountAndMetadataLinesOnly() {+ val result = PhotoSearchResult(+ totalCount = 42,+ photos = listOf(+ PhotoHitData(7L, "IMG_1.jpg", 1_700_000_000_000L, 4000, 3000, "Camera", "image/jpeg"),+ PhotoHitData(8L, "IMG_2.jpg", 1_700_000_100_000L, 3000, 4000, null, null),+ ),+ )+ val text = summarizePhotoSearch(result)+ assertTrue(text.startsWith("Found 42 photo(s), showing 2:"), text)+ assertTrue(text.contains("id=7 IMG_1.jpg"), text)+ assertTrue(text.contains("4000x3000"), text)+ assertTrue(text.contains("album=Camera"), text)+ assertFalse(text.contains("content://"), text)+ assertFalse(text.contains("/storage/"), text)+ assertEquals("No photos found", summarizePhotoSearch(PhotoSearchResult(0, emptyList())))+ }++ @Test fun summaryReCapsAtTenEvenIfProviderMisbehaves() {+ val photos = (1..25).map { PhotoHitData(it.toLong(), "p$it.jpg", it.toLong(), 1, 1) }+ val text = summarizePhotoSearch(PhotoSearchResult(25, photos))+ assertEquals(10, text.lines().size - 1)+ assertTrue(text.contains("showing 10"), text)+ }+}
photos/AGENTS.md
diff --git a/photos/AGENTS.md b/photos/AGENTS.mdindex 1d4d52342c..9399975c28 100644--- a/photos/AGENTS.md+++ b/photos/AGENTS.md@@ -4,7 +4,7 @@ _Install: ./install photos (dev by default)._ - Gradle: :photos / dir: photos/-- Package roots present: ui, data, domain, platform, service, widget+- Package roots present: ui, data, domain, platform, service, widget, intents - Entry files: MainActivity.kt, Route.kt, Navigation.kt - Deps: :library:map, :library:image, :library:ml, :library:room, :library:ink, :library:widgets, :library:biometric, :library:ocr, :library:downloadservice - Metadata: metadata_data/photos.md (present)@@ -77,6 +77,9 @@ _Install: ./install photos (dev by default)._ - com/vayunmathur/photos/domain/FaceQuality.kt — which faces may form people - com/vayunmathur/photos/domain/FaceClustering.kt — batch average-linkage grouping - com/vayunmathur/photos/domain/FaceClusterIdentity.kt — keeps person ids/names across regroups+### intents/ — assistant IPC (metadata only)+- com/vayunmathur/photos/intents/SearchPhotosIntent.kt — `photos_search_photos`: filtered (file-name/folder/date) metadata search over `PhotoDao.searchPhotoMetadata`; returns the matching count plus at most 10 hits (`library.intents.photos.PhotoHitData`: id, file name, taken date, dimensions, album, MIME). Never returns image bytes, thumbnails, URIs/paths, location, OCR text or embeddings; trashed items are excluded in SQL and the secure-folder vault is never opened. Guarded by the signature permission `com.vayunmathur.photos.permissions.ACCESS_PHOTOS`.+- com/vayunmathur/photos/intents/PhotosSearchContract.kt — provider-side validation/clamping (limit 1–10, text/date-range normalisation) and row→hit mapping ### widget/ — home widget - com/vayunmathur/photos/widget/PhotoGlanceWidget.kt — includes `PhotoGlanceWidgetReceiver` (one widget, one file) ### platform/ — motion-photo
photos/src/main/AndroidManifest.xml
diff --git a/photos/src/main/AndroidManifest.xml b/photos/src/main/AndroidManifest.xmlindex af353fc2d6..1f767a1272 100644--- a/photos/src/main/AndroidManifest.xml+++ b/photos/src/main/AndroidManifest.xml@@ -24,6 +24,10 @@ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />++ <permission+ android:name="com.vayunmathur.photos.permissions.ACCESS_PHOTOS"+ android:protectionLevel="signature" /> <application android:allowBackup="true" android:dataExtractionRules="@xml/data_extraction_rules"@@ -70,6 +74,12 @@ <data android:mimeType="video/*" /> </intent-filter> </activity>+ <activity+ android:name=".intents.SearchPhotosIntent"+ android:exported="true"+ android:theme="@android:style/Theme.NoDisplay"+ android:permission="com.vayunmathur.photos.permissions.ACCESS_PHOTOS">+ </activity> <receiver android:name=".widget.PhotoGlanceWidgetReceiver" android:exported="false">
photos/src/main/java/com/vayunmathur/photos/data/PhotoDatabase.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/data/PhotoDatabase.kt b/photos/src/main/java/com/vayunmathur/photos/data/PhotoDatabase.ktindex 25ad617e0e..c0bdf4131a 100644--- a/photos/src/main/java/com/vayunmathur/photos/data/PhotoDatabase.kt+++ b/photos/src/main/java/com/vayunmathur/photos/data/PhotoDatabase.kt@@ -176,6 +176,41 @@ interface PhotoDao { } } + /**+ * Metadata-only assistant search: the exact columns+ * [com.vayunmathur.library.intents.photos.PhotoHitData] carries, so no+ * URI, OCR text or CLIP embedding is ever loaded for this call. Trashed+ * items are excluded; the secure-folder vault lives in a separate+ * database and is never queried here.+ */+ @Query(+ "SELECT id, name, date, width, height, album, mimeType FROM Photo WHERE isTrashed = 0 " ++ "AND (:album IS NULL OR album = :album COLLATE NOCASE) " ++ "AND date >= :fromMillis AND date <= :toMillis " ++ "AND name LIKE :namePattern ESCAPE '\\' ORDER BY date DESC LIMIT :limit"+ )+ suspend fun searchPhotoMetadata(+ album: String?,+ fromMillis: Long,+ toMillis: Long,+ namePattern: String,+ limit: Int,+ ): List<PhotoMetadataRow>++ /** Count companion of [searchPhotoMetadata] (same filters, no limit). */+ @Query(+ "SELECT count(*) FROM Photo WHERE isTrashed = 0 " ++ "AND (:album IS NULL OR album = :album COLLATE NOCASE) " ++ "AND date >= :fromMillis AND date <= :toMillis " ++ "AND name LIKE :namePattern ESCAPE '\\'"+ )+ suspend fun countPhotoMetadata(+ album: String?,+ fromMillis: Long,+ toMillis: Long,+ namePattern: String,+ ): Int+ /** Photos already scanned by OCR (numerator of the search-index progress bar). */ @Query("SELECT count(*) FROM Photo WHERE ocrScanned = 1 AND isTrashed = 0 AND duration IS NULL") fun getOCRCountFlow(): Flow<Int>@@ -395,6 +430,21 @@ internal fun photoFtsMatchQuery(query: String): String = .take(16) .joinToString(" ") { "\"$it*\"" } +/**+ * The only columns the assistant metadata search reads (see+ * [PhotoDao.searchPhotoMetadata]). Deliberately has no uri, lat/long,+ * ocrText/ocrBoxes or clipEmbedding field.+ */+data class PhotoMetadataRow(+ val id: Long,+ val name: String,+ val date: Long,+ val width: Int,+ val height: Int,+ val album: String?,+ val mimeType: String?,+)+ /** Lightweight projection of a photo's CLIP embedding for in-memory search. */ data class PhotoEmbedding( val id: Long,
photos/src/main/java/com/vayunmathur/photos/data/PhotosRepository.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/data/PhotosRepository.kt b/photos/src/main/java/com/vayunmathur/photos/data/PhotosRepository.ktindex 97bf667a5d..49be25be59 100644--- a/photos/src/main/java/com/vayunmathur/photos/data/PhotosRepository.kt+++ b/photos/src/main/java/com/vayunmathur/photos/data/PhotosRepository.kt@@ -76,6 +76,23 @@ open class PhotosRepository internal constructor(context: Context) : open suspend fun setFavorite(ids: List<Long>, value: Boolean) = photoDao.setFavorite(ids, value) suspend fun searchPhotos(query: String): List<Photo> = photoDao.searchPhotos(query) + /** Metadata-only assistant search (see [PhotoDao.searchPhotoMetadata]). */+ suspend fun searchPhotoMetadata(+ album: String?,+ fromMillis: Long,+ toMillis: Long,+ namePattern: String,+ limit: Int,+ ): List<PhotoMetadataRow> = photoDao.searchPhotoMetadata(album, fromMillis, toMillis, namePattern, limit)++ /** Count companion of [searchPhotoMetadata] (same filters, no limit). */+ suspend fun countPhotoMetadata(+ album: String?,+ fromMillis: Long,+ toMillis: Long,+ namePattern: String,+ ): Int = photoDao.countPhotoMetadata(album, fromMillis, toMillis, namePattern)+ /** Shared constants and helpers for PhotosRepository. */ companion object { @Volatile
photos/src/main/java/com/vayunmathur/photos/intents/PhotosSearchContract.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/intents/PhotosSearchContract.kt b/photos/src/main/java/com/vayunmathur/photos/intents/PhotosSearchContract.ktnew file mode 100644index 0000000000..a2c861d760--- /dev/null+++ b/photos/src/main/java/com/vayunmathur/photos/intents/PhotosSearchContract.kt@@ -0,0 +1,75 @@+package com.vayunmathur.photos.intents++import com.vayunmathur.library.intents.photos.PHOTOS_MAX_LIMIT+import com.vayunmathur.library.intents.photos.PhotoHitData+import com.vayunmathur.library.intents.photos.PhotoSearchQuery+import com.vayunmathur.library.intents.photos.PhotoSearchResult+import com.vayunmathur.photos.data.PhotoMetadataRow++/** Max accepted file-name query length; longer input is truncated. */+const val PHOTOS_MAX_QUERY_CHARS = 200++/** Max accepted folder/album filter length; longer input is truncated. */+const val PHOTOS_MAX_ALBUM_CHARS = 60++/** File names are truncated to this length before they cross the wire. */+const val PHOTOS_MAX_FILENAME_CHARS = 120++/** MIME types are truncated to this length before they cross the wire. */+const val PHOTOS_MAX_MIME_CHARS = 80++/**+ * A [PhotoSearchQuery] after provider-side validation: text truncated,+ * limit clamped to 1..[PHOTOS_MAX_LIMIT], and a swapped date range+ * normalised so [fromMillis] never exceeds [toMillis]. A null bound means+ * that side of the range is open.+ */+data class ValidatedPhotoSearch(+ val query: String,+ val album: String?,+ val fromMillis: Long?,+ val toMillis: Long?,+ val limit: Int,+)++/** Validates/clamps a raw wire query; never throws on model-supplied input. */+fun validatePhotoSearch(input: PhotoSearchQuery): ValidatedPhotoSearch {+ val rawFrom = input.fromMillis+ val rawTo = input.toMillis+ val swapped = rawFrom != null && rawTo != null && rawFrom > rawTo+ val lo = if (swapped) rawTo else rawFrom+ val hi = if (swapped) rawFrom else rawTo+ return ValidatedPhotoSearch(+ query = input.query.trim().take(PHOTOS_MAX_QUERY_CHARS),+ album = input.album?.trim()?.takeIf { it.isNotBlank() }?.take(PHOTOS_MAX_ALBUM_CHARS),+ fromMillis = lo,+ toMillis = hi,+ limit = input.limit.coerceIn(1, PHOTOS_MAX_LIMIT),+ )+}++/** Builds a literal substring `LIKE` pattern: wildcards escaped, wrapped in `%…%`. */+fun photoNamePattern(query: String): String =+ "%" + query.replace("\\", "\\\\").replace("%", "\\%").replace("_", "\\_") + "%"++/**+ * Maps one metadata row to its wire hit. Only metadata crosses: the row (and+ * therefore the hit) has no URI/path, image bytes, thumbnail, location, OCR+ * text or embedding field to leak.+ */+fun PhotoMetadataRow.toPhotoHit(): PhotoHitData = PhotoHitData(+ id = id,+ fileName = name.take(PHOTOS_MAX_FILENAME_CHARS),+ takenMillis = date,+ width = width,+ height = height,+ album = album?.take(PHOTOS_MAX_ALBUM_CHARS),+ mimeType = mimeType?.take(PHOTOS_MAX_MIME_CHARS),+)++/** Assembles the wire result, re-applying the hit cap defensively. */+fun buildPhotoSearchResult(totalCount: Int, rows: List<PhotoMetadataRow>, limit: Int): PhotoSearchResult =+ PhotoSearchResult(+ totalCount = totalCount.coerceAtLeast(0),+ photos = rows.take(limit.coerceIn(1, PHOTOS_MAX_LIMIT)).map { it.toPhotoHit() },+ )
photos/src/main/java/com/vayunmathur/photos/intents/SearchPhotosIntent.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/intents/SearchPhotosIntent.kt b/photos/src/main/java/com/vayunmathur/photos/intents/SearchPhotosIntent.ktnew file mode 100644index 0000000000..b98d881487--- /dev/null+++ b/photos/src/main/java/com/vayunmathur/photos/intents/SearchPhotosIntent.kt@@ -0,0 +1,35 @@+package com.vayunmathur.photos.intents++import com.vayunmathur.library.intents.photos.PhotoSearchQuery+import com.vayunmathur.library.intents.photos.PhotoSearchResult+import com.vayunmathur.library.util.AssistantIntent+import com.vayunmathur.photos.data.PhotosRepository+import kotlinx.serialization.InternalSerializationApi+import kotlinx.serialization.serializer++/**+ * Assistant contract: filtered photo metadata search (file name, folder,+ * date range). Returns the matching count plus at most+ * [com.vayunmathur.library.intents.photos.PHOTOS_MAX_LIMIT] newest-first+ * metadata hits. Reads only the main photo table: trashed items are excluded+ * in SQL and the biometric secure-folder vault is never opened. No image+ * bytes, thumbnails, URIs or paths ever leave this app through this intent.+ */+@OptIn(InternalSerializationApi::class)+class SearchPhotosIntent :+ AssistantIntent<PhotoSearchQuery, PhotoSearchResult>(+ serializer<PhotoSearchQuery>(),+ serializer<PhotoSearchResult>(),+ ) {++ override suspend fun performCalculation(input: PhotoSearchQuery): PhotoSearchResult {+ val query = validatePhotoSearch(input)+ val repo = PhotosRepository.get(this)+ val from = query.fromMillis ?: 0L+ val to = query.toMillis ?: Long.MAX_VALUE+ val pattern = photoNamePattern(query.query)+ val rows = repo.searchPhotoMetadata(query.album, from, to, pattern, query.limit)+ val total = repo.countPhotoMetadata(query.album, from, to, pattern)+ return buildPhotoSearchResult(total, rows, query.limit)+ }+}
photos/src/test/java/com/vayunmathur/photos/intents/PhotosMetadataDaoTest.kt
diff --git a/photos/src/test/java/com/vayunmathur/photos/intents/PhotosMetadataDaoTest.kt b/photos/src/test/java/com/vayunmathur/photos/intents/PhotosMetadataDaoTest.ktnew file mode 100644index 0000000000..5efb6c19aa--- /dev/null+++ b/photos/src/test/java/com/vayunmathur/photos/intents/PhotosMetadataDaoTest.kt@@ -0,0 +1,62 @@+package com.vayunmathur.photos.intents++import androidx.room3.Room+import androidx.test.core.app.ApplicationProvider+import com.vayunmathur.photos.data.Photo+import com.vayunmathur.photos.data.PhotoDatabase+import kotlin.test.AfterTest+import kotlin.test.Test+import kotlin.test.assertEquals+import kotlinx.coroutines.test.runTest+import org.junit.runner.RunWith+import org.robolectric.RobolectricTestRunner++/** DAO behaviour behind SearchPhotosIntent: filters, trash exclusion, cap. */+@RunWith(RobolectricTestRunner::class)+class PhotosMetadataDaoTest {++ private val context = ApplicationProvider.getApplicationContext<android.content.Context>()+ private val db: PhotoDatabase = Room.inMemoryDatabaseBuilder(context, PhotoDatabase::class.java)+ .allowMainThreadQueries()+ .build()+ private val dao = db.photoDao()++ @AfterTest fun closeDb() = db.close()++ private fun photo(name: String, date: Long, album: String?, trashed: Boolean = false) = Photo(+ name = name, uri = "content://media/external/images/media/$name", date = date,+ width = 4000, height = 3000, dateModified = date, exifSet = true,+ lat = 1.0, long = 2.0, videoData = null, panoData = null,+ isTrashed = trashed, album = album, mimeType = "image/jpeg",+ ocrText = "secret text", clipEmbedding = byteArrayOf(1, 2, 3),+ )++ @Test fun searchFiltersByAlbumDateAndNameExcludingTrashed() = runTest {+ dao.upsertAll(+ listOf(+ photo("beach1.jpg", 1_000L, "Camera"),+ photo("beach2.jpg", 2_000L, "Camera"),+ photo("beach3.jpg", 3_000L, "Screenshots"),+ photo("beach4.jpg", 4_000L, "Camera", trashed = true),+ photo("mountain.jpg", 5_000L, "Camera"),+ ),+ )+ val all = dao.searchPhotoMetadata(null, 0L, Long.MAX_VALUE, photoNamePattern(""), 10)+ assertEquals(4, all.size)+ assertEquals(4, dao.countPhotoMetadata(null, 0L, Long.MAX_VALUE, photoNamePattern("")))+ // Newest first, trashed excluded despite matching every other filter.+ assertEquals("mountain.jpg", all.first().name)++ val camera = dao.searchPhotoMetadata("camera", 0L, Long.MAX_VALUE, photoNamePattern("beach"), 10)+ assertEquals(listOf("beach2.jpg", "beach1.jpg"), camera.map { it.name })+ assertEquals(2, dao.countPhotoMetadata("camera", 0L, Long.MAX_VALUE, photoNamePattern("beach")))++ val ranged = dao.searchPhotoMetadata(null, 1_500L, 3_000L, photoNamePattern(""), 10)+ assertEquals(listOf("beach3.jpg", "beach2.jpg"), ranged.map { it.name })++ val capped = dao.searchPhotoMetadata(null, 0L, Long.MAX_VALUE, photoNamePattern(""), 2)+ assertEquals(2, capped.size)+ // Count is uncapped even when the hit list is capped.+ assertEquals(4, dao.countPhotoMetadata(null, 0L, Long.MAX_VALUE, photoNamePattern("")))+ }+}
photos/src/test/java/com/vayunmathur/photos/intents/PhotosSearchContractTest.kt
diff --git a/photos/src/test/java/com/vayunmathur/photos/intents/PhotosSearchContractTest.kt b/photos/src/test/java/com/vayunmathur/photos/intents/PhotosSearchContractTest.ktnew file mode 100644index 0000000000..17bf4bd7f2--- /dev/null+++ b/photos/src/test/java/com/vayunmathur/photos/intents/PhotosSearchContractTest.kt@@ -0,0 +1,81 @@+package com.vayunmathur.photos.intents++import com.vayunmathur.library.intents.photos.PHOTOS_MAX_LIMIT+import com.vayunmathur.library.intents.photos.PhotoHitData+import com.vayunmathur.library.intents.photos.PhotoSearchQuery+import com.vayunmathur.library.intents.photos.PhotoSearchResult+import com.vayunmathur.photos.data.PhotoMetadataRow+import kotlin.test.Test+import kotlin.test.assertEquals+import kotlin.test.assertFalse+import kotlin.test.assertTrue+import kotlinx.serialization.json.Json++/** Pins the metadata-only wire contract and every provider-side cap. */+class PhotosSearchContractTest {++ @Test fun limitClampsToOneThroughTen() {+ assertEquals(1, validatePhotoSearch(PhotoSearchQuery(limit = 0)).limit)+ assertEquals(1, validatePhotoSearch(PhotoSearchQuery(limit = -4)).limit)+ assertEquals(5, validatePhotoSearch(PhotoSearchQuery(limit = 5)).limit)+ assertEquals(PHOTOS_MAX_LIMIT, validatePhotoSearch(PhotoSearchQuery(limit = 999)).limit)+ assertEquals(10, PHOTOS_MAX_LIMIT)+ }++ @Test fun queryAndAlbumAreTrimmedAndTruncated() {+ val v = validatePhotoSearch(+ PhotoSearchQuery(query = " " + "a".repeat(500) + " ", album = " " + "b".repeat(100) + " "),+ )+ assertEquals(PHOTOS_MAX_QUERY_CHARS, v.query.length)+ assertEquals(PHOTOS_MAX_ALBUM_CHARS, v.album?.length)+ assertEquals(null, validatePhotoSearch(PhotoSearchQuery(album = " ")).album)+ }++ @Test fun swappedDateRangeIsNormalised() {+ val v = validatePhotoSearch(PhotoSearchQuery(fromMillis = 2_000L, toMillis = 1_000L))+ assertEquals(1_000L, v.fromMillis)+ assertEquals(2_000L, v.toMillis)+ val open = validatePhotoSearch(PhotoSearchQuery())+ assertEquals(null, open.fromMillis)+ assertEquals(null, open.toMillis)+ }++ @Test fun namePatternEscapesLikeWildcards() {+ assertEquals("%beach%", photoNamePattern("beach"))+ assertEquals("%100\\%\\_\\\\%", photoNamePattern("100%_\\"))+ }++ @Test fun resultCapsHitsAndTruncatesFileNames() {+ val rows = (1..25).map { i ->+ PhotoMetadataRow(i.toLong(), "n".repeat(200) + i, 1_000L + i, 4000, 3000, "Camera", "image/jpeg")+ }+ val result = buildPhotoSearchResult(totalCount = 25, rows = rows, limit = 999)+ assertEquals(25, result.totalCount)+ assertEquals(PHOTOS_MAX_LIMIT, result.photos.size)+ assertTrue(result.photos.all { it.fileName.length == PHOTOS_MAX_FILENAME_CHARS })+ }++ @Test fun wireDtosCarryMetadataOnly() {+ val hitFields = PhotoHitData::class.java.declaredFields.filter { !it.isSynthetic && it.name != "Companion" && !it.name.startsWith("$") }.map { it.name }.toSet()+ assertEquals(setOf("id", "fileName", "takenMillis", "width", "height", "album", "mimeType"), hitFields)+ val banned = listOf("uri", "path", "byte", "thumbnail", "lat", "lon", "ocr", "clip", "embedding", "content")+ for (field in hitFields + PhotoSearchResult::class.java.declaredFields.map { it.name }) {+ for (word in banned) {+ assertFalse(field.lowercase().contains(word), "metadata-only violation: $field")+ }+ }+ // The metadata row the provider reads has no URI/location/payload column either.+ val rowFields = PhotoMetadataRow::class.java.declaredFields.filter { !it.isSynthetic && it.name != "Companion" && !it.name.startsWith("$") }.map { it.name }.toSet()+ assertEquals(setOf("id", "name", "date", "width", "height", "album", "mimeType"), rowFields)+ }++ @Test fun serialisedHitHasNoUriOrPath() {+ val json = Json.encodeToString(+ PhotoHitData(7L, "IMG_1.jpg", 123L, 4000, 3000, "Camera", "image/jpeg"),+ )+ assertTrue(json.contains("\"fileName\":\"IMG_1.jpg\""), json)+ assertFalse(json.contains("uri", ignoreCase = true), json)+ assertFalse(json.contains("content://"), json)+ assertFalse(json.contains("/storage/"), json)+ }+}