@@ -779,22 +779,10 @@ void ApiLayerManifestFile::AddManifestFilesAndroid(const std::string &openxr_com
779779}
780780#endif // defined(XR_USE_PLATFORM_ANDROID) && defined(XR_KHR_LOADER_INIT_SUPPORT)
781781
782- void ApiLayerManifestFile::CreateIfValid (ManifestFileType type, const std::string &filename, std::istream &json_stream ,
782+ void ApiLayerManifestFile::CreateIfValid (ManifestFileType type, const std::string &filename, const Json::Value &root_node ,
783783 LibraryLocator locate_library,
784784 std::vector<std::unique_ptr<ApiLayerManifestFile>> &manifest_files) {
785785 std::ostringstream error_ss (" ApiLayerManifestFile::CreateIfValid " );
786- Json::CharReaderBuilder builder;
787- std::string errors;
788- Json::Value root_node = Json::nullValue;
789- if (!Json::parseFromStream (builder, json_stream, &root_node, &errors) || !root_node.isObject ()) {
790- error_ss << " failed to parse " << filename << " ." ;
791- if (!errors.empty ()) {
792- error_ss << " (Error message: " << errors << " )" ;
793- }
794- error_ss << " Is it a valid layer manifest file?" ;
795- LoaderLogger::LogErrorMessage (" " , error_ss.str ());
796- return ;
797- }
798786 JsonVersion file_version = {};
799787 if (!ManifestFile::IsValidJson (root_node, file_version)) {
800788 error_ss << " isValidJson indicates " << filename << " is not a valid manifest file." ;
@@ -842,6 +830,36 @@ void ApiLayerManifestFile::CreateIfValid(ManifestFileType type, const std::strin
842830 enabled = false ;
843831 }
844832
833+ #if defined(XR_OS_ANDROID)
834+ auto &disable_prop_node = layer_root_node[" disable_sys_prop" ];
835+ // Check if there's an system property to enable this API layer
836+ auto &enable_prop_node = layer_root_node[" enable_sys_prop" ];
837+ if (!enable_prop_node.isNull () && enable_prop_node.isString ()) {
838+ std::string enable_sys_prop = enable_prop_node.asString ();
839+ if (enable_sys_prop.empty ()) {
840+ error_ss << " Implicit layer " << filename << " has a present but empty \" enable_sys_prop\" " ;
841+ LoaderLogger::LogErrorMessage (" " , error_ss.str ());
842+ return ;
843+ }
844+ // TODO other validation on the enable_sys_prop?
845+ // If it's not set to true, disable this layer
846+ if (!PlatformUtilsGetBoolSysProp (enable_sys_prop.c_str (), true )) {
847+ enabled = false ;
848+ }
849+ }
850+
851+ std::string disable_sys_prop = disable_prop_node.asString ();
852+ if (disable_sys_prop.empty ()) {
853+ error_ss << " Implicit layer " << filename << " has a present but empty \" disable_sys_prop\" " ;
854+ LoaderLogger::LogErrorMessage (" " , error_ss.str ());
855+ return ;
856+ }
857+ // TODO other validation on the disable_sys_prop?
858+ if (PlatformUtilsGetBoolSysProp (disable_sys_prop.c_str (), false )) {
859+ enabled = false ;
860+ }
861+ #endif
862+
845863 // Not enabled, so pretend like it isn't even there.
846864 if (!enabled) {
847865 error_ss << " Implicit layer " << filename << " is disabled" ;
@@ -910,6 +928,26 @@ void ApiLayerManifestFile::CreateIfValid(ManifestFileType type, const std::strin
910928 manifest_files.back ()->ParseCommon (layer_root_node);
911929}
912930
931+ void ApiLayerManifestFile::CreateIfValid (ManifestFileType type, const std::string &filename, std::istream &json_stream,
932+ LibraryLocator locate_library,
933+ std::vector<std::unique_ptr<ApiLayerManifestFile>> &manifest_files) {
934+ std::ostringstream error_ss (" ApiLayerManifestFile::CreateIfValid " );
935+ Json::CharReaderBuilder builder;
936+ std::string errors;
937+ Json::Value root_node = Json::nullValue;
938+ if (!Json::parseFromStream (builder, json_stream, &root_node, &errors) || !root_node.isObject ()) {
939+ error_ss << " failed to parse " << filename << " ." ;
940+ if (!errors.empty ()) {
941+ error_ss << " (Error message: " << errors << " )" ;
942+ }
943+ error_ss << " Is it a valid layer manifest file?" ;
944+ LoaderLogger::LogErrorMessage (" " , error_ss.str ());
945+ return ;
946+ }
947+
948+ CreateIfValid (type, filename, root_node, locate_library, manifest_files);
949+ }
950+
913951void ApiLayerManifestFile::CreateIfValid (ManifestFileType type, const std::string &filename,
914952 std::vector<std::unique_ptr<ApiLayerManifestFile>> &manifest_files) {
915953 std::ifstream json_stream (filename, std::ifstream::in);
@@ -966,6 +1004,24 @@ void ApiLayerManifestFile::PopulateApiLayerProperties(XrApiLayerProperties &prop
9661004// Find all layer manifest files in the appropriate search paths/registries for the given type.
9671005XrResult ApiLayerManifestFile::FindManifestFiles (const std::string &openxr_command, ManifestFileType type,
9681006 std::vector<std::unique_ptr<ApiLayerManifestFile>> &manifest_files) {
1007+ bool search_json_layer = true ;
1008+ bool search_broker_layer = true ;
1009+
1010+ #if defined(XR_KHR_LOADER_INIT_SUPPORT) && defined(XR_USE_PLATFORM_ANDROID)
1011+ Json::Value virtual_manifest;
1012+ bool system_broker = true ;
1013+ ManifestFileSource runtime_source = ManifestFileSource::FROM_JSON_MANIFEST;
1014+ XrResult result = GetPlatformRuntimeVirtualManifest (virtual_manifest, runtime_source);
1015+ if (XR_SUCCESS == result) {
1016+ if (runtime_source == ManifestFileSource::FROM_INSTALLABLE_BROKER) {
1017+ system_broker = false ;
1018+ search_json_layer = false ;
1019+ }
1020+ } else {
1021+ search_broker_layer = false ;
1022+ }
1023+ #endif // defined(XR_USE_PLATFORM_ANDROID) && defined(XR_KHR_LOADER_INIT_SUPPORT)
1024+
9691025 std::string relative_path;
9701026 std::string override_env_var;
9711027 std::string registry_location;
@@ -998,7 +1054,9 @@ XrResult ApiLayerManifestFile::FindManifestFiles(const std::string &openxr_comma
9981054
9991055 bool override_active = false ;
10001056 std::vector<std::string> filenames;
1001- ReadDataFilesInSearchPaths (override_env_var, relative_path, override_active, filenames);
1057+ if (search_json_layer) {
1058+ ReadDataFilesInSearchPaths (override_env_var, relative_path, override_active, filenames);
1059+ }
10021060
10031061#ifdef XR_OS_WINDOWS
10041062 // Read the registry if the override wasn't active.
@@ -1012,6 +1070,22 @@ XrResult ApiLayerManifestFile::FindManifestFiles(const std::string &openxr_comma
10121070 }
10131071
10141072#if defined(XR_KHR_LOADER_INIT_SUPPORT) && defined(XR_USE_PLATFORM_ANDROID)
1073+ if (search_broker_layer) {
1074+ std::vector<Json::Value> virtual_manifests;
1075+ result = GetPlatformApiLayerVirtualManifests (type == ManifestFileType::MANIFEST_TYPE_IMPLICIT_API_LAYER, system_broker,
1076+ virtual_manifests);
1077+ if (XR_SUCCESS == result) {
1078+ for (const auto &virtual_manifest : virtual_manifests) {
1079+ ApiLayerManifestFile::CreateIfValid (type, " virtual manifest" , virtual_manifest,
1080+ &ApiLayerManifestFile::LocateLibraryInAssets, manifest_files);
1081+ }
1082+ } else {
1083+ LoaderLogger::LogInfoMessage (openxr_command,
1084+ " ApiLayerManifestFile::FindManifestFiles - failed to get virtual manifest files from "
1085+ " system/installable broker, likely not supported by current broker version." );
1086+ }
1087+ }
1088+
10151089 ApiLayerManifestFile::AddManifestFilesAndroid (openxr_command, type, manifest_files);
10161090#endif // defined(XR_USE_PLATFORM_ANDROID) && defined(XR_KHR_LOADER_INIT_SUPPORT)
10171091
0 commit comments