From 5fcd98ba730e6a54feb928f056aaa2a24aa9fa88 Mon Sep 17 00:00:00 2001 From: "j.foucher" Date: Sun, 1 Mar 2026 14:14:30 +0100 Subject: [PATCH] Add Android platform support to plugin Whitelist Android in .uplugin Runtime module and handle read-only APK paths for SSL certificate copy on Android (ProjectSavedDir fallback). No change to Win64 behavior. Co-Authored-By: Claude Opus 4.6 --- .../PS_AI_ConvAgent/PS_AI_ConvAgent.uplugin | 3 ++- .../Private/PS_AI_ConvAgent.cpp | 24 +++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Unreal/PS_AI_Agent/Plugins/PS_AI_ConvAgent/PS_AI_ConvAgent.uplugin b/Unreal/PS_AI_Agent/Plugins/PS_AI_ConvAgent/PS_AI_ConvAgent.uplugin index 164b959..aa81aa4 100644 --- a/Unreal/PS_AI_Agent/Plugins/PS_AI_ConvAgent/PS_AI_ConvAgent.uplugin +++ b/Unreal/PS_AI_Agent/Plugins/PS_AI_ConvAgent/PS_AI_ConvAgent.uplugin @@ -22,7 +22,8 @@ "PlatformAllowList": [ "Win64", "Mac", - "Linux" + "Linux", + "Android" ] }, { diff --git a/Unreal/PS_AI_Agent/Plugins/PS_AI_ConvAgent/Source/PS_AI_ConvAgent/Private/PS_AI_ConvAgent.cpp b/Unreal/PS_AI_Agent/Plugins/PS_AI_ConvAgent/Source/PS_AI_ConvAgent/Private/PS_AI_ConvAgent.cpp index f89f0ea..69e4014 100644 --- a/Unreal/PS_AI_Agent/Plugins/PS_AI_ConvAgent/Source/PS_AI_ConvAgent/Private/PS_AI_ConvAgent.cpp +++ b/Unreal/PS_AI_Agent/Plugins/PS_AI_ConvAgent/Source/PS_AI_ConvAgent/Private/PS_AI_ConvAgent.cpp @@ -46,13 +46,29 @@ void FPS_AI_ConvAgentModule::StartupModule() void FPS_AI_ConvAgentModule::EnsureSSLCertificates() { - const FString ProjectCertPath = FPaths::ProjectContentDir() / TEXT("Certificates") / TEXT("cacert.pem"); + const FString CertRelPath = FString(TEXT("Certificates")) / TEXT("cacert.pem"); + const FString ProjectCertPath = FPaths::ProjectContentDir() / CertRelPath; + + // Check standard location (works on all platforms, including Android if cert was staged). if (FPlatformFileManager::Get().GetPlatformFile().FileExists(*ProjectCertPath)) { UE_LOG(LogPS_AI_ConvAgent, Log, TEXT("SSL cacert.pem found at: %s"), *ProjectCertPath); return; } +#if PLATFORM_ANDROID + // On Android, ProjectContentDir lives inside the APK (read-only). + // Use ProjectSavedDir as a writable fallback for the cert copy. + const FString CopyDestPath = FPaths::ProjectSavedDir() / CertRelPath; + if (FPlatformFileManager::Get().GetPlatformFile().FileExists(*CopyDestPath)) + { + UE_LOG(LogPS_AI_ConvAgent, Log, TEXT("SSL cacert.pem found at: %s"), *CopyDestPath); + return; + } +#else + const FString CopyDestPath = ProjectCertPath; +#endif + // Try to auto-copy from the plugin's Resources directory. TSharedPtr Plugin = IPluginManager::Get().FindPlugin(TEXT("PS_AI_ConvAgent")); if (Plugin.IsValid()) @@ -63,10 +79,10 @@ void FPS_AI_ConvAgentModule::EnsureSSLCertificates() if (FPlatformFileManager::Get().GetPlatformFile().FileExists(*PluginCertPath)) { FPlatformFileManager::Get().GetPlatformFile().CreateDirectoryTree( - *(FPaths::ProjectContentDir() / TEXT("Certificates"))); - if (FPlatformFileManager::Get().GetPlatformFile().CopyFile(*ProjectCertPath, *PluginCertPath)) + *FPaths::GetPath(CopyDestPath)); + if (FPlatformFileManager::Get().GetPlatformFile().CopyFile(*CopyDestPath, *PluginCertPath)) { - UE_LOG(LogPS_AI_ConvAgent, Log, TEXT("Copied SSL cacert.pem from plugin to: %s"), *ProjectCertPath); + UE_LOG(LogPS_AI_ConvAgent, Log, TEXT("Copied SSL cacert.pem from plugin to: %s"), *CopyDestPath); return; } }