package com.liulishuo.filedownloader; import android.os.SystemClock; /* loaded from: classes.dex */ public class DownloadSpeedMonitor implements IDownloadSpeed$Monitor, IDownloadSpeed$Lookup { private long a; private long b; private long c; private long d; private int e; private int f = 1000; @Override // com.liulishuo.filedownloader.IDownloadSpeed$Monitor public void a(long j) { if (this.d <= 0) { return; } long j2 = j - this.c; this.a = 0L; long uptimeMillis = SystemClock.uptimeMillis() - this.d; if (uptimeMillis <= 0) { this.e = (int) j2; } else { this.e = (int) (j2 / uptimeMillis); } } @Override // com.liulishuo.filedownloader.IDownloadSpeed$Monitor public void b(long j) { this.d = SystemClock.uptimeMillis(); this.c = j; } @Override // com.liulishuo.filedownloader.IDownloadSpeed$Monitor public void c(long j) { if (this.f <= 0) { return; } boolean z = true; if (this.a != 0) { long uptimeMillis = SystemClock.uptimeMillis() - this.a; if (uptimeMillis >= this.f || (this.e == 0 && uptimeMillis > 0)) { this.e = (int) ((j - this.b) / uptimeMillis); this.e = Math.max(0, this.e); } else { z = false; } } if (z) { this.b = j; this.a = SystemClock.uptimeMillis(); } } @Override // com.liulishuo.filedownloader.IDownloadSpeed$Monitor public void reset() { this.e = 0; this.a = 0L; } }