// 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.util; import android.app.AlarmManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Handler; import android.os.SystemClock; import com.olio.data.object.analytics.DumpsysBatteryStatsHelper; import java.util.Date; import java.util.concurrent.atomic.AtomicLong; // Referenced classes of package com.olio.util: // ALog public class RecoveryTimer { private static final String BROADCAST_FILTER = "com.olio.timer:ID-%d-%s"; private static final String BROADCAST_FILTER_NO_INCREMENT = "com.olio.timer:ID-%s"; private static AtomicLong token = new AtomicLong(0L); private Runnable mAction; private Context mContext; private Handler mHandler; private PendingIntent mPendingIntent; private BroadcastReceiver mReceiver = new BroadcastReceiver() { final RecoveryTimer this$0; public void onReceive(Context context, Intent intent) { ALog.d("At '%s' timer %s was triggered", new Object[] { (new Date()).toString(), mRequestId }); DumpsysBatteryStatsHelper.getInstance().log("timer_fired=%s", new Object[] { mRequestId }); mHandler.post(mAction); } { this$0 = RecoveryTimer.this; super(); } }; private final String mRequestId; private final String mTag; private final long mToken; public RecoveryTimer(String s) { this(s, true); } public RecoveryTimer(String s, boolean flag) { mToken = token.getAndIncrement(); mTag = s; if (flag) { mRequestId = String.format("com.olio.timer:ID-%d-%s", new Object[] { Long.valueOf(mToken), mTag }); return; } else { mRequestId = String.format("com.olio.timer:ID-%s", new Object[] { mTag }); return; } } private static long getBaseTime(int i) { if (i == 0 || i == 1) { return System.currentTimeMillis(); } if (i == 2 || i == 3) { return SystemClock.elapsedRealtime(); } else { return 0L; } } public void cancel() { this; JVM INSTR monitorenter ; ALog.d("At '%s' timer %s was canceled", new Object[] { (new Date()).toString(), mRequestId }); if (mContext != null) goto _L2; else goto _L1 _L1: ALog.e("missing context", new Object[0]); _L4: this; JVM INSTR monitorexit ; return; _L2: if (mPendingIntent != null) { ALog.d("cancelling pending intent with AlarmManager", new Object[0]); ((AlarmManager)mContext.getSystemService("alarm")).cancel(mPendingIntent); } if (true) goto _L4; else goto _L3 _L3: Exception exception; exception; throw exception; } public void dispose() { this; JVM INSTR monitorenter ; ALog.d("dispose", new Object[0]); if (mContext != null) { mContext.unregisterReceiver(mReceiver); } cancel(); mPendingIntent = null; mHandler = null; mContext = null; ALog.d("At '%s' timer %s was disposed", new Object[] { (new Date()).toString(), mRequestId }); this; JVM INSTR monitorexit ; return; Exception exception; exception; throw exception; } public void init(Context context, Handler handler) { this; JVM INSTR monitorenter ; mHandler = handler; mContext = context; mContext.registerReceiver(mReceiver, new IntentFilter(mRequestId)); if (mPendingIntent == null) { ALog.d("creating new pending intent", new Object[0]); context = new Intent(mRequestId); mPendingIntent = PendingIntent.getBroadcast(mContext, 0, context, 0x10000000); } ALog.d("At '%s' timer %s was initialized", new Object[] { (new Date()).toString(), mRequestId }); this; JVM INSTR monitorexit ; return; context; throw context; } public void setRepeating(long l, long l1, Runnable runnable) { this; JVM INSTR monitorenter ; if (mContext == null) { throw new IllegalStateException("Please call init first"); } break MISSING_BLOCK_LABEL_26; runnable; this; JVM INSTR monitorexit ; throw runnable; AlarmManager alarmmanager = (AlarmManager)mContext.getSystemService("alarm"); mAction = runnable; alarmmanager.setRepeating(1, l, l1, mPendingIntent); this; JVM INSTR monitorexit ; } public void startOrRestart(long l, long l1, Runnable runnable) { this; JVM INSTR monitorenter ; startOrRestartWithMode(l, l1, 0, runnable); this; JVM INSTR monitorexit ; return; runnable; throw runnable; } public void startOrRestart(long l, Runnable runnable) { this; JVM INSTR monitorenter ; startOrRestartWithMode(l, 0, runnable); this; JVM INSTR monitorexit ; return; runnable; throw runnable; } public void startOrRestartExact(long l, Runnable runnable) { this; JVM INSTR monitorenter ; startOrRestartWithMode(l, 0, runnable, true); this; JVM INSTR monitorexit ; return; runnable; throw runnable; } public void startOrRestartWithMode(long l, int i, Runnable runnable) { this; JVM INSTR monitorenter ; startOrRestartWithMode(l, i, runnable, false); this; JVM INSTR monitorexit ; return; runnable; throw runnable; } public void startOrRestartWithMode(long l, int i, Runnable runnable, boolean flag) { this; JVM INSTR monitorenter ; if (mContext == null) { throw new IllegalStateException(String.format("Please initialize timer %s first", new Object[] { mRequestId })); } break MISSING_BLOCK_LABEL_40; runnable; this; JVM INSTR monitorexit ; throw runnable; String s = (new Date()).toString(); Object obj; long l1; if (flag) { obj = "an exact"; } else { obj = "a"; } ALog.d("At '%s' %s timer %s was started with countdown: %s millis", new Object[] { s, obj, mRequestId, Long.valueOf(l) }); obj = (AlarmManager)mContext.getSystemService("alarm"); mAction = runnable; l1 = getBaseTime(i); if (!flag) { break MISSING_BLOCK_LABEL_149; } ((AlarmManager) (obj)).setExact(i, l1 + l, mPendingIntent); _L1: this; JVM INSTR monitorexit ; return; ((AlarmManager) (obj)).set(i, l1 + l, mPendingIntent); goto _L1 } public void startOrRestartWithMode(long l, final long timeout, final int mode, final Runnable action) { this; JVM INSTR monitorenter ; if (mContext == null) { throw new IllegalStateException("Please call init first"); } break MISSING_BLOCK_LABEL_26; action; this; JVM INSTR monitorexit ; throw action; ALog.d("At '%s' timer %s was started in: %d millis with: %s period", new Object[] { (new Date()).toString(), mRequestId, Long.valueOf(l), Long.valueOf(timeout) }); final AlarmManager alarmManager = (AlarmManager)mContext.getSystemService("alarm"); mAction = new Runnable() { final RecoveryTimer this$0; final Runnable val$action; final AlarmManager val$alarmManager; final int val$mode; final long val$timeout; public void run() { action.run(); long l1 = RecoveryTimer.getBaseTime(mode); alarmManager.set(mode, timeout + l1, mPendingIntent); } { this$0 = RecoveryTimer.this; action = runnable; mode = i; alarmManager = alarmmanager; timeout = l; super(); } }; alarmManager.set(mode, getBaseTime(mode) + l, mPendingIntent); this; JVM INSTR monitorexit ; } public String toString() { return mRequestId; } }