Skip to content

Commit ee8a1dc

Browse files
fix(jni): fix and use cache
1 parent b3fef1e commit ee8a1dc

File tree

181 files changed

+5778
-2857
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+5778
-2857
lines changed

goldenmaster/Plugins/Counter/Source/CounterJni/Private/Generated/CounterJni.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717

1818
#include "Counter/CounterJni.h"
1919
#include "Counter/Generated/CounterFactory.h"
20+
#include "Counter/Generated/Jni/CounterJniCache.h"
2021
#include "Engine/Engine.h"
2122
#include "CounterSettings.h"
2223
#include "Modules/ModuleManager.h"
@@ -25,12 +26,18 @@ limitations under the License.
2526

2627
void FCounterJniModule::StartupModule()
2728
{
29+
#if PLATFORM_ANDROID && USE_ANDROID_JNI
30+
CounterJniCache::init();
31+
#endif
2832
}
2933

3034
void FCounterJniModule::ShutdownModule()
3135
{
3236
// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
3337
// we call this function before unloading the module.
38+
#if PLATFORM_ANDROID && USE_ANDROID_JNI
39+
CounterJniCache::clear();
40+
#endif
3441
}
3542

3643
IMPLEMENT_MODULE(FCounterJniModule, CounterJni)

goldenmaster/Plugins/Counter/Source/CounterJni/Private/Generated/Jni/CounterCounterJniAdapter.cpp

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ limitations under the License.
2222

