2014-03-14 14:13:41 -04:00
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
# include "LaunchPrivatePCH.h"
# include "ExceptionHandling.h"
2014-10-07 05:41:02 -04:00
# include "AndroidPlatformCrashContext.h"
2014-03-14 14:13:41 -04:00
# include "AndroidJNI.h"
2014-05-13 11:40:41 -04:00
# include <Android/asset_manager.h>
# include <Android/asset_manager_jni.h>
2014-03-14 14:13:41 -04:00
# define JNI_CURRENT_VERSION JNI_VERSION_1_6
2014-06-06 11:44:12 -04:00
# define USE_JNI_HELPER 0
2014-03-14 14:13:41 -04:00
JavaVM * GJavaVM ;
jobject GJavaGlobalThis = NULL ;
2014-07-21 16:20:58 -04:00
// Pointer to target widget for virtual keyboard contents
2014-09-18 19:55:06 -04:00
static IVirtualKeyboardEntry * VirtualKeyboardWidget = NULL ;
2014-07-21 16:20:58 -04:00
2014-04-23 18:59:23 -04:00
extern FString GFilePathBase ;
2014-09-09 12:20:07 -04:00
extern FString GFontPathBase ;
2014-05-13 11:40:41 -04:00
extern bool GOBBinAPK ;
2014-04-23 18:59:23 -04:00
2014-06-06 11:44:12 -04:00
# if USE_JNI_HELPER
2014-03-14 14:13:41 -04:00
//////////////////////////////////////////////////////////////////////////
// FJNIHelper
// Caches access to the environment, attached to the current thread
2014-06-02 07:02:40 -04:00
class FJNIHelper : public TThreadSingleton < FJNIHelper >
2014-03-14 14:13:41 -04:00
{
public :
static JNIEnv * GetEnvironment ( )
{
return Get ( ) . CachedEnv ;
}
private :
JNIEnv * CachedEnv = NULL ;
private :
2014-06-02 07:02:40 -04:00
friend class TThreadSingleton < FJNIHelper > ;
2014-03-14 14:13:41 -04:00
FJNIHelper ( )
: CachedEnv ( nullptr )
{
check ( GJavaVM ) ;
GJavaVM - > GetEnv ( ( void * * ) & CachedEnv , JNI_CURRENT_VERSION ) ;
const jint AttachResult = GJavaVM - > AttachCurrentThread ( & CachedEnv , nullptr ) ;
if ( AttachResult = = JNI_ERR )
{
FPlatformMisc : : LowLevelOutputDebugString ( TEXT ( " FJNIHelper failed to attach thread to Java VM! " ) ) ;
check ( false ) ;
}
}
~ FJNIHelper ( )
{
check ( GJavaVM ) ;
const jint DetachResult = GJavaVM - > DetachCurrentThread ( ) ;
if ( DetachResult = = JNI_ERR )
{
FPlatformMisc : : LowLevelOutputDebugString ( TEXT ( " FJNIHelper failed to detach thread from Java VM! " ) ) ;
check ( false ) ;
}
CachedEnv = nullptr ;
}
} ;
2014-06-02 09:08:02 -04:00
DECLARE_THREAD_SINGLETON ( FJNIHelper ) ;
2014-03-14 14:13:41 -04:00
2014-06-06 11:44:12 -04:00
# endif // USE_JNI_HELPER
2014-03-14 14:13:41 -04:00
JNIEnv * GetJavaEnv ( bool bRequireGlobalThis )
{
//@TODO: ANDROID: Remove the other version if the helper works well
2014-06-06 11:44:12 -04:00
# if USE_JNI_HELPER
2014-03-14 14:13:41 -04:00
if ( ! bRequireGlobalThis | | ( GJavaGlobalThis ! = nullptr ) )
{
return FJNIHelper : : GetEnvironment ( ) ;
}
else
{
return nullptr ;
}
# else
JNIEnv * Env = NULL ;
GJavaVM - > GetEnv ( ( void * * ) & Env , JNI_CURRENT_VERSION ) ;
jint AttachResult = GJavaVM - > AttachCurrentThread ( & Env , NULL ) ;
if ( AttachResult = = JNI_ERR )
{
FPlatformMisc : : LowLevelOutputDebugString ( L " UNIT TEST -- Failed to get the JNI environment! " ) ;
check ( false ) ;
return nullptr ;
}
return ( ! bRequireGlobalThis | | ( GJavaGlobalThis ! = nullptr ) ) ? Env : nullptr ;
# endif
}
//////////////////////////////////////////////////////////////////////////
//Declare all the static members of the class defs
jclass JDef_GameActivity : : ClassID ;
2014-09-18 17:09:29 -04:00
jmethodID JDef_GameActivity : : AndroidThunkJava_KeepScreenOn ;
2014-09-16 17:32:10 -04:00
jmethodID JDef_GameActivity : : AndroidThunkJava_Vibrate ;
2014-03-14 14:13:41 -04:00
jmethodID JDef_GameActivity : : AndroidThunkJava_ShowConsoleWindow ;
2014-07-21 16:20:58 -04:00
jmethodID JDef_GameActivity : : AndroidThunkJava_ShowVirtualKeyboardInput ;
2014-03-14 14:13:41 -04:00
jmethodID JDef_GameActivity : : AndroidThunkJava_LaunchURL ;
2014-07-28 12:50:02 -04:00
jmethodID JDef_GameActivity : : AndroidThunkJava_ResetAchievements ;
2014-04-28 12:19:40 -04:00
jmethodID JDef_GameActivity : : AndroidThunkJava_ShowAdBanner ;
jmethodID JDef_GameActivity : : AndroidThunkJava_HideAdBanner ;
jmethodID JDef_GameActivity : : AndroidThunkJava_CloseAdBanner ;
2014-05-13 11:40:41 -04:00
jmethodID JDef_GameActivity : : AndroidThunkJava_GetAssetManager ;
2014-08-04 20:46:25 -04:00
jmethodID JDef_GameActivity : : AndroidThunkJava_Minimize ;
jmethodID JDef_GameActivity : : AndroidThunkJava_ForceQuit ;
2014-09-09 12:20:07 -04:00
jmethodID JDef_GameActivity : : AndroidThunkJava_GetFontDirectory ;
2014-09-12 11:37:24 -04:00
jmethodID JDef_GameActivity : : AndroidThunkJava_IsMusicActive ;
2014-03-14 14:13:41 -04:00
DEFINE_LOG_CATEGORY_STATIC ( LogEngine , Log , All ) ;
//Game-specific crash reporter
2014-10-01 14:45:04 -04:00
void EngineCrashHandler ( const FGenericCrashContext & GenericContext )
2014-03-14 14:13:41 -04:00
{
const FAndroidCrashContext & Context = static_cast < const FAndroidCrashContext & > ( GenericContext ) ;
static int32 bHasEntered = 0 ;
if ( FPlatformAtomics : : InterlockedCompareExchange ( & bHasEntered , 1 , 0 ) = = 0 )
{
const SIZE_T StackTraceSize = 65535 ;
ANSICHAR * StackTrace = ( ANSICHAR * ) FMemory : : Malloc ( StackTraceSize ) ;
StackTrace [ 0 ] = 0 ;
// Walk the stack and dump it to the allocated memory.
FPlatformStackWalk : : StackWalkAndDump ( StackTrace , StackTraceSize , 0 , Context . Context ) ;
UE_LOG ( LogEngine , Error , TEXT ( " %s " ) , ANSI_TO_TCHAR ( StackTrace ) ) ;
FMemory : : Free ( StackTrace ) ;
GError - > HandleError ( ) ;
FPlatformMisc : : RequestExit ( true ) ;
}
}
2014-09-18 17:09:29 -04:00
void AndroidThunkCpp_KeepScreenOn ( bool Enable )
{
if ( JNIEnv * Env = GetJavaEnv ( ) )
{
// call the java side
Env - > CallVoidMethod ( GJavaGlobalThis , JDef_GameActivity : : AndroidThunkJava_KeepScreenOn , Enable ) ;
}
}
2014-09-16 17:32:10 -04:00
void AndroidThunkCpp_Vibrate ( int64_t Duration )
{
if ( JNIEnv * Env = GetJavaEnv ( ) )
{
// call the java side
Env - > CallVoidMethod ( GJavaGlobalThis , JDef_GameActivity : : AndroidThunkJava_Vibrate , Duration ) ;
}
}
2014-03-14 14:13:41 -04:00
void AndroidThunkCpp_ShowConsoleWindow ( )
{
if ( JNIEnv * Env = GetJavaEnv ( ) )
{
// figure out all the possible texture formats that are allowed
TArray < FString > PossibleTargetPlatforms ;
FPlatformMisc : : GetValidTargetPlatforms ( PossibleTargetPlatforms ) ;
// separate the format suffixes with commas
FString ConsoleText ;
for ( int32 FormatIndex = 0 ; FormatIndex < PossibleTargetPlatforms . Num ( ) ; FormatIndex + + )
{
const FString & Format = PossibleTargetPlatforms [ FormatIndex ] ;
int32 UnderscoreIndex ;
if ( Format . FindLastChar ( ' _ ' , UnderscoreIndex ) )
{
if ( ConsoleText ! = TEXT ( " " ) )
{
ConsoleText + = " , " ;
}
ConsoleText + = Format . Mid ( UnderscoreIndex + 1 ) ;
}
}
// call the java side
jstring ConsoleTextJava = Env - > NewStringUTF ( TCHAR_TO_UTF8 ( * ConsoleText ) ) ;
Env - > CallVoidMethod ( GJavaGlobalThis , JDef_GameActivity : : AndroidThunkJava_ShowConsoleWindow , ConsoleTextJava ) ;
Env - > DeleteLocalRef ( ConsoleTextJava ) ;
}
}
2014-09-18 19:55:06 -04:00
void AndroidThunkCpp_ShowVirtualKeyboardInput ( TSharedPtr < IVirtualKeyboardEntry > TextWidget , int32 InputType , const FString & Label , const FString & Contents )
2014-07-21 16:20:58 -04:00
{
if ( JNIEnv * Env = GetJavaEnv ( ) )
{
// remember target widget for contents
VirtualKeyboardWidget = & ( * TextWidget ) ;
// call the java side
jstring LabelJava = Env - > NewStringUTF ( TCHAR_TO_UTF8 ( * Label ) ) ;
jstring ContentsJava = Env - > NewStringUTF ( TCHAR_TO_UTF8 ( * Contents ) ) ;
Env - > CallVoidMethod ( GJavaGlobalThis , JDef_GameActivity : : AndroidThunkJava_ShowVirtualKeyboardInput , InputType , LabelJava , ContentsJava ) ;
Env - > DeleteLocalRef ( ContentsJava ) ;
Env - > DeleteLocalRef ( LabelJava ) ;
}
}
//This function is declared in the Java-defined class, GameActivity.java: "public native void nativeVirtualKeyboardResult(bool update, String contents);"
extern " C " void Java_com_epicgames_ue4_GameActivity_nativeVirtualKeyboardResult ( JNIEnv * jenv , jobject thiz , jboolean update , jstring contents )
{
// update text widget with new contents if OK pressed
if ( update = = JNI_TRUE )
{
if ( VirtualKeyboardWidget ! = NULL )
{
const char * javaChars = jenv - > GetStringUTFChars ( contents , 0 ) ;
2014-09-18 19:55:06 -04:00
VirtualKeyboardWidget - > SetTextFromVirtualKeyboard ( FText : : FromString ( FString ( UTF8_TO_TCHAR ( javaChars ) ) ) ) ;
2014-07-21 16:20:58 -04:00
//Release the string
jenv - > ReleaseStringUTFChars ( contents , javaChars ) ;
}
}
// release reference
VirtualKeyboardWidget = NULL ;
}
2014-03-14 14:13:41 -04:00
void AndroidThunkCpp_LaunchURL ( const FString & URL )
{
if ( JNIEnv * Env = GetJavaEnv ( ) )
{
jstring Argument = Env - > NewStringUTF ( TCHAR_TO_UTF8 ( * URL ) ) ;
Env - > CallVoidMethod ( GJavaGlobalThis , JDef_GameActivity : : AndroidThunkJava_LaunchURL , Argument ) ;
Env - > DeleteLocalRef ( Argument ) ;
}
}
2014-07-28 12:50:02 -04:00
void AndroidThunkCpp_ResetAchievements ( )
{
if ( JNIEnv * Env = GetJavaEnv ( ) )
{
Env - > CallVoidMethod ( GJavaGlobalThis , JDef_GameActivity : : AndroidThunkJava_ResetAchievements ) ;
}
}
2014-04-28 12:19:40 -04:00
void AndroidThunkCpp_ShowAdBanner ( const FString & AdUnitID , bool bShowOnBottomOfScreen )
{
if ( JNIEnv * Env = GetJavaEnv ( ) )
{
jstring AdUnitIDArg = Env - > NewStringUTF ( TCHAR_TO_UTF8 ( * AdUnitID ) ) ;
Env - > CallVoidMethod ( GJavaGlobalThis , JDef_GameActivity : : AndroidThunkJava_ShowAdBanner , AdUnitIDArg , bShowOnBottomOfScreen ) ;
Env - > DeleteLocalRef ( AdUnitIDArg ) ;
}
}
void AndroidThunkCpp_HideAdBanner ( )
{
if ( JNIEnv * Env = GetJavaEnv ( ) )
{
Env - > CallVoidMethod ( GJavaGlobalThis , JDef_GameActivity : : AndroidThunkJava_HideAdBanner ) ;
}
}
void AndroidThunkCpp_CloseAdBanner ( )
{
if ( JNIEnv * Env = GetJavaEnv ( ) )
{
Env - > CallVoidMethod ( GJavaGlobalThis , JDef_GameActivity : : AndroidThunkJava_CloseAdBanner ) ;
}
}
2014-05-13 11:40:41 -04:00
namespace
{
jobject GJavaAssetManager = NULL ;
AAssetManager * GAssetManagerRef = NULL ;
}
AAssetManager * AndroidThunkCpp_GetAssetManager ( )
{
if ( ! GAssetManagerRef )
{
if ( JNIEnv * Env = GetJavaEnv ( ) )
{
GJavaAssetManager = Env - > CallObjectMethod ( GJavaGlobalThis , JDef_GameActivity : : AndroidThunkJava_GetAssetManager ) ;
Env - > NewGlobalRef ( GJavaAssetManager ) ;
GAssetManagerRef = AAssetManager_fromJava ( Env , GJavaAssetManager ) ;
}
}
return GAssetManagerRef ;
}
2014-08-04 20:46:25 -04:00
void AndroidThunkCpp_Minimize ( )
{
if ( JNIEnv * Env = GetJavaEnv ( ) )
{
Env - > CallVoidMethod ( GJavaGlobalThis , JDef_GameActivity : : AndroidThunkJava_Minimize ) ;
}
}
void AndroidThunkCpp_ForceQuit ( )
{
if ( JNIEnv * Env = GetJavaEnv ( ) )
{
Env - > CallVoidMethod ( GJavaGlobalThis , JDef_GameActivity : : AndroidThunkJava_ForceQuit ) ;
}
}
2014-09-12 11:37:24 -04:00
bool AndroidThunkCpp_IsMusicActive ( )
{
bool active = false ;
if ( JNIEnv * Env = GetJavaEnv ( ) )
{
active = ( bool ) Env - > CallObjectMethod ( GJavaGlobalThis , JDef_GameActivity : : AndroidThunkJava_IsMusicActive ) ;
}
return active ;
}
2014-03-14 14:13:41 -04:00
//The JNI_OnLoad function is triggered by loading the game library from
//the Java source file.
// static
// {
// System.loadLibrary("MyGame");
// }
//
// Use the JNI_OnLoad function to map all the class IDs and method IDs to their respective
// variables. That way, later when the Java functions need to be called, the IDs will be ready.
// It is much slower to keep looking up the class and method IDs.
2014-08-04 20:46:25 -04:00
# if UE_BUILD_SHIPPING
# define CHECK_JNI_RESULT( Id )
# else
# define CHECK_JNI_RESULT( Id ) \
if ( Id = = 0 ) \
{ \
FPlatformMisc : : LowLevelOutputDebugString ( TEXT ( " JNI_OnLoad: Failed to find " # Id ) ) ; \
}
# endif
2014-03-14 14:13:41 -04:00
JNIEXPORT jint JNI_OnLoad ( JavaVM * InJavaVM , void * InReserved )
{
FPlatformMisc : : LowLevelOutputDebugString ( L " In the JNI_OnLoad function " ) ;
JNIEnv * env = NULL ;
InJavaVM - > GetEnv ( ( void * * ) & env , JNI_CURRENT_VERSION ) ;
2014-08-04 20:46:25 -04:00
// if you have problems with stuff being missing esspecially in distribution builds then it could be because proguard is stripping things from java
// check proguard-project.txt and see if your stuff is included in the exceptions
2014-03-14 14:13:41 -04:00
GJavaVM = InJavaVM ;
JDef_GameActivity : : ClassID = env - > FindClass ( " com/epicgames/ue4/GameActivity " ) ;
2014-08-04 20:46:25 -04:00
CHECK_JNI_RESULT ( JDef_GameActivity : : ClassID ) ;
2014-03-14 14:13:41 -04:00
2014-09-18 17:09:29 -04:00
JDef_GameActivity : : AndroidThunkJava_KeepScreenOn = env - > GetMethodID ( JDef_GameActivity : : ClassID , " AndroidThunkJava_KeepScreenOn " , " (Z)V " ) ;
CHECK_JNI_RESULT ( JDef_GameActivity : : AndroidThunkJava_KeepScreenOn ) ;
2014-09-16 17:32:10 -04:00
JDef_GameActivity : : AndroidThunkJava_Vibrate = env - > GetMethodID ( JDef_GameActivity : : ClassID , " AndroidThunkJava_Vibrate " , " (J)V " ) ;
CHECK_JNI_RESULT ( JDef_GameActivity : : AndroidThunkJava_Vibrate ) ;
2014-03-14 14:13:41 -04:00
JDef_GameActivity : : AndroidThunkJava_ShowConsoleWindow = env - > GetMethodID ( JDef_GameActivity : : ClassID , " AndroidThunkJava_ShowConsoleWindow " , " (Ljava/lang/String;)V " ) ;
2014-08-04 20:46:25 -04:00
CHECK_JNI_RESULT ( JDef_GameActivity : : AndroidThunkJava_ShowConsoleWindow ) ;
2014-07-21 16:20:58 -04:00
JDef_GameActivity : : AndroidThunkJava_ShowVirtualKeyboardInput = env - > GetMethodID ( JDef_GameActivity : : ClassID , " AndroidThunkJava_ShowVirtualKeyboardInput " , " (ILjava/lang/String;Ljava/lang/String;)V " ) ;
2014-08-04 20:46:25 -04:00
CHECK_JNI_RESULT ( JDef_GameActivity : : AndroidThunkJava_ShowVirtualKeyboardInput ) ;
2014-03-14 14:13:41 -04:00
JDef_GameActivity : : AndroidThunkJava_LaunchURL = env - > GetMethodID ( JDef_GameActivity : : ClassID , " AndroidThunkJava_LaunchURL " , " (Ljava/lang/String;)V " ) ;
2014-08-04 20:46:25 -04:00
CHECK_JNI_RESULT ( JDef_GameActivity : : AndroidThunkJava_LaunchURL ) ;
2014-07-28 12:50:02 -04:00
JDef_GameActivity : : AndroidThunkJava_ResetAchievements = env - > GetMethodID ( JDef_GameActivity : : ClassID , " AndroidThunkJava_ResetAchievements " , " ()V " ) ;
2014-04-28 12:19:40 -04:00
JDef_GameActivity : : AndroidThunkJava_ShowAdBanner = env - > GetMethodID ( JDef_GameActivity : : ClassID , " AndroidThunkJava_ShowAdBanner " , " (Ljava/lang/String;Z)V " ) ;
2014-08-04 20:46:25 -04:00
CHECK_JNI_RESULT ( JDef_GameActivity : : AndroidThunkJava_ShowAdBanner ) ;
2014-04-28 12:19:40 -04:00
JDef_GameActivity : : AndroidThunkJava_HideAdBanner = env - > GetMethodID ( JDef_GameActivity : : ClassID , " AndroidThunkJava_HideAdBanner " , " ()V " ) ;
2014-08-04 20:46:25 -04:00
CHECK_JNI_RESULT ( JDef_GameActivity : : AndroidThunkJava_HideAdBanner ) ;
2014-04-28 12:19:40 -04:00
JDef_GameActivity : : AndroidThunkJava_CloseAdBanner = env - > GetMethodID ( JDef_GameActivity : : ClassID , " AndroidThunkJava_CloseAdBanner " , " ()V " ) ;
2014-08-04 20:46:25 -04:00
CHECK_JNI_RESULT ( JDef_GameActivity : : AndroidThunkJava_CloseAdBanner ) ;
2014-05-13 11:40:41 -04:00
JDef_GameActivity : : AndroidThunkJava_GetAssetManager = env - > GetMethodID ( JDef_GameActivity : : ClassID , " AndroidThunkJava_GetAssetManager " , " ()Landroid/content/res/AssetManager; " ) ;
2014-08-04 20:46:25 -04:00
CHECK_JNI_RESULT ( JDef_GameActivity : : AndroidThunkJava_GetAssetManager ) ;
JDef_GameActivity : : AndroidThunkJava_Minimize = env - > GetMethodID ( JDef_GameActivity : : ClassID , " AndroidThunkJava_Minimize " , " ()V " ) ;
CHECK_JNI_RESULT ( JDef_GameActivity : : AndroidThunkJava_Minimize ) ;
JDef_GameActivity : : AndroidThunkJava_ForceQuit = env - > GetMethodID ( JDef_GameActivity : : ClassID , " AndroidThunkJava_ForceQuit " , " ()V " ) ;
CHECK_JNI_RESULT ( JDef_GameActivity : : AndroidThunkJava_ForceQuit ) ;
2014-09-09 12:20:07 -04:00
JDef_GameActivity : : AndroidThunkJava_GetFontDirectory = env - > GetStaticMethodID ( JDef_GameActivity : : ClassID , " AndroidThunkJava_GetFontDirectory " , " ()Ljava/lang/String; " ) ;
CHECK_JNI_RESULT ( JDef_GameActivity : : AndroidThunkJava_GetFontDirectory ) ;
2014-09-12 11:37:24 -04:00
JDef_GameActivity : : AndroidThunkJava_IsMusicActive = env - > GetMethodID ( JDef_GameActivity : : ClassID , " AndroidThunkJava_IsMusicActive " , " ()Z " ) ;
2014-09-18 16:41:28 -04:00
CHECK_JNI_RESULT ( JDef_GameActivity : : AndroidThunkJava_IsMusicActive ) ;
2014-05-21 18:18:08 -04:00
2014-03-14 14:13:41 -04:00
// hook signals
# if UE_BUILD_DEBUG
if ( GAlwaysReportCrash )
# else
if ( ! FPlatformMisc : : IsDebuggerPresent ( ) | | GAlwaysReportCrash )
# endif
{
FPlatformMisc : : SetCrashHandler ( EngineCrashHandler ) ;
}
2014-04-23 18:59:23 -04:00
// Cache path to external storage
jclass EnvClass = env - > FindClass ( " android/os/Environment " ) ;
jmethodID getExternalStorageDir = env - > GetStaticMethodID ( EnvClass , " getExternalStorageDirectory " , " ()Ljava/io/File; " ) ;
jobject externalStoragePath = env - > CallStaticObjectMethod ( EnvClass , getExternalStorageDir , nullptr ) ;
jmethodID getFilePath = env - > GetMethodID ( env - > FindClass ( " java/io/File " ) , " getPath " , " ()Ljava/lang/String; " ) ;
jstring pathString = ( jstring ) env - > CallObjectMethod ( externalStoragePath , getFilePath , nullptr ) ;
const char * nativePathString = env - > GetStringUTFChars ( pathString , 0 ) ;
// Copy that somewhere safe
GFilePathBase = FString ( nativePathString ) ;
// then release...
env - > ReleaseStringUTFChars ( pathString , nativePathString ) ;
FPlatformMisc : : LowLevelOutputDebugStringf ( TEXT ( " Path found as '%s' \n " ) , * GFilePathBase ) ;
2014-05-13 11:40:41 -04:00
// Next we check to see if the OBB file is in the APK
jmethodID isOBBInAPKMethod = env - > GetStaticMethodID ( JDef_GameActivity : : ClassID , " isOBBInAPK " , " ()Z " ) ;
GOBBinAPK = ( bool ) env - > CallStaticBooleanMethod ( JDef_GameActivity : : ClassID , isOBBInAPKMethod , nullptr ) ;
2014-04-23 18:59:23 -04:00
2014-09-09 12:20:07 -04:00
// Get the system font directory
jstring fontPath = ( jstring ) env - > CallStaticObjectMethod ( JDef_GameActivity : : ClassID , JDef_GameActivity : : AndroidThunkJava_GetFontDirectory ) ;
const char * nativeFontPathString = env - > GetStringUTFChars ( fontPath , 0 ) ;
GFontPathBase = FString ( nativeFontPathString ) ;
env - > ReleaseStringUTFChars ( fontPath , nativeFontPathString ) ;
FPlatformMisc : : LowLevelOutputDebugStringf ( TEXT ( " Font Path found as '%s' \n " ) , * GFontPathBase ) ;
2014-03-14 14:13:41 -04:00
// Wire up to core delegates, so core code can call out to Java
DECLARE_DELEGATE_OneParam ( FAndroidLaunchURLDelegate , const FString & ) ;
extern CORE_API FAndroidLaunchURLDelegate OnAndroidLaunchURL ;
OnAndroidLaunchURL = FAndroidLaunchURLDelegate : : CreateStatic ( & AndroidThunkCpp_LaunchURL ) ;
2014-08-04 20:46:25 -04:00
FPlatformMisc : : LowLevelOutputDebugString ( L " In the JNI_OnLoad function 5 " ) ;
2014-03-14 14:13:41 -04:00
return JNI_CURRENT_VERSION ;
}
//Native-defined functions
//This function is declared in the Java-defined class, GameActivity.java: "public native void nativeSetGlobalActivity();"
extern " C " void Java_com_epicgames_ue4_GameActivity_nativeSetGlobalActivity ( JNIEnv * jenv , jobject thiz )
{
if ( ! GJavaGlobalThis )
{
GJavaGlobalThis = jenv - > NewGlobalRef ( thiz ) ;
if ( ! GJavaGlobalThis )
{
FPlatformMisc : : LowLevelOutputDebugString ( L " Error setting the global GameActivity activity " ) ;
check ( false ) ;
}
}
}
extern " C " bool Java_com_epicgames_ue4_GameActivity_nativeIsShippingBuild ( JNIEnv * LocalJNIEnv , jobject LocalThiz )
{
# if UE_BUILD_SHIPPING
return JNI_TRUE ;
# else
return JNI_FALSE ;
# endif
}