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
+33 -7

No files matched your search

@@ -184,15 +184,22 @@ object PatchStore {
takeNodesEach({ named("application") }) {
takeNodesEach({ named("activity") }) {
takeNodesEach({ named("intent-filter") }) {
takeNodesEach({ named("category") }) {
when (attributeName()) {
"android.intent.category.INFO" -> null
"android.intent.category.LAUNCHER" -> null
else -> this
}
val hasIntent = elem<JSONArray>("nodes").elemEach<JSONObject> { named("category") }.map {
when (it.attributeName()) {
"com.oculus.intent.category.VR" -> true
"android.intent.category.LAUNCHER" -> true
else -> false
}
}.reduceOrNull { l, r -> l || r } ?: false
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"))
}
}
}
}
@@ -86,3 +86,22 @@ fun createCategory(value: String): JSONObject {
)
)
}
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)
)
)
}