package io.grpc.okhttp; import com.google.common.base.Preconditions; import io.grpc.okhttp.internal.framed.ErrorCode; import io.grpc.okhttp.internal.framed.Header; import io.grpc.okhttp.internal.framed.Settings; import java.util.EnumMap; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import o.C14957gcv; import o.C15111ghZ; import o.C15155gij; /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public class OkHttpFrameLogger { private static final int BUFFER_LENGTH_THRESHOLD = 64; private final Level level; private final Logger logger; /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public enum Direction { INBOUND, OUTBOUND } /* JADX INFO: Access modifiers changed from: package-private */ public OkHttpFrameLogger(Level level, Class cls) { this(level, Logger.getLogger(cls.getName())); } OkHttpFrameLogger(Level level, Logger logger) { this.level = (Level) Preconditions.checkNotNull(level, "level"); this.logger = (Logger) Preconditions.checkNotNull(logger, "logger"); } private static String toString(Settings settings) { EnumMap enumMap = new EnumMap(SettingParams.class); for (SettingParams settingParams : SettingParams.values()) { if (settings.isSet(settingParams.getBit())) { enumMap.put((EnumMap) settingParams, (SettingParams) Integer.valueOf(settings.get(settingParams.getBit()))); } } return enumMap.toString(); } private boolean isEnabled() { return this.logger.isLoggable(this.level); } /* JADX INFO: Access modifiers changed from: package-private */ public void logData(Direction direction, int i, C15111ghZ c15111ghZ, int i2, boolean z) { if (isEnabled()) { Logger logger = this.logger; Level level = this.level; StringBuilder sb = new StringBuilder(); sb.append(direction); sb.append(" DATA: streamId="); sb.append(i); sb.append(" endStream="); sb.append(z); sb.append(" length="); sb.append(i2); sb.append(" bytes="); sb.append(toString(c15111ghZ)); logger.log(level, sb.toString()); } } /* JADX INFO: Access modifiers changed from: package-private */ public void logHeaders(Direction direction, int i, List
list, boolean z) { if (isEnabled()) { Logger logger = this.logger; Level level = this.level; StringBuilder sb = new StringBuilder(); sb.append(direction); sb.append(" HEADERS: streamId="); sb.append(i); sb.append(" headers="); sb.append(list); sb.append(" endStream="); sb.append(z); logger.log(level, sb.toString()); } } public void logPriority(Direction direction, int i, int i2, int i3, boolean z) { if (isEnabled()) { Logger logger = this.logger; Level level = this.level; StringBuilder sb = new StringBuilder(); sb.append(direction); sb.append(" PRIORITY: streamId="); sb.append(i); sb.append(" streamDependency="); sb.append(i2); sb.append(" weight="); sb.append(i3); sb.append(" exclusive="); sb.append(z); logger.log(level, sb.toString()); } } /* JADX INFO: Access modifiers changed from: package-private */ public void logRstStream(Direction direction, int i, ErrorCode errorCode) { if (isEnabled()) { Logger logger = this.logger; Level level = this.level; StringBuilder sb = new StringBuilder(); sb.append(direction); sb.append(" RST_STREAM: streamId="); sb.append(i); sb.append(" errorCode="); sb.append(errorCode); logger.log(level, sb.toString()); } } /* JADX INFO: Access modifiers changed from: package-private */ public void logSettingsAck(Direction direction) { if (isEnabled()) { Logger logger = this.logger; Level level = this.level; StringBuilder sb = new StringBuilder(); sb.append(direction); sb.append(" SETTINGS: ack=true"); logger.log(level, sb.toString()); } } /* JADX INFO: Access modifiers changed from: package-private */ public void logSettings(Direction direction, Settings settings) { if (isEnabled()) { Logger logger = this.logger; Level level = this.level; StringBuilder sb = new StringBuilder(); sb.append(direction); sb.append(" SETTINGS: ack=false settings="); sb.append(toString(settings)); logger.log(level, sb.toString()); } } /* JADX INFO: Access modifiers changed from: package-private */ public void logPing(Direction direction, long j) { if (isEnabled()) { Logger logger = this.logger; Level level = this.level; StringBuilder sb = new StringBuilder(); sb.append(direction); sb.append(" PING: ack=false bytes="); sb.append(j); logger.log(level, sb.toString()); } } /* JADX INFO: Access modifiers changed from: package-private */ public void logPingAck(Direction direction, long j) { if (isEnabled()) { Logger logger = this.logger; Level level = this.level; StringBuilder sb = new StringBuilder(); sb.append(direction); sb.append(" PING: ack=true bytes="); sb.append(j); logger.log(level, sb.toString()); } } /* JADX INFO: Access modifiers changed from: package-private */ public void logPushPromise(Direction direction, int i, int i2, List
list) { if (isEnabled()) { Logger logger = this.logger; Level level = this.level; StringBuilder sb = new StringBuilder(); sb.append(direction); sb.append(" PUSH_PROMISE: streamId="); sb.append(i); sb.append(" promisedStreamId="); sb.append(i2); sb.append(" headers="); sb.append(list); logger.log(level, sb.toString()); } } /* JADX INFO: Access modifiers changed from: package-private */ public void logGoAway(Direction direction, int i, ErrorCode errorCode, C15155gij c15155gij) { if (isEnabled()) { Logger logger = this.logger; Level level = this.level; StringBuilder sb = new StringBuilder(); sb.append(direction); sb.append(" GO_AWAY: lastStreamId="); sb.append(i); sb.append(" errorCode="); sb.append(errorCode); sb.append(" length="); sb.append(c15155gij.a()); sb.append(" bytes="); C15111ghZ c15111ghZ = new C15111ghZ(); C14957gcv.e(c15155gij, ""); c15155gij.a(c15111ghZ, c15155gij.a()); sb.append(toString(c15111ghZ)); logger.log(level, sb.toString()); } } /* JADX INFO: Access modifiers changed from: package-private */ public void logWindowsUpdate(Direction direction, int i, long j) { if (isEnabled()) { Logger logger = this.logger; Level level = this.level; StringBuilder sb = new StringBuilder(); sb.append(direction); sb.append(" WINDOW_UPDATE: streamId="); sb.append(i); sb.append(" windowSizeIncrement="); sb.append(j); logger.log(level, sb.toString()); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public enum SettingParams { HEADER_TABLE_SIZE(1), ENABLE_PUSH(2), MAX_CONCURRENT_STREAMS(4), MAX_FRAME_SIZE(5), MAX_HEADER_LIST_SIZE(6), INITIAL_WINDOW_SIZE(7); private final int bit; SettingParams(int i) { this.bit = i; } public final int getBit() { return this.bit; } } private static String toString(C15111ghZ c15111ghZ) { if (c15111ghZ.c <= 64) { return c15111ghZ.q().c(); } int min = (int) Math.min(c15111ghZ.c, 64L); StringBuilder sb = new StringBuilder(); sb.append(c15111ghZ.e(min).c()); sb.append("..."); return sb.toString(); } }