WiGLE WiFi Wardriving FOSS v2.63版本的 MD5 值为:20a157bff1dec2e81d8268d404e15cb5

以下内容为反编译后的 ErrorReportActivity.java 源代码,内容仅作参考


package net.wigle.wigleandroid;

import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.Menu;
import android.view.MenuItem;
import android.view.WindowManager;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import net.wigle.wigleandroid.util.FileUtility;
import org.apache.commons.io.IOUtils;
public class ErrorReportActivity extends AppCompatActivity {
    public static final int MAX_STACK_TRANSACTION_SIZE = 1046528;
    private static final int MENU_EMAIL = 12;
    private static final int MENU_EXIT = 11;
    private boolean fromFailure = false;
    private String stack;
    private String stackFilePath;

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        MainActivity.setLocale(this);
        setContentView(R.layout.error);
        String latestStackfilePath = FileUtility.getLatestStackfilePath(getApplicationContext());
        this.stackFilePath = latestStackfilePath;
        if (latestStackfilePath == null || latestStackfilePath.isEmpty()) {
            finish();
        }
        this.stack = getLatestStack(this.stackFilePath);
        ((TextView) findViewById(R.id.errorreport)).setText(this.stack);
        Intent intent = getIntent();
        if (intent.getBooleanExtra("doEmail", false)) {
            this.fromFailure = true;
            setupEmail(this.stack, this.stackFilePath);
        }
        final String stringExtra = intent.getStringExtra(MainActivity.ERROR_REPORT_DIALOG);
        if (stringExtra != null) {
            this.fromFailure = true;
            shutdownRestOfApp();
            Handler handler = new Handler();
            Runnable runnable = new Runnable() {
                @Override
                public void run() {
                    AlertDialog.Builder builder = new AlertDialog.Builder(ErrorReportActivity.this);
                    builder.setCancelable(false);
                    builder.setTitle(ErrorReportActivity.this.getString(R.string.fatal_title));
                    builder.setMessage((stringExtra.contains("SQL") ? ErrorReportActivity.this.getString(R.string.fatal_db_warn) : "") + "\n\n*** " + ErrorReportActivity.this.getString(R.string.fatal_pre_message) + ": ***\n" + stringExtra + "\n\n" + ErrorReportActivity.this.getString(R.string.fatal_post_message));
                    AlertDialog create = builder.create();
                    create.setButton(-1, "OK, Shutdown", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            try {
                                dialogInterface.dismiss();
                            } catch (Exception e) {
                                MainActivity.info("exception dismissing alert dialog: " + e);
                            }
                        }
                    });
                    try {
                        if (ErrorReportActivity.this.isFinishing()) {
                            return;
                        }
                        create.show();
                    } catch (WindowManager.BadTokenException e) {
                        MainActivity.info("window probably gone when trying to display dialog. windowEx: " + e, e);
                    }
                }
            };
            handler.removeCallbacks(runnable);
            handler.postDelayed(runnable, 100L);
        }
    }

    private void shutdownRestOfApp() {
        MainActivity.info("ErrorReportActivity: shutting down app");
        MainActivity mainActivity = MainActivity.getMainActivity();
        if (mainActivity != null) {
            mainActivity.finishSoon();
        }
        if (NetworkActivity.networkActivity != null) {
            NetworkActivity.networkActivity.finish();
        }
        if (SpeechActivity.speechActivity != null) {
            SpeechActivity.speechActivity.finish();
        }
    }

    private String getLatestStack(String str) {
        StringBuilder sb;
        BufferedReader bufferedReader;
        String str2;
        StringBuilder sb2 = new StringBuilder("No Error Report found");
        if (str == null) {
            return sb2.toString();
        }
        BufferedReader bufferedReader2 = null;
        try {
            try {
                bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(str), "UTF-8"));
            } catch (IOException e) {
                e = e;
            }
        } catch (Throwable th) {
            th = th;
        }
        try {
            sb2.setLength(0);
            for (String readLine = bufferedReader.readLine(); readLine != null; readLine = bufferedReader.readLine()) {
                sb2.append(readLine).append(IOUtils.LINE_SEPARATOR_UNIX);
            }
            str2 = this.stack;
        } catch (IOException e2) {
            e = e2;
            bufferedReader2 = bufferedReader;
            MainActivity.error("error reading stack file: " + e, e);
            if (bufferedReader2 != null) {
                try {
                    bufferedReader2.close();
                } catch (IOException e3) {
                    e = e3;
                    sb = new StringBuilder();
                    MainActivity.error(sb.append("error closing stack file: ").append(e).toString(), e);
                    return sb2.toString();
                }
            }
            return sb2.toString();
        } catch (Throwable th2) {
            th = th2;
            bufferedReader2 = bufferedReader;
            if (bufferedReader2 != null) {
                try {
                    bufferedReader2.close();
                } catch (IOException e4) {
                    MainActivity.error("error closing stack file: " + e4, e4);
                }
            }
            throw th;
        }
        if (str2 == null || str2.length() > 1046528) {
            String sb3 = sb2.toString();
            try {
                bufferedReader.close();
            } catch (IOException e5) {
                MainActivity.error("error closing stack file: " + e5, e5);
            }
            return sb3;
        }
        try {
            bufferedReader.close();
        } catch (IOException e6) {
            e = e6;
            sb = new StringBuilder();
            MainActivity.error(sb.append("error closing stack file: ").append(e).toString(), e);
            return sb2.toString();
        }
        return sb2.toString();
    }

    private void setupEmail(String str, String str2) {
        MainActivity.info("ErrorReport onCreate");
        Intent intent = new Intent("android.intent.action.SEND");
        intent.putExtra("android.intent.extra.EMAIL", new String[]{"wiwiwa@wigle.net"});
        intent.putExtra("android.intent.extra.SUBJECT", "WigleWifi error report");
        intent.setType("text/plain");
        if (str == null && str2 != null && !str2.isEmpty()) {
            intent.putExtra("android.intent.extra.STREAM", str2);
        } else {
            intent.putExtra("android.intent.extra.TEXT", str);
        }
        try {
            startActivity(Intent.createChooser(intent, "Email WigleWifi error report?"));
        } catch (ActivityNotFoundException e) {
            MainActivity.warn("No email activity found: " + e.getLocalizedMessage(), e);
        } catch (RuntimeException e2) {
            MainActivity.warn("Runtime exception trying to send stack intent [stack: " + (str != null ? Integer.valueOf(str.length()) : "(none)") + " file:" + str2 + "]; ", e2);
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        if (this.fromFailure) {
            menu.add(0, 11, 0, getString(R.string.menu_exit)).setIcon(17301560);
        } else {
            menu.add(0, 11, 0, getString(R.string.menu_return)).setIcon(17301541);
        }
        menu.add(0, 12, 0, getString(R.string.menu_error_report)).setIcon(17301584);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem menuItem) {
        int itemId = menuItem.getItemId();
        if (itemId == 11) {
            finish();
            return true;
        } else if (itemId != 12) {
            return false;
        } else {
            setupEmail(this.stack, this.stackFilePath);
            return true;
        }
    }
}