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 <noreply@anthropic.com>
This commit is contained in:
j.foucher 2026-03-01 14:14:30 +01:00
parent 8fcb8b6f30
commit 5fcd98ba73
2 changed files with 22 additions and 5 deletions

View File

@ -22,7 +22,8 @@
"PlatformAllowList": [ "PlatformAllowList": [
"Win64", "Win64",
"Mac", "Mac",
"Linux" "Linux",
"Android"
] ]
}, },
{ {

View File

@ -46,13 +46,29 @@ void FPS_AI_ConvAgentModule::StartupModule()
void FPS_AI_ConvAgentModule::EnsureSSLCertificates() 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)) if (FPlatformFileManager::Get().GetPlatformFile().FileExists(*ProjectCertPath))
{ {
UE_LOG(LogPS_AI_ConvAgent, Log, TEXT("SSL cacert.pem found at: %s"), *ProjectCertPath); UE_LOG(LogPS_AI_ConvAgent, Log, TEXT("SSL cacert.pem found at: %s"), *ProjectCertPath);
return; 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. // Try to auto-copy from the plugin's Resources directory.
TSharedPtr<IPlugin> Plugin = IPluginManager::Get().FindPlugin(TEXT("PS_AI_ConvAgent")); TSharedPtr<IPlugin> Plugin = IPluginManager::Get().FindPlugin(TEXT("PS_AI_ConvAgent"));
if (Plugin.IsValid()) if (Plugin.IsValid())
@ -63,10 +79,10 @@ void FPS_AI_ConvAgentModule::EnsureSSLCertificates()
if (FPlatformFileManager::Get().GetPlatformFile().FileExists(*PluginCertPath)) if (FPlatformFileManager::Get().GetPlatformFile().FileExists(*PluginCertPath))
{ {
FPlatformFileManager::Get().GetPlatformFile().CreateDirectoryTree( FPlatformFileManager::Get().GetPlatformFile().CreateDirectoryTree(
*(FPaths::ProjectContentDir() / TEXT("Certificates"))); *FPaths::GetPath(CopyDestPath));
if (FPlatformFileManager::Get().GetPlatformFile().CopyFile(*ProjectCertPath, *PluginCertPath)) 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; return;
} }
} }