Merge pull request #304 from NoblesseOblige/master

More logging stuff to ensure we get logs
This commit is contained in:
TwistedUmbrella 2014-02-18 13:52:50 -05:00
commit 44b8937a4f
10 changed files with 150 additions and 66 deletions

View File

@ -36,6 +36,10 @@
<string name="games_listing">Available Dreamcast Games</string>
<string name="report_issue">Previous Crash Detected</string>
<string name="platform">Copying logcat content to clipboard\nPlease paste in the issue report</string>
<string name="log_saved">Log saved to %1$s</string>
<string name="bios_config">Configuration failed!</string>
<string name="menu_debug">Submit Error Logs</string>
<string name="customize_touch_controls">Customize Touch Controls</string>
<string name="launch_editor">Launch Editor</string>
@ -109,9 +113,5 @@
<string name="textOn">ON</string>
<string name="textOff">OFF</string>
<string name="platform">Copying logcat content to clipboard\nPlease paste in the issue report</string>
<string name="bios_config">Configuration failed!</string>
<string name="menu_debug">Submit Error Logs</string>
</resources>

View File

@ -40,7 +40,6 @@ import android.widget.TextView;
import android.widget.Toast;
import com.android.util.FileUtils;
import com.reicast.emulator.config.OptionsFragment;
import com.reicast.emulator.emu.JNIdc;
public class FileBrowser extends Fragment {

View File

@ -23,7 +23,6 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.TextView;
import android.widget.Toast;
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.OnOpenListener;
@ -83,6 +82,12 @@ public class MainActivity extends SlidingFragmentActivity implements
}
}
/**
* Load the GUI interface for display to the user
*
* @param bundle
* The savedInstanceState passed from onCreate
*/
private void loadInterface(Bundle savedInstanceState) {
if (!getFilesDir().exists()) {
getFilesDir().mkdir();
@ -270,6 +275,14 @@ public class MainActivity extends SlidingFragmentActivity implements
});
}
/**
* Display a dialog to notify the user of prior crash
*
* @param string
* A generalized summary of the crash cause
* @param bundle
* The savedInstanceState passed from onCreate
*/
private void initiateReport(final String error, final Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setTitle(getString(R.string.report_issue));
@ -284,9 +297,6 @@ public class MainActivity extends SlidingFragmentActivity implements
builder.setPositiveButton("Report",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(MainActivity.this,
getString(R.string.platform),
Toast.LENGTH_SHORT).show();
GenerateLogs mGenerateLogs = new GenerateLogs(MainActivity.this);
mGenerateLogs.setUnhandled(error);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {

View File

@ -25,7 +25,6 @@ import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.android.util.DreamTime;
import com.reicast.emulator.R;
@ -351,9 +350,6 @@ public class ConfigureFragment extends Fragment {
}
public void generateErrorLog() {
Toast.makeText(parentActivity,
parentActivity.getString(R.string.platform), Toast.LENGTH_SHORT)
.show();
GenerateLogs mGenerateLogs = new GenerateLogs(parentActivity);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
mGenerateLogs.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,

View File

@ -394,6 +394,14 @@ public class InputModFragment extends Fragment {
});
}
/**
* Retrieve an image to serve as a visual representation
*
* @param int
* The x start value of the image within the atlas
* @param int
* The y start value of the image within the atlas
*/
private Drawable getButtonImage(int x, int y) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
Runtime.getRuntime().freeMemory();
@ -446,6 +454,10 @@ public class InputModFragment extends Fragment {
}
}
/**
* Prompt the user to specify the controller to modify
*
*/
private void selectController() {
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
builder.setTitle(getString(R.string.select_controller_title));
@ -480,6 +492,14 @@ public class InputModFragment extends Fragment {
super(c);
}
/**
* Prompt the user for the button to be assigned
*
* @param string
* The name of the emulator button being defined
* @param textview
* The output display for the assigned button value
*/
public void intiateSearch(String button, final TextView output) {
this.button = button;
this.output = output;
@ -495,35 +515,36 @@ public class InputModFragment extends Fragment {
isMapping = false;
dialog.dismiss();
}
});
});
builder.setOnKeyListener(new Dialog.OnKeyListener() {
public boolean onKey(DialogInterface dialog, int keyCode,
KeyEvent event) {
if (!(keyCode == KeyEvent.KEYCODE_DPAD_UP
|| keyCode == KeyEvent.KEYCODE_DPAD_DOWN
|| keyCode == KeyEvent.KEYCODE_DPAD_LEFT
|| keyCode == KeyEvent.KEYCODE_DPAD_RIGHT)
&& isDpadDevice(event)) {
int value = mapButton(keyCode, event);
isMapping = false;
dialog.dismiss();
if (value != -1) {
String label = output.getText().toString();
if (label.contains(":")) {
label = label.substring(0, label.indexOf(":"));
}
output.setText(label + ": " + String.valueOf(value));
return true;
int value = mapButton(keyCode, event);
isMapping = false;
dialog.dismiss();
if (value != -1) {
String label = output.getText().toString();
if (label.contains(":")) {
label = label.substring(0, label.indexOf(":"));
}
output.setText(label + ": " + String.valueOf(value));
return true;
}
return false;
}
});
builder.create();
builder.show();
}
/**
* Assign the user button to the emulator button
*
* @param int
* The keycode generated by the button being assigned
* @param keyevent
* The keyevent generated by the button being assigned
*/
private int mapButton(int keyCode, KeyEvent event) {
if (android.os.Build.MODEL.startsWith("R800")) {
if (keyCode == KeyEvent.KEYCODE_MENU)
@ -578,18 +599,6 @@ public class InputModFragment extends Fragment {
}
}
public static boolean isDpadDevice(android.view.InputEvent event) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
if ((event.getSource() & InputDevice.SOURCE_DPAD)
!= InputDevice.SOURCE_DPAD) {
return true;
} else {
return false;
}
}
return false;
}
private void remKeyCode(final String button, final TextView output) {
mPrefs.edit().remove(button + player).commit();
String label = output.getText().toString();

View File

@ -16,7 +16,6 @@ import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import com.reicast.emulator.MainActivity;
import com.reicast.emulator.R;
public class OptionsFragment extends Fragment {

View File

@ -9,10 +9,15 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import android.annotation.SuppressLint;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Handler;
import android.widget.Toast;
import com.reicast.emulator.R;
public class GenerateLogs extends AsyncTask<String, Integer, String> {
@ -35,17 +40,17 @@ public class GenerateLogs extends AsyncTask<String, Integer, String> {
private Context mContext;
private String currentTime;
private String debug_directory;
public GenerateLogs(Context mContext) {
this.mContext = mContext;
this.currentTime = String.valueOf(System.currentTimeMillis());
}
@SuppressLint("NewApi")
protected void onPreExecute() {
}
/**
* Obtain the specific parameters of the current device
*
*/
private String discoverCPUData() {
String s = "MODEL: " + Build.MODEL;
s += "\r\n";
@ -85,6 +90,12 @@ public class GenerateLogs extends AsyncTask<String, Integer, String> {
return s;
}
/**
* Read the output of a shell command
*
* @param string
* The shell command being issued to the terminal
*/
public static String readOutput(String command) {
try {
Process p = Runtime.getRuntime().exec(command);
@ -110,7 +121,8 @@ public class GenerateLogs extends AsyncTask<String, Integer, String> {
@Override
protected String doInBackground(String... params) {
String logOuput = params[0] + "/" + currentTime + ".txt";
debug_directory = params[0];
File logFile = new File(debug_directory, currentTime + ".txt");
Process mLogcatProc = null;
BufferedReader reader = null;
final StringBuilder log = new StringBuilder();
@ -209,8 +221,7 @@ public class GenerateLogs extends AsyncTask<String, Integer, String> {
reader.close();
reader = null;
}
File file = new File(logOuput);
BufferedWriter writer = new BufferedWriter(new FileWriter(file));
BufferedWriter writer = new BufferedWriter(new FileWriter(logFile));
writer.write(log.toString());
writer.flush();
writer.close();
@ -222,15 +233,60 @@ public class GenerateLogs extends AsyncTask<String, Integer, String> {
}
@Override
protected void onPostExecute(String response) {
protected void onPostExecute(final String response) {
if (response != null && !response.equals(null)) {
UploadLogs mUploadLogs = new UploadLogs(mContext, currentTime);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
mUploadLogs.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,
response);
Handler handler = new Handler();
if (isNetworkAvailable(false)) {
handler.post(new Runnable() {
public void run() {
Toast.makeText(mContext,
mContext.getString(R.string.platform),
Toast.LENGTH_SHORT).show();
UploadLogs mUploadLogs = new UploadLogs(mContext,
currentTime);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
mUploadLogs.executeOnExecutor(
AsyncTask.THREAD_POOL_EXECUTOR, response);
} else {
mUploadLogs.execute(response);
}
}
});
} else {
mUploadLogs.execute(response);
handler.post(new Runnable() {
public void run() {
Toast.makeText(
mContext,
mContext.getString(R.string.log_saved,
debug_directory), Toast.LENGTH_SHORT)
.show();
}
});
}
}
}
/**
* Check for network connectivity, either wifi or any
*
* @param boolean
* Whether to consider all data or just wifi
*/
public boolean isNetworkAvailable(boolean wifi_only) {
ConnectivityManager connectivityManager = (ConnectivityManager) mContext
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager
.getActiveNetworkInfo();
if (wifi_only) {
return activeNetworkInfo != null
/*
* && activeNetworkInfo.getType() ==
* ConnectivityManager.TYPE_WIFI
*/
&& connectivityManager.getNetworkInfo(
ConnectivityManager.TYPE_WIFI).isConnected();
} else {
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
}
}
}

View File

@ -21,10 +21,18 @@ import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.StrictMode;
import com.reicast.emulator.R;
/**
* Upload the specialized logcat to reicast issues
*
* @param context
* The context this method will be executed from
* @param string
* The system time at which the log was made
*/
public class UploadLogs extends AsyncTask<String, Integer, Object> {
private String currentTime;
@ -35,22 +43,31 @@ public class UploadLogs extends AsyncTask<String, Integer, Object> {
this.mContext = mContext;
this.currentTime = currentTime;
}
/**
* Set the URL for where the log will be uploaded
*
* @param string
* The URL of the log upload server
*/
public void setPostUrl(String logUrl) {
this.logUrl = logUrl;
}
@SuppressLint("NewApi")
protected void onPreExecute() {
if (logUrl == null || logUrl.equals(null)) {
logUrl = "http://twisted.dyndns.tv:3194/ReicastBot/report/submit.php";
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
.permitAll().build();
StrictMode.setThreadPolicy(policy);
}
}
@Override
protected Object doInBackground(String... params) {
HttpClient client = new DefaultHttpClient();
if (logUrl == null || logUrl.equals(null)) {
logUrl = "http://twisted.dyndns.tv:3194/ReicastBot/report/submit.php";
}
HttpPost post = new HttpPost(logUrl);
try {
ArrayList<NameValuePair> mPairs = new ArrayList<NameValuePair>();

View File

@ -7,7 +7,6 @@ import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.Environment;
import android.view.Gravity;
import android.view.View;

View File

@ -3,7 +3,6 @@ package com.reicast.emulator.periph;
/******************************************************************************/
import tv.ouya.console.api.OuyaController;
import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Handler;