alexandroid/decompiled/jadx/sources/com/amazonaws/event/ProgressReportingInputStream.java
KaKi87 a47fad5135 📦 Add decompiled Alexa 2.2.730155.0 (jadx, apktool, Hermes strings)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 00:04:16 +01:00

94 lines
3.3 KiB
Java

package com.amazonaws.event;
import com.amazonaws.internal.SdkFilterInputStream;
import java.io.IOException;
import java.io.InputStream;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
/* loaded from: classes5.dex */
public class ProgressReportingInputStream extends SdkFilterInputStream {
private static final int BYTES_IN_KB = 1024;
private static final int THRESHOLD_IN_KB = 8;
private boolean fireCompletedEvent;
private final ProgressListenerCallbackExecutor listenerCallbackExecutor;
private int notificationThreshold;
private int unnotifiedByteCount;
public ProgressReportingInputStream(InputStream inputStream, ProgressListenerCallbackExecutor progressListenerCallbackExecutor) {
super(inputStream);
this.notificationThreshold = 8192;
this.listenerCallbackExecutor = progressListenerCallbackExecutor;
}
private void notify(int i) {
int i2 = this.unnotifiedByteCount + i;
this.unnotifiedByteCount = i2;
if (i2 >= this.notificationThreshold) {
this.listenerCallbackExecutor.progressChanged(new ProgressEvent(i2));
this.unnotifiedByteCount = 0;
}
}
private void notifyCompleted() {
if (this.fireCompletedEvent) {
ProgressEvent progressEvent = new ProgressEvent(this.unnotifiedByteCount);
progressEvent.setEventCode(4);
this.unnotifiedByteCount = 0;
this.listenerCallbackExecutor.progressChanged(progressEvent);
}
}
@Override // com.amazonaws.internal.SdkFilterInputStream, java.io.FilterInputStream, java.io.InputStream, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
int i = this.unnotifiedByteCount;
if (i > 0) {
this.listenerCallbackExecutor.progressChanged(new ProgressEvent(i));
this.unnotifiedByteCount = 0;
}
super.close();
}
public boolean getFireCompletedEvent() {
return this.fireCompletedEvent;
}
@Override // com.amazonaws.internal.SdkFilterInputStream, java.io.FilterInputStream, java.io.InputStream
public int read() throws IOException {
int read = super.read();
if (read == -1) {
notifyCompleted();
return read;
}
notify(1);
return read;
}
@Override // com.amazonaws.internal.SdkFilterInputStream, java.io.FilterInputStream, java.io.InputStream
public void reset() throws IOException {
super.reset();
ProgressEvent progressEvent = new ProgressEvent(this.unnotifiedByteCount);
progressEvent.setEventCode(32);
this.listenerCallbackExecutor.progressChanged(progressEvent);
this.unnotifiedByteCount = 0;
}
public void setFireCompletedEvent(boolean z) {
this.fireCompletedEvent = z;
}
public void setNotificationThreshold(int i) {
this.notificationThreshold = i * 1024;
}
@Override // com.amazonaws.internal.SdkFilterInputStream, java.io.FilterInputStream, java.io.InputStream
public int read(byte[] bArr, int i, int i2) throws IOException {
int read = super.read(bArr, i, i2);
if (read == -1) {
notifyCompleted();
}
if (read != -1) {
notify(read);
}
return read;
}
}