components/webapps/docs/projects/al-site-settings/design.md
This document outlines the design of the fix for site settings issues for TWAs on Desktop Android, specifically addressing problems with shared UIDs and multiple apps for the same origin. This design is implemented at HEAD.
Refactor the storage keys in InstalledWebappDataRegister to use the Android
Package Name instead of the Android UID. This solves issues with multiple apps
claiming the same origin and apps sharing a UID (like Calendar).
Chrome tracks installed web apps (TWAs and WebAPKs) to manage permissions and
browsing data. It previously used the Android UID assigned at install time as
the key to store this data in SharedPreferences.
InstalledWebappRegistrar skipped
registration for a second app claiming the same origin because it
deduplicated by origin only.InstalledWebappDataRegister overwrote data (like package name) when the
second app registered. On uninstall of one package, it cleared all data for
the shared UID, breaking the other app's association in Chrome.TrustedWebActivitySettingsNavigation queried data by Android UID. For apps
sharing a UID, this returned merged origins for all sharing apps, failing to
isolate them in the Site Settings UI.See web_app_identifiers_android.md for details on how these IDs relate.
The primary key in InstalledWebappDataRegister was switched from Android UID
to Android Package Name.
uid.xxx to packageName.xxx.packageName extracted
from intent data to query and clear data.packageName
directly to query data for Site Settings, ensuring full isolation for apps
sharing a UID.To migrate from UID-keyed storage to Package Name-keyed storage, the following
steps are taken (triggered in prefetchPreferences on a background thread):
trusted_web_activity_uids.packageName, appName, domain set, and origin
set.packageName is present:
packageName to the new trusted_web_activity_packages set.packageName.appName, packageName.domain,
packageName.origin.uid.packageName, uid.appName,
uid.domain, uid.origin).trusted_web_activity_uids key to mark
migration complete.Option B (Package Name keys) was chosen as the cleanest architectural solution as it properly isolates apps even if they share a UID, and the package name is available in all relevant broadcasts.