refactor: Activity launcher categories

Should fix YVR behavior.
This commit is contained in:
Mathew Tkachuk committed 2025-03-08 14:34:35 +03:00
1 parent 3c6b910233
commit 479deff61a
2 files changed
+34 -8

No files matched your search

@@ -184,15 +184,22 @@ object PatchStore {
takeNodesEach({ named("application") }) { takeNodesEach({ named("application") }) {
takeNodesEach({ named("activity") }) { takeNodesEach({ named("activity") }) {
takeNodesEach({ named("intent-filter") }) { takeNodesEach({ named("intent-filter") }) {
takeNodesEach({ named("category") }) { val hasIntent = elem<JSONArray>("nodes").elemEach<JSONObject> { named("category") }.map {
when (attributeName()) { when (it.attributeName()) {
"android.intent.category.INFO" -> null "com.oculus.intent.category.VR" -> true
"android.intent.category.LAUNCHER" -> null "android.intent.category.LAUNCHER" -> true
else -> this else -> false
} }
} }.reduceOrNull { l, r -> l || r } ?: false
takeNodes { takeNodes {
this?.put(createCategory("android.intent.category.LAUNCHER")) if (!hasIntent) this else {
JSONArray()
.put(createAction("android.intent.action.MAIN"))
.put(createCategory("android.intent.category.LAUNCHER"))
.put(createCategory("com.oculus.intent.category.VR"))
.put(createCategory("com.yvr.intent.category.VR"))
}
} }
} }
} }
@@ -85,4 +85,23 @@ fun createCategory(value: String): JSONObject {
.put("data", value) .put("data", value)
) )
) )
} }
fun createAction(value: String): JSONObject {
return JSONObject()
.put("node_type", "element")
.put("name", "action")
.put(
"attributes",
JSONArray()
.put(
JSONObject()
.put("name", "name")
.put("id", 16842755)
.put("uri", "http://schemas.android.com/apk/res/android")
.put("prefix", "android")
.put("value_type", "STRING")
.put("data", value)
)
)
}