diff --git a/android/libinfo/info.c b/android/libinfo/info.c index 225cc10c1a..073a505575 100644 --- a/android/libinfo/info.c +++ b/android/libinfo/info.c @@ -7,7 +7,7 @@ const char* GetLibraryList(void); JNIEXPORT jstring JNICALL Java_org_opencv_android_StaticHelper_getLibraryList(JNIEnv *, jclass); #define PACKAGE_NAME "org.opencv.lib_v" CVAUX_STR(CV_VERSION_EPOCH) CVAUX_STR(CV_VERSION_MAJOR) "_" ANDROID_PACKAGE_PLATFORM -#define PACKAGE_REVISION CVAUX_STR(CV_VERSION_MINOR) "." CVAUX_STR(ANDROID_PACKAGE_RELEASE) +#define PACKAGE_REVISION CVAUX_STR(CV_VERSION_MINOR) "." CVAUX_STR(ANDROID_PACKAGE_RELEASE) "." CVAUX_STR(CV_VERSION_REVISION) const char* GetPackageName(void) { diff --git a/android/package/AndroidManifest.xml b/android/package/AndroidManifest.xml index 3b6bc7d047..8997b161bc 100644 --- a/android/package/AndroidManifest.xml +++ b/android/package/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="@OPENCV_VERSION_PATCH@@OPENCV_VERSION_TWEAK@@ANDROID_PACKAGE_RELEASE@" + android:versionName="@OPENCV_VERSION_PATCH@.@OPENCV_VERSION_TWEAK@.@ANDROID_PACKAGE_RELEASE@" > diff --git a/android/service/engine/jni/NativeService/PackageInfo.cpp b/android/service/engine/jni/NativeService/PackageInfo.cpp index 7428de01b0..2eb8230739 100644 --- a/android/service/engine/jni/NativeService/PackageInfo.cpp +++ b/android/service/engine/jni/NativeService/PackageInfo.cpp @@ -136,7 +136,17 @@ inline int SplitVersion(const vector& features, const string& package_ve // Taking release and build number from package revision vector tmp2 = SplitStringVector(package_version, '.'); - result += atoi(tmp2[0].c_str())*100 + atoi(tmp2[1].c_str()); + if (tmp2.size() == 2) + { + // the 2nd digit is revision + result += atoi(tmp2[0].c_str())*100 + 00; + } + else + { + // the 2nd digit is part of library version + // the 3rd digit is revision + result += atoi(tmp2[0].c_str())*100 + atoi(tmp2[1].c_str()); + } } else { @@ -194,10 +204,10 @@ inline int SplitPlatfrom(const vector& features) * Example: armv7_neon */ PackageInfo::PackageInfo(int version, int platform, int cpu_id, std::string install_path): -Version(version), -Platform(platform), -CpuID(cpu_id), -InstallPath("") + Version(version), + Platform(platform), + CpuID(cpu_id), + InstallPath("") { #ifndef __SUPPORT_TEGRA3 Platform = PLATFORM_UNKNOWN; diff --git a/android/service/engine/jni/Tests/PackageInfoTest.cpp b/android/service/engine/jni/Tests/PackageInfoTest.cpp index 2e747c305d..6bc84856ce 100644 --- a/android/service/engine/jni/Tests/PackageInfoTest.cpp +++ b/android/service/engine/jni/Tests/PackageInfoTest.cpp @@ -157,6 +157,20 @@ TEST(PackageInfo, MipsFromFullName) } #endif +TEST(PackageInfo, Check2DigitRevision) +{ + PackageInfo info("org.opencv.lib_v23_armv7a_neon", "/data/data/org.opencv.lib_v23_armv7_neon", "4.1"); + EXPECT_EQ(2030400, info.GetVersion()); + EXPECT_EQ(ARCH_ARMv7 | FEATURES_HAS_NEON, info.GetCpuID()); +} + +TEST(PackageInfo, Check3DigitRevision) +{ + PackageInfo info("org.opencv.lib_v23_armv7a_neon", "/data/data/org.opencv.lib_v23_armv7_neon", "4.1.5"); + EXPECT_EQ(2030401, info.GetVersion()); + EXPECT_EQ(ARCH_ARMv7 | FEATURES_HAS_NEON, info.GetCpuID()); +} + TEST(PackageInfo, Comparator1) { PackageInfo info1(2040000, PLATFORM_UNKNOWN, ARCH_X86); diff --git a/android/service/engine/src/org/opencv/engine/manager/ManagerActivity.java b/android/service/engine/src/org/opencv/engine/manager/ManagerActivity.java index 6f604fb875..fad2797727 100644 --- a/android/service/engine/src/org/opencv/engine/manager/ManagerActivity.java +++ b/android/service/engine/src/org/opencv/engine/manager/ManagerActivity.java @@ -299,10 +299,9 @@ public class ManagerActivity extends Activity else NativeLibDir = "/data/data/" + mInstalledPackageInfo[i].packageName + "/lib"; - OpenCVLibraryInfo NativeInfo = new OpenCVLibraryInfo(NativeLibDir); - if (PackageName.equals("org.opencv.engine")) { + OpenCVLibraryInfo NativeInfo = new OpenCVLibraryInfo(NativeLibDir); if (NativeInfo.status()) { PublicName = "Built-in OpenCV library"; @@ -348,9 +347,7 @@ public class ManagerActivity extends Activity if (null != ActivePackagePath) { - int start = ActivePackagePath.indexOf(mInstalledPackageInfo[i].packageName); - int stop = start + mInstalledPackageInfo[i].packageName.length(); - if (start >= 0 && ActivePackagePath.charAt(stop) == '/') + if (ActivePackagePath.equals(NativeLibDir)) { temp.put("Activity", "y"); Tags = "active"; @@ -405,13 +402,22 @@ public class ManagerActivity extends Activity if (OpenCVersion == null || PackageVersion == null) return "unknown"; - int dot = PackageVersion.indexOf("."); - if (dot == -1 || OpenCVersion.length() == 0) + String[] revisions = PackageVersion.split("\\."); + + if (revisions.length <= 1 || OpenCVersion.length() == 0) return "unknown"; else - return OpenCVersion.substring(0, OpenCVersion.length()-1) + "." + - OpenCVersion.toCharArray()[OpenCVersion.length()-1] + "." + - PackageVersion.substring(0, dot) + " rev " + PackageVersion.substring(dot+1); + if (revisions.length == 2) + // the 2nd digit is revision + return OpenCVersion.substring(0, OpenCVersion.length()-1) + "." + + OpenCVersion.toCharArray()[OpenCVersion.length()-1] + "." + + revisions[0] + " rev " + revisions[1]; + else + // the 2nd digit is part of library version + // the 3rd digit is revision + return OpenCVersion.substring(0, OpenCVersion.length()-1) + "." + + OpenCVersion.toCharArray()[OpenCVersion.length()-1] + "." + + revisions[0] + "." + revisions[1] + " rev " + revisions[2]; } protected String ConvertPackageName(String Name, String Version)