diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..2f633b6 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,26 @@ +name: Android CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: set up JDK 11 + uses: actions/setup-java@v4 + with: + java-version: '11' + distribution: 'temurin' + cache: gradle + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Build with Gradle + run: ./gradlew build diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b43ace5..f160127 100755 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,7 +2,7 @@ - + diff --git a/build.gradle.txt b/build.gradle.txt new file mode 100644 index 0000000..2b3d359 --- /dev/null +++ b/build.gradle.txt @@ -0,0 +1,44 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + ext.kotlin_version = "1.5.21" + repositories { + jcenter() + mavenCentral() + google() + maven { url 'https://jitpack.io' } + } + dependencies { + classpath "com.android.tools.build:gradle:7.0.2" + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + jcenter() + mavenCentral() + google() + maven { url 'https://jitpack.io' } + maven { url "https://raw.githubusercontent.com/andvipgroup/CameraLib/master" } + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} + +ext { + minSdkVersion = 24 + compileSdkVersion = 33 + targetSdkVersion = 31 + buildToolsVersion = "31.0.0" + javaVersion = JavaVersion.VERSION_1_8 + abiFilters = "armeabi-v7a,arm64-v8a" + localTest = false + isMasterPkg = true + hackJarName = "hack.jar" + versionCode = 100 + versionName = "1.0.0" + masterPkg = "virtual.camera.app" + assistPkg = "virtual.camera.app.assist" +} \ No newline at end of file diff --git a/check_env_demo/code/native-lib.cpp b/check_env_demo/code/native-lib.cpp index 1cb3958..aece0ec 100755 --- a/check_env_demo/code/native-lib.cpp +++ b/check_env_demo/code/native-lib.cpp @@ -1,13 +1,20 @@ #include #include -#include -# include -# include -#include +#include extern "C" JNIEXPORT jint JNICALL Java_check_env_MainActivity_isPathReallyExist(JNIEnv *env, jobject, jstring path) { + // Convert the Java string to a C-style string const char *cpath = env->GetStringUTFChars(path, nullptr); - int result1 = syscall(__NR_faccessat,AT_FDCWD, cpath, F_OK, 0); - return result1; + if (cpath == nullptr) { + return -1; // Return error if the conversion fails + } + + // Check if the path exists using access + int result = access(cpath, F_OK); + + // Release the memory allocated for the C-style string + env->ReleaseStringUTFChars(path, cpath); + + return result; // Return 0 if the path exists, -1 otherwise } \ No newline at end of file