From 9823b7cd0846ac8442ac231dc0753bcfc0e354ff Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Tue, 4 Dec 2012 15:37:27 +0400 Subject: [PATCH] Internal version of OpenCV inside OpenCV Manager added to the list of installed packages. --- .../org/opencv/engine/MarketConnector.java | 16 +++----- .../engine/manager/ManagerActivity.java | 37 ++++++++++++++++--- 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/android/service/engine/src/org/opencv/engine/MarketConnector.java b/android/service/engine/src/org/opencv/engine/MarketConnector.java index 5a5c098686..da595915f2 100644 --- a/android/service/engine/src/org/opencv/engine/MarketConnector.java +++ b/android/service/engine/src/org/opencv/engine/MarketConnector.java @@ -20,8 +20,6 @@ public class MarketConnector private static final String TAG = "OpenCVEngine/MarketConnector"; protected Context mContext; - public boolean mIncludeManager = true; - public MarketConnector(Context context) { mContext = context; @@ -100,15 +98,13 @@ public class MarketConnector { List AllPackages = mContext.getPackageManager().getInstalledPackages(PackageManager.GET_CONFIGURATIONS); List OpenCVPackages = new ArrayList(); - if (mIncludeManager) - { - try { - OpenCVPackages.add(mContext.getPackageManager().getPackageInfo("org.opencv.engine", PackageManager.GET_CONFIGURATIONS)); - } catch (NameNotFoundException e) { - Log.e(TAG, "OpenCV Manager package info was not found!"); - e.printStackTrace(); - } + try { + OpenCVPackages.add(mContext.getPackageManager().getPackageInfo("org.opencv.engine", PackageManager.GET_CONFIGURATIONS)); + } catch (NameNotFoundException e) { + Log.e(TAG, "OpenCV Manager package info was not found!"); + e.printStackTrace(); } + Iterator it = AllPackages.iterator(); while(it.hasNext()) { 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 8bb2cd76ed..6515715059 100644 --- a/android/service/engine/src/org/opencv/engine/manager/ManagerActivity.java +++ b/android/service/engine/src/org/opencv/engine/manager/ManagerActivity.java @@ -7,7 +7,9 @@ import java.util.StringTokenizer; import org.opencv.engine.HardwareDetector; import org.opencv.engine.MarketConnector; import org.opencv.engine.OpenCVEngineInterface; +import org.opencv.engine.OpenCVLibraryInfo; import org.opencv.engine.R; +import android.annotation.TargetApi; import android.app.Activity; import android.app.AlertDialog; import android.content.BroadcastReceiver; @@ -266,10 +268,10 @@ public class ManagerActivity extends Activity } }; + @TargetApi(Build.VERSION_CODES.GINGERBREAD) synchronized protected void FillPackageList() { synchronized (mListViewItems) { - mMarket.mIncludeManager = false; mInstalledPackageInfo = mMarket.GetInstalledOpenCVPackages(); mListViewItems.clear(); @@ -277,12 +279,36 @@ public class ManagerActivity extends Activity { // Convert to Items for package list view HashMap temp = new HashMap(); - String PublicName = mMarket.GetApplicationName(mInstalledPackageInfo[i].applicationInfo); - int idx = 0; + String PackageName = ""; + String PublicName = ""; String OpenCVersion = "unknown"; String HardwareName = ""; - StringTokenizer tokenizer = new StringTokenizer(mInstalledPackageInfo[i].packageName, "_"); + String NativeLibDir = ""; + String VersionName = ""; + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) + NativeLibDir = mInstalledPackageInfo[i].applicationInfo.nativeLibraryDir; + else + NativeLibDir = "/data/data/" + mInstalledPackageInfo[i].packageName + "/lib"; + + OpenCVLibraryInfo nativeInfo = new OpenCVLibraryInfo(NativeLibDir); + + if (nativeInfo.status()) + { + PublicName = nativeInfo.publicName(); + PackageName = nativeInfo.packageName(); + VersionName = nativeInfo.versionName(); + } + else + { + PublicName = mMarket.GetApplicationName(mInstalledPackageInfo[i].applicationInfo); + PackageName = mInstalledPackageInfo[i].packageName; + VersionName = mInstalledPackageInfo[i].versionName; + } + + int idx = 0; + StringTokenizer tokenizer = new StringTokenizer(PackageName, "_"); while (tokenizer.hasMoreTokens()) { if (idx == 1) @@ -326,8 +352,9 @@ public class ManagerActivity extends Activity } temp.put("Name", PublicName); - temp.put("Version", NormalizeVersion(OpenCVersion, mInstalledPackageInfo[i].versionName)); + temp.put("Version", NormalizeVersion(OpenCVersion, VersionName)); temp.put("Hardware", HardwareName); + mListViewItems.add(temp); }