正在查看: Betterhalf.ai v5.1.1 应用的 BitmapDownloader.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Betterhalf.ai v5.1.1 应用的 BitmapDownloader.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.clevertap.android.sdk.bitmap;
import androidx.constraintlayout.widget.ConstraintLayout;
import com.clevertap.android.sdk.Constants;
import com.clevertap.android.sdk.Logger;
import com.clevertap.android.sdk.Utils;
import com.clevertap.android.sdk.network.DownloadedBitmap;
import com.clevertap.android.sdk.network.DownloadedBitmapFactory;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.Map;
import kotlin.Metadata;
import kotlin.Pair;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
@Metadata(d1 = {"\u0000F\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010\u000b\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\t\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\u0018\u00002\u00020\u0001B+\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0005\u0012\u0014\b\u0002\u0010\u0006\u001a\u000e\u0012\u0004\u0012\u00020\b\u0012\u0004\u0012\u00020\t0\u0007¢\u0006\u0002\u0010\nJ\u0010\u0010\u0011\u001a\u00020\f2\u0006\u0010\u0012\u001a\u00020\u0013H\u0002J\u000e\u0010\u0014\u001a\u00020\u00152\u0006\u0010\u000f\u001a\u00020\u0010R\u000e\u0010\u0004\u001a\u00020\u0005X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u000b\u001a\u00020\fX\u0082.¢\u0006\u0002\n\u0000R\u000e\u0010\r\u001a\u00020\u000eX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000R\u001a\u0010\u0006\u001a\u000e\u0012\u0004\u0012\u00020\b\u0012\u0004\u0012\u00020\t0\u0007X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u000f\u001a\u00020\u0010X\u0082.¢\u0006\u0002\n\u0000¨\u0006\u0016"}, d2 = {"Lcom/clevertap/android/sdk/bitmap/BitmapDownloader;", "", "httpUrlConnectionParams", "Lcom/clevertap/android/sdk/bitmap/HttpUrlConnectionParams;", "bitmapInputStreamReader", "Lcom/clevertap/android/sdk/bitmap/IBitmapInputStreamReader;", "sizeConstrainedPair", "Lkotlin/Pair;", "", "", "(Lcom/clevertap/android/sdk/bitmap/HttpUrlConnectionParams;Lcom/clevertap/android/sdk/bitmap/IBitmapInputStreamReader;Lkotlin/Pair;)V", "connection", "Ljava/net/HttpURLConnection;", "downloadStartTimeInMilliseconds", "", "srcUrl", "", "createConnection", Constants.KEY_URL, "Ljava/net/URL;", "downloadBitmap", "Lcom/clevertap/android/sdk/network/DownloadedBitmap;", "clevertap-core_release"}, k = 1, mv = {1, 7, 1}, xi = ConstraintLayout.LayoutParams.Table.LAYOUT_CONSTRAINT_VERTICAL_CHAINSTYLE)
public final class BitmapDownloader {
private final IBitmapInputStreamReader bitmapInputStreamReader;
private HttpURLConnection connection;
private long downloadStartTimeInMilliseconds;
private final HttpUrlConnectionParams httpUrlConnectionParams;
private final Pair<Boolean, Integer> sizeConstrainedPair;
private String srcUrl;
public BitmapDownloader(HttpUrlConnectionParams httpUrlConnectionParams, IBitmapInputStreamReader iBitmapInputStreamReader, Pair<Boolean, Integer> pair) {
Intrinsics.checkNotNullParameter(httpUrlConnectionParams, "httpUrlConnectionParams");
Intrinsics.checkNotNullParameter(iBitmapInputStreamReader, "bitmapInputStreamReader");
Intrinsics.checkNotNullParameter(pair, "sizeConstrainedPair");
this.httpUrlConnectionParams = httpUrlConnectionParams;
this.bitmapInputStreamReader = iBitmapInputStreamReader;
this.sizeConstrainedPair = pair;
}
public BitmapDownloader(HttpUrlConnectionParams httpUrlConnectionParams, IBitmapInputStreamReader iBitmapInputStreamReader, Pair pair, int i, DefaultConstructorMarker defaultConstructorMarker) {
this(httpUrlConnectionParams, iBitmapInputStreamReader, (i & 4) != 0 ? new Pair(false, 0) : pair);
}
public final DownloadedBitmap downloadBitmap(String srcUrl) {
Intrinsics.checkNotNullParameter(srcUrl, "srcUrl");
Logger.v("initiating bitmap download in BitmapDownloader....");
this.srcUrl = srcUrl;
this.downloadStartTimeInMilliseconds = Utils.getNowInMillis();
HttpURLConnection httpURLConnection = null;
try {
HttpURLConnection createConnection = createConnection(new URL(srcUrl));
this.connection = createConnection;
if (createConnection == null) {
Intrinsics.throwUninitializedPropertyAccessException("connection");
createConnection = null;
}
createConnection.connect();
if (createConnection.getResponseCode() != 200) {
Logger.d("File not loaded completely not going forward. URL was: " + srcUrl);
DownloadedBitmap nullBitmapWithStatus = DownloadedBitmapFactory.INSTANCE.nullBitmapWithStatus(DownloadedBitmap.Status.DOWNLOAD_FAILED);
HttpURLConnection httpURLConnection2 = this.connection;
if (httpURLConnection2 == null) {
Intrinsics.throwUninitializedPropertyAccessException("connection");
} else {
httpURLConnection = httpURLConnection2;
}
httpURLConnection.disconnect();
return nullBitmapWithStatus;
}
Logger.v("Downloading " + srcUrl + "....");
int contentLength = createConnection.getContentLength();
Pair<Boolean, Integer> pair = this.sizeConstrainedPair;
boolean booleanValue = ((Boolean) pair.component1()).booleanValue();
int intValue = ((Number) pair.component2()).intValue();
if (booleanValue && contentLength > intValue) {
Logger.v("Image size is larger than " + intValue + " bytes. Cancelling download!");
DownloadedBitmap nullBitmapWithStatus2 = DownloadedBitmapFactory.INSTANCE.nullBitmapWithStatus(DownloadedBitmap.Status.SIZE_LIMIT_EXCEEDED);
HttpURLConnection httpURLConnection3 = this.connection;
if (httpURLConnection3 == null) {
Intrinsics.throwUninitializedPropertyAccessException("connection");
} else {
httpURLConnection = httpURLConnection3;
}
httpURLConnection.disconnect();
return nullBitmapWithStatus2;
}
IBitmapInputStreamReader iBitmapInputStreamReader = this.bitmapInputStreamReader;
InputStream inputStream = createConnection.getInputStream();
Intrinsics.checkNotNullExpressionValue(inputStream, "inputStream");
DownloadedBitmap readInputStream = iBitmapInputStreamReader.readInputStream(inputStream, createConnection, this.downloadStartTimeInMilliseconds);
HttpURLConnection httpURLConnection4 = this.connection;
if (httpURLConnection4 == null) {
Intrinsics.throwUninitializedPropertyAccessException("connection");
} else {
httpURLConnection = httpURLConnection4;
}
httpURLConnection.disconnect();
return readInputStream;
} catch (Throwable th) {
try {
Logger.v("Couldn't download the notification icon. URL was: " + srcUrl);
th.printStackTrace();
return DownloadedBitmapFactory.INSTANCE.nullBitmapWithStatus(DownloadedBitmap.Status.DOWNLOAD_FAILED);
} finally {
try {
HttpURLConnection httpURLConnection5 = this.connection;
if (httpURLConnection5 == null) {
Intrinsics.throwUninitializedPropertyAccessException("connection");
} else {
httpURLConnection = httpURLConnection5;
}
httpURLConnection.disconnect();
} catch (Throwable th2) {
Logger.v("Couldn't close connection!", th2);
}
}
}
}
private final HttpURLConnection createConnection(URL url) {
URLConnection openConnection = url.openConnection();
Intrinsics.checkNotNull(openConnection, "null cannot be cast to non-null type java.net.HttpURLConnection");
HttpURLConnection httpURLConnection = (HttpURLConnection) openConnection;
httpURLConnection.setConnectTimeout(this.httpUrlConnectionParams.getConnectTimeout());
httpURLConnection.setReadTimeout(this.httpUrlConnectionParams.getReadTimeout());
httpURLConnection.setUseCaches(this.httpUrlConnectionParams.getUseCaches());
httpURLConnection.setDoInput(this.httpUrlConnectionParams.getDoInput());
for (Map.Entry<String, String> entry : this.httpUrlConnectionParams.getRequestMap().entrySet()) {
httpURLConnection.addRequestProperty(entry.getKey(), entry.getValue());
}
return httpURLConnection;
}
}