2323
#include "Counter/Generated/Jni/CounterCounterJniAdapter.h"
2424
#include "Counter/Generated/Jni/CounterDataJavaConverter.h"
25+
#include "Counter/Generated/Jni/CounterJniCache.h"
2526
#include "Async/Future.h"
2627
#include "Async/Async.h"
2728
#include "Engine/Engine.h"
@@ -58,7 +59,6 @@ void UCounterCounterJniAdapter::Initialize(FSubsystemCollectionBase& Collection)
5859
gUCounterCounterJniAdapterHandle = this;
5960
#if PLATFORM_ANDROID
6061
#if USE_ANDROID_JNI
61-
m_javaJniServiceClass = FAndroidApplication::FindJavaClassGlobalRef("counter/counterjniservice/CounterJniService");
6262
auto Env = FAndroidApplication::GetJavaEnv();
6363
jclass BridgeClass = FAndroidApplication::FindJavaClassGlobalRef("counter/counterjniservice/CounterJniServiceStarter");
6464
if (BridgeClass == nullptr)
@@ -67,7 +67,7 @@ void UCounterCounterJniAdapter::Initialize(FSubsystemCollectionBase& Collection)
6767
return;
6868
}
6969
auto functionSignature = "(Landroid/content/Context;)Lcounter/counter_api/ICounter;";
70-
jmethodID StartMethod = Env->GetStaticMethodID(BridgeClass, "start", functionSignature);
70+
static jmethodID StartMethod = Env->GetStaticMethodID(BridgeClass, "start", functionSignature);
7171
if (StartMethod == nullptr)
7272
{
7373
UE_LOG(LogTemp, Warning, TEXT("CounterJavaServiceStarter:start; method not found"));
@@ -78,6 +78,7 @@ void UCounterCounterJniAdapter::Initialize(FSubsystemCollectionBase& Collection)
7878

7979
m_javaJniServiceInstance = Env->NewGlobalRef(localRef);
8080
Env->DeleteLocalRef(localRef);
81+
Env->DeleteGlobalRef(BridgeClass);
8182
#endif
8283
#endif
8384
}
@@ -88,7 +89,6 @@ void UCounterCounterJniAdapter::Deinitialize()
8889
gUCounterCounterJniAdapterHandle = nullptr;
8990
#if PLATFORM_ANDROID
9091
#if USE_ANDROID_JNI
91-
m_javaJniServiceClass = nullptr;
9292
if (m_javaJniServiceInstance)
9393
{
9494
FAndroidApplication::GetJavaEnv()->DeleteGlobalRef(m_javaJniServiceInstance);
@@ -99,7 +99,7 @@ void UCounterCounterJniAdapter::Deinitialize()
9999
jclass BridgeClass = FAndroidApplication::FindJavaClassGlobalRef("counter/counterjniservice/CounterJniServiceStarter");
100100
if (BridgeClass != nullptr)
101101
{
102-
jmethodID StopMethod = Env->GetStaticMethodID(BridgeClass, "stop", "(Landroid/content/Context;)V");
102+
static jmethodID StopMethod = Env->GetStaticMethodID(BridgeClass, "stop", "(Landroid/content/Context;)V");
103103
if (StopMethod != nullptr)
104104
{
105105
jobject Activity = FJavaWrapper::GameActivityThis; // Unreal’s activity
@@ -110,6 +110,7 @@ void UCounterCounterJniAdapter::Deinitialize()
110110
UE_LOG(LogTemp, Warning, TEXT("CounterJavaServiceStarter:stop; method not found, failed to stop service"));
111111
return;
112112
}
113+
Env->DeleteGlobalRef(BridgeClass);
113114
}
114115
else
115116
{
@@ -155,13 +156,13 @@ void UCounterCounterJniAdapter::callJniServiceReady(bool isServiceReady)
155156
#if PLATFORM_ANDROID && USE_ANDROID_JNI
156157
if (JNIEnv* Env = FAndroidApplication::GetJavaEnv())
157158
{
158-
if (!m_javaJniServiceClass || !m_javaJniServiceInstance)
159+
if (!CounterJniCache::javaClassCounter || !m_javaJniServiceInstance)
159160
{
160161
UE_LOG(LogCounterCounter_JNI, Warning, TEXT("counter/counterjniservice/CounterJniService:nativeServiceReady(Z)V CLASS not found"));
161162
return;
162163
}
163164

164-
static const jmethodID MethodID = Env->GetMethodID(m_javaJniServiceClass, "nativeServiceReady", "(Z)V");
165+
static const jmethodID MethodID = CounterJniCache::serviceClassCounterReadyMethodID;
165166

166167
if (MethodID != nullptr)
167168
{
@@ -181,12 +182,12 @@ void UCounterCounterJniAdapter::OnValueChangedSignal(const FCustomTypesVector3D&
181182
UE_LOG(LogCounterCounter_JNI, Verbose, TEXT("Notify java jni UCounterCounterJniAdapter::onValueChanged "));
182183
if (JNIEnv* Env = FAndroidApplication::GetJavaEnv())
183184
{
184-
if (m_javaJniServiceClass == nullptr || m_javaJniServiceInstance == nullptr)
185+
if (CounterJniCache::serviceClassCounter == nullptr || m_javaJniServiceInstance == nullptr)
185186
{
186187
UE_LOG(LogCounterCounter_JNI, Warning, TEXT("counter/counterjniservice/CounterJniService:onValueChanged (LcustomTypes/customTypes_api/Vector3D;Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;[LcustomTypes/customTypes_api/Vector3D;[Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;)V CLASS not found"));
187188
return;
188189
}
189-
static const jmethodID MethodID = Env->GetMethodID(m_javaJniServiceClass, "onValueChanged", "(LcustomTypes/customTypes_api/Vector3D;Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;[LcustomTypes/customTypes_api/Vector3D;[Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;)V");
190+
jmethodID MethodID = CounterJniCache::serviceClassCounterValueChangedSignalMethodID;
190191
if (MethodID == nullptr)
191192
{
192193
UE_LOG(LogCounterCounter_JNI, Warning, TEXT("counter/counterjniservice/CounterJniService:onValueChanged (LcustomTypes/customTypes_api/Vector3D;Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;[LcustomTypes/customTypes_api/Vector3D;[Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;)V not found"));
@@ -211,13 +212,12 @@ void UCounterCounterJniAdapter::OnVectorChanged(const FCustomTypesVector3D& Vect
211212
UE_LOG(LogCounterCounter_JNI, Verbose, TEXT("Notify java jni UCounterCounterJniAdapter::OnVector "));
212213
if (JNIEnv* Env = FAndroidApplication::GetJavaEnv())
213214
{
214-
if (m_javaJniServiceClass == nullptr)
215+
if (CounterJniCache::serviceClassCounter == nullptr)
215216
{
216217
UE_LOG(LogCounterCounter_JNI, Warning, TEXT("counter/counterjniservice/CounterJniService::onVectorChanged(LcustomTypes/customTypes_api/Vector3D;)V CLASS not found"));
217218
return;
218219
}
219-
220-
static const jmethodID MethodID = Env->GetMethodID(m_javaJniServiceClass, "onVectorChanged", "(LcustomTypes/customTypes_api/Vector3D;)V");
220+
jmethodID MethodID = CounterJniCache::serviceClassCounterVectorChangedMethodID;
221221
if (MethodID == nullptr)
222222
{
223223
UE_LOG(LogCounterCounter_JNI, Warning, TEXT("counter/counterjniservice/CounterJniService:onVectorChanged(LcustomTypes/customTypes_api/Vector3D;)V not found"));
@@ -236,13 +236,12 @@ void UCounterCounterJniAdapter::OnExternVectorChanged(const FVector& ExternVecto
236236
UE_LOG(LogCounterCounter_JNI, Verbose, TEXT("Notify java jni UCounterCounterJniAdapter::OnExternVector "));
237237
if (JNIEnv* Env = FAndroidApplication::GetJavaEnv())
238238
{
239-
if (m_javaJniServiceClass == nullptr)
239+
if (CounterJniCache::serviceClassCounter == nullptr)
240240
{
241241
UE_LOG(LogCounterCounter_JNI, Warning, TEXT("counter/counterjniservice/CounterJniService::onExternVectorChanged(Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;)V CLASS not found"));
242242
return;
243243
}
244-
245-
static const jmethodID MethodID = Env->GetMethodID(m_javaJniServiceClass, "onExternVectorChanged", "(Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;)V");
244+
jmethodID MethodID = CounterJniCache::serviceClassCounterExternVectorChangedMethodID;
246245
if (MethodID == nullptr)
247246
{
248247
UE_LOG(LogCounterCounter_JNI, Warning, TEXT("counter/counterjniservice/CounterJniService:onExternVectorChanged(Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;)V not found"));
@@ -261,13 +260,12 @@ void UCounterCounterJniAdapter::OnVectorArrayChanged(const TArray<FCustomTypesVe
261260
UE_LOG(LogCounterCounter_JNI, Verbose, TEXT("Notify java jni UCounterCounterJniAdapter::OnVectorArray "));
262261
if (JNIEnv* Env = FAndroidApplication::GetJavaEnv())
263262
{
264-
if (m_javaJniServiceClass == nullptr)
263+
if (CounterJniCache::serviceClassCounter == nullptr)
265264
{
266265
UE_LOG(LogCounterCounter_JNI, Warning, TEXT("counter/counterjniservice/CounterJniService::onVectorArrayChanged([LcustomTypes/customTypes_api/Vector3D;)V CLASS not found"));
267266
return;
268267
}
269-
270-
static const jmethodID MethodID = Env->GetMethodID(m_javaJniServiceClass, "onVectorArrayChanged", "([LcustomTypes/customTypes_api/Vector3D;)V");
268+
jmethodID MethodID = CounterJniCache::serviceClassCounterVectorArrayChangedMethodID;
271269
if (MethodID == nullptr)
272270
{
273271
UE_LOG(LogCounterCounter_JNI, Warning, TEXT("counter/counterjniservice/CounterJniService:onVectorArrayChanged([LcustomTypes/customTypes_api/Vector3D;)V not found"));
@@ -286,13 +284,12 @@ void UCounterCounterJniAdapter::OnExternVectorArrayChanged(const TArray<FVector>
286284
UE_LOG(LogCounterCounter_JNI, Verbose, TEXT("Notify java jni UCounterCounterJniAdapter::OnExternVectorArray "));
287285
if (JNIEnv* Env = FAndroidApplication::GetJavaEnv())
288286
{
289-
if (m_javaJniServiceClass == nullptr)
287+
if (CounterJniCache::serviceClassCounter == nullptr)
290288
{
291289
UE_LOG(LogCounterCounter_JNI, Warning, TEXT("counter/counterjniservice/CounterJniService::onExternVectorArrayChanged([Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;)V CLASS not found"));
292290
return;
293291
}
294-
295-
static const jmethodID MethodID = Env->GetMethodID(m_javaJniServiceClass, "onExternVectorArrayChanged", "([Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;)V");
292+
jmethodID MethodID = CounterJniCache::serviceClassCounterExternVectorArrayChangedMethodID;
296293
if (MethodID == nullptr)
297294
{
298295
UE_LOG(LogCounterCounter_JNI, Warning, TEXT("counter/counterjniservice/CounterJniService:onExternVectorArrayChanged([Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;)V not found"));

goldenmaster/Plugins/Counter/Source/CounterJni/Private/Generated/Jni/CounterCounterJniClient.cpp

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ limitations under the License.
3939

4040
#include "Counter/Generated/Jni/CounterCounterJniClient.h"
4141
#include "Counter/Generated/Jni/CounterDataJavaConverter.h"
42+
#include "Counter/Generated/Jni/CounterJniCache.h"
4243

4344
#include "Async/Async.h"
4445
#include "Engine/Engine.h"
@@ -167,9 +168,12 @@ void UCounterCounterJniClient::Initialize(FSubsystemCollectionBase& Collection)
167168

168169
#if PLATFORM_ANDROID && USE_ANDROID_JNI
169170
JNIEnv* Env = FAndroidApplication::GetJavaEnv();
170-
m_javaJniClientClass = FAndroidApplication::FindJavaClassGlobalRef("counter/counterjniclient/CounterJniClient");
171-
jmethodID constructor = Env->GetMethodID(m_javaJniClientClass, "<init>", "()V");
172-
jobject localRef = Env->NewObject(m_javaJniClientClass, constructor);
171+
if (CounterJniCache::clientClassCounterCtor == nullptr)
172+
{
173+
UE_LOG(LogCounterCounterClient_JNI, Warning, TEXT("Java Client Class counter/counterjniclient/CounterJniClient not found"));
174+
return;
175+
}
176+
jobject localRef = Env->NewObject(CounterJniCache::clientClassCounter, CounterJniCache::clientClassCounterCtor);
173177
m_javaJniClientInstance = Env->NewGlobalRef(localRef);
174178
FAndroidApplication::GetJavaEnv()->DeleteLocalRef(localRef);
175179
#endif
@@ -182,7 +186,6 @@ void UCounterCounterJniClient::Deinitialize()
182186
#if PLATFORM_ANDROID && USE_ANDROID_JNI
183187
JNIEnv* Env = FAndroidApplication::GetJavaEnv();
184188
Env->DeleteGlobalRef(m_javaJniClientInstance);
185-
m_javaJniClientClass = nullptr;
186189
m_javaJniClientInstance = nullptr;
187190
#endif
188191

@@ -226,12 +229,12 @@ void UCounterCounterJniClient::SetVector(const FCustomTypesVector3D& InVector)
226229
#if PLATFORM_ANDROID && USE_ANDROID_JNI
227230
if (JNIEnv* Env = FAndroidApplication::GetJavaEnv())
228231
{
229-
if (m_javaJniClientClass == nullptr)
232+
if (CounterJniCache::javaClassCounter == nullptr)
230233
{
231234
UE_LOG(LogCounterCounterClient_JNI, Warning, TEXT("counter/counterjniclient/CounterJniClient:setVector (LcustomTypes/customTypes_api/Vector3D;)V CLASS not found"));
232235
return;
233236
}
234-
static jmethodID MethodID = Env->GetMethodID(m_javaJniClientClass, "setVector", "(LcustomTypes/customTypes_api/Vector3D;)V");
237+
jmethodID MethodID = CounterJniCache::javaClassCounterVectorSetterId;
235238
if (MethodID == nullptr)
236239
{
237240
UE_LOG(LogCounterCounterClient_JNI, Warning, TEXT("counter/counterjniclient/CounterJniClient:setVector (LcustomTypes/customTypes_api/Vector3D;)V not found"));
@@ -271,12 +274,12 @@ void UCounterCounterJniClient::SetExternVector(const FVector& InExternVector)
271274
#if PLATFORM_ANDROID && USE_ANDROID_JNI
272275
if (JNIEnv* Env = FAndroidApplication::GetJavaEnv())
273276
{
274-
if (m_javaJniClientClass == nullptr)
277+
if (CounterJniCache::javaClassCounter == nullptr)
275278
{
276279
UE_LOG(LogCounterCounterClient_JNI, Warning, TEXT("counter/counterjniclient/CounterJniClient:setExternVector (Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;)V CLASS not found"));
277280
return;
278281
}
279-
static jmethodID MethodID = Env->GetMethodID(m_javaJniClientClass, "setExternVector", "(Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;)V");
282+
jmethodID MethodID = CounterJniCache::javaClassCounterExternVectorSetterId;
280283
if (MethodID == nullptr)
281284
{
282285
UE_LOG(LogCounterCounterClient_JNI, Warning, TEXT("counter/counterjniclient/CounterJniClient:setExternVector (Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;)V not found"));
@@ -316,12 +319,12 @@ void UCounterCounterJniClient::SetVectorArray(const TArray<FCustomTypesVector3D>
316319
#if PLATFORM_ANDROID && USE_ANDROID_JNI
317320
if (JNIEnv* Env = FAndroidApplication::GetJavaEnv())
318321
{
319-
if (m_javaJniClientClass == nullptr)
322+
if (CounterJniCache::javaClassCounter == nullptr)
320323
{
321324
UE_LOG(LogCounterCounterClient_JNI, Warning, TEXT("counter/counterjniclient/CounterJniClient:setVectorArray ([LcustomTypes/customTypes_api/Vector3D;)V CLASS not found"));
322325
return;
323326
}
324-
static jmethodID MethodID = Env->GetMethodID(m_javaJniClientClass, "setVectorArray", "([LcustomTypes/customTypes_api/Vector3D;)V");
327+
jmethodID MethodID = CounterJniCache::javaClassCounterVectorArraySetterId;
325328
if (MethodID == nullptr)
326329
{
327330
UE_LOG(LogCounterCounterClient_JNI, Warning, TEXT("counter/counterjniclient/CounterJniClient:setVectorArray ([LcustomTypes/customTypes_api/Vector3D;)V not found"));
@@ -361,12 +364,12 @@ void UCounterCounterJniClient::SetExternVectorArray(const TArray<FVector>& InExt
361364
#if PLATFORM_ANDROID && USE_ANDROID_JNI
362365
if (JNIEnv* Env = FAndroidApplication::GetJavaEnv())
363366
{
364-
if (m_javaJniClientClass == nullptr)
367+
if (CounterJniCache::javaClassCounter == nullptr)
365368
{
366369
UE_LOG(LogCounterCounterClient_JNI, Warning, TEXT("counter/counterjniclient/CounterJniClient:setExternVectorArray ([Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;)V CLASS not found"));
367370
return;
368371
}
369-
static jmethodID MethodID = Env->GetMethodID(m_javaJniClientClass, "setExternVectorArray", "([Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;)V");
372+
jmethodID MethodID = CounterJniCache::javaClassCounterExternVectorArraySetterId;
370373
if (MethodID == nullptr)
371374
{
372375
UE_LOG(LogCounterCounterClient_JNI, Warning, TEXT("counter/counterjniclient/CounterJniClient:setExternVectorArray ([Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;)V not found"));
@@ -394,13 +397,13 @@ FVector UCounterCounterJniClient::Increment(const FVector& InVec)
394397
TPromise<FVector> Promise;
395398

396399
#if PLATFORM_ANDROID && USE_ANDROID_JNI
397-
if (m_javaJniClientClass == nullptr)
400+
if (CounterJniCache::clientClassCounter == nullptr)
398401
{
399402
UE_LOG(LogCounterCounterClient_JNI, Warning, TEXT("counter/counterjniclient/CounterJniClient:incrementAsync:(Ljava/lang/String;Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;)V CLASS not found"));
400403
return FVector(0.f, 0.f, 0.f);
401404
}
402405
JNIEnv* Env = FAndroidApplication::GetJavaEnv();
403-
static jmethodID MethodID = Env->GetMethodID(m_javaJniClientClass, "incrementAsync", "(Ljava/lang/String;Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;)V");
406+
jmethodID MethodID = CounterJniCache::clientClassCounterIncrementAsyncMethodID;
404407
if (MethodID != nullptr)
405408
{
406409
auto id = gUCounterCounterJniClientmethodHelper.StorePromise(Promise);
@@ -432,13 +435,13 @@ TArray<FVector> UCounterCounterJniClient::IncrementArray(const TArray<FVector>&
432435
TPromise<TArray<FVector>> Promise;
433436

434437
#if PLATFORM_ANDROID && USE_ANDROID_JNI
435-
if (m_javaJniClientClass == nullptr)
438+
if (CounterJniCache::clientClassCounter == nullptr)
436439
{
437440
UE_LOG(LogCounterCounterClient_JNI, Warning, TEXT("counter/counterjniclient/CounterJniClient:incrementArrayAsync:(Ljava/lang/String;[Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;)V CLASS not found"));
438441
return TArray<FVector>();
439442
}
440443
JNIEnv* Env = FAndroidApplication::GetJavaEnv();
441-
static jmethodID MethodID = Env->GetMethodID(m_javaJniClientClass, "incrementArrayAsync", "(Ljava/lang/String;[Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;)V");
444+
jmethodID MethodID = CounterJniCache::clientClassCounterIncrementArrayAsyncMethodID;
442445
if (MethodID != nullptr)
443446
{
444447
auto id = gUCounterCounterJniClientmethodHelper.StorePromise(Promise);
@@ -470,13 +473,13 @@ FCustomTypesVector3D UCounterCounterJniClient::Decrement(const FCustomTypesVecto
470473
TPromise<FCustomTypesVector3D> Promise;
471474

472475
#if PLATFORM_ANDROID && USE_ANDROID_JNI
473-
if (m_javaJniClientClass == nullptr)
476+
if (CounterJniCache::clientClassCounter == nullptr)
474477
{
475478
UE_LOG(LogCounterCounterClient_JNI, Warning, TEXT("counter/counterjniclient/CounterJniClient:decrementAsync:(Ljava/lang/String;LcustomTypes/customTypes_api/Vector3D;)V CLASS not found"));
476479
return FCustomTypesVector3D();
477480
}
478481
JNIEnv* Env = FAndroidApplication::GetJavaEnv();
479-
static jmethodID MethodID = Env->GetMethodID(m_javaJniClientClass, "decrementAsync", "(Ljava/lang/String;LcustomTypes/customTypes_api/Vector3D;)V");
482+
jmethodID MethodID = CounterJniCache::clientClassCounterDecrementAsyncMethodID;
480483
if (MethodID != nullptr)
481484
{
482485
auto id = gUCounterCounterJniClientmethodHelper.StorePromise(Promise);
@@ -508,13 +511,13 @@ TArray<FCustomTypesVector3D> UCounterCounterJniClient::DecrementArray(const TArr
508511
TPromise<TArray<FCustomTypesVector3D>> Promise;
509512

510513
#if PLATFORM_ANDROID && USE_ANDROID_JNI
511-
if (m_javaJniClientClass == nullptr)
514+
if (CounterJniCache::clientClassCounter == nullptr)
512515
{
513516
UE_LOG(LogCounterCounterClient_JNI, Warning, TEXT("counter/counterjniclient/CounterJniClient:decrementArrayAsync:(Ljava/lang/String;[LcustomTypes/customTypes_api/Vector3D;)V CLASS not found"));
514517
return TArray<FCustomTypesVector3D>();
515518
}
516519
JNIEnv* Env = FAndroidApplication::GetJavaEnv();
517-
static jmethodID MethodID = Env->GetMethodID(m_javaJniClientClass, "decrementArrayAsync", "(Ljava/lang/String;[LcustomTypes/customTypes_api/Vector3D;)V");
520+
jmethodID MethodID = CounterJniCache::clientClassCounterDecrementArrayAsyncMethodID;
518521
if (MethodID != nullptr)
519522
{
520523
auto id = gUCounterCounterJniClientmethodHelper.StorePromise(Promise);
@@ -551,12 +554,12 @@ bool UCounterCounterJniClient::_bindToService(FString servicePackage, FString co
551554
m_lastConnectionId = connectionId;
552555
#if PLATFORM_ANDROID && USE_ANDROID_JNI
553556
JNIEnv* Env = FAndroidApplication::GetJavaEnv();
554-
if (m_javaJniClientClass == nullptr)
557+
if (CounterJniCache::clientClassCounter == nullptr)
555558
{
556559
UE_LOG(LogCounterCounterClient_JNI, Warning, TEXT("counter/counterjniclient/CounterJniClient:bind:(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)Z CLASS not found"));
557560
return false;
558561
}
559-
static jmethodID MethodID = Env->GetMethodID(m_javaJniClientClass, "bind", "(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)Z");
562+
jmethodID MethodID = CounterJniCache::clientClassCounterBindMethodID;
560563
if (MethodID != nullptr)
561564
{
562565
jobject Activity = FJavaWrapper::GameActivityThis;
@@ -580,12 +583,12 @@ void UCounterCounterJniClient::_unbind()
580583

581584
#if PLATFORM_ANDROID && USE_ANDROID_JNI
582585
JNIEnv* Env = FAndroidApplication::GetJavaEnv();
583-
if (m_javaJniClientClass == nullptr)
586+
if (CounterJniCache::clientClassCounter == nullptr)
584587
{
585588
UE_LOG(LogCounterCounterClient_JNI, Warning, TEXT("counter/counterjniclient/CounterJniClient:unbind:()V CLASS not found"));
586589
return;
587590
}
588-
static jmethodID MethodID = Env->GetMethodID(m_javaJniClientClass, "unbind", "()V");
591+
jmethodID MethodID = CounterJniCache::clientClassCounterUnbindMethodID;
589592
if (MethodID != nullptr)
590593
{
591594
FJavaWrapper::CallVoidMethod(Env, m_javaJniClientInstance, MethodID);

0 commit comments

Comments
 (0)