improve profile isolation
This commit is contained in:
+3
-1
@@ -150,7 +150,9 @@ object GlobalComponents {
|
||||
|
||||
//RustHttpConfig.setClient(lazy { newComponents.core.client })
|
||||
|
||||
newComponents.core.engine.warmUp()
|
||||
if (mode == ComponentsMode.FULL) {
|
||||
newComponents.core.engine.warmUp()
|
||||
}
|
||||
|
||||
fun restorePreviousCustomTabs() {
|
||||
if (previousCustomTabs.isEmpty()) return
|
||||
|
||||
+4
@@ -57,6 +57,10 @@ class ProfileContext(private val base: Context, val relativePath: String) :
|
||||
return customApplicationInfo
|
||||
}
|
||||
|
||||
override fun getApplicationContext(): Context {
|
||||
return this
|
||||
}
|
||||
|
||||
override fun getFilesDir(): File {
|
||||
return customFilesDir
|
||||
}
|
||||
|
||||
+3
-4
@@ -303,15 +303,14 @@ class IntentReceiverActivity : Activity() {
|
||||
contextId: String?,
|
||||
) {
|
||||
val message = "This PWA was originally installed in a different profile. " +
|
||||
"Opening it here will use your current profile's data and settings, " +
|
||||
"which means you won't see the same content, preferences, or saved data " +
|
||||
"that you had in the original profile.\n\n" +
|
||||
"Opening it here uses only your current profile's data and settings. " +
|
||||
"The original profile's app state and saved data will not be used.\n\n" +
|
||||
"Do you want to proceed anyway?"
|
||||
|
||||
AlertDialog.Builder(this)
|
||||
.setTitle("PWA Profile Mismatch")
|
||||
.setMessage(message)
|
||||
.setPositiveButton("Open Anyway") { _, _ ->
|
||||
.setPositiveButton("Open in Current Profile") { _, _ ->
|
||||
Log.d(TAG, "User chose to open PWA despite profile mismatch")
|
||||
launchPwaWithContext(url, contextId)
|
||||
}
|
||||
|
||||
+4
-4
@@ -144,7 +144,7 @@ class GeckoPwaApiImpl(
|
||||
|
||||
val (iconBitmap, isMaskable) = loadPwaIcon(manifest)
|
||||
|
||||
val shortcutId = generateShortcutId(manifest.startUrl)
|
||||
val shortcutId = generateShortcutId(manifest.startUrl, profileUuid)
|
||||
val launchToken = resolveLaunchToken(
|
||||
shortcutManager = shortcutManager,
|
||||
shortcutId = shortcutId,
|
||||
@@ -189,11 +189,11 @@ class GeckoPwaApiImpl(
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a collision-resistant shortcut ID from a URL using SHA-256.
|
||||
* Generates a collision-resistant shortcut ID from URL + profile using SHA-256.
|
||||
*/
|
||||
private fun generateShortcutId(url: String): String {
|
||||
private fun generateShortcutId(url: String, profileUuid: String): String {
|
||||
val digest = MessageDigest.getInstance("SHA-256")
|
||||
val hash = digest.digest(url.toByteArray())
|
||||
val hash = digest.digest("$url::$profileUuid".toByteArray())
|
||||
val hex = hash.take(16).joinToString("") { "%02x".format(it) }
|
||||
return "pwa_$hex"
|
||||
}
|
||||
|
||||
+2
-4
@@ -232,9 +232,7 @@ class Core(
|
||||
*/
|
||||
val customTabsStore by lazy { CustomTabsServiceStore() }
|
||||
|
||||
// Must use the base application context (not ProfileContext) so the database
|
||||
// matches what WebAppLauncherActivity (from the library) uses when loading manifests.
|
||||
val webAppManifestStorage by lazy { ManifestStorage(context.applicationContext) }
|
||||
val webAppManifestStorage by lazy { ManifestStorage(context) }
|
||||
|
||||
val webAppShortcutManager by lazy {
|
||||
WebAppShortcutManager(context, client, webAppManifestStorage)
|
||||
@@ -288,4 +286,4 @@ class Core(
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user