From c4d18cb81ba64b555454e96a995aca682b72c989 Mon Sep 17 00:00:00 2001 From: rcelyte Date: Wed, 13 Sep 2023 05:28:57 +0000 Subject: [PATCH] Add OpenXR permission --- QuestPatcher.Core/Models/PatchingOptions.cs | 2 ++ QuestPatcher.Core/Patching/PatchingManager.cs | 36 +++++++++++++++++++ QuestPatcher/Views/PatchingView.axaml | 1 + 3 files changed, 39 insertions(+) diff --git a/QuestPatcher.Core/Models/PatchingOptions.cs b/QuestPatcher.Core/Models/PatchingOptions.cs index a5b3fd0..ac9cfda 100644 --- a/QuestPatcher.Core/Models/PatchingOptions.cs +++ b/QuestPatcher.Core/Models/PatchingOptions.cs @@ -23,6 +23,8 @@ public bool HandTracking public bool Microphone { get; set; } + public bool OpenXR { get; set; } + public bool FlatScreenSupport { get; set; } public HandTrackingVersion HandTrackingType { get; set; } diff --git a/QuestPatcher.Core/Patching/PatchingManager.cs b/QuestPatcher.Core/Patching/PatchingManager.cs index c23e0f0..8329ee2 100644 --- a/QuestPatcher.Core/Patching/PatchingManager.cs +++ b/QuestPatcher.Core/Patching/PatchingManager.cs @@ -35,6 +35,7 @@ public class PatchingManager : INotifyPropertyChanged private const int DebuggableAttributeResourceId = 16842767; private const int LegacyStorageAttributeResourceId = 16844291; private const int ValueAttributeResourceId = 16842788; + private const int AuthoritiesAttributeResourceId = 16842776; /// /// Compression level to use when adding files to the APK during patching. @@ -191,6 +192,41 @@ private async Task PatchManifest(ApkZip apk) addingFeatures.Add("oculus.software.handtracking"); } + if (permissions.OpenXR) + { + Log.Information("Adding OpenXR permission . . ."); + + addingPermissions.AddRange(new[] { + "org.khronos.openxr.permission.OPENXR", + "org.khronos.openxr.permission.OPENXR_SYSTEM", + }); + + AxmlElement providerElement = new("provider") { + Attributes = {new("authorities", AndroidNamespaceUri, AuthoritiesAttributeResourceId, "org.khronos.openxr.runtime_broker;org.khronos.openxr.system_runtime_broker")}, + }; + AxmlElement runtimeIntent = new("intent") { + Children = { + new("action") { + Attributes = {new("name", AndroidNamespaceUri, NameAttributeResourceId, "org.khronos.openxr.OpenXRRuntimeService")}, + }, + }, + }; + AxmlElement layerIntent = new("intent") { + Children = { + new("action") { + Attributes = {new("name", AndroidNamespaceUri, NameAttributeResourceId, "org.khronos.openxr.OpenXRApiLayerService")}, + }, + }, + }; + manifest.Children.Add(new("queries") { + Children = { + providerElement, + runtimeIntent, + layerIntent, + }, + }); + } + // Find which features and permissions already exist to avoid adding existing ones var existingPermissions = GetExistingChildren(manifest, "uses-permission"); var existingFeatures = GetExistingChildren(manifest, "uses-feature"); diff --git a/QuestPatcher/Views/PatchingView.axaml b/QuestPatcher/Views/PatchingView.axaml index 4787090..76e39d7 100644 --- a/QuestPatcher/Views/PatchingView.axaml +++ b/QuestPatcher/Views/PatchingView.axaml @@ -19,6 +19,7 @@ Allow Debugging Disable VR Requirement Enable Microphone + Enable OpenXR Hand Tracking Type