// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.geocities.com/kpdus/jad.html // Decompiler options: braces fieldsfirst space lnc package com.olio.data.object.analytics; import android.content.Context; import android.content.IntentFilter; import android.content.res.Resources; import android.os.Environment; import android.os.Handler; import android.os.HandlerThread; import android.os.SystemClock; import com.olio.util.ALog; import com.olio.util.SharedUtils; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.text.SimpleDateFormat; import java.util.Locale; public class DumpsysBatteryStatsHelper { private static final String BATTERY_STATS_COPY_PREFIX = "battery_stats_"; private static final String CPU_STATS_COPY_PREFIX = "cpu_stats_"; private static final String CPU_STATS_TXT = "olio_cpu_stats.txt"; private static final String OLIO_DUMPSYS_COPY_PREFIX = "olio_dumpsys_"; private static final String OLIO_DUMPSYS_TXT = "olio_dumpsys.txt"; private static final SimpleDateFormat myDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS_Z"); private static final DumpsysBatteryStatsHelper theInstance = new DumpsysBatteryStatsHelper(); Context context; private String fileLocation; private Handler mBackgroundHandler; private HandlerThread mBackgroundThread; private boolean shouldLog; private BufferedWriter writer; public DumpsysBatteryStatsHelper() { shouldLog = false; } public static DumpsysBatteryStatsHelper getInstance() { return theInstance; } public void close() { if (!shouldLog) { return; } ALog.d("DumpsysBatteryStatsHelper: close", new Object[0]); if (mBackgroundThread != null) { mBackgroundThread.quitSafely(); } try { writer.close(); return; } catch (IOException ioexception) { ALog.e("DumpsysBatteryStatsHelper couldn't close file", new Object[0]); } } public transient void log(final long processorTime, final long currentTime, final String formatString, final Object events[]) { if (!shouldLog) { return; } else { ALog.d("DumpsysBatteryStatsHelper: log", new Object[0]); mBackgroundHandler.post(new Runnable() { final DumpsysBatteryStatsHelper this$0; final long val$currentTime; final Object val$events[]; final String val$formatString; final long val$processorTime; public void run() { Object obj = new IntentFilter("android.intent.action.BATTERY_CHANGED"); obj = context.registerReceiver(null, ((IntentFilter) (obj))); int i; if (obj == null) { ALog.w("WatchTransfer: battery state unknown", new Object[0]); i = -1; } else { i = SharedUtils.batteryPercentage(((android.content.Intent) (obj))); } try { writer.append(String.format(Locale.US, "%d,%d,%d,", new Object[] { Long.valueOf(processorTime), Long.valueOf(currentTime), Integer.valueOf(i) })); writer.append(String.format(Locale.US, formatString, events)); writer.newLine(); writer.flush(); return; } catch (IOException ioexception) { ALog.e("DumpsysBatteryStatsHelper couldn't write to file", ioexception, new Object[0]); } } { this$0 = DumpsysBatteryStatsHelper.this; processorTime = l; currentTime = l1; formatString = s; events = aobj; super(); } }); return; } } public transient void log(String s, Object aobj[]) { if (!shouldLog) { return; } else { log(SystemClock.elapsedRealtime(), System.currentTimeMillis(), s, aobj); return; } } public void makeBatteryStatsCopy(long l, Context context1) { if (shouldLog) goto _L2; else goto _L1 _L1: return; _L2: Object obj; Object obj1; Object obj2; IOException ioexception; Object obj3; String s; ALog.d("DumpsysBatteryStatsHelper makeBatteryStatsCopy", new Object[0]); obj = null; ioexception = null; obj2 = null; obj1 = myDateFormat.format(Long.valueOf(l)); s = String.format(Locale.US, "%s%s.txt", new Object[] { "battery_stats_", obj1 }); context1 = (new StringBuilder()).append(Environment.getExternalStorageDirectory()).append(File.separator).append(context1.getResources().getString(com.olio.comunication.R.string.base_file_directory)).append(File.separator).toString(); obj1 = null; obj3 = null; context1 = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(context1, s)))); obj = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec("dumpsys batterystats").getInputStream())); _L5: obj1 = ((BufferedReader) (obj)).readLine(); if (obj1 == null) goto _L4; else goto _L3 _L3: context1.write(((String) (obj1))); context1.newLine(); goto _L5 ioexception; obj2 = obj; _L8: obj = obj2; obj1 = context1; ALog.e("Exception getting batterystats", ioexception, new Object[0]); if (obj2 != null) { try { ((BufferedReader) (obj2)).close(); } // Misplaced declaration of an exception variable catch (Object obj) { ALog.e("Exception closing buffer", ((Throwable) (obj)), new Object[0]); } } if (context1 != null) { try { context1.close(); return; } // Misplaced declaration of an exception variable catch (Context context1) { ALog.e("Exception closing buffer", context1, new Object[0]); } return; } goto _L1 _L4: if (obj != null) { try { ((BufferedReader) (obj)).close(); } // Misplaced declaration of an exception variable catch (Object obj) { ALog.e("Exception closing buffer", ((Throwable) (obj)), new Object[0]); } } if (context1 == null) { break MISSING_BLOCK_LABEL_268; } context1.close(); return; context1; ALog.e("Exception closing buffer", context1, new Object[0]); return; context1; _L7: if (obj != null) { try { ((BufferedReader) (obj)).close(); } // Misplaced declaration of an exception variable catch (Object obj) { ALog.e("Exception closing buffer", ((Throwable) (obj)), new Object[0]); } } if (obj1 != null) { try { ((BufferedWriter) (obj1)).close(); } // Misplaced declaration of an exception variable catch (Object obj) { ALog.e("Exception closing buffer", ((Throwable) (obj)), new Object[0]); } } throw context1; Exception exception; exception; obj = ioexception; obj1 = context1; context1 = exception; continue; /* Loop/switch isn't completed */ exception; obj1 = context1; context1 = exception; if (true) goto _L7; else goto _L6 _L6: ioexception; context1 = obj3; goto _L8 ioexception; goto _L8 } public void makeOlioDumpsysCopy(final long currentTime, final Context context) { if (!shouldLog) { return; } else { mBackgroundHandler.post(new Runnable() { final DumpsysBatteryStatsHelper this$0; final Context val$context; final long val$currentTime; public void run() { Object obj3; ALog.d("DumpsysBatteryStatsHelper makeOlioDumpsysCopy", new Object[0]); Object obj = DumpsysBatteryStatsHelper.myDateFormat.format(Long.valueOf(currentTime)); obj = String.format(Locale.US, "%s%s.txt", new Object[] { "olio_dumpsys_", obj }); String s1 = (new StringBuilder()).append(Environment.getExternalStorageDirectory()).append(File.separator).append(context.getResources().getString(com.olio.comunication.R.string.base_file_directory)).append(File.separator).toString(); String s = (new StringBuilder()).append(Environment.getExternalStorageDirectory()).append(File.separator).append(context.getResources().getString(com.olio.comunication.R.string.base_file_directory)).append(File.separator).toString(); Object obj2 = null; Object obj5 = null; Object obj1 = null; obj3 = null; Object obj4 = null; Exception exception; try { obj = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(s1, ((String) (obj)))))); } // Misplaced declaration of an exception variable catch (Object obj3) { obj = obj5; continue; /* Loop/switch isn't completed */ } finally { } _L4: obj1 = new BufferedReader(new InputStreamReader(new FileInputStream(new File(s, "olio_dumpsys.txt")))); _L3: obj2 = ((BufferedReader) (obj1)).readLine(); if (obj2 == null) goto _L2; else goto _L1 _L1: ((BufferedWriter) (obj)).write(((String) (obj2))); ((BufferedWriter) (obj)).newLine(); goto _L3 obj3; obj4 = obj1; _L7: obj1 = obj4; obj2 = obj; ALog.e("Exception getting batterystats", ((Throwable) (obj3)), new Object[0]); if (obj4 != null) { try { ((BufferedReader) (obj4)).close(); } // Misplaced declaration of an exception variable catch (Object obj1) { ALog.e("Exception closing buffer", ((Throwable) (obj1)), new Object[0]); } } if (obj != null) { try { ((BufferedWriter) (obj)).close(); } // Misplaced declaration of an exception variable catch (Object obj) { ALog.e("Exception closing buffer", ((Throwable) (obj)), new Object[0]); } } break MISSING_BLOCK_LABEL_275; _L2: if (obj1 != null) { try { ((BufferedReader) (obj1)).close(); } // Misplaced declaration of an exception variable catch (Object obj1) { ALog.e("Exception closing buffer", ((Throwable) (obj1)), new Object[0]); } } if (obj != null) { try { ((BufferedWriter) (obj)).close(); } // Misplaced declaration of an exception variable catch (Object obj) { ALog.e("Exception closing buffer", ((Throwable) (obj)), new Object[0]); } } break MISSING_BLOCK_LABEL_275; _L5: if (obj1 != null) { try { ((BufferedReader) (obj1)).close(); } // Misplaced declaration of an exception variable catch (Object obj1) { ALog.e("Exception closing buffer", ((Throwable) (obj1)), new Object[0]); } } if (obj2 != null) { try { ((BufferedWriter) (obj2)).close(); } // Misplaced declaration of an exception variable catch (Object obj1) { ALog.e("Exception closing buffer", ((Throwable) (obj1)), new Object[0]); } } throw obj; try { writer.close(); obj = new FileOutputStream(new File(fileLocation, "olio_dumpsys.txt")); writer = new BufferedWriter(new OutputStreamWriter(((java.io.OutputStream) (obj)))); return; } // Misplaced declaration of an exception variable catch (Object obj) { ALog.e("unable to close the writer while deleting the file", new Object[0]); } return; exception; obj1 = obj3; obj2 = obj; obj = exception; continue; /* Loop/switch isn't completed */ obj3; obj2 = obj; obj = obj3; if (true) goto _L5; else goto _L4 obj3; if (true) goto _L7; else goto _L6 _L6: } { this$0 = DumpsysBatteryStatsHelper.this; currentTime = l; context = context1; super(); } }); return; } } public void open(Context context1, boolean flag) { shouldLog = flag; if (!flag) { return; } ALog.d("DumpsysBatteryStatsHelper: open", new Object[0]); fileLocation = (new StringBuilder()).append(Environment.getExternalStorageDirectory()).append(File.separator).append(context1.getResources().getString(com.olio.comunication.R.string.base_file_directory)).append(File.separator).toString(); context = context1; mBackgroundThread = new HandlerThread("DumpsysBattStatsHelperThread", 10); mBackgroundThread.start(); mBackgroundHandler = new Handler(mBackgroundThread.getLooper()); try { writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(fileLocation, "olio_dumpsys.txt"), true))); return; } // Misplaced declaration of an exception variable catch (Context context1) { ALog.e("DumpsysBatteryStatsHelper couldn't open file", context1, new Object[0]); } } /* static BufferedWriter access$002(DumpsysBatteryStatsHelper dumpsysbatterystatshelper, BufferedWriter bufferedwriter) { dumpsysbatterystatshelper.writer = bufferedwriter; return bufferedwriter; } */ }