天津出行司机端 v6.9.3版本的 MD5 值为:b7a18e0f0e865860fd80aa9ed7cf4ae1
以下内容为反编译后的 DoKitWebUtil.java 源代码,内容仅作参考
package com.didichuxing.doraemonkit.util;
import android.content.Context;
import android.webkit.WebView;
import com.didichuxing.doraemonkit.aop.WebViewHook;
import com.didichuxing.doraemonkit.config.GpsMockConfig;
import com.didichuxing.doraemonkit.model.LatLng;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class DoKitWebUtil {
public static void webViewLoadLocalHtml(final WebView view, String jsPath) {
String htmlData = assetFileToString(view.getContext(), jsPath);
view.loadDataWithBaseURL("http://localhost", htmlData, "text/html", "UTF-8", null);
view.postDelayed(new Runnable() {
@Override
public void run() {
LatLng latLng = GpsMockConfig.getMockLocation();
if (latLng == null) {
latLng = new LatLng(0.0d, 0.0d);
}
String url = String.format("javascript:init(%s,%s)", Double.valueOf(latLng.latitude), Double.valueOf(latLng.longitude));
WebView webView = view;
WebViewHook.inject(webView);
webView.loadUrl(WebViewHook.getSafeUrl(url));
}
}, 1000L);
}
public static String assetFileToString(Context c, String urlStr) {
InputStream in = null;
try {
in = c.getAssets().open(urlStr);
} catch (IOException var4) {
var4.printStackTrace();
}
return inputStreamToString(in);
}
private static String inputStreamToString(InputStream in) {
String line;
if (in == null) {
return "";
}
try {
try {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(in));
StringBuilder sb = new StringBuilder();
do {
line = bufferedReader.readLine();
if (line != null) {
sb.append(line);
sb.append("\n");
continue;
}
} while (line != null);
bufferedReader.close();
in.close();
String var4 = sb.toString();
return var4;
} catch (Exception var14) {
var14.printStackTrace();
if (in != null) {
try {
in.close();
return null;
} catch (IOException var13) {
var13.printStackTrace();
return null;
}
}
return null;
}
} finally {
if (in != null) {
try {
in.close();
} catch (IOException var132) {
var132.printStackTrace();
}
}
}
}
}