Warn users of Telechips devices that app will crash with their broken libc

This commit is contained in:
pelya
2011-06-22 16:43:22 +03:00
parent 4e214b0ffd
commit 819febb3af
10 changed files with 107 additions and 11 deletions

View File

@@ -149,6 +149,7 @@ class Settings
out.writeInt(Globals.OptionalDataDownload.length);
for(int i = 0; i < Globals.OptionalDataDownload.length; i++)
out.writeBoolean(Globals.OptionalDataDownload[i]);
out.writeBoolean(Globals.BrokenLibCMessageShown);
out.close();
settingsLoaded = true;
@@ -283,6 +284,7 @@ class Settings
Globals.OptionalDataDownload = new boolean[settingsFile.readInt()];
for(int i = 0; i < Globals.OptionalDataDownload.length; i++)
Globals.OptionalDataDownload[i] = settingsFile.readBoolean();
Globals.BrokenLibCMessageShown = settingsFile.readBoolean();
settingsLoaded = true;
@@ -394,9 +396,67 @@ class Settings
static ArrayList<Menu> menuStack = new ArrayList<Menu> ();
public static void showConfig(final MainActivity p, boolean firstStart)
public static void showConfig(final MainActivity p, final boolean firstStart)
{
settingsChanged = true;
if( !Globals.BrokenLibCMessageShown )
{
Globals.BrokenLibCMessageShown = true;
try {
InputStream in = p.getAssets().open("stdout-test");
File outDir = p.getFilesDir();
try {
outDir.mkdirs();
} catch( SecurityException ee ) { };
byte[] buf = new byte[16384];
OutputStream out = null;
String path = outDir.getAbsolutePath() + "/" + "stdout-test";
out = new FileOutputStream( path );
int len = in.read(buf);
while (len >= 0)
{
if(len > 0)
out.write(buf, 0, len);
len = in.read(buf);
}
out.flush();
out.close();
Settings.nativeChmod(path, 0755);
if( (new ProcessBuilder().command(path).start()).waitFor() != 42 )
{
System.out.println("libSDL: stdout-test FAILED, your libc is broken");
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(p.getResources().getString(R.string.broken_libc_title));
builder.setMessage(p.getResources().getString(R.string.broken_libc_text));
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
dialog.dismiss();
showConfig(p, firstStart);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
dialog.dismiss();
showConfig(p, firstStart);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
return;
}
System.out.println("libSDL: stdout-test passed, your libc seems to be good");
} catch ( Exception eeee ) {
System.out.println("libSDL: Cannot run stdout-test: " + eeee.toString());
}
}
if( Globals.OptionalDataDownload == null )
{
@@ -2401,5 +2461,6 @@ class Settings
private static native void nativeSetMultitouchGestureSensitivity(int sensitivity);
private static native void nativeSetTouchscreenCalibration(int x1, int y1, int x2, int y2);
public static native void nativeSetEnv(final String name, final String value);
public static native int nativeChmod(final String name, int mode);
}