forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mobile: Move the JNI initialization and shutdown into separate functi…
…ons (envoyproxy#38499) This is needed so that we can initialize and shutdown the JNI code in a custom `JNI_OnLoad` and `JNI_OnUnLoad`. Risk Level: low Testing: CI Docs Changes: n/a Release Notes: n/a Platform Specific Features: android Signed-off-by: Fredy Wijaya <[email protected]>
- Loading branch information
Showing
5 changed files
with
118 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#include "library/jni/jni_init.h" | ||
|
||
#include "library/jni/jni_helper.h" | ||
#include "library/jni/jni_utility.h" | ||
|
||
namespace Envoy { | ||
namespace JNI { | ||
|
||
void initialize(JavaVM* jvm) { | ||
JniHelper::initialize(jvm); | ||
JniUtility::initCache(); | ||
JniHelper::addToCache( | ||
"io/envoyproxy/envoymobile/utilities/AndroidNetworkLibrary", | ||
/* methods= */ {}, | ||
/* static_methods= */ | ||
{ | ||
{"isCleartextTrafficPermitted", "(Ljava/lang/String;)Z"}, | ||
{"tagSocket", "(III)V"}, | ||
{"verifyServerCertificates", | ||
"([[B[B[B)Lio/envoyproxy/envoymobile/utilities/AndroidCertVerifyResult;"}, | ||
{"addTestRootCertificate", "([B)V"}, | ||
{"clearTestRootCertificates", "()V"}, | ||
|
||
}, | ||
/* fields= */ {}, /* static_fields= */ {}); | ||
JniHelper::addToCache("io/envoyproxy/envoymobile/utilities/AndroidCertVerifyResult", | ||
/* methods= */ | ||
{ | ||
{"isIssuedByKnownRoot", "()Z"}, | ||
{"getStatus", "()I"}, | ||
{"getCertificateChainEncoded", "()[[B"}, | ||
}, | ||
/* static_methods= */ {}, | ||
/* fields= */ {}, /* static_fields= */ {}); | ||
JniHelper::addToCache("io/envoyproxy/envoymobile/engine/types/EnvoyOnEngineRunning", | ||
/* methods= */ | ||
{ | ||
{"invokeOnEngineRunning", "()Ljava/lang/Object;"}, | ||
}, | ||
/* static_methods= */ {}, | ||
/* fields= */ {}, /* static_fields= */ {}); | ||
JniHelper::addToCache("io/envoyproxy/envoymobile/engine/types/EnvoyLogger", | ||
/* methods= */ | ||
{ | ||
{"log", "(ILjava/lang/String;)V"}, | ||
}, | ||
/* static_methods= */ {}, | ||
/* fields= */ {}, /* static_fields= */ {}); | ||
JniHelper::addToCache("io/envoyproxy/envoymobile/engine/types/EnvoyEventTracker", | ||
/* methods= */ | ||
{ | ||
{"track", "(Ljava/util/Map;)V"}, | ||
}, | ||
/* static_methods= */ {}, | ||
/* fields= */ {}, /* static_fields= */ {}); | ||
JniHelper::addToCache( | ||
"io/envoyproxy/envoymobile/engine/types/EnvoyHTTPCallbacks", | ||
/* methods= */ | ||
{ | ||
{"onHeaders", | ||
"(Ljava/util/Map;ZLio/envoyproxy/envoymobile/engine/types/EnvoyStreamIntel;)V"}, | ||
{"onData", | ||
"(Ljava/nio/ByteBuffer;ZLio/envoyproxy/envoymobile/engine/types/EnvoyStreamIntel;)V"}, | ||
{"onTrailers", | ||
"(Ljava/util/Map;Lio/envoyproxy/envoymobile/engine/types/EnvoyStreamIntel;)V"}, | ||
{"onComplete", "(Lio/envoyproxy/envoymobile/engine/types/EnvoyStreamIntel;Lio/envoyproxy/" | ||
"envoymobile/engine/types/EnvoyFinalStreamIntel;)V"}, | ||
{"onError", | ||
"(ILjava/lang/String;ILio/envoyproxy/envoymobile/engine/types/EnvoyStreamIntel;Lio/" | ||
"envoyproxy/envoymobile/engine/types/EnvoyFinalStreamIntel;)V"}, | ||
{"onCancel", "(Lio/envoyproxy/envoymobile/engine/types/EnvoyStreamIntel;Lio/envoyproxy/" | ||
"envoymobile/engine/types/EnvoyFinalStreamIntel;)V"}, | ||
{"onSendWindowAvailable", "(Lio/envoyproxy/envoymobile/engine/types/EnvoyStreamIntel;)V"}, | ||
}, | ||
/* static_methods= */ {}, | ||
/* fields= */ {}, /* static_fields= */ {}); | ||
} | ||
|
||
void finalize() { JniHelper::finalize(); } | ||
|
||
} // namespace JNI | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
#include <jni.h> | ||
|
||
namespace Envoy { | ||
namespace JNI { | ||
|
||
/** Initializes the JNI code for Envoy Mobile. This is typically called in `JNI_OnLoad`. */ | ||
void initialize(JavaVM* jvm); | ||
|
||
/** Performs a cleanup in the JNI code. This is typically called in `JNI_OnUnload`. */ | ||
void finalize(); | ||
|
||
} // namespace JNI | ||
} // namespace Envoy |