Skip to content

Commit 35862ce

Browse files
committed
Simplify mechanism to pass input args to Android app
1 parent d62218d commit 35862ce

File tree

4 files changed

+5
-119
lines changed

4 files changed

+5
-119
lines changed

integration-test/Integration.Tests.Android.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ BeforeAll {
244244
# TODO: Re-enable once Android SDK tag persistence is fixed (`test.crash_id` tag set before crash is not synced to the captured crash on Android)
245245

246246
# Write-Host "Running crash-capture test (will crash)..." -ForegroundColor Yellow
247-
# $global:AndroidCrashResult = Invoke-AndroidApp -ExecutablePath $script:ActivityName -Arguments "-e test crash-capture"
247+
# $cmdlineCrashArgs = "-e cmdline '-crash-capture'"
248+
# $global:AndroidCrashResult = Invoke-AndroidApp -ExecutablePath $script:ActivityName -Arguments $cmdlineCrashArgs
248249

249250
# Write-Host "Crash test exit code: $($global:AndroidCrashResult.ExitCode)" -ForegroundColor Cyan
250251

@@ -256,7 +257,8 @@ BeforeAll {
256257

257258
Write-Host "Running message-capture test (will upload crash from previous run)..." -ForegroundColor Yellow
258259
# TODO: When AndroidProvider is added to app-runner: Invoke-DeviceApp $script:ActivityName -Arguments "-e test message-capture"
259-
$global:AndroidMessageResult = Invoke-AndroidApp -ExecutablePath $script:ActivityName -Arguments "-e test message-capture"
260+
$cmdlineMessageArgs = "-e cmdline '-message-capture'"
261+
$global:AndroidMessageResult = Invoke-AndroidApp -ExecutablePath $script:ActivityName -Arguments $cmdlineMessageArgs
260262

261263
Write-Host "Message test exit code: $($global:AndroidMessageResult.ExitCode)" -ForegroundColor Cyan
262264
}

sample/Source/SentryPlayground/SentryPlayground.Build.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,5 @@ public SentryPlayground(ReadOnlyTargetRules Target) : base(Target)
2020
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
2121

2222
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
23-
24-
// Register Android UPL for Intent extras handling (integration tests)
25-
if (Target.Platform == UnrealTargetPlatform.Android)
26-
{
27-
string PluginPath = Utils.MakePathRelativeTo(ModuleDirectory, Target.RelativeEnginePath);
28-
AdditionalPropertiesForReceipt.Add("AndroidPlugin", Path.Combine(PluginPath, "SentryPlayground_Android_UPL.xml"));
29-
}
3023
}
3124
}

sample/Source/SentryPlayground/SentryPlaygroundGameInstance.cpp

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -14,73 +14,13 @@
1414
#include "Misc/CommandLine.h"
1515
#include "Engine/Engine.h"
1616

17-
#if PLATFORM_ANDROID
18-
#include "Android/AndroidJNI.h"
19-
#include "Android/AndroidApplication.h"
20-
21-
// Helper function to get command-line arguments from Android Intent extras
22-
// Calls the AndroidThunkJava_GetIntentCommandLine() method added via UPL
23-
FString GetIntentCommandLineFromAndroid()
24-
{
25-
FString Result;
26-
27-
if (JNIEnv* Env = FAndroidApplication::GetJavaEnv())
28-
{
29-
// Get GameActivity class
30-
jclass GameActivityClass = FAndroidApplication::FindJavaClass("com/epicgames/unreal/GameActivity");
31-
if (GameActivityClass != nullptr)
32-
{
33-
// Find our custom method: AndroidThunkJava_GetIntentCommandLine()
34-
jmethodID GetIntentCmdLineMethod = Env->GetMethodID(
35-
GameActivityClass,
36-
"AndroidThunkJava_GetIntentCommandLine",
37-
"()Ljava/lang/String;"
38-
);
39-
40-
if (GetIntentCmdLineMethod != nullptr)
41-
{
42-
// Get the GameActivity instance
43-
jobject GameActivityObj = FAndroidApplication::GetGameActivityThis();
44-
if (GameActivityObj != nullptr)
45-
{
46-
// Call the method
47-
jstring JavaResult = (jstring)Env->CallObjectMethod(GameActivityObj, GetIntentCmdLineMethod);
48-
if (JavaResult != nullptr)
49-
{
50-
// Convert Java string to FString
51-
const char* JavaChars = Env->GetStringUTFChars(JavaResult, nullptr);
52-
Result = FString(UTF8_TO_TCHAR(JavaChars));
53-
Env->ReleaseStringUTFChars(JavaResult, JavaChars);
54-
Env->DeleteLocalRef(JavaResult);
55-
}
56-
}
57-
}
58-
59-
Env->DeleteLocalRef(GameActivityClass);
60-
}
61-
}
62-
63-
return Result;
64-
}
65-
#endif
66-
6717
void USentryPlaygroundGameInstance::Init()
6818
{
6919
Super::Init();
7020

7121
FString CommandLine = FCommandLine::Get();
7222

73-
#if PLATFORM_ANDROID
74-
// On Android, merge Intent extras into command line
75-
// Intent extras are passed via: adb shell am start -n <package>/<activity> -e test crash-capture
76-
FString IntentCommandLine = GetIntentCommandLineFromAndroid();
77-
if (!IntentCommandLine.IsEmpty())
78-
{
79-
UE_LOG(LogSentrySample, Display, TEXT("[SentryPlayground] Intent command line: %s"), *IntentCommandLine);
80-
// Prepend Intent args so they take precedence over default command line
81-
CommandLine = IntentCommandLine + TEXT(" ") + CommandLine;
82-
}
83-
#endif
23+
UE_LOG(LogSentrySample, Display, TEXT("Startin app with commandline: %s\n"), *CommandLine);
8424

8525
// Check for expected test parameters to decide between running integration tests
8626
// or launching the sample app with UI for manual testing

sample/Source/SentryPlayground/SentryPlayground_Android_UPL.xml

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)