429 lines
12 KiB
Java
429 lines
12 KiB
Java
package o;
|
|
|
|
import android.net.Uri;
|
|
import android.os.Handler;
|
|
import android.os.Looper;
|
|
import android.text.TextUtils;
|
|
import com.android.volley.AuthFailureError;
|
|
import com.android.volley.VolleyError;
|
|
import java.io.UnsupportedEncodingException;
|
|
import java.net.URLEncoder;
|
|
import java.util.Collections;
|
|
import java.util.Map;
|
|
import o.C1117VzR;
|
|
import o.C15788ibz;
|
|
import o.InterfaceC17333vqS;
|
|
import o.qWd;
|
|
|
|
/* loaded from: classes.dex */
|
|
public abstract class HJP<T> implements Comparable<HJP<T>> {
|
|
private static final String DEFAULT_PARAMS_ENCODING = "UTF-8";
|
|
private InterfaceC17333vqS.IeS mCacheEntry;
|
|
private boolean mCanceled;
|
|
private final int mDefaultTrafficStatsTag;
|
|
private C15788ibz.HBt mErrorListener;
|
|
private final qWd.HBt mEventLog;
|
|
private final Object mLock;
|
|
private final int mMethod;
|
|
private HBt mRequestCompleteListener;
|
|
private C1117VzR mRequestQueue;
|
|
private boolean mResponseDelivered;
|
|
private XAJ mRetryPolicy;
|
|
private Integer mSequence;
|
|
private boolean mShouldCache;
|
|
private boolean mShouldRetryConnectionErrors;
|
|
private boolean mShouldRetryServerErrors;
|
|
private Object mTag;
|
|
private final String mUrl;
|
|
|
|
/* loaded from: classes.dex */
|
|
interface HBt {
|
|
void d(HJP<?> hjp, C15788ibz<?> c15788ibz);
|
|
|
|
void e(HJP<?> hjp);
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
public enum Sts {
|
|
LOW,
|
|
NORMAL,
|
|
HIGH,
|
|
IMMEDIATE
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
public abstract void deliverResponse(T t);
|
|
|
|
protected Map<String, String> getParams() throws AuthFailureError {
|
|
return null;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
public VolleyError parseNetworkError(VolleyError volleyError) {
|
|
return volleyError;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
public abstract C15788ibz<T> parseNetworkResponse(DrQ drQ);
|
|
|
|
@Deprecated
|
|
public HJP(String str, C15788ibz.HBt hBt) {
|
|
this(-1, str, hBt);
|
|
}
|
|
|
|
public HJP(int i, String str, C15788ibz.HBt hBt) {
|
|
this.mEventLog = qWd.HBt.d ? new qWd.HBt() : null;
|
|
this.mLock = new Object();
|
|
this.mShouldCache = true;
|
|
this.mCanceled = false;
|
|
this.mResponseDelivered = false;
|
|
this.mShouldRetryServerErrors = false;
|
|
this.mShouldRetryConnectionErrors = false;
|
|
this.mCacheEntry = null;
|
|
this.mMethod = i;
|
|
this.mUrl = str;
|
|
this.mErrorListener = hBt;
|
|
setRetryPolicy(new kSb());
|
|
this.mDefaultTrafficStatsTag = findDefaultTrafficStatsTag(str);
|
|
}
|
|
|
|
public C15788ibz.HBt getErrorListener() {
|
|
C15788ibz.HBt hBt;
|
|
synchronized (this.mLock) {
|
|
hBt = this.mErrorListener;
|
|
}
|
|
return hBt;
|
|
}
|
|
|
|
private static int findDefaultTrafficStatsTag(String str) {
|
|
Uri parse;
|
|
String host;
|
|
if (TextUtils.isEmpty(str) || (parse = Uri.parse(str)) == null || (host = parse.getHost()) == null) {
|
|
return 0;
|
|
}
|
|
return host.hashCode();
|
|
}
|
|
|
|
public void addMarker(String str) {
|
|
if (qWd.HBt.d) {
|
|
this.mEventLog.c(str, Thread.currentThread().getId());
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public void finish(String str) {
|
|
C1117VzR c1117VzR = this.mRequestQueue;
|
|
if (c1117VzR != null) {
|
|
synchronized (c1117VzR.d) {
|
|
c1117VzR.d.remove(this);
|
|
}
|
|
synchronized (c1117VzR.i) {
|
|
for (C1117VzR.HBt hBt : c1117VzR.i) {
|
|
}
|
|
}
|
|
c1117VzR.d();
|
|
}
|
|
if (qWd.HBt.d) {
|
|
long id = Thread.currentThread().getId();
|
|
if (Looper.myLooper() != Looper.getMainLooper()) {
|
|
new Handler(Looper.getMainLooper()).post(new Runnable(this, str, id) { // from class: o.HJP.3
|
|
private long b;
|
|
private HJP c;
|
|
private String d;
|
|
|
|
{
|
|
this.c = this;
|
|
this.d = str;
|
|
this.b = id;
|
|
}
|
|
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
this.c.mEventLog.c(this.d, this.b);
|
|
this.c.mEventLog.e(this.c.toString());
|
|
}
|
|
});
|
|
} else {
|
|
this.mEventLog.c(str, id);
|
|
this.mEventLog.e(toString());
|
|
}
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public void sendEvent(int i) {
|
|
C1117VzR c1117VzR = this.mRequestQueue;
|
|
if (c1117VzR != null) {
|
|
c1117VzR.d();
|
|
}
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public final HJP<?> setSequence(int i) {
|
|
this.mSequence = Integer.valueOf(i);
|
|
return this;
|
|
}
|
|
|
|
public final int getSequence() {
|
|
Integer num = this.mSequence;
|
|
if (num == null) {
|
|
throw new IllegalStateException("getSequence called before setSequence");
|
|
}
|
|
return num.intValue();
|
|
}
|
|
|
|
public String getCacheKey() {
|
|
String url = getUrl();
|
|
int method = getMethod();
|
|
if (method == 0 || method == -1) {
|
|
return url;
|
|
}
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append(Integer.toString(method));
|
|
sb.append('-');
|
|
sb.append(url);
|
|
return sb.toString();
|
|
}
|
|
|
|
public void cancel() {
|
|
synchronized (this.mLock) {
|
|
this.mCanceled = true;
|
|
this.mErrorListener = null;
|
|
}
|
|
}
|
|
|
|
public boolean isCanceled() {
|
|
boolean z;
|
|
synchronized (this.mLock) {
|
|
z = this.mCanceled;
|
|
}
|
|
return z;
|
|
}
|
|
|
|
public Map<String, String> getHeaders() throws AuthFailureError {
|
|
return Collections.emptyMap();
|
|
}
|
|
|
|
@Deprecated
|
|
protected Map<String, String> getPostParams() throws AuthFailureError {
|
|
return getParams();
|
|
}
|
|
|
|
@Deprecated
|
|
protected String getPostParamsEncoding() {
|
|
return getParamsEncoding();
|
|
}
|
|
|
|
@Deprecated
|
|
public String getPostBodyContentType() {
|
|
return getBodyContentType();
|
|
}
|
|
|
|
@Deprecated
|
|
public byte[] getPostBody() throws AuthFailureError {
|
|
Map<String, String> postParams = getPostParams();
|
|
if (postParams == null || postParams.size() <= 0) {
|
|
return null;
|
|
}
|
|
return encodeParameters(postParams, getPostParamsEncoding());
|
|
}
|
|
|
|
public String getBodyContentType() {
|
|
StringBuilder sb = new StringBuilder("application/x-www-form-urlencoded; charset=");
|
|
sb.append(getParamsEncoding());
|
|
return sb.toString();
|
|
}
|
|
|
|
public byte[] getBody() throws AuthFailureError {
|
|
Map<String, String> params = getParams();
|
|
if (params == null || params.size() <= 0) {
|
|
return null;
|
|
}
|
|
return encodeParameters(params, getParamsEncoding());
|
|
}
|
|
|
|
private byte[] encodeParameters(Map<String, String> map, String str) {
|
|
StringBuilder sb = new StringBuilder();
|
|
try {
|
|
for (Map.Entry<String, String> entry : map.entrySet()) {
|
|
if (entry.getKey() == null || entry.getValue() == null) {
|
|
throw new IllegalArgumentException(String.format("Request#getParams() or Request#getPostParams() returned a map containing a null key or value: (%s, %s). All keys and values must be non-null.", entry.getKey(), entry.getValue()));
|
|
}
|
|
sb.append(URLEncoder.encode(entry.getKey(), str));
|
|
sb.append('=');
|
|
sb.append(URLEncoder.encode(entry.getValue(), str));
|
|
sb.append('&');
|
|
}
|
|
return sb.toString().getBytes(str);
|
|
} catch (UnsupportedEncodingException e) {
|
|
throw new RuntimeException("Encoding not supported: ".concat(String.valueOf(str)), e);
|
|
}
|
|
}
|
|
|
|
public Sts getPriority() {
|
|
return Sts.NORMAL;
|
|
}
|
|
|
|
public final int getTimeoutMs() {
|
|
return getRetryPolicy().b();
|
|
}
|
|
|
|
public void markDelivered() {
|
|
synchronized (this.mLock) {
|
|
this.mResponseDelivered = true;
|
|
}
|
|
}
|
|
|
|
public boolean hasHadResponseDelivered() {
|
|
boolean z;
|
|
synchronized (this.mLock) {
|
|
z = this.mResponseDelivered;
|
|
}
|
|
return z;
|
|
}
|
|
|
|
public void deliverError(VolleyError volleyError) {
|
|
C15788ibz.HBt hBt;
|
|
synchronized (this.mLock) {
|
|
hBt = this.mErrorListener;
|
|
}
|
|
if (hBt != null) {
|
|
hBt.onErrorResponse(volleyError);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public void setNetworkRequestCompleteListener(HBt hBt) {
|
|
synchronized (this.mLock) {
|
|
this.mRequestCompleteListener = hBt;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public void notifyListenerResponseReceived(C15788ibz<?> c15788ibz) {
|
|
HBt hBt;
|
|
synchronized (this.mLock) {
|
|
hBt = this.mRequestCompleteListener;
|
|
}
|
|
if (hBt != null) {
|
|
hBt.d(this, c15788ibz);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public void notifyListenerResponseNotUsable() {
|
|
HBt hBt;
|
|
synchronized (this.mLock) {
|
|
hBt = this.mRequestCompleteListener;
|
|
}
|
|
if (hBt != null) {
|
|
hBt.e(this);
|
|
}
|
|
}
|
|
|
|
@Override // java.lang.Comparable
|
|
public int compareTo(HJP<T> hjp) {
|
|
Sts priority = getPriority();
|
|
Sts priority2 = hjp.getPriority();
|
|
return priority == priority2 ? this.mSequence.intValue() - hjp.mSequence.intValue() : priority2.ordinal() - priority.ordinal();
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder sb = new StringBuilder("0x");
|
|
sb.append(Integer.toHexString(getTrafficStatsTag()));
|
|
String obj = sb.toString();
|
|
StringBuilder sb2 = new StringBuilder();
|
|
sb2.append(isCanceled() ? "[X] " : "[ ] ");
|
|
sb2.append(getUrl());
|
|
sb2.append(" ");
|
|
sb2.append(obj);
|
|
sb2.append(" ");
|
|
sb2.append(getPriority());
|
|
sb2.append(" ");
|
|
sb2.append(this.mSequence);
|
|
return sb2.toString();
|
|
}
|
|
|
|
public final boolean shouldRetryServerErrors() {
|
|
return this.mShouldRetryServerErrors;
|
|
}
|
|
|
|
public final boolean shouldRetryConnectionErrors() {
|
|
return this.mShouldRetryConnectionErrors;
|
|
}
|
|
|
|
public final boolean shouldCache() {
|
|
return this.mShouldCache;
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public HJP<?> setTag(Object obj) {
|
|
this.mTag = obj;
|
|
return this;
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public final HJP<?> setShouldRetryServerErrors(boolean z) {
|
|
this.mShouldRetryServerErrors = z;
|
|
return this;
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public final HJP<?> setShouldRetryConnectionErrors(boolean z) {
|
|
this.mShouldRetryConnectionErrors = z;
|
|
return this;
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public final HJP<?> setShouldCache(boolean z) {
|
|
this.mShouldCache = z;
|
|
return this;
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public HJP<?> setRetryPolicy(XAJ xaj) {
|
|
this.mRetryPolicy = xaj;
|
|
return this;
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public HJP<?> setRequestQueue(C1117VzR c1117VzR) {
|
|
this.mRequestQueue = c1117VzR;
|
|
return this;
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public HJP<?> setCacheEntry(InterfaceC17333vqS.IeS ieS) {
|
|
this.mCacheEntry = ieS;
|
|
return this;
|
|
}
|
|
|
|
public String getUrl() {
|
|
return this.mUrl;
|
|
}
|
|
|
|
public int getTrafficStatsTag() {
|
|
return this.mDefaultTrafficStatsTag;
|
|
}
|
|
|
|
public Object getTag() {
|
|
return this.mTag;
|
|
}
|
|
|
|
public XAJ getRetryPolicy() {
|
|
return this.mRetryPolicy;
|
|
}
|
|
|
|
protected String getParamsEncoding() {
|
|
return DEFAULT_PARAMS_ENCODING;
|
|
}
|
|
|
|
public int getMethod() {
|
|
return this.mMethod;
|
|
}
|
|
|
|
public InterfaceC17333vqS.IeS getCacheEntry() {
|
|
return this.mCacheEntry;
|
|
}
|
|
}
|