diff --git a/app/build.gradle b/app/build.gradle index be415186..489eae03 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,7 +5,7 @@ plugins { // 10,00,000 major-minor-build def AppMajorVersion = 1 def AppMinorVersion = 3 -def AppBuildNumber = 66 +def AppBuildNumber = 70 def AppVersionName = AppMajorVersion + "." + AppMinorVersion + "." + AppBuildNumber def AppVersionCode = AppMajorVersion * 100000 + AppMinorVersion * 1000 + AppBuildNumber @@ -39,6 +39,7 @@ android { cppFlags '-std=c++17 -fexceptions -Wno-error=format-security -fopenmp' // cppFlags '-std=c++17 -Wno-error=format-security' // arguments "-DANDROID_STL=c++_shared" + arguments "-DNCNN_DISABLE_EXCEPTION=OFF", "-DTERM_CORE_ROOT=" + coreroot, "-DOpenCV_DIR=" + opencvsdk + "/sdk/native/jni", "-DHDRPLUS_ROOT=" + hdrplusroot, "-DNCNN_ROOT=" + ncnnroot, "-DHALIDE_ROOT=" + halideroot abiFilters 'arm64-v8a', 'armeabi-v7a' // setAbiFilters(['arm64-v8a']) } @@ -74,34 +75,15 @@ android { } } - flavorDimensions "apps" - productFlavors { - WP { - dimension = "apps" - externalNativeBuild { - cmake { - arguments "-DNCNN_DISABLE_EXCEPTION=OFF", "-DTERM_CORE_ROOT=" + coreroot, "-DOpenCV_DIR=" + opencvsdk + "/sdk/native/jni", "-DHDRPLUS_ROOT=" + hdrplusroot, "-DNCNN_ROOT=" + ncnnroot, "-DHALIDE_ROOT=" + halideroot - abiFilters "arm64-v8a" - } - } - } - RP { - dimension = "apps" - externalNativeBuild { - cmake { - arguments "-DUSING_PLZ=1", "-DNCNN_DISABLE_EXCEPTION=OFF", "-DTERM_CORE_ROOT=" + coreroot, "-DOpenCV_DIR=" + opencvsdk + "/sdk/native/jni", "-DHDRPLUS_ROOT=" + hdrplusroot, "-DNCNN_ROOT=" + ncnnroot, "-DHALIDE_ROOT=" + halideroot - abiFilters "arm64-v8a" - } - } - } - N938 { - dimension = "apps" - externalNativeBuild { - cmake { - arguments "-DUSING_N938=1", "-DNCNN_DISABLE_EXCEPTION=OFF", "-DTERM_CORE_ROOT=" + coreroot, "-DOpenCV_DIR=" + opencvsdk + "/sdk/native/jni", "-DHDRPLUS_ROOT=" + hdrplusroot, "-DNCNN_ROOT=" + ncnnroot, "-DHALIDE_ROOT=" + halideroot - abiFilters "armeabi-v7a" - } - } + splits { + boolean isReleaseTask = gradle.startParameter.taskNames.any { it.contains("Release") } + // enabled on release build + abi { + enable isReleaseTask + reset() + include "armeabi-v7a", "arm64-v8a" + // include "arm64-v8a" + universalApk false } } @@ -109,19 +91,15 @@ android { variant.outputs.all { output -> if (outputFileName.endsWith('.apk')) { def buildTypeFlag = "dbg" - def flavor = variant.flavorName def prevFileName = "mpapp" - def buildType = variant.buildType if(variant.buildType.name.equals('release')) { buildTypeFlag = "rel" } - if (flavor.equals("N938")) prevFileName = "N938" - else if (flavor.equals("RP")) prevFileName = "rpapp" - def fileName = "${prevFileName}_v${defaultConfig.versionName}_${buildTypeFlag}_${new Date(System.currentTimeMillis()).format("yyyyMMdd")}.apk" - def outputDir = new File("${project.buildDir}/${buildType}") + def abi = output.getFilter(com.android.build.OutputFile.ABI) + if (abi == null) abi = "all" + if (abi.contains("v7a")) prevFileName = "N938" + def fileName = "${prevFileName}_v${defaultConfig.versionName}_${buildTypeFlag}_${new Date(System.currentTimeMillis()).format("yyyyMMdd")}_${abi}.apk" outputFileName = fileName - - // variant.getPackageApplication().outputDirectory = outputDir // new File(project.rootDir.absolutePath + "/app/build/") } } } diff --git a/app/src/main/cpp/CMakeLists.txt b/app/src/main/cpp/CMakeLists.txt index 59b29b0e..9d18a0af 100644 --- a/app/src/main/cpp/CMakeLists.txt +++ b/app/src/main/cpp/CMakeLists.txt @@ -17,15 +17,12 @@ set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") add_definitions(-DUSING_ETHERNET) -# USING_N938 defined in gradle -# USING_PLZ defined in gradle - -#if(ANDROID_ABI STREQUAL "armeabi-v7a") -# add_definitions(-DUSING_N938) -#elseif(ANDROID_ABI STREQUAL "arm64-v8a") -# # add_definitions(-DUSING_N938) -# # add_definitions(-DUSING_PLZ) -#endif() +if(ANDROID_ABI STREQUAL "armeabi-v7a") + add_definitions(-DUSING_N938) +elseif(ANDROID_ABI STREQUAL "arm64-v8a") + # add_definitions(-DUSING_N938) + add_definitions(-DUSING_PLZ) +endif() # OUTPUT_DBG_INFO: 输出调试相关信息 add_definitions(-DOUTPUT_DBG_INFO) diff --git a/app/src/main/cpp/MicroPhoto.cpp b/app/src/main/cpp/MicroPhoto.cpp index 7c717ca7..a7f1a29c 100644 --- a/app/src/main/cpp/MicroPhoto.cpp +++ b/app/src/main/cpp/MicroPhoto.cpp @@ -1424,7 +1424,7 @@ Java_com_xypower_mpapp_MicroPhotoService_releasePowerControl( extern "C" JNIEXPORT jint JNICALL -Java_com_xypower_mpapp_MainActivity_getCustomAppId(JNIEnv *env, jobject thiz) { +Java_com_xypower_mpapp_MicroPhotoService_getCustomAppId(JNIEnv *env, jobject thiz) { #ifdef USING_N938 return 2; #elif defined(USING_PLZ) diff --git a/app/src/main/java/com/xypower/mpapp/MainActivity.java b/app/src/main/java/com/xypower/mpapp/MainActivity.java index 47b94a97..009dc428 100644 --- a/app/src/main/java/com/xypower/mpapp/MainActivity.java +++ b/app/src/main/java/com/xypower/mpapp/MainActivity.java @@ -73,7 +73,7 @@ public class MainActivity extends AppCompatActivity { Date date = new Date(BuildConfig.BUILD_TIMESTAMP); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); String caption = "MP"; - switch (getCustomAppId()) { + switch (MicroPhotoService.getCustomAppId()) { case 1: caption = "RP"; break; @@ -640,6 +640,6 @@ public class MainActivity extends AppCompatActivity { } - private native int getCustomAppId(); + } \ No newline at end of file diff --git a/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java b/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java index 15ea34cf..87bd2016 100644 --- a/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java +++ b/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java @@ -1681,6 +1681,8 @@ cellSignalStrengthGsm.getDbm(); public static native long requestPowerControl(int type); public static native boolean releasePowerControl(long powerControlHandle); + public static native int getCustomAppId(); + ////////////////////////GPS//////////////////// // private static final String GPS_LOCATION_NAME = android.location.LocationManager.GPS_PROVIDER; private LocationManager mLocationManager; diff --git a/common/src/main/java/com/xypower/common/FileUploader.java b/common/src/main/java/com/xypower/common/FileUploader.java index 1e5343ae..e647eb21 100644 --- a/common/src/main/java/com/xypower/common/FileUploader.java +++ b/common/src/main/java/com/xypower/common/FileUploader.java @@ -6,6 +6,7 @@ import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -92,8 +93,22 @@ public class FileUploader { } request.writeBytes(this.CRLF); - byte[] bytes = Files.readAllBytes(uploadFile.toPath()); - request.write(bytes); + FileInputStream fis = null; + try { + fis = new FileInputStream(uploadFile); + int bufferSize = 1024; + byte[] buffer = new byte[bufferSize]; + int length = -1; + while ((length = fis.read(buffer)) != -1) { + request.write(buffer, 0, length); + } + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + FilesUtils.closeFriendly(fis); + } + // byte[] bytes = Files.readAllBytes(uploadFile.toPath()); + // request.write(bytes); } /**