Skip to content

luoyesiqiu/SafeCall

Repository files navigation

SafeCall

Safely calls an Android native function, guaranteed function crashes at most once.

Usages

Dependency

Add the following code block to the project's build.gradle or settings.gradle (gradle7.0+).

repositories {
    ...
    maven { url 'https://jitpack.io' }
}

Add the following code block to the module's build.gradle.

android {
    ...
    buildFeatures {
        prefab true
    }
}

dependencies {
    implementation 'com.github.luoyesiqiu:SafeCall:1.0.1'
}

Add following code block to CMakeLists.txt.

find_package(safecall REQUIRED CONFIG)
target_link_libraries(myapp safecall::safecall)

Includes this header file in your project.

#include "safe_call.h"

Call a has no return value function.

void problem_call() {
    //This function may throw some crashes.
    ...
}

SAFE_CALL_VOID(problem_call);

Call a has a return value function.

int problem_call(int arg) {
    //This function may throw some crashes.
    ...
    return 0;
}
int ret = 0;
SAFE_CALL(problem_call,ret,123);

About

Safely calls an Android native function.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published