feat(models): Add Custom URL & Local Path Fulfillment for Allowlist Models#598
Open
Mazafard wants to merge 1 commit intogoogle-ai-edge:mainfrom
Open
feat(models): Add Custom URL & Local Path Fulfillment for Allowlist Models#598Mazafard wants to merge 1 commit intogoogle-ai-edge:mainfrom
Mazafard wants to merge 1 commit intogoogle-ai-edge:mainfrom
Conversation
murshidadigitalmarket78-tech
approved these changes
Apr 8, 2026
murshidadigitalmarket78-tech
approved these changes
Apr 8, 2026
murshidadigitalmarket78-tech
approved these changes
Apr 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #576
Description
This PR introduces a flexible override mechanism to the existing model downloading framework. It allows users to bypass the default Hugging Face download link and supply their own custom URL or local device path to fulfill any pre-defined
model_allowlist.jsonmodel mapping natively.This enables seamless integration for users operating in air-gapped environments, heavily constrained networks, or local testing scenarios, specifically optimizing the developer experience without requiring a hardcoded manifest edit or creating new unstructured "global" import objects.
Implementation Details
[Icon] Import Custombutton strictly visible if the model download status evaluates toNOT_DOWNLOADED. This safely accompanies the existing download component directly on the model's panel.ModelFulfillmentDialoginside theDownloadModelPanellogic. It uses modern state-hoisting and standard AndroidActivityResultContracts.OpenDocument()for picking internal device files efficiently.DownloadRepository.ktto securely propagate thecustomUrlpayload override, preserving the worker execution context while explicitly sidestepping the default URL.fulfillModelWithLocalUriusingDispatchers.IOto read standard ContentResolver streams and seamlessly flush bytes directly into the prescribed storage partitions.Security & Validation
This implementation enforces rigid validation rules ensuring structural integrity isn't broken. If a model expects to be compiled as
model.task, it cannot be fulfilled via a stray.binor mismatched target..lastPathSegmentextraction directly from Android'sUri.parse()library instead of manual string truncation. This implicitly drops noisy tracking markers (?download=true,#anchor) ensuring validation fires strictly on physical path nomenclature.OpenableColumns.DISPLAY_NAMEagainst the literal allowlist properties before triggering File streams.