Let the submission fail to avoid introducing possible issues
This commit is contained in:
parent
fa2b229c95
commit
7158b640c9
|
@ -37,7 +37,7 @@
|
|||
|
||||
<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="log_saved">Log saved to \"System Path\"</string>
|
||||
<string name="bios_config">Configuration failed!</string>
|
||||
<string name="menu_debug">Submit Error Logs</string>
|
||||
|
||||
|
|
|
@ -10,8 +10,6 @@ import java.io.InputStream;
|
|||
import java.io.InputStreamReader;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
|
@ -40,7 +38,6 @@ 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;
|
||||
|
@ -121,8 +118,7 @@ public class GenerateLogs extends AsyncTask<String, Integer, String> {
|
|||
|
||||
@Override
|
||||
protected String doInBackground(String... params) {
|
||||
debug_directory = params[0];
|
||||
File logFile = new File(debug_directory, currentTime + ".txt");
|
||||
File logFile = new File(params[0], currentTime + ".txt");
|
||||
Process mLogcatProc = null;
|
||||
BufferedReader reader = null;
|
||||
final StringBuilder log = new StringBuilder();
|
||||
|
@ -235,46 +231,17 @@ public class GenerateLogs extends AsyncTask<String, Integer, String> {
|
|||
@Override
|
||||
protected void onPostExecute(final String response) {
|
||||
if (response != null && !response.equals(null)) {
|
||||
if (isNetworkAvailable(false)) {
|
||||
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);
|
||||
}
|
||||
Toast.makeText(mContext, mContext.getString(R.string.log_saved),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
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 {
|
||||
Toast.makeText(
|
||||
mContext,
|
||||
mContext.getString(R.string.log_saved, debug_directory),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
mUploadLogs.execute(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,20 @@ public class UploadLogs extends AsyncTask<String, Integer, Object> {
|
|||
this.mContext = mContext;
|
||||
this.currentTime = currentTime;
|
||||
}
|
||||
|
||||
private void RedirectSubmission(Header[] headers, String content) {
|
||||
UploadLogs mUploadLogs = new UploadLogs(mContext,
|
||||
currentTime);
|
||||
mUploadLogs.setPostUrl(headers[headers.length - 1]
|
||||
.getValue());
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
mUploadLogs.executeOnExecutor(
|
||||
AsyncTask.THREAD_POOL_EXECUTOR, content);
|
||||
} else {
|
||||
mUploadLogs.execute(content);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the URL for where the log will be uploaded
|
||||
*
|
||||
|
@ -79,16 +93,7 @@ public class UploadLogs extends AsyncTask<String, Integer, Object> {
|
|||
if (statusCode != HttpStatus.SC_OK) {
|
||||
Header[] headers = getResponse.getHeaders("Location");
|
||||
if (headers != null && headers.length != 0) {
|
||||
UploadLogs mUploadLogs = new UploadLogs(mContext,
|
||||
currentTime);
|
||||
mUploadLogs.setPostUrl(headers[headers.length - 1]
|
||||
.getValue());
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
mUploadLogs.executeOnExecutor(
|
||||
AsyncTask.THREAD_POOL_EXECUTOR, params[0]);
|
||||
} else {
|
||||
mUploadLogs.execute(params[0]);
|
||||
}
|
||||
RedirectSubmission(headers, params[0]);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -61,7 +61,6 @@ public class OnScreenMenu {
|
|||
if (mContext instanceof GL2JNIActivity) {
|
||||
((GL2JNIActivity) mContext).displayDebug(new DebugPopup(mContext));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class FpsPopup extends PopupWindow {
|
||||
|
@ -84,6 +83,15 @@ public class OnScreenMenu {
|
|||
}
|
||||
}
|
||||
|
||||
private void removePopUp(PopupWindow window) {
|
||||
window.dismiss();
|
||||
popups.remove(window);
|
||||
if (mContext instanceof GL2JNIActivity) {
|
||||
((GL2JNIActivity) mContext)
|
||||
.displayPopUp(((GL2JNIActivity) OnScreenMenu.this.mContext).popUp);
|
||||
}
|
||||
}
|
||||
|
||||
public class DebugPopup extends PopupWindow {
|
||||
|
||||
public DebugPopup(Context c) {
|
||||
|
@ -98,12 +106,7 @@ public class OnScreenMenu {
|
|||
|
||||
hlay.addView(addbut(R.drawable.up, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
popups.remove(this);
|
||||
dismiss();
|
||||
if (mContext instanceof GL2JNIActivity) {
|
||||
((GL2JNIActivity) mContext)
|
||||
.displayPopUp(((GL2JNIActivity) OnScreenMenu.this.mContext).popUp);
|
||||
}
|
||||
removePopUp(DebugPopup.this);
|
||||
}
|
||||
}), debugParams);
|
||||
|
||||
|
@ -137,7 +140,7 @@ public class OnScreenMenu {
|
|||
|
||||
hlay.addView(addbut(R.drawable.close, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
popups.remove(this);
|
||||
popups.remove(DebugPopup.this);
|
||||
dismiss();
|
||||
}
|
||||
}), debugParams);
|
||||
|
@ -178,12 +181,7 @@ public class OnScreenMenu {
|
|||
|
||||
hlay.addView(addbut(R.drawable.up, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
popups.remove(this);
|
||||
dismiss();
|
||||
if (mContext instanceof GL2JNIActivity) {
|
||||
((GL2JNIActivity) mContext)
|
||||
.displayPopUp(((GL2JNIActivity) OnScreenMenu.this.mContext).popUp);
|
||||
}
|
||||
removePopUp(ConfigPopup.this);
|
||||
}
|
||||
}), configParams);
|
||||
|
||||
|
@ -284,7 +282,7 @@ public class OnScreenMenu {
|
|||
|
||||
hlay.addView(addbut(R.drawable.close, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
popups.remove(this);
|
||||
popups.remove(ConfigPopup.this);
|
||||
dismiss();
|
||||
}
|
||||
}), configParams);
|
||||
|
|
Loading…
Reference in New Issue