Internal version of OpenCV inside OpenCV Manager added to the list of installed packages.
authorAlexander Smorkalov <alexander.smorkalov@itseez.com>
Tue, 4 Dec 2012 11:37:27 +0000 (15:37 +0400)
committerAlexander Smorkalov <alexander.smorkalov@itseez.com>
Tue, 4 Dec 2012 11:37:27 +0000 (15:37 +0400)
android/service/engine/src/org/opencv/engine/MarketConnector.java
android/service/engine/src/org/opencv/engine/manager/ManagerActivity.java

index 5a5c098..da59591 100644 (file)
@@ -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<PackageInfo> AllPackages = mContext.getPackageManager().getInstalledPackages(PackageManager.GET_CONFIGURATIONS);
         List<PackageInfo> OpenCVPackages = new ArrayList<PackageInfo>();
-        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<PackageInfo> it = AllPackages.iterator();
         while(it.hasNext())
         {
index 8bb2cd7..6515715 100644 (file)
@@ -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<String,String> temp = new HashMap<String,String>();
-                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);
             }