blob: 8f355716d17a8a7480a217b0f4da33fa8847cac2 [file]
/*
* Copyright (C) 2026 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_VULKAN_LAYERS_LAYER_ENVIRONMENT_H
#define ANDROID_VULKAN_LAYERS_LAYER_ENVIRONMENT_H
#include <memory>
#include <string>
#include <vector>
namespace android {
struct NativeLoaderNamespace;
}
namespace vulkan {
namespace layers {
// Abstraction for a loaded dynamic library to allow mocking symbols
class DynamicLibrary {
public:
virtual ~DynamicLibrary() = default;
virtual void* GetSymbol(const std::string& name) const = 0;
};
class LayerEnvironment {
public:
LayerEnvironment() = default;
virtual ~LayerEnvironment() = default;
// Environment queries
virtual bool IsDebuggable() const;
virtual bool IsOSDebuggable() const;
virtual bool IsAppDebuggable() const;
virtual bool IsAppInjectable() const;
virtual std::string GetProcessName() const;
virtual bool IsZygoteProcess() const;
virtual std::string GetPackageName() const;
virtual android::NativeLoaderNamespace* GetAppNamespace() const;
// System properties
virtual std::string GetProperty(const std::string& key) const;
// Settings
virtual std::string GetDebugLayers() const;
virtual std::string GetLayerPaths() const;
virtual std::string GetExplicitLayerPaths() const;
virtual std::string GetImplicitLayerPaths() const;
// Filesystem operations
virtual bool FileExists(const std::string& path) const;
virtual std::vector<std::string> ListDirectory(
const std::string& path) const;
virtual std::vector<std::string> ReadFileLines(
const std::string& path) const;
virtual std::vector<std::string> ListZipDirectory(
const std::string& zipPath,
const std::string& dirInZip) const;
// Library loading wrappers
virtual std::unique_ptr<DynamicLibrary> LoadLibrary(
const std::string& path) const;
virtual std::unique_ptr<DynamicLibrary> LoadLibraryInNamespace(
const std::string& path,
android::NativeLoaderNamespace* ns) const;
virtual std::unique_ptr<DynamicLibrary> LoadLibraryInExportedNamespace(
const std::string& path,
const std::string& ns_name) const;
};
} // namespace layers
} // namespace vulkan
#endif // ANDROID_VULKAN_LAYERS_LAYER_ENVIRONMENT_H