Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cb3bbb08 authored by Jacky Wang's avatar Jacky Wang
Browse files

[Catalyst] Refine launch intent for graph

Bug: 407910711
Flag: EXEMPT library
Test: devtool
Change-Id: I80cb0d3d11042db1d6f2c3110dd2bf5b6a659c70
parent fb12077b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -414,7 +414,8 @@ fun PreferenceMetadata.toProto(
            restricted = metadata.isRestricted(context)
        }
        metadata.intent(context)?.let { actionTarget = it.toActionTarget(context) }
        screenMetadata.getLaunchIntent(context, metadata)?.let { launchIntent = it.toProto() }
        val launchTarget = if (screenMetadata != metadata) metadata else null
        screenMetadata.getLaunchIntent(context, launchTarget)?.let { launchIntent = it.toProto() }
        for (tag in metadata.tags(context)) addTags(tag)
    }
    persistent = metadata.isPersistent(context)
+2 −4
Original line number Diff line number Diff line
@@ -44,11 +44,9 @@ fun Intent.toProto(): IntentProto = intentProto {
    this@toProto.type?.let { mimeType = it }
}

fun IntentProto.toIntent(): Intent? {
    if (!hasComponent()) return null
    val componentName = ComponentName.unflattenFromString(component) ?: return null
fun IntentProto.toIntent(): Intent {
    val intent = Intent()
    intent.component = componentName
    if (hasComponent()) intent.component = ComponentName.unflattenFromString(component)
    if (hasAction()) intent.action = action
    if (hasData()) intent.data = Uri.parse(data)
    if (hasPkg()) intent.`package` = pkg