Skip to content

Commit 85e9a4a

Browse files
authored
Merge pull request #2205 from bugsnag/PLAT-14323/jni-onload
Use JNI_OnLoad to link the NDK plugin
2 parents f7ef874 + 7c25eea commit 85e9a4a

12 files changed

Lines changed: 376 additions & 132 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
## TBD
44

5+
### Enhancements
6+
7+
* `bugsnag-plugin-android-ndk` no longer exports the `Java_` JNI functions, and instead uses the JNI `RegisterNatives` API to register the native methods.
8+
[#2205](https://github.com/bugsnag/bugsnag-android/pull/2205)
9+
510
### Bug fixes
611

712
* The `bugsnag-plugin-android-exitinfo` plugin now calls `setProcessState` (if configured) on a background thread and swallows any rate-limiting errors, so that it does not block the main thread during startup

bugsnag-plugin-android-ndk/api/bugsnag-plugin-android-ndk.api

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public final class com/bugsnag/android/ndk/NativeBridge : com/bugsnag/android/in
3333
public final fun updateContext (Ljava/lang/String;)V
3434
public final fun updateInForeground (ZLjava/lang/String;)V
3535
public final fun updateIsLaunching (Z)V
36-
public final fun updateLastRunInfo (I)V
3736
public final fun updateLowMemory (ZLjava/lang/String;)V
3837
public final fun updateOrientation (Ljava/lang/String;)V
3938
public final fun updateUserEmail (Ljava/lang/String;)V

bugsnag-plugin-android-ndk/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
plugins {
22
loadDefaultPlugins()
3+
id("bugsnag-jni-link-table-plugin")
34
}
45

56
android {

bugsnag-plugin-android-ndk/src/main/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ include_directories(
3535
jni/external/libunwindstack-ndk/include
3636
)
3737

38-
target_include_directories(bugsnag-ndk PRIVATE ${BUGSNAG_DIR}/assets/include)
39-
4038
target_link_libraries(
4139
# Specifies the target library.
4240
bugsnag-ndk

bugsnag-plugin-android-ndk/src/main/exported_native_symbols-RelWithDebInfo.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ global:
66
__emutls_get_address;
77
__gxx_personality_v0;
88
Java_*;
9+
JNI_OnLoad;
910
extern "C++" {
1011
"std::get_terminate()";
1112
"std::set_terminate(void (*)())";

bugsnag-plugin-android-ndk/src/main/java/com/bugsnag/android/ndk/NativeBridge.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,12 @@ class NativeBridge(private val bgTaskService: BackgroundTaskService) : StateObse
8484
external fun updateContext(context: String)
8585
external fun updateInForeground(inForeground: Boolean, activityName: String)
8686
external fun updateIsLaunching(isLaunching: Boolean)
87-
external fun updateLastRunInfo(consecutiveLaunchCrashes: Int)
8887
external fun updateOrientation(orientation: String)
8988
external fun updateUserId(newValue: String)
9089
external fun updateUserEmail(newValue: String)
9190
external fun updateUserName(newValue: String)
92-
external fun getSignalUnwindStackFunction(): Long
9391
external fun updateLowMemory(newValue: Boolean, memoryTrimLevelDescription: String)
92+
external fun getSignalUnwindStackFunction(): Long
9493
external fun addFeatureFlag(name: String, variant: String?)
9594
external fun clearFeatureFlag(name: String)
9695
external fun clearFeatureFlags()
@@ -139,7 +138,6 @@ class NativeBridge(private val bgTaskService: BackgroundTaskService) : StateObse
139138
event.contextActivity ?: ""
140139
)
141140

142-
is StateEvent.UpdateLastRunInfo -> updateLastRunInfo(event.consecutiveLaunchCrashes)
143141
is StateEvent.UpdateIsLaunching -> {
144142
updateIsLaunching(event.isLaunching)
145143

0 commit comments

Comments
 (0)