package c5;

import android.os.Bundle;
import android.os.Message;
import android.util.Log;
import r4.AbstractC0983h;

/* JADX INFO: loaded from: classes.dex */
public final class h extends X4.i {

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public long f4761l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public final /* synthetic */ i f4762m;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public h(i iVar, X4.g gVar) {
        super(gVar);
        this.f4762m = iVar;
        this.f4761l = 0L;
    }

    @Override // X4.u
    public final long p(X4.e eVar, long j5) {
        AbstractC0983h.e("sink", eVar);
        long jP = this.f3326k.p(eVar, 8192L);
        long j6 = this.f4761l + (jP != -1 ? jP : 0L);
        this.f4761l = j6;
        i iVar = this.f4762m;
        g gVar = iVar.f4764l;
        long jA = iVar.f4763k.a();
        f fVar = (f) gVar;
        if (jP == -1) {
            Log.d("FLUTTER OTA", "Download is complete");
            return jP;
        }
        if (jA < 1) {
            Log.d("FLUTTER OTA", "Content-length header is missing. Cannot compute progress.");
            return jP;
        }
        if (fVar.f4752m != null) {
            Message message = new Message();
            Bundle bundle = new Bundle();
            bundle.putLong("BYTES_DOWNLOADED", j6);
            bundle.putLong("BYTES_TOTAL", jA);
            message.setData(bundle);
            fVar.f4753n.sendMessage(message);
            fVar.f4750k = Long.valueOf(jA);
        }
        return jP;
    }
}
