package com.facetec.sdk; import java.io.IOException; import java.nio.ByteBuffer; /* loaded from: classes.dex */ final class ne implements mv { private boolean a; private ms c = new ms(); private nj e; /* JADX INFO: Access modifiers changed from: package-private */ public ne(nj njVar) { if (njVar == null) { throw new NullPointerException("sink == null"); } this.e = njVar; } @Override // com.facetec.sdk.nj public final void c(ms msVar, long j) throws IOException { if (this.a) { throw new IllegalStateException("closed"); } this.c.c(msVar, j); r(); } @Override // com.facetec.sdk.mv public final mv e(String str) throws IOException { if (this.a) { throw new IllegalStateException("closed"); } this.c.e(str); return r(); } @Override // com.facetec.sdk.mv public final mv e(byte[] bArr) throws IOException { if (this.a) { throw new IllegalStateException("closed"); } this.c.e(bArr); return r(); } @Override // com.facetec.sdk.mv public final mv d(byte[] bArr, int i, int i2) throws IOException { if (this.a) { throw new IllegalStateException("closed"); } this.c.d(bArr, i, i2); return r(); } @Override // java.nio.channels.WritableByteChannel public final int write(ByteBuffer byteBuffer) throws IOException { if (this.a) { throw new IllegalStateException("closed"); } int write = this.c.write(byteBuffer); r(); return write; } @Override // com.facetec.sdk.mv public final mv h(int i) throws IOException { if (this.a) { throw new IllegalStateException("closed"); } this.c.h(i); return r(); } @Override // com.facetec.sdk.mv public final mv g(int i) throws IOException { if (this.a) { throw new IllegalStateException("closed"); } this.c.g(i); return r(); } @Override // com.facetec.sdk.mv public final mv f(int i) throws IOException { if (this.a) { throw new IllegalStateException("closed"); } this.c.f(i); return r(); } @Override // com.facetec.sdk.mv public final mv n(long j) throws IOException { if (this.a) { throw new IllegalStateException("closed"); } this.c.n(j); return r(); } @Override // com.facetec.sdk.mv public final mv h(long j) throws IOException { if (this.a) { throw new IllegalStateException("closed"); } this.c.h(j); return r(); } @Override // com.facetec.sdk.mv public final mv r() throws IOException { if (this.a) { throw new IllegalStateException("closed"); } long e = this.c.e(); if (e > 0) { this.e.c(this.c, e); } return this; } @Override // com.facetec.sdk.mv, com.facetec.sdk.nj, java.io.Flushable public final void flush() throws IOException { if (this.a) { throw new IllegalStateException("closed"); } if (this.c.e > 0) { nj njVar = this.e; ms msVar = this.c; njVar.c(msVar, msVar.e); } this.e.flush(); } @Override // com.facetec.sdk.nj, java.io.Closeable, java.lang.AutoCloseable public final void close() throws IOException { if (this.a) { return; } try { if (this.c.e > 0) { nj njVar = this.e; ms msVar = this.c; njVar.c(msVar, msVar.e); } th = null; } catch (Throwable th) { th = th; } try { this.e.close(); } catch (Throwable th2) { if (th == null) { th = th2; } } this.a = true; if (th != null) { ng.b(th); } } @Override // com.facetec.sdk.nj public final nh b() { return this.e.b(); } public final String toString() { StringBuilder sb = new StringBuilder("buffer("); sb.append(this.e); sb.append(")"); return sb.toString(); } @Override // java.nio.channels.Channel public final boolean isOpen() { return !this.a; } @Override // com.facetec.sdk.mv public final ms d() { return this.c; } }