Warkop v5.73.0版本的 MD5 值为:a4330ec2d6f5e146f59fc7622f3cdb45
以下内容为反编译后的 IASWebViewClient.java 源代码,内容仅作参考
package com.inappstory.sdk.stories.ui.views;
import android.annotation.TargetApi;
import android.net.Uri;
import android.webkit.MimeTypeMap;
import android.webkit.URLUtil;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.inappstory.sdk.InAppStoryService;
import com.inappstory.sdk.lrudiskcache.LruDiskCache;
import com.inappstory.sdk.stories.cache.Downloader;
import com.inappstory.sdk.utils.ZipLoader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class IASWebViewClient extends WebViewClient {
public static void copyFile(File file, File file2) throws IOException {
FileInputStream fileInputStream = new FileInputStream(file);
FileOutputStream fileOutputStream = new FileOutputStream(file2);
byte[] bArr = new byte[1024];
while (true) {
int read = fileInputStream.read(bArr);
if (read > 0) {
fileOutputStream.write(bArr, 0, read);
} else {
fileInputStream.close();
fileOutputStream.close();
return;
}
}
}
private File getCachedFile(String str, String str2) {
InAppStoryService inAppStoryService = InAppStoryService.getInstance();
if (inAppStoryService == null) {
return null;
}
LruDiskCache commonCache = inAppStoryService.getCommonCache();
try {
return Downloader.updateFile(commonCache.getFullFile(str2), str, commonCache, str2);
} catch (Exception e15) {
InAppStoryService.createExceptionLog(e15);
return null;
}
}
private File getFileByUrl(String str) {
String str2;
if (str.startsWith("http://file-assets")) {
str2 = Uri.parse(str.replace("http://file-assets", ZipLoader.FILE)).getPath();
} else if (str.startsWith(ZipLoader.FILE)) {
str2 = Uri.parse(str).getPath();
} else {
str2 = null;
}
if (str2 != null) {
return new File(str2);
}
if (str.startsWith("data:") || !URLUtil.isValidUrl(str)) {
return null;
}
return getCachedFile(str, Downloader.cropUrl(str, true));
}
protected WebResourceResponse getChangedResponse(String str) throws FileNotFoundException {
String mimeTypeFromExtension;
WebResourceResponse webResourceResponse;
Map<String, String> responseHeaders;
File fileByUrl = getFileByUrl(str);
WebResourceResponse webResourceResponse2 = null;
if (fileByUrl == null || !fileByUrl.exists()) {
return null;
}
try {
mimeTypeFromExtension = MimeTypeMap.getSingleton().getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(fileByUrl.getAbsolutePath()));
} catch (Exception e15) {
e = e15;
}
try {
if (mimeTypeFromExtension != null) {
if (mimeTypeFromExtension.isEmpty()) {
}
webResourceResponse = new WebResourceResponse(mimeTypeFromExtension, "BINARY", new FileInputStream(fileByUrl));
responseHeaders = webResourceResponse.getResponseHeaders();
if (responseHeaders == null) {
responseHeaders = new HashMap<>();
}
HashMap hashMap = new HashMap(responseHeaders);
hashMap.put("Access-Control-Allow-Origin", "*");
webResourceResponse.setResponseHeaders(hashMap);
return webResourceResponse;
}
responseHeaders = webResourceResponse.getResponseHeaders();
if (responseHeaders == null) {
}
HashMap hashMap2 = new HashMap(responseHeaders);
hashMap2.put("Access-Control-Allow-Origin", "*");
webResourceResponse.setResponseHeaders(hashMap2);
return webResourceResponse;
} catch (Exception e16) {
e = e16;
webResourceResponse2 = webResourceResponse;
InAppStoryService.createExceptionLog(e);
return webResourceResponse2;
}
mimeTypeFromExtension = "application/octet-stream";
webResourceResponse = new WebResourceResponse(mimeTypeFromExtension, "BINARY", new FileInputStream(fileByUrl));
}
@Override
@TargetApi(21)
public WebResourceResponse shouldInterceptRequest(WebView webView, WebResourceRequest webResourceRequest) {
try {
WebResourceResponse changedResponse = getChangedResponse(webResourceRequest.getUrl().toString());
if (changedResponse != null) {
return changedResponse;
}
} catch (FileNotFoundException unused) {
}
return super.shouldInterceptRequest(webView, webResourceRequest);
}
@Override
public WebResourceResponse shouldInterceptRequest(WebView webView, String str) {
try {
WebResourceResponse changedResponse = getChangedResponse(str);
if (changedResponse != null) {
return changedResponse;
}
} catch (FileNotFoundException unused) {
}
return super.shouldInterceptRequest(webView, str);
}
}