Commit 48e11f52 authored by Edward Wang's avatar Edward Wang
Browse files

Extend and improve CPU incompatibility checking

parent f41a3a18
......@@ -46,6 +46,7 @@ $(VLC_APK): $(LIBVLCJNI) $(JAVA_SOURCES)
date +"%Y-%m-%d" > $(SRC)/assets/builddate.txt
echo `id -u -n`@`hostname` > $(SRC)/assets/builder.txt
git rev-parse --short HEAD > $(SRC)/assets/revision.txt
./gen-env.sh $(SRC)
$(VERBOSE)cd $(SRC) && ant $(ANT_OPTS) $(ANT_TARGET)
VLC_MODULES=`./find_modules.sh $(VLC_BUILD_DIR)`
......
#!/bin/bash
# Simple script to generate env.txt
ENVTXT=$1/assets/env.txt
function optional_var {
echo -n "$1=" >> $ENVTXT
ONE=\$$1
T=`eval echo $ONE`
if [ -z "$T" ]; then
echo -n "0" >> $ENVTXT
else
echo -n "$T" >> $ENVTXT
fi
echo -n -e "\n" >> $ENVTXT
}
rm -f $ENVTXT
echo -e "ANDROID_ABI=$ANDROID_ABI" >> $ENVTXT
optional_var "NO_NEON"
optional_var "NO_FPU"
optional_var "NO_ARMV6"
revision.txt
builddate.txt
builder.txt
\ No newline at end of file
builder.txt
env.txt
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/logo"
android:layout_width="130dp"
android:layout_height="wrap_content"
android:scaleType="centerInside"
android:layout_gravity="center_horizontal"
android:contentDescription="@string/info"
android:src="@drawable/cone" />
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/error_no_neon"
android:textColor="#FF0000"
android:textSize="20dp" />
</LinearLayout>
</ScrollView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/logo"
android:layout_width="130dp"
android:layout_height="154dp"
android:layout_gravity="center_horizontal"
android:contentDescription="@string/info"
android:scaleType="centerInside"
android:src="@drawable/cone" />
<TextView
android:id="@+id/errormsg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/error_not_compatible"
android:textColor="#FF0000"
android:textSize="20dp" />
</LinearLayout>
</ScrollView>
\ No newline at end of file
......@@ -88,6 +88,7 @@
<string name="open_mrl_dialog_title">Open network stream</string>
<string name="open_mrl_dialog_msg">Enter network MRL: e.g. http://, mms:// or rtsp://</string>
<string name="media_library">Media library</string>
<string name="error_not_compatible">Sorry, but your device is currently not supported by this version of VLC for Android™.\n\nThe error message is (please mention this when debugging):\n</string>
<!-- About -->
<string name="app_name_full">VLC for Android™</string>
......@@ -131,5 +132,4 @@
<item>@string/aout_audiotrack</item>
<item>@string/aout_opensles</item>
</string-array>
<string name="error_no_neon">Sorry, but your device is currently not supported by this version of VLC for Android™</string>
</resources>
......@@ -178,10 +178,10 @@ public class LibVLC {
private void init() throws LibVlcException {
Log.v(TAG, "Initializing LibVLC");
if (!mIsInitialized) {
/* if (!Util.hasNeon()) {
Log.e(TAG, "Required CPU feature is missing.");
if(!Util.hasCompatibleCPU()) {
Log.e(TAG, Util.getErrorMsg());
return;
} */
}
Context context = VLCApplication.getAppContext();
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
nativeInit(pref.getBoolean("enable_verbose_mode", true));
......
......@@ -21,11 +21,13 @@
package org.videolan.vlc;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
import java.util.Properties;
import android.content.Context;
import android.graphics.Bitmap;
......@@ -34,6 +36,7 @@ import android.view.View;
import android.widget.Toast;
public class Util {
public final static String TAG = "VLC/Util";
/** A set of utility functions for the VLC application */
/** Print an on-screen message to alert the user */
......@@ -185,8 +188,32 @@ public class Util {
return android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH;
}
public static boolean hasNeon()
private static String errorMsg = null;
private static boolean isCompatible = false;
public static String getErrorMsg() {
return errorMsg;
}
public static boolean hasCompatibleCPU()
{
// If already checked return cached result
if(errorMsg != null) return isCompatible;
Properties properties = new Properties();
try {
properties.load(new ByteArrayInputStream(Util.readAsset("env.txt", "").getBytes("UTF-8")));
} catch (IOException e) {
// Shouldn't happen if done correctly
e.printStackTrace();
errorMsg = "IOException whilst reading compile flags";
isCompatible = false;
return false;
}
String ANDROID_ABI = properties.getProperty("ANDROID_ABI");
boolean NO_NEON = properties.getProperty("NO_NEON").equals("1");
boolean NO_FPU = properties.getProperty("NO_FPU").equals("1");
boolean NO_ARMV6 = properties.getProperty("NO_ARMV6").equals("1");
boolean hasNeon = false, hasFpu = false, hasArmV6 = false, hasArmV7 = false;
ProcessBuilder cmd;
try {
......@@ -197,13 +224,46 @@ public class Util {
InputStream in = process.getInputStream();
byte[] re = new byte[1024];
while(in.read(re) != -1){
if (new String(re).contains("neon"))
return true;
if(!hasNeon && new String(re).contains("neon"))
hasNeon = true;
if(!hasArmV7 && new String(re).contains("ARMv7"))
hasArmV7 = true;
if(!hasArmV7 && !hasArmV6 && new String(re).contains("ARMv6"))
hasArmV6 = true;
if(!hasFpu && new String(re).contains("vfp"))
hasFpu = true;
}
in.close();
} catch(IOException ex){
ex.printStackTrace();
errorMsg = "IOException whilst reading cpuinfo flags";
isCompatible = false;
return false;
}
if(ANDROID_ABI.equals("armeabi-v7a") && !hasArmV7) {
errorMsg = "ARMv7 build on non-ARMv7 device";
isCompatible = false;
return false;
}
if(ANDROID_ABI.equals("armeabi")) {
if(!NO_ARMV6 && !hasArmV6) {
errorMsg = "ARMv6 build on non-ARMv6 device";
isCompatible = false;
return false;
} else if(!NO_FPU && !hasFpu) {
errorMsg = "FPU-enabled build on non-FPU device";
isCompatible = false;
return false;
}
}
if(!NO_NEON && !hasNeon) {
errorMsg = "NEON build on non-NEON device";
isCompatible = false;
return false;
}
return false;
errorMsg = null;
isCompatible = true;
return true;
}
}
......@@ -4,7 +4,6 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
......@@ -13,22 +12,29 @@ import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.videolan.vlc.R;
import org.videolan.vlc.Util;
import android.app.Activity;
import android.os.AsyncTask;
import android.os.Build;
//import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
public class CompatErrorActivity extends Activity {
public final static String TAG = "VLC/CompatErrorActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.no_neon);
setContentView(R.layout.not_compatible);
TextView tv = (TextView)findViewById(R.id.errormsg);
tv.setText(getResources().getString(R.string.error_not_compatible) + "\n" + Util.getErrorMsg());
super.onCreate(savedInstanceState);
AsyncHttpRequest asyncHttpRequest = new AsyncHttpRequest();
asyncHttpRequest.execute(Build.MODEL, Build.DEVICE);
//AsyncHttpRequest asyncHttpRequest = new AsyncHttpRequest();
//asyncHttpRequest.execute(Build.MODEL, Build.DEVICE);
}
public class AsyncHttpRequest extends AsyncTask<String, String, Boolean> {
......
......@@ -98,14 +98,14 @@ public class MainActivity extends SherlockFragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
/*if (!Util.hasNeon()) {
Log.e(TAG, "CPU is missing NEON.");
if (!Util.hasCompatibleCPU()) {
Log.e(TAG, Util.getErrorMsg());
super.onCreate(savedInstanceState);
Intent i = new Intent(this, CompatErrorActivity.class);
startActivity(i);
finish();
return;
}*/
}
if (Util.isICSOrLater()) /* Bug on pre-ICS, the progress bar is always present */
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment