// 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.os.SystemClock; import com.olio.state.CurrentDevice; import com.olio.util.ALog; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; // Referenced classes of package com.olio.data.object.analytics: // AnalyticsLogger, PropertyAppender, AnalyticsLog public class CpuStatsLogger implements AnalyticsLogger { public static class CpuStats { private long timeInSleep; private long timeWithCpuOnScreenOff; private long timeWithScreenOn; public long getTimeInSleep() { return timeInSleep; } public long getTimeWithCpuOnScreenOff() { return timeWithCpuOnScreenOff; } public long getTimeWithScreenOn() { return timeWithScreenOn; } public CpuStats(long l, long l1, long l2) { timeInSleep = l; timeWithCpuOnScreenOff = l1; timeWithScreenOn = l2; ALog.d("CpuStats: %d, %d, %d", new Object[] { Long.valueOf(l), Long.valueOf(l1), Long.valueOf(l2) }); } } private static final String SCREEN_OFF_CPU_ON_ENTRY_VALUE = "300000"; private static final String SCREEN_OFF_CPU_ON_PROPERTY_APPENDER_NAME = "CpuStatsUtils.ScreenOffCpuOn"; private static final String SCREEN_ON_ENTRY_VALUE = "800000"; private static final String SCREEN_ON_PROPERTY_APPENDER_NAME = "CpuStatsUtils.ScreenOn"; private static final String SLEEP_APPENDER_NAME = "CpuStatsUtils.SleepTime"; private Context context; private PropertyAppender screenOffAppender; private PropertyAppender screenOnAppender; private PropertyAppender sleepAppender; public CpuStatsLogger() { } protected CpuStats currentValuesFromFile() { Object obj; Object obj2; long l; long l1; ALog.d("CpuStatsLogger currentValuesFromFile", new Object[0]); obj = null; obj2 = null; l1 = 0L; l = 0L; Object obj1 = new BufferedReader(new InputStreamReader(new FileInputStream(new File("/sys/devices/system/cpu/cpu0/cpufreq/stats/", "time_in_state")))); long l2 = l1; _L2: l1 = l2; obj = ((BufferedReader) (obj1)).readLine(); if (obj == null) { break; /* Loop/switch isn't completed */ } obj = ((String) (obj)).split(" "); if ("300000".equals(obj[0])) { l2 = Long.parseLong(obj[1]); continue; /* Loop/switch isn't completed */ } l2 = l1; if (!"800000".equals(obj[0])) { continue; /* Loop/switch isn't completed */ } l2 = Long.parseLong(obj[1]); l = l2; l2 = l1; if (true) goto _L2; else goto _L1 _L1: if (obj1 == null) { break MISSING_BLOCK_LABEL_140; } ((BufferedReader) (obj1)).close(); long l3; l3 = l; l2 = l1; _L3: return new CpuStats(SystemClock.elapsedRealtime() - l2 - l3, l2, l3); obj; ALog.e("Exception closing buffer", ((Throwable) (obj)), new Object[0]); l2 = l1; l3 = l; goto _L3 obj; obj1 = obj2; obj2 = obj; _L7: obj = obj1; ALog.e("Exception getting batterystats", ((Throwable) (obj2)), new Object[0]); l2 = l1; l3 = l; if (obj1 == null) goto _L3; else goto _L4 _L4: ((BufferedReader) (obj1)).close(); l2 = l1; l3 = l; goto _L3 obj; ALog.e("Exception closing buffer", ((Throwable) (obj)), new Object[0]); l2 = l1; l3 = l; goto _L3 Exception exception; exception; obj1 = obj; obj = exception; _L6: if (obj1 != null) { try { ((BufferedReader) (obj1)).close(); } catch (IOException ioexception) { ALog.e("Exception closing buffer", ioexception, new Object[0]); } } throw obj; obj; if (true) goto _L6; else goto _L5 _L5: exception; goto _L7 } public void onSessionEnd(Long long1) { ALog.d("CpuStatsLogger onSessionEnd", new Object[0]); onUpdate(long1); long l = screenOffAppender.getProperyValue(); long l1 = screenOnAppender.getProperyValue(); long l2 = sleepAppender.getProperyValue(); AnalyticsLog.logCpuStats(long1.longValue(), CurrentDevice.getSoftwareVersion(), l2, l, l1, context.getContentResolver()); resetLogs(); } public void onUpdate(Long long1) { ALog.d("CpuStatsLogger onUpdate", new Object[0]); long1 = currentValuesFromFile(); screenOffAppender.addData(((CpuStats) (long1)).timeWithCpuOnScreenOff); screenOnAppender.addData(long1.getTimeWithScreenOn()); sleepAppender.addData(long1.getTimeInSleep()); } public void register(Context context1) { ALog.d("CpuStatsLogger register", new Object[0]); context = context1; screenOffAppender = PropertyAppender.propertyAppenderForName("300000", context1); screenOnAppender = PropertyAppender.propertyAppenderForName("CpuStatsUtils.ScreenOn", context1); sleepAppender = PropertyAppender.propertyAppenderForName("CpuStatsUtils.SleepTime", context1); context1 = currentValuesFromFile(); screenOffAppender.addData(((CpuStats) (context1)).timeWithCpuOnScreenOff); screenOnAppender.addData(context1.getTimeWithScreenOn()); sleepAppender.addData(context1.getTimeInSleep()); } public void resetLogs() { ALog.d("CpuStatsLogger resetLogs", new Object[0]); screenOffAppender.clear(); screenOnAppender.clear(); sleepAppender.clear(); } }