Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/org/adblockplus/android/CrashHandler.java

Issue 5697499218051072: Usage of new API, cleanups (reduced) (Closed)
Patch Set: Fixed leftover first-batch review issues. Created April 16, 2014, 5:51 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/org/adblockplus/android/CrashHandler.java
diff --git a/src/org/adblockplus/android/CrashHandler.java b/src/org/adblockplus/android/CrashHandler.java
index 25b54eff2a2c376a5421445533e7d0538f5b2c1d..34085ed63903f5e664b44294610a61ee56357a47 100644
--- a/src/org/adblockplus/android/CrashHandler.java
+++ b/src/org/adblockplus/android/CrashHandler.java
@@ -34,17 +34,18 @@ import android.util.Log;
public class CrashHandler implements UncaughtExceptionHandler
{
public static final String REPORT_FILE = "AdblockPlus_Crash_Report.txt";
- private UncaughtExceptionHandler defaultUEH;
- private NotificationManager notificationManager;
- private Context context;
+ private final UncaughtExceptionHandler defaultUEH;
+ private final Context context;
+
+ private NotificationManager notificationManager;
private boolean generateReport;
private boolean restoreProxy;
private String host;
private String port;
private String excl;
- public CrashHandler(Context context)
+ public CrashHandler(final Context context)
{
defaultUEH = Thread.getDefaultUncaughtExceptionHandler();
this.context = context;
@@ -59,7 +60,7 @@ public class CrashHandler implements UncaughtExceptionHandler
}
@Override
- public void uncaughtException(Thread t, Throwable e)
+ public void uncaughtException(final Thread t, final Throwable e)
{
if (generateReport)
writeToFile(e, REPORT_FILE);
@@ -73,7 +74,7 @@ public class CrashHandler implements UncaughtExceptionHandler
{
notificationManager.cancel(ProxyService.ONGOING_NOTIFICATION_ID);
}
- catch (Throwable ex)
+ catch (final Throwable ex)
{
ex.printStackTrace();
}
@@ -83,27 +84,27 @@ public class CrashHandler implements UncaughtExceptionHandler
defaultUEH.uncaughtException(t, e);
}
- public void generateReport(boolean report)
+ public void generateReport(final boolean report)
{
generateReport = report;
}
@SuppressLint("WorldReadableFiles")
- private void writeToFile(Throwable error, String filename)
+ private void writeToFile(final Throwable error, final String filename)
{
Log.e("DCR", "Writing crash report");
int versionCode = -1;
try
{
- PackageInfo pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
+ final PackageInfo pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
versionCode = pi.versionCode;
}
- catch (NameNotFoundException ex)
+ catch (final NameNotFoundException ex)
{
}
try
{
- PrintWriter pw = new PrintWriter(context.openFileOutput(filename, Context.MODE_WORLD_READABLE));
+ final PrintWriter pw = new PrintWriter(context.openFileOutput(filename, Context.MODE_WORLD_READABLE));
// Write Android version
pw.println(Build.VERSION.SDK_INT);
// Write application build number
@@ -111,7 +112,7 @@ public class CrashHandler implements UncaughtExceptionHandler
// Write exception data
printThrowable(error, pw);
- Throwable cause = error.getCause();
+ final Throwable cause = error.getCause();
// Write cause data
if (cause != null)
{
@@ -121,19 +122,19 @@ public class CrashHandler implements UncaughtExceptionHandler
pw.flush();
pw.close();
}
- catch (Throwable e)
+ catch (final Throwable e)
{
e.printStackTrace();
}
}
- private void printThrowable(Throwable error, PrintWriter pw)
+ private void printThrowable(final Throwable error, final PrintWriter pw)
{
// Use simplest format for speed - we do not have much time
pw.println(error.getClass().getName());
pw.println(error.getMessage());
- StackTraceElement[] trace = error.getStackTrace();
- for (StackTraceElement element : trace)
+ final StackTraceElement[] trace = error.getStackTrace();
+ for (final StackTraceElement element : trace)
{
pw.print(element.getClassName());
pw.print("|");
@@ -148,7 +149,7 @@ public class CrashHandler implements UncaughtExceptionHandler
}
}
- public void saveProxySettings(String host, String port, String excl)
+ public void saveProxySettings(final String host, final String port, final String excl)
{
Log.e("DCR", "Saving proxy " + host + ":" + port + "/" + excl);
this.host = host;
@@ -166,7 +167,7 @@ public class CrashHandler implements UncaughtExceptionHandler
{
p = Integer.valueOf(port);
}
- catch (NumberFormatException e)
+ catch (final NumberFormatException e)
{
// ignore - no valid port, it will be correctly processed later
}
« no previous file with comments | « src/org/adblockplus/android/ConfigurationActivity.java ('k') | src/org/adblockplus/android/CrashReportDialog.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld