summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBogDan Vatra <bog_dan_ro@yahoo.com>2011-10-20 18:50:14 +0300
committerBogDan Vatra <bog_dan_ro@yahoo.com>2011-10-20 18:50:14 +0300
commite41868a3119245c5002eb21c1bc1369a0654c85e (patch)
treec359451398f428b2333f4f75d6643adbacd8bf1d
parentc5a0b8021ddeea8450d469b4661db448d1eadc7f (diff)
Check device cpu extensions (e.g. vfp, neon) and download the best one
for your device (if avaiable).
-rw-r--r--Ministro/src/org/kde/necessitas/ministro/MinistroActivity.java49
-rw-r--r--MinistroConfigurationTool/src/org/kde/ministro/config/MinistroConfigurationToolActivity.java67
2 files changed, 111 insertions, 5 deletions
diff --git a/Ministro/src/org/kde/necessitas/ministro/MinistroActivity.java b/Ministro/src/org/kde/necessitas/ministro/MinistroActivity.java
index 11568b9..65f6985 100644
--- a/Ministro/src/org/kde/necessitas/ministro/MinistroActivity.java
+++ b/Ministro/src/org/kde/necessitas/ministro/MinistroActivity.java
@@ -17,11 +17,14 @@
package org.kde.necessitas.ministro;
+import java.io.BufferedReader;
+import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
@@ -67,7 +70,7 @@ public class MinistroActivity extends Activity
{
public native static int nativeChmode(String filepath, int mode);
- private static final String DOMAIN_NAME="http://files.kde.org/necessitas/ministro/";
+ private static final String DOMAIN_NAME="http://files.kde.org/necessitas/ministro/necessitas/";
private String[] m_modules;
private int m_id=-1;
@@ -187,7 +190,7 @@ public class MinistroActivity extends Activity
return new URL(DOMAIN_NAME+MinistroService.getRepository(c)+"/android/"+android.os.Build.CPU_ABI+"/android-"+android.os.Build.VERSION.SDK_INT+"/versions.xml");
}
- private static URL getLibsXmlUrl(Context c, double version) throws MalformedURLException
+ private static URL getLibsXmlUrl(Context c, String version) throws MalformedURLException
{
return new URL(DOMAIN_NAME+MinistroService.getRepository(c)+"/android/"+android.os.Build.CPU_ABI+"/android-"+android.os.Build.VERSION.SDK_INT+"/libs-"+version+".xml");
}
@@ -201,6 +204,40 @@ public class MinistroActivity extends Activity
return false;
}
+ private static String deviceSupportedFeatures(String supportedFeatures)
+ {
+ if (null==supportedFeatures)
+ return "";
+ String [] serverFeaturesList=supportedFeatures.trim().split(" ");
+ String [] deviceFeaturesList=null;
+ try {
+ FileInputStream fstream = new FileInputStream("/proc/cpuinfo");
+ DataInputStream in = new DataInputStream(fstream);
+ BufferedReader br = new BufferedReader(new InputStreamReader(in));
+ String strLine;
+ while ((strLine = br.readLine()) != null)
+ {
+ if (strLine.startsWith("Features"))
+ {
+ deviceFeaturesList=strLine.substring(strLine.indexOf(":")+1).trim().split(" ");
+ break;
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ return "";
+ }
+
+ String features="";
+ for(String sfeature: serverFeaturesList)
+ for (String dfeature: deviceFeaturesList)
+ if (sfeature.equals(dfeature))
+ features+="_"+dfeature;
+
+ return features;
+ }
+
+
public static double downloadVersionXmlFile(Context c, boolean checkOnly)
{
if (!isOnline(c))
@@ -221,8 +258,10 @@ public class MinistroActivity extends Activity
if (checkOnly)
return version;
-
- connection = getLibsXmlUrl(c, version).openConnection();
+ String supportedFeatures=null;
+ if (root.hasAttribute("features"))
+ supportedFeatures=root.getAttribute("features");
+ connection = getLibsXmlUrl(c, version+deviceSupportedFeatures(supportedFeatures)).openConnection();
connection.setRequestProperty("Accept-Encoding", "gzip,deflate");
File file= new File(MinistroService.instance().getVersionXmlFile());
file.delete();
@@ -623,7 +662,7 @@ public class MinistroActivity extends Activity
File dir=new File(m_qtLibsRootPath);
dir.mkdirs();
nativeChmode(m_qtLibsRootPath, 0755);
- bindService(new Intent("org.kde.necessitas.ministro"), m_ministroConnection, Context.BIND_AUTO_CREATE);
+ bindService(new Intent("org.kde.necessitas.ministro.IMinistro"), m_ministroConnection, Context.BIND_AUTO_CREATE);
}
@Override
diff --git a/MinistroConfigurationTool/src/org/kde/ministro/config/MinistroConfigurationToolActivity.java b/MinistroConfigurationTool/src/org/kde/ministro/config/MinistroConfigurationToolActivity.java
new file mode 100644
index 0000000..d62b828
--- /dev/null
+++ b/MinistroConfigurationTool/src/org/kde/ministro/config/MinistroConfigurationToolActivity.java
@@ -0,0 +1,67 @@
+/*
+ Copyright (c) 2011, BogDan Vatra <bog_dan_ro@yahoo.com>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+package org.kde.ministro.config;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.ComponentName;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+
+public class MinistroConfigurationToolActivity extends Activity {
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ try
+ {
+ Intent intent = new Intent();
+ intent.setComponent(new ComponentName("org.kde.necessitas.ministro", "org.kde.necessitas.ministro.MinistroConfigActivity"));
+ startActivity(intent);
+ finish();
+ }
+ catch (Exception e) {
+ AlertDialog.Builder downloadDialog = new AlertDialog.Builder(this);
+ downloadDialog.setMessage("This tool needs latest Ministro service. Would you like to install it?");
+ downloadDialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialogInterface, int i) {
+ try
+ {
+ Uri uri = Uri.parse("market://search?q=pname:org.kde.necessitas.ministro");
+ Intent intent = new Intent(Intent.ACTION_VIEW, uri);
+ startActivity(intent);
+ finish();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ finish();
+ }
+ }
+ });
+
+ downloadDialog.setNegativeButton("No", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialogInterface, int i) {
+ finish();
+ }
+ });
+ downloadDialog.show();
+ }
+ super.onCreate(savedInstanceState);
+ }
+}