工作空间 v3.6.5.2版本的 MD5 值为:58e65af156c65a63bf64ed2e64960853
以下内容为反编译后的 ZlaWebFragment.java 源代码,内容仅作参考
package com.uusafe.h5app.library.browser.fragment;
import android.app.ActivityManager;
import android.app.Dialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Bitmap;
import android.net.Uri;
import android.net.http.SslError;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Process;
import android.text.TextUtils;
import android.util.Base64;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import android.webkit.GeolocationPermissions;
import android.webkit.HttpAuthHandler;
import android.webkit.JavascriptInterface;
import android.webkit.JsPromptResult;
import android.webkit.SslErrorHandler;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.FileProvider;
import androidx.lifecycle.Lifecycle;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.huawei.hms.framework.common.ContainerUtils;
import com.uber.autodispose.l;
import com.uusafe.base.modulesdk.module.bean.ModuleInfo;
import com.uusafe.base.modulesdk.module.event.AppStateChangeEvent;
import com.uusafe.base.modulesdk.module.event.ModuleMessageEvent;
import com.uusafe.base.modulesdk.module.event.NoticeAddEvent;
import com.uusafe.base.modulesdk.module.event.SecretaryAddEvent;
import com.uusafe.base.modulesdk.module.event.TableH5InstallFinishEvent;
import com.uusafe.base.modulesdk.module.event.TodoAddEvent;
import com.uusafe.base.modulesdk.module.global.AppConfig;
import com.uusafe.base.modulesdk.module.global.CommGlobal;
import com.uusafe.base.modulesdk.module.netapi.BaseApis;
import com.uusafe.base.modulesdk.module.router.ARouterConfig;
import com.uusafe.commbase.bean.AllAloneAppMessageInfo;
import com.uusafe.commbase.bean.AloneAppMessageInfo;
import com.uusafe.commbase.bean.NoticeInfo;
import com.uusafe.commbase.global.BaseGlobal;
import com.uusafe.commbase.utils.CommPackageUtils;
import com.uusafe.coolindicator.CoolIndicatorLayout;
import com.uusafe.emm.policy.PolicyProtocol;
import com.uusafe.emm.policy.PolicyProvider;
import com.uusafe.h5app.library.Env;
import com.uusafe.h5app.library.Logger;
import com.uusafe.h5app.library.api.ConfigInfo;
import com.uusafe.h5app.library.api.H5ApplicationInfo;
import com.uusafe.h5app.library.api.IConstants;
import com.uusafe.h5app.library.browser.CustomWebView;
import com.uusafe.h5app.library.browser.utils.ProcessUtils;
import com.uusafe.h5app.library.internal.entity.ZlaInfo;
import com.uusafe.h5app.library.utils.AppUtils;
import com.uusafe.h5app.library.utils.CustomURLEncoder;
import com.uusafe.h5app.library.utils.DialogUtils;
import com.uusafe.h5app.library.utils.MD5Util;
import com.uusafe.h5app.library.utils.ToastUtil;
import com.uusafe.h5app.library.utils.Utils;
import com.uusafe.jsbridge.MbsJsBridge;
import com.uusafe.jsbridge.http.DSLog;
import com.uusafe.main.plugin.api.listener.ZWebViewLoadListener;
import com.uusafe.mbs.h5library.R;
import com.uusafe.permission.util.PermissionsUtils;
import com.uusafe.servicemodule.H5BGModuleImpl;
import com.uusafe.uibase.dialog.CommonDialog;
import com.uusafe.utils.common.JsonUtil;
import com.uusafe.utils.common.NativeUtil;
import com.uusafe.utils.common.StringUtils;
import com.uusafe.utils.common.ZZLog;
import com.uusafe.utils.progress.ProgressDialog;
import com.xiaomi.mipush.sdk.Constants;
import com.zhizhangyi.platform.network.zhttp.base.utils.Util;
import com.zhizhangyi.platform.zpush.internal.longlink.socketio.engine.engineio.client.transports.PollingXHR;
import com.zhizhangyi.platform.zwebview.AbsAgentWebSettings;
import com.zhizhangyi.platform.zwebview.AgentWeb;
import com.zhizhangyi.platform.zwebview.AgentWebConfig;
import com.zhizhangyi.platform.zwebview.DefaultWebClient;
import com.zhizhangyi.platform.zwebview.IAgentWebSettings;
import com.zhizhangyi.platform.zwebview.MiddlewareWebChromeBase;
import com.zhizhangyi.platform.zwebview.MiddlewareWebClientBase;
import com.zhizhangyi.platform.zwebview.WebListenerManager;
import com.zhizhangyi.platform.zwebview.download.DefaultDownloadImpl;
import com.zhizhangyi.platform.zwebview.download.DownloadListener;
import com.zhizhangyi.platform.zwebview.download.Extra;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URL;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import net.sqlcipher.database.SQLiteDatabase;
import org.greenrobot.eventbus.ThreadMode;
import org.greenrobot.eventbus.e;
import org.greenrobot.eventbus.n;
import org.json.JSONException;
import org.json.JSONObject;
@Route(path = ARouterConfig.RouterPath.UUSAFE_BIZ_H5_WEB_FRAGMENT)
public class ZlaWebFragment extends H5BaseFragment {
static boolean set = false;
private H5ApplicationInfo appInfo;
private AppStateChangeEvent appStateChangeEvent;
private ConfigInfo configInfo;
private AgentWeb mAgentWeb;
Dialog mDialog;
private String mTmpFilePath;
private ValueCallback<Uri[]> mUploadFile;
BroadcastReceiver networkListener;
private AgentWeb.PreAgentWeb preAgentWeb;
int screenOrientation;
ZWebViewLoadListener zWebViewLoadListener;
public String appId = "";
private String startUrl = "";
boolean isInTabbar = false;
public boolean backListener = false;
public boolean hasToDoListener = false;
public boolean hasSecretaryListener = false;
public boolean hasNoticeListener = false;
public boolean hasAppStatusListener = false;
public boolean customizeWorktable = false;
boolean hiddentitlebutton = false;
boolean hiddenbackbutton = false;
boolean hiddenclosebutton = false;
boolean hiddenstatusbutton = false;
boolean hideProgress = false;
LinearLayout rootLinearLayout = null;
HashMap<String, String> cachePromptStr = new HashMap<>();
HashMap<String, MbsJsBridge> bridgeMap = new HashMap<>();
private DownloadListener mDownloadListener = new DownloadListener() {
@Override
public boolean onStart(String str, String str2, String str3, String str4, long j, Extra extra) {
Logger.d("url:" + String.format("url:[%s] contentDisposition:[%s] mimetype:[%s]", str, str3, str4));
ZlaWebFragment.this.showH5ProgressBar();
String fileName = StringUtils.areNotEmpty(str3) ? ZlaWebFragment.this.getFileName(str3) : "";
ZlaWebFragment.this.setCheckSsl();
new DownloaderTask(str2, fileName).execute(str);
return true;
}
};
long lastActiveTime = -1;
long lastInactiveTime = -1;
private boolean checkSsl = false;
static class AnonymousClass11 {
static final int[] $SwitchMap$com$uusafe$base$modulesdk$module$event$AppStateChangeEvent$AppStateChangeType = new int[AppStateChangeEvent.AppStateChangeType.values().length];
static {
try {
$SwitchMap$com$uusafe$base$modulesdk$module$event$AppStateChangeEvent$AppStateChangeType[AppStateChangeEvent.AppStateChangeType.APP_CHANGE.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$com$uusafe$base$modulesdk$module$event$AppStateChangeEvent$AppStateChangeType[AppStateChangeEvent.AppStateChangeType.DOWNLOAD_START.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
$SwitchMap$com$uusafe$base$modulesdk$module$event$AppStateChangeEvent$AppStateChangeType[AppStateChangeEvent.AppStateChangeType.DOWNLOAD_PROGRESS.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
$SwitchMap$com$uusafe$base$modulesdk$module$event$AppStateChangeEvent$AppStateChangeType[AppStateChangeEvent.AppStateChangeType.DOWNLOAD_PAUSE.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
try {
$SwitchMap$com$uusafe$base$modulesdk$module$event$AppStateChangeEvent$AppStateChangeType[AppStateChangeEvent.AppStateChangeType.DOWNLOAD_SUCCESS.ordinal()] = 5;
} catch (NoSuchFieldError unused5) {
}
try {
$SwitchMap$com$uusafe$base$modulesdk$module$event$AppStateChangeEvent$AppStateChangeType[AppStateChangeEvent.AppStateChangeType.DOWNLOAD_ERROR.ordinal()] = 6;
} catch (NoSuchFieldError unused6) {
}
}
}
private class DownloaderTask extends AsyncTask<String, Long, String> {
String fileName;
String userAgent;
public DownloaderTask(String str, String str2) {
this.userAgent = "";
this.fileName = "";
this.userAgent = str;
this.fileName = str2;
}
@Override
protected void onCancelled() {
super.onCancelled();
}
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
public String doInBackground(String... strArr) {
FileOutputStream fileOutputStream;
String str = strArr[0];
if (StringUtils.isEmpty(this.fileName)) {
this.fileName = str.substring(str.lastIndexOf("/") + 1);
this.fileName = URLDecoder.decode(this.fileName);
}
File file = new File(ZlaWebFragment.this.getContext().getExternalFilesDir(null) + "/download/" + MD5Util.encode(str) + "/");
if (!file.exists()) {
file.mkdirs();
}
File file2 = new File(file, this.fileName);
if (file2.exists()) {
return file2.getAbsolutePath();
}
try {
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
httpURLConnection.setRequestProperty("User-Agent", this.userAgent);
httpURLConnection.setRequestProperty("Cookie", AgentWebConfig.getCookiesByUrl(str));
httpURLConnection.setReadTimeout(PolicyProvider.DataContract.TYPE_ENCRYPTION);
httpURLConnection.setConnectTimeout(PolicyProvider.DataContract.TYPE_ENCRYPTION);
httpURLConnection.setRequestProperty("Charset", "UTF-8");
httpURLConnection.setRequestMethod(Util.HTTP_GET);
List<String> list = httpURLConnection.getHeaderFields().get("Content-Length");
long parseLong = (list == null || list.size() < 1) ? 0L : Long.parseLong(list.get(0));
if (httpURLConnection.getResponseCode() == 200) {
InputStream inputStream = httpURLConnection.getInputStream();
if (inputStream.available() > 0) {
parseLong = inputStream.available();
}
if (inputStream != null) {
fileOutputStream = new FileOutputStream(file2);
byte[] bArr = new byte[4096];
long j = 0;
loop0: while (true) {
long j2 = 0;
do {
int read = inputStream.read(bArr);
if (read == -1) {
break loop0;
}
fileOutputStream.write(bArr, 0, read);
long j3 = read;
j += j3;
j2 += j3;
} while (j2 < 20480);
publishProgress(Long.valueOf(j), Long.valueOf(parseLong));
}
} else {
fileOutputStream = null;
}
if (fileOutputStream != null) {
fileOutputStream.flush();
fileOutputStream.close();
}
return file2.getAbsolutePath();
}
} catch (Exception e2) {
file2.delete();
e2.printStackTrace();
}
return null;
}
@Override
public void onPostExecute(String str) {
super.onPostExecute((DownloaderTask) str);
ZlaWebFragment.this.hideProgressBar();
if (StringUtils.isEmpty(str)) {
Toast makeText = Toast.makeText(ZlaWebFragment.this.getContext(), "文件下载错误!请稍后再试!", 1);
makeText.setGravity(17, 0, 0);
makeText.show();
return;
}
File file = new File(str);
ZlaWebFragment zlaWebFragment = ZlaWebFragment.this;
zlaWebFragment.openFile(zlaWebFragment.getContext(), file.getAbsolutePath());
}
@Override
public void onProgressUpdate(Long... lArr) {
if (lArr.length != 2 || lArr[0].longValue() <= 0 || lArr[1].longValue() <= 0 || ZlaWebFragment.this.getmProgressDialog() == null) {
return;
}
ProgressDialog progressDialog = ZlaWebFragment.this.getmProgressDialog();
progressDialog.setProgressText("下载中" + ((int) ((((float) lArr[0].longValue()) * 100.0f) / ((float) lArr[1].longValue()))) + "/100");
}
}
public class TrustAllManager implements X509TrustManager {
public TrustAllManager() {
}
@Override
public void checkClientTrusted(X509Certificate[] x509CertificateArr, String str) {
}
@Override
public void checkServerTrusted(X509Certificate[] x509CertificateArr, String str) {
}
@Override
public X509Certificate[] getAcceptedIssuers() {
return null;
}
}
private void cleanData() {
String mainProcessStr = H5BGModuleImpl.getMainProcessStr(getContext(), ModuleMessageEvent.MessageEventType.EVENT_H5AUTOREMOVECOOKIE);
if (mainProcessStr == null || !mainProcessStr.equals("true")) {
return;
}
ValueCallback<Boolean> valueCallback = new ValueCallback<Boolean>() {
@Override
public void onReceiveValue(Boolean bool) {
}
};
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeAllCookies(valueCallback);
cookieManager.removeSessionCookies(valueCallback);
cookieManager.flush();
}
private MiddlewareWebClientBase getMiddlewareWebClient() {
return new MiddlewareWebClientBase() {
@Override
public void onPageFinished(WebView webView, String str) {
if (webView.getProgress() == 100 && ZlaWebFragment.this.mAgentWeb != null) {
ZlaWebFragment.this.mAgentWeb.getJsAccessEntrace().callJs("var $html = document.querySelector('html');var uubridge = $html.hasAttribute('uubridge') ? $html.getAttribute('uubridge') || 'false' : 'false';Bridge.registerModules(uubridge,'" + str + "');");
}
if (ZlaWebFragment.this.zWebViewLoadListener != null && webView.getProgress() == 100) {
ZlaWebFragment.this.zWebViewLoadListener.onSuccess(0);
}
super.onPageFinished(webView, str);
}
@Override
public void onPageStarted(WebView webView, String str, Bitmap bitmap) {
super.onPageStarted(webView, str, bitmap);
}
@Override
public void onReceivedError(WebView webView, WebResourceRequest webResourceRequest, WebResourceError webResourceError) {
String uri = webResourceRequest.getUrl().toString();
String url = webView.getUrl();
if (url == null || uri == null || !url.equals(uri) || !ZlaWebFragment.this.isPageUrl(uri)) {
return;
}
super.onReceivedError(webView, webResourceRequest, webResourceError);
}
@Override
public void onReceivedHttpAuthRequest(final WebView webView, final HttpAuthHandler httpAuthHandler, String str, String str2) {
final EditText editText = new EditText(ZlaWebFragment.this.getContext());
editText.setHint("用户名");
final EditText editText2 = new EditText(ZlaWebFragment.this.getContext());
editText2.setHint("密码");
editText2.setInputType(129);
LinearLayout linearLayout = new LinearLayout(ZlaWebFragment.this.getContext());
linearLayout.setOrientation(1);
linearLayout.addView(editText);
linearLayout.addView(editText2);
AlertDialog.Builder negativeButton = new AlertDialog.Builder(ZlaWebFragment.this.getContext()).setTitle("身份验证").setView(linearLayout).setCancelable(false).setPositiveButton(R.string.alert_ok_str, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
httpAuthHandler.proceed(editText.getText().toString(), editText2.getText().toString());
dialogInterface.dismiss();
}
}).setNegativeButton(R.string.appLock_cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
webView.stopLoading();
}
});
if (webView != null) {
negativeButton.show();
}
}
@Override
public void onReceivedSslError(WebView webView, final SslErrorHandler sslErrorHandler, SslError sslError) {
if (webView != null) {
String mainProcessStr = H5BGModuleImpl.getMainProcessStr(ZlaWebFragment.this.getContext(), ModuleMessageEvent.MessageEventType.EVENT_WEBVIEW_SSL);
if (StringUtils.areNotEmpty(mainProcessStr) && mainProcessStr.equals("false")) {
sslErrorHandler.proceed();
return;
}
ZlaWebFragment zlaWebFragment = ZlaWebFragment.this;
zlaWebFragment.mDialog = new CommonDialog.Builder(((H5BaseFragment) zlaWebFragment).mActivity).setTitleShow(false).setMessage(ZlaWebFragment.this.getText(R.string.h5sdk_network_https)).setCancelable(false).setPositiveListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
sslErrorHandler.proceed();
ZlaWebFragment.this.mDialog.dismiss();
}
}).setNegativeListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
sslErrorHandler.cancel();
ZlaWebFragment.this.mDialog.dismiss();
}
}).create();
ZlaWebFragment.this.mDialog.show();
}
}
@Override
public WebResourceResponse shouldInterceptRequest(WebView webView, String str) {
return super.shouldInterceptRequest(webView, str);
}
@Override
public boolean shouldOverrideUrlLoading(WebView webView, String str) {
return super.shouldOverrideUrlLoading(webView, str);
}
@Override
public WebResourceResponse shouldInterceptRequest(WebView webView, WebResourceRequest webResourceRequest) {
return super.shouldInterceptRequest(webView, webResourceRequest);
}
@Override
public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest webResourceRequest) {
String uri = webResourceRequest.getUrl().toString();
if (StringUtils.isEmpty(uri)) {
return true;
}
if (uri.startsWith("content:")) {
webView.loadUrl(webResourceRequest.getUrl().toString());
return true;
}
if (uri.startsWith("res:")) {
try {
webView.loadUrl(ZlaWebFragment.this.getUriFromFile(new File(Env.getAppResFile(ZlaWebFragment.this.getContext(), ZlaWebFragment.this.appId, uri))).toString());
return true;
} catch (Exception e2) {
e2.printStackTrace();
}
} else if (uri.contains("://") && !ZlaWebFragment.this.isPageUrl(uri)) {
try {
ZlaWebFragment.this.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(uri)));
} catch (Exception unused) {
}
return true;
}
return super.shouldOverrideUrlLoading(webView, webResourceRequest);
}
};
}
private IAgentWebSettings getSettings() {
return new AbsAgentWebSettings() {
private AgentWeb mAgentWeb;
@Override
protected void bindAgentWebSupport(AgentWeb agentWeb) {
this.mAgentWeb = agentWeb;
}
@Override
public WebListenerManager setDownloader(WebView webView, android.webkit.DownloadListener downloadListener) {
super.setDownloader(webView, DefaultDownloadImpl.create(ZlaWebFragment.this.getActivity(), webView, ZlaWebFragment.this.mDownloadListener, this.mAgentWeb.getPermissionInterceptor()));
return this;
}
@Override
public IAgentWebSettings toSetting(WebView webView) {
super.toSetting(webView);
WebSettings settings = webView.getSettings();
Utils.setWebViewAllowFileAccess(settings, true);
settings.setSavePassword(false);
settings.setJavaScriptEnabled(true);
settings.setSupportZoom(true);
settings.setBuiltInZoomControls(true);
settings.setDisplayZoomControls(false);
settings.setUseWideViewPort(true);
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
settings.setLoadWithOverviewMode(true);
settings.setUserAgentString(settings.getUserAgentString().concat(" Mbs/").concat("3.6.5.2").concat(" "));
settings.setGeolocationEnabled(true);
settings.setDatabaseEnabled(true);
settings.setMinimumFontSize(8);
if (Build.VERSION.SDK_INT >= 16) {
Utils.setWebViewAllowFileAccessFromFileURLs(settings, true);
settings.setAllowUniversalAccessFromFileURLs(true);
}
return this;
}
};
}
public Uri getUriFromFile(File file) {
if (Build.VERSION.SDK_INT >= 24) {
return FileProvider.getUriForFile(getContext(), BaseGlobal.getInstance().getFileProvider(), file);
}
return Uri.fromFile(file);
}
private String getUrl() {
ConfigInfo configInfo;
String str = this.startUrl;
if (str != null && str.length() != 0 && (configInfo = this.configInfo) != null) {
Set<String> startParamNames = configInfo.getStartParamNames();
if (startParamNames.size() == 0) {
return this.startUrl;
}
try {
StringBuilder sb = new StringBuilder(this.startUrl);
sb.append("?");
for (String str2 : startParamNames) {
String string = this.configInfo.getString(str2);
sb.append(URLEncoder.encode(str2, CommGlobal.charsetName));
sb.append(ContainerUtils.KEY_VALUE_DELIMITER);
sb.append(URLEncoder.encode(string, CommGlobal.charsetName));
sb.append(ContainerUtils.FIELD_DELIMITER);
}
Logger.log("拼凑后的url=" + sb.toString());
sb.deleteCharAt(sb.length() + (-1));
return sb.toString();
} catch (Throwable th) {
Logger.logE(th);
return this.startUrl;
}
}
return this.startUrl;
}
private boolean isLocalPath(String str) {
return str.startsWith("res:") || str.startsWith("app:") || str.startsWith("./") || str.startsWith("/");
}
private void loadIndexUrl() {
if (this.preAgentWeb == null || this.mAgentWeb != null) {
return;
}
String str = "";
int i = this.appInfo.mode;
if (i == 1) {
str = getUrl();
} else if (i == 2) {
try {
str = getUriFromFile(new File(getUrl())).toString();
if (StringUtils.areNotEmpty(this.appInfo.localScheme)) {
str = str + "?" + this.appInfo.localScheme;
}
} catch (Exception e2) {
e2.printStackTrace();
}
} else {
str = this.startUrl;
if (isLocalPath(str)) {
str = getUriFromFile(new File(Env.getAppResFile(getContext(), this.appId, str))).toString();
}
}
if (StringUtils.areNotEmpty(str)) {
this.checkSsl = true;
this.mAgentWeb = this.preAgentWeb.go(str);
}
}
public static ZlaWebFragment newInstance(Bundle bundle) {
ZlaWebFragment zlaWebFragment = new ZlaWebFragment();
zlaWebFragment.setArguments(bundle);
return zlaWebFragment;
}
public void openFile(Context context, String str) {
File file = new File(str);
if (file.exists()) {
String mIMEType = NativeUtil.getMIMEType(file);
Intent intent = new Intent();
intent.addFlags(SQLiteDatabase.CREATE_IF_NECESSARY);
intent.setAction("android.intent.action.VIEW");
if (Build.VERSION.SDK_INT >= 24) {
intent.setFlags(1);
intent.setDataAndType(FileProvider.getUriForFile(context, context.getPackageName() + AppUtils.h5Authority, file), mIMEType);
} else {
intent.setDataAndType(Uri.fromFile(file), mIMEType);
}
try {
context.startActivity(intent);
} catch (Exception e2) {
e2.printStackTrace();
}
}
}
private void parseArgs() {
Bundle arguments = getArguments();
boolean z = true;
if (arguments != null && arguments.getSerializable(AppConfig.KeyBundle.UU_MOS_MODULE_INFO) != null) {
this.isInTabbar = true;
this.mModuleInfo = (ModuleInfo) arguments.getSerializable(AppConfig.KeyBundle.UU_MOS_MODULE_INFO);
this.appInfo = new H5ApplicationInfo();
this.appInfo.name = this.mModuleInfo.getTitle();
setToolbarTitle(this.mModuleInfo.getTitle());
if (this.mModuleInfo.getHideTitle() == 1) {
this.hiddentitlebutton = true;
}
if (this.mModuleInfo.getHideBack() == 1) {
this.hiddenbackbutton = true;
}
this.appId = this.mModuleInfo.getLocalH5PkgName();
String scheme = this.mModuleInfo.getScheme();
if (this.mModuleInfo.getLocalH5PkgName() != null && this.mModuleInfo.getLocalH5PkgName().length() > 0) {
if (!e.a().b(this)) {
e.a().e(this);
}
loadLocalTabH5Url();
return;
}
this.startUrl = this.mModuleInfo.getUrl();
if (this.mModuleInfo.getSchemeFlag() == 1 && StringUtils.areNotEmpty(this.mModuleInfo.getScheme())) {
URI create = URI.create(this.startUrl);
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(create.getScheme());
stringBuffer.append("://");
stringBuffer.append(create.getHost());
if (StringUtils.areNotEmpty(create.getPort() + "") && create.getPort() > 0) {
stringBuffer.append(Constants.COLON_SEPARATOR);
stringBuffer.append(create.getPort());
}
String htmlUrlScheme = CommPackageUtils.getHtmlUrlScheme(scheme, getContext());
try {
htmlUrlScheme = CustomURLEncoder.encode(htmlUrlScheme, "UTF-8");
} catch (Exception unused) {
}
stringBuffer.append("/");
stringBuffer.append(htmlUrlScheme);
this.startUrl = stringBuffer.toString();
return;
}
return;
}
if (arguments != null) {
this.appInfo = (H5ApplicationInfo) arguments.getParcelable(IConstants.KEY_EXTRA_APPINFO);
}
H5ApplicationInfo h5ApplicationInfo = this.appInfo;
if (h5ApplicationInfo == null) {
this.appInfo = new H5ApplicationInfo();
this.appInfo.mode = 3;
this.configInfo = new ConfigInfo();
this.appId = "";
if (arguments != null) {
String string = arguments.getString(IConstants.KEY_EXTRA_APP_PARAM);
if (StringUtils.areNotEmpty(string)) {
try {
JSONObject jSONObject = new JSONObject(string);
this.startUrl = JsonUtil.getString(jSONObject, "url");
this.startUrl = CommPackageUtils.getHtmlUrlScheme(this.startUrl, getContext());
this.hiddentitlebutton = JsonUtil.getInt(jSONObject, "hiddentitlebutton", 0) == 1;
this.hiddenbackbutton = JsonUtil.getInt(jSONObject, "hiddenbackbutton", 0) == 1;
this.hiddenclosebutton = JsonUtil.getInt(jSONObject, "hiddenclosebutton", 0) == 1;
if (JsonUtil.getInt(jSONObject, "hiddenstatusbutton", 0) != 1) {
z = false;
}
this.hiddenstatusbutton = z;
this.hideProgress = JsonUtil.getBoolean(jSONObject, "hideProgress", false);
} catch (Exception unused2) {
}
}
}
} else {
this.hiddentitlebutton = h5ApplicationInfo.hideTitle == 1;
this.hiddenbackbutton = this.appInfo.hideBack == 1;
this.hiddenclosebutton = this.appInfo.hideClose == 1;
this.hiddenstatusbutton = this.appInfo.hideStatusBar == 1;
this.screenOrientation = this.appInfo.screenOrientation;
if (arguments != null) {
this.configInfo = (ConfigInfo) arguments.getParcelable(IConstants.KEY_EXTRA_CONFINFO);
this.appId = arguments.getString(IConstants.KEY_EXTRA_PKG);
this.startUrl = arguments.getString(IConstants.KEY_EXTRA_STARTURL);
}
}
if (this.hiddenstatusbutton) {
getActivity().getWindow().addFlags(1024);
}
}
private void printActivityInfo() {
Logger.d("被启动的activity,cls=" + ZlaWebFragment.class.getName() + ",taskId=" + ((H5BaseFragment) this).mActivity.getTaskId() + ",processId=" + Process.myPid() + ",appId=" + this.appId + ",startUrl=" + this.startUrl + ",appInfo=" + this.appInfo);
}
private String substring(String str, String str2) {
int indexOf = str.indexOf(str2);
return indexOf >= 0 ? str.substring(indexOf).replace(str2, "").replace("\"", "") : "未知文件";
}
public void activateCallback() {
this.lastActiveTime = System.currentTimeMillis();
excuteWebviewJs("var e = document.createEvent('HTMLEvents');var evt = 'activate';e.initEvent(evt, false, true);document.dispatchEvent(e);");
}
@Override
public int attachLayoutRes() {
return 0;
}
public void backCallback() {
excuteWebviewJs("var e = document.createEvent('HTMLEvents');var evt = 'back';e.initEvent(evt, false, true);document.dispatchEvent(e);");
}
@Override
public <T> l<T> bindLifecycle() {
return null;
}
void excuteWebviewJs(String str) {
AgentWeb agentWeb = this.mAgentWeb;
if (agentWeb == null) {
return;
}
agentWeb.getJsAccessEntrace().callJs(str);
}
public AppStateChangeEvent getAppStateChangeEvent() {
return this.appStateChangeEvent;
}
@Override
public Context getCurrentContext() {
return null;
}
public String getFileName(String str) {
if (TextUtils.isEmpty(str)) {
return "未知文件";
}
try {
if (str.contains("filename*=utf-8''")) {
return substring(URLDecoder.decode(str, CommGlobal.charsetName), "filename*=utf-8''");
}
if (str.contains("=?UTF8?B?")) {
StringBuffer stringBuffer = new StringBuffer();
for (String str2 : substring(str, "filename=").split(" ")) {
String substring = substring(str2, "=?UTF8?B?");
if (substring.length() > 2) {
stringBuffer.append(substring.substring(0, substring.length() - 2));
}
}
return new String(Base64.decode(stringBuffer.toString().getBytes(), 0));
}
return URLDecoder.decode(substring(str, ContainerUtils.KEY_VALUE_DELIMITER), CommGlobal.charsetName);
} catch (Exception e2) {
e2.printStackTrace();
return "未知文件";
}
}
@Override
protected int getLayoutResID() {
if (this.customizeWorktable) {
return R.layout.h5sdk_fragment_plugin_zlaweb;
}
return R.layout.h5sdk_fragment_zlaweb;
}
protected MiddlewareWebChromeBase getMiddlewareWebChrome() {
return new MiddlewareWebChromeBase() {
@Override
public void onGeolocationPermissionsShowPrompt(String str, GeolocationPermissions.Callback callback) {
callback.invoke(str, true, false);
}
@Override
public boolean onJsPrompt(WebView webView, String str, String str2, String str3, JsPromptResult jsPromptResult) {
if (ZlaWebFragment.this.bridgeMap.get(str) != null) {
if (str2.equals("timestamp") && StringUtils.areNotEmpty(str3)) {
if (ZlaWebFragment.this.cachePromptStr.containsKey(str3)) {
ZlaWebFragment.this.cachePromptStr.remove(str3);
if (ZlaWebFragment.this.bridgeMap.get(str).callJsPrompt(ZlaWebFragment.this.cachePromptStr.get(str3), jsPromptResult)) {
return true;
}
}
} else if (ZlaWebFragment.this.bridgeMap.get(str).callJsPrompt(str2, jsPromptResult)) {
return true;
}
}
if (StringUtils.areNotEmpty(str3) && str3.equals("CallJava")) {
ZZLog.e("onJsPrompt url==" + str + "message==" + str2);
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put(PollingXHR.Request.EVENT_SUCCESS, false);
jSONObject.put("msg", "error");
jsPromptResult.confirm(jSONObject.toString());
} catch (JSONException e2) {
e2.printStackTrace();
}
return true;
}
return super.onJsPrompt(webView, str, str2, str3, jsPromptResult);
}
@Override
public void onReceivedTitle(WebView webView, String str) {
super.onReceivedTitle(webView, str);
ZlaWebFragment zlaWebFragment = ZlaWebFragment.this;
if (!zlaWebFragment.hiddenbackbutton) {
((H5BaseFragment) zlaWebFragment).backImage.setVisibility(0);
if (ZlaWebFragment.this.isInTabbar && !webView.canGoBack()) {
((H5BaseFragment) ZlaWebFragment.this).backImage.setVisibility(8);
}
}
ModuleInfo moduleInfo = ZlaWebFragment.this.mModuleInfo;
if (moduleInfo != null && StringUtils.areNotEmpty(moduleInfo.getTitle())) {
ZlaWebFragment zlaWebFragment2 = ZlaWebFragment.this;
zlaWebFragment2.setTitleText(zlaWebFragment2.mModuleInfo.getTitle());
} else if (StringUtils.isEmpty(ZlaWebFragment.this.appId)) {
ZlaWebFragment.this.setToolbarTitle(str);
}
}
@Override
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> valueCallback, WebChromeClient.FileChooserParams fileChooserParams) {
Logger.d("onShowFileChooser: fileChooserParams: " + fileChooserParams + " isCapture:" + fileChooserParams.isCaptureEnabled());
try {
String str = "";
String[] acceptTypes = fileChooserParams.getAcceptTypes();
String lowerCase = (acceptTypes == null || acceptTypes.length <= 0) ? IConstants.ACCEPT_TYPE_ALL : acceptTypes[0].toLowerCase();
if (IConstants.ACCEPT_TYPE_IMAGE.equalsIgnoreCase(lowerCase)) {
str = Utils.getFileChooserTmpPicFile(((H5BaseFragment) ZlaWebFragment.this).mActivity).getAbsolutePath();
} else if (IConstants.ACCEPT_TYPE_VIDEO.equalsIgnoreCase(lowerCase)) {
str = Utils.getFileChooserTmpVideoFile(((H5BaseFragment) ZlaWebFragment.this).mActivity).getAbsolutePath();
}
ZlaWebFragment.this.setFileChooserInfo(valueCallback, str);
if (fileChooserParams.isCaptureEnabled()) {
if (IConstants.ACCEPT_TYPE_IMAGE.equalsIgnoreCase(lowerCase)) {
if (PermissionsUtils.hasPermission(ZlaWebFragment.this, PermissionsUtils.CAMERA)) {
AppUtils.openSystemCamera(((H5BaseFragment) ZlaWebFragment.this).mActivity, 1, new File(str), 2001);
} else {
PermissionsUtils.requestPermission(ZlaWebFragment.this, 138, PermissionsUtils.CAMERA);
valueCallback.onReceiveValue(null);
}
} else if (IConstants.ACCEPT_TYPE_AUDIO.equalsIgnoreCase(lowerCase)) {
if (PermissionsUtils.hasPermission(ZlaWebFragment.this, PermissionsUtils.VIDEO)) {
AppUtils.openSystemMicrophone(((H5BaseFragment) ZlaWebFragment.this).mActivity, 2, 2003);
} else {
PermissionsUtils.requestPermission(ZlaWebFragment.this, 138, PermissionsUtils.VIDEO);
valueCallback.onReceiveValue(null);
}
} else if (IConstants.ACCEPT_TYPE_VIDEO.equalsIgnoreCase(lowerCase)) {
if (PermissionsUtils.hasPermission(ZlaWebFragment.this, PermissionsUtils.VIDEO)) {
AppUtils.openSystemCamcorder(((H5BaseFragment) ZlaWebFragment.this).mActivity, 3, new File(str));
} else {
PermissionsUtils.requestPermission(ZlaWebFragment.this, 138, PermissionsUtils.VIDEO);
valueCallback.onReceiveValue(null);
}
}
} else if (IConstants.ACCEPT_TYPE_IMAGE.equalsIgnoreCase(lowerCase)) {
DialogUtils.showFileUploadDialog(ZlaWebFragment.this, lowerCase, valueCallback, str);
} else {
if (TextUtils.isEmpty(lowerCase)) {
lowerCase = IConstants.ACCEPT_TYPE_ALL;
}
AppUtils.requestGetFileIntent(ZlaWebFragment.this, lowerCase, 4);
}
} catch (Throwable th) {
th.printStackTrace();
}
return true;
}
};
}
public String getProcessName(Context context) {
if (context == null) {
return null;
}
for (ActivityManager.RunningAppProcessInfo runningAppProcessInfo : ((ActivityManager) context.getSystemService("activity")).getRunningAppProcesses()) {
if (runningAppProcessInfo.pid == Process.myPid()) {
return runningAppProcessInfo.processName;
}
}
return null;
}
public void hideProgressText() {
getmProgressDialog().hideProgressText();
}
public void inactivateCallback() {
this.lastInactiveTime = System.currentTimeMillis();
excuteWebviewJs("var e = document.createEvent('HTMLEvents');var evt = 'inactivate';e.initEvent(evt, false, true);document.dispatchEvent(e);");
}
@Override
public void initData() {
showRefresh(false);
setToolbarTitle(this.appInfo.name);
printActivityInfo();
H5BGModuleImpl.checkDebug(getContext());
if (ProcessUtils.isBrowserProcess(getContext()) && StringUtils.areNotEmpty(this.appInfo.name)) {
NativeUtil.setTaskInfo(getActivity(), this.appInfo.name);
}
}
@Override
protected void initInjector() {
}
@Override
public void initLifecycleObserver(Lifecycle lifecycle) {
}
@Override
public void initView(Bundle bundle) {
}
void initView(View view) {
if (this.hiddentitlebutton) {
this.toolbar.setVisibility(8);
} else {
if (this.hiddenbackbutton) {
((H5BaseFragment) this).backImage.setVisibility(8);
}
if (this.hiddenclosebutton) {
this.cancelImage.setVisibility(8);
}
}
if (this.isInTabbar) {
((H5BaseFragment) this).backImage.setVisibility(8);
this.cancelImage.setVisibility(8);
}
if (this.networkListener == null) {
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
intentFilter.setPriority(1000);
this.networkListener = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals("android.net.conn.CONNECTIVITY_CHANGE")) {
if (Utils.isNetWorkAvalible(ZlaWebFragment.this.getContext())) {
ZlaWebFragment.this.onlineCallback();
} else {
ZlaWebFragment.this.offlineCallback();
}
}
}
};
getContext().registerReceiver(this.networkListener, intentFilter);
}
}
void initWebview(View view) {
if (Build.VERSION.SDK_INT >= 28) {
try {
WebView.setDataDirectorySuffix(getProcessName(getContext()));
} catch (Exception e2) {
e2.printStackTrace();
}
}
if (this.hideProgress) {
AgentWeb.CommonBuilder useMiddlewareWebClient = AgentWeb.with(this).setAgentWebParent((LinearLayout) view, -1, new LinearLayout.LayoutParams(-1, -1)).closeIndicator().setAgentWebWebSettings(getSettings()).setSecurityType(AgentWeb.SecurityType.STRICT_CHECK).setMainFrameErrorView(R.layout.h5sdk_error_view, -1).useMiddlewareWebChrome(getMiddlewareWebChrome()).useMiddlewareWebClient(getMiddlewareWebClient());
if (Build.VERSION.SDK_INT <= 23) {
useMiddlewareWebClient.setWebView(new CustomWebView(getContext()));
}
this.preAgentWeb = useMiddlewareWebClient.createAgentWeb().ready();
} else {
AgentWeb.CommonBuilder useMiddlewareWebClient2 = AgentWeb.with(this).setAgentWebParent((LinearLayout) view, -1, new LinearLayout.LayoutParams(-1, -1)).setCustomIndicator(new CoolIndicatorLayout(getActivity())).setAgentWebWebSettings(getSettings()).setSecurityType(AgentWeb.SecurityType.STRICT_CHECK).setMainFrameErrorView(R.layout.h5sdk_error_view, -1).useMiddlewareWebChrome(getMiddlewareWebChrome()).useMiddlewareWebClient(getMiddlewareWebClient());
if (Build.VERSION.SDK_INT <= 23) {
useMiddlewareWebClient2.setWebView(new CustomWebView(getContext()));
}
this.preAgentWeb = useMiddlewareWebClient2.createAgentWeb().ready();
}
CookieManager.getInstance().setAcceptThirdPartyCookies(this.preAgentWeb.get().getWebCreator().getWebView(), true);
this.preAgentWeb.get().getWebCreator().getWebView().addJavascriptInterface(new Object() {
@JavascriptInterface
public void prompt(String str, String str2) {
ZlaWebFragment.this.cachePromptStr.put(str2, str);
}
@JavascriptInterface
public void registerModules(String str, String str2) {
if (StringUtils.isEmpty(str) || str.equalsIgnoreCase("false")) {
return;
}
MbsJsBridge mbsJsBridge = ZlaWebFragment.this.bridgeMap.get(str2);
if (mbsJsBridge == null) {
mbsJsBridge = new MbsJsBridge(ZlaWebFragment.this);
ZlaWebFragment.this.bridgeMap.put(str2, mbsJsBridge);
}
mbsJsBridge.registerModules(str);
mbsJsBridge.injectJs(ZlaWebFragment.this.mAgentWeb.getWebCreator().getWebView(), true);
ZlaWebFragment.this.readyCallback();
}
}, DSLog.LOGTAG);
this.preAgentWeb.get().getWebCreator().getWebView().addJavascriptInterface(new Object() {
@JavascriptInterface
public void d(String str) {
ZZLog.d("JsLog", str, new Object[0]);
}
@JavascriptInterface
public void e(String str) {
ZZLog.e("JsLog", str, new Object[0]);
}
}, "Log");
this.preAgentWeb.get().getWebCreator().getWebView().addJavascriptInterface(new Object() {
@JavascriptInterface
public void hideZoomControl() {
ZlaWebFragment.this.preAgentWeb.get().getAgentWebSettings().getWebSettings().setDisplayZoomControls(false);
}
}, "Native");
String[] split = getUrl().split("kkToken=");
if (split.length == 2) {
syncCookie(split[0], split[1]);
}
}
protected boolean isPageUrl(String str) {
return str.contains(DefaultWebClient.HTTP_SCHEME) || str.contains(DefaultWebClient.HTTPS_SCHEME) || str.contains("ftp://");
}
void loadLocalTabH5Url() {
String str = Env.getH5TabDir(getContext()) + "/" + this.appId;
File file = new File(str, "zla.json");
if (this.mModuleInfo.getSchemeFlag() == 1 && StringUtils.areNotEmpty(this.mModuleInfo.getScheme())) {
H5ApplicationInfo h5ApplicationInfo = this.appInfo;
h5ApplicationInfo.mode = 2;
h5ApplicationInfo.localScheme = this.mModuleInfo.getScheme();
H5ApplicationInfo h5ApplicationInfo2 = this.appInfo;
h5ApplicationInfo2.localScheme = CommPackageUtils.getHtmlUrlScheme(h5ApplicationInfo2.localScheme, getContext());
try {
if (this.appInfo.localScheme.contains("?")) {
String substring = this.appInfo.localScheme.substring(0, this.appInfo.localScheme.indexOf("?"));
this.appInfo.localScheme = this.appInfo.localScheme.substring(this.appInfo.localScheme.indexOf("?") + 1);
this.appInfo.localScheme = CustomURLEncoder.encode(this.appInfo.localScheme, "UTF-8");
this.startUrl = str + "/" + substring;
} else {
this.appInfo.localScheme = CustomURLEncoder.encode(this.appInfo.localScheme, "UTF-8");
ZlaInfo zlaInfo = com.uusafe.h5app.library.utils.JsonUtil.getZlaInfo(file);
this.startUrl = str + "/" + zlaInfo.application.index;
}
return;
} catch (Exception unused) {
ZlaInfo zlaInfo2 = null;
try {
zlaInfo2 = com.uusafe.h5app.library.utils.JsonUtil.getZlaInfo(file);
} catch (IOException e2) {
e2.printStackTrace();
}
this.startUrl = str + "/" + zlaInfo2.application.index;
return;
}
}
try {
ZlaInfo zlaInfo3 = com.uusafe.h5app.library.utils.JsonUtil.getZlaInfo(file);
this.startUrl = str + "/" + zlaInfo3.application.index;
} catch (Exception unused2) {
}
}
public void offlineCallback() {
excuteWebviewJs("var e = document.createEvent('HTMLEvents');var evt = 'offline';e.initEvent(evt, false, true);document.dispatchEvent(e);");
}
@Override
public void onActivityResult(int i, int i2, Intent intent) {
Logger.d("onActivityResult requestCode=" + i + ",resultCode=" + i2 + ",data=" + intent);
if (i == 1) {
try {
if (i2 == -1) {
File file = new File(this.mTmpFilePath);
if (file.exists()) {
this.mUploadFile.onReceiveValue(new Uri[]{Uri.fromFile(file)});
} else {
this.mUploadFile.onReceiveValue(null);
}
} else {
this.mUploadFile.onReceiveValue(null);
}
} catch (Throwable unused) {
ValueCallback<Uri[]> valueCallback = this.mUploadFile;
if (valueCallback != null) {
valueCallback.onReceiveValue(null);
}
}
} else if (i == 2) {
try {
this.mUploadFile.onReceiveValue(new Uri[]{intent.getData()});
} catch (Throwable unused2) {
ValueCallback<Uri[]> valueCallback2 = this.mUploadFile;
if (valueCallback2 != null) {
valueCallback2.onReceiveValue(null);
}
}
} else if (i != 3) {
if (i != 4) {
return;
}
try {
this.mUploadFile.onReceiveValue(new Uri[]{intent.getData()});
} catch (Throwable unused3) {
ValueCallback<Uri[]> valueCallback3 = this.mUploadFile;
if (valueCallback3 != null) {
valueCallback3.onReceiveValue(null);
}
}
} else {
try {
if (i2 == -1) {
File file2 = new File(this.mTmpFilePath);
if (file2.exists()) {
this.mUploadFile.onReceiveValue(new Uri[]{Uri.fromFile(file2)});
} else {
this.mUploadFile.onReceiveValue(null);
}
} else {
this.mUploadFile.onReceiveValue(null);
}
} catch (Throwable unused4) {
ValueCallback<Uri[]> valueCallback4 = this.mUploadFile;
if (valueCallback4 != null) {
valueCallback4.onReceiveValue(null);
}
}
}
}
@Override
public void onBack() {
if (this.backListener) {
backCallback();
} else if (this.mAgentWeb.back() || this.mModuleInfo != null) {
} else {
((H5BaseFragment) this).mActivity.finish();
}
}
@Override
public boolean onBackPressedSupport() {
boolean z = this.backListener;
if (this.mAgentWeb.getWebCreator().getWebView().canGoBack()) {
z = true;
}
onBack();
return z;
}
@Override
public void onClick(View view) {
}
@Override
@Nullable
public View onCreateView(LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, Bundle bundle) {
Bundle arguments = getArguments();
if (arguments != null) {
this.customizeWorktable = arguments.getBoolean("customizeWorktable");
}
return super.onCreateView(layoutInflater, viewGroup, bundle);
}
@Override
public void onDestroyView() {
cleanData();
this.cachePromptStr.clear();
AgentWeb agentWeb = this.mAgentWeb;
if (agentWeb != null) {
agentWeb.getWebLifeCycle().onDestroy();
}
ProgressDialog progressDialog = ((H5BaseFragment) this).mProgressDialog;
if (progressDialog != null) {
progressDialog.dismiss();
}
if (this.networkListener != null) {
try {
getContext().unregisterReceiver(this.networkListener);
} catch (Exception unused) {
}
}
if (e.a().b(this)) {
e.a().g(this);
}
super.onDestroyView();
}
@Override
public void onHiddenChanged(boolean z) {
super.onHiddenChanged(z);
if (!this.isInTabbar || z) {
return;
}
loadIndexUrl();
}
@Override
public void onPause() {
pauseJS();
AgentWeb agentWeb = this.mAgentWeb;
if (agentWeb != null) {
agentWeb.getWebLifeCycle().onPause();
}
super.onPause();
}
@n(threadMode = ThreadMode.MAIN)
public void onReceiveAppInstalled(TableH5InstallFinishEvent tableH5InstallFinishEvent) {
ZZLog.e("onReceiveAppInstalled appid===" + tableH5InstallFinishEvent.getAppid());
ModuleInfo moduleInfo = this.mModuleInfo;
if (moduleInfo == null || !moduleInfo.getLocalH5PkgName().equals(tableH5InstallFinishEvent.getAppid())) {
return;
}
ZZLog.e("loadIndexUrl appid===" + tableH5InstallFinishEvent.getAppid());
loadLocalTabH5Url();
if (isHidden()) {
return;
}
loadIndexUrl();
}
@n(threadMode = ThreadMode.MAIN)
public void onReceiveAppStateChangeEvent(AppStateChangeEvent appStateChangeEvent) {
this.appStateChangeEvent = appStateChangeEvent;
if (this.hasAppStatusListener && appStateChangeEvent != null) {
JSONObject jSONObject = new JSONObject();
StringBuffer stringBuffer = new StringBuffer();
switch (AnonymousClass11.$SwitchMap$com$uusafe$base$modulesdk$module$event$AppStateChangeEvent$AppStateChangeType[appStateChangeEvent.getAppStateChangeType().ordinal()]) {
case 1:
stringBuffer.append("var e = document.createEvent('HTMLEvents');var evt = 'biz_appchange';e.initEvent(evt, false, true);");
break;
case 2:
JsonUtil.putString(jSONObject, PolicyProtocol.APP_APP_ID, appStateChangeEvent.getAppId());
stringBuffer.append("var e = document.createEvent('HTMLEvents');var evt = 'biz_appstart';e.initEvent(evt, false, true);");
stringBuffer.append("e.returnObj=" + jSONObject.toString() + ";");
break;
case 3:
JsonUtil.putString(jSONObject, PolicyProtocol.APP_APP_ID, appStateChangeEvent.getAppId());
try {
new DecimalFormat("##.#");
jSONObject.put("percent", Math.round(appStateChangeEvent.getPercent() * 100.0f));
} catch (Exception e2) {
e2.printStackTrace();
}
stringBuffer.append("var e = document.createEvent('HTMLEvents');var evt = 'biz_appprogress';e.initEvent(evt, false, true);");
stringBuffer.append("e.returnObj=" + jSONObject.toString() + ";");
break;
case 4:
JsonUtil.putString(jSONObject, PolicyProtocol.APP_APP_ID, appStateChangeEvent.getAppId());
stringBuffer.append("var e = document.createEvent('HTMLEvents');var evt = 'biz_apppause';e.initEvent(evt, false, true);");
stringBuffer.append("e.returnObj=" + jSONObject.toString() + ";");
break;
case 5:
JsonUtil.putString(jSONObject, PolicyProtocol.APP_APP_ID, appStateChangeEvent.getAppId());
stringBuffer.append("var e = document.createEvent('HTMLEvents');var evt = 'biz_appready';e.initEvent(evt, false, true);");
stringBuffer.append("e.returnObj=" + jSONObject.toString() + ";");
break;
case 6:
JsonUtil.putString(jSONObject, PolicyProtocol.APP_APP_ID, appStateChangeEvent.getAppId());
stringBuffer.append("var e = document.createEvent('HTMLEvents');var evt = 'biz_apperror';e.initEvent(evt, false, true);");
stringBuffer.append("e.returnObj=" + jSONObject.toString() + ";");
break;
}
stringBuffer.append("document.dispatchEvent(e);");
excuteWebviewJs(stringBuffer.toString());
}
}
@n(threadMode = ThreadMode.MAIN)
public void onReceiveNoticeAddEvent(NoticeAddEvent noticeAddEvent) {
if (!this.hasNoticeListener || noticeAddEvent == null || noticeAddEvent.getReturnObj() == null) {
return;
}
JSONObject jSONObject = new JSONObject();
StringBuffer stringBuffer = new StringBuffer();
try {
NoticeInfo noticeInfo = (NoticeInfo) JsonUtil.fromJson(noticeAddEvent.getReturnObj(), (Class<Object>) NoticeInfo.class);
JsonUtil.putString(jSONObject, "title", noticeInfo.getTitle());
JsonUtil.putString(jSONObject, "noticeId", noticeInfo.getNoticeId());
JsonUtil.putLong(jSONObject, "timestamp", noticeInfo.getTimestamp());
JsonUtil.putInt(jSONObject, "number", noticeAddEvent.getNumber());
stringBuffer.append("var e = document.createEvent('HTMLEvents');var evt = 'biz_notice';e.initEvent(evt, false, true);");
stringBuffer.append("e.returnObj=" + jSONObject.toString() + ";");
stringBuffer.append("document.dispatchEvent(e);");
excuteWebviewJs(stringBuffer.toString());
} catch (Exception e2) {
e2.printStackTrace();
}
}
@n(threadMode = ThreadMode.MAIN)
public void onReceiveSecretaryAddEvent(SecretaryAddEvent secretaryAddEvent) {
if (!this.hasSecretaryListener || secretaryAddEvent == null || secretaryAddEvent.getReturnObj() == null) {
return;
}
try {
JSONObject jSONObject = new JSONObject();
StringBuffer stringBuffer = new StringBuffer();
AllAloneAppMessageInfo allAloneAppMessageInfo = (AllAloneAppMessageInfo) JsonUtil.fromJson(secretaryAddEvent.getReturnObj(), (Class<Object>) AllAloneAppMessageInfo.class);
JsonUtil.putString(jSONObject, "title", allAloneAppMessageInfo.getTitle());
JsonUtil.putString(jSONObject, "content", allAloneAppMessageInfo.getSummary());
JsonUtil.putLong(jSONObject, "timestamp", allAloneAppMessageInfo.getTimestamp());
stringBuffer.append("var e = document.createEvent('HTMLEvents');var evt = 'biz_secretary';e.initEvent(evt, false, true);");
stringBuffer.append("e.returnObj=" + jSONObject.toString() + ";");
stringBuffer.append("document.dispatchEvent(e);");
excuteWebviewJs(stringBuffer.toString());
} catch (Exception e2) {
e2.printStackTrace();
}
}
@n(threadMode = ThreadMode.MAIN)
public void onReceiveTodoAddEvent(TodoAddEvent todoAddEvent) {
if (!this.hasToDoListener || todoAddEvent == null || todoAddEvent.getReturnObj() == null) {
return;
}
JSONObject jSONObject = new JSONObject();
StringBuffer stringBuffer = new StringBuffer();
try {
AllAloneAppMessageInfo allAloneAppMessageInfo = (AllAloneAppMessageInfo) JsonUtil.fromJson(todoAddEvent.getReturnObj(), (Class<Object>) AllAloneAppMessageInfo.class);
if (allAloneAppMessageInfo.getAloneAppMessageInfoList().size() > 0) {
AloneAppMessageInfo aloneAppMessageInfo = allAloneAppMessageInfo.getAloneAppMessageInfoList().get(0);
JsonUtil.putString(jSONObject, PolicyProtocol.APP_APP_ID, aloneAppMessageInfo.getPkgName());
JsonUtil.putString(jSONObject, "appName", aloneAppMessageInfo.getAloneAppInfo().getAppName());
JsonUtil.putString(jSONObject, "title", aloneAppMessageInfo.getTitle());
JsonUtil.putString(jSONObject, "summary", aloneAppMessageInfo.getSummary());
JsonUtil.putString(jSONObject, PolicyProtocol.SHORTCUT_ICON_URL, BaseApis.getDownloadUrlByFileid(aloneAppMessageInfo.getAloneAppInfo().getIconFileId()));
JsonUtil.putInt(jSONObject, "number", aloneAppMessageInfo.getUnread());
JsonUtil.putInt(jSONObject, "platform", aloneAppMessageInfo.getAloneAppInfo().getPlatform());
JsonUtil.putLong(jSONObject, "timestamp", aloneAppMessageInfo.getTimestamp());
}
stringBuffer.append("var e = document.createEvent('HTMLEvents');var evt = 'biz_todo';e.initEvent(evt, false, true);");
stringBuffer.append("e.returnObj=" + jSONObject.toString() + ";");
stringBuffer.append("document.dispatchEvent(e);");
excuteWebviewJs(stringBuffer.toString());
} catch (Exception e2) {
e2.printStackTrace();
}
}
@Override
public void onRefresh() {
AgentWeb agentWeb = this.mAgentWeb;
if (agentWeb != null) {
agentWeb.getUrlLoader().reload();
}
}
@Override
public void onRequestPermissionsResult(int i, @NonNull String[] strArr, @NonNull int[] iArr) {
switch (i) {
case 2001:
if (iArr[0] == 0) {
String absolutePath = Utils.getFileChooserTmpPicFile(((H5BaseFragment) this).mActivity).getAbsolutePath();
updateFileChooserInfo(absolutePath);
AppUtils.openSystemCamera(this, 1, new File(absolutePath), 2001);
return;
}
ToastUtil.show(((H5BaseFragment) this).mActivity, getResources().getString(R.string.h5sdk_toast_open_camera_error));
this.mUploadFile.onReceiveValue(null);
return;
case 2002:
if (iArr[0] == 0) {
String absolutePath2 = Utils.getFileChooserTmpPicFile(((H5BaseFragment) this).mActivity).getAbsolutePath();
updateFileChooserInfo(absolutePath2);
AppUtils.openSystemCamcorder(this, 3, new File(absolutePath2));
return;
}
ToastUtil.show(((H5BaseFragment) this).mActivity, getResources().getString(R.string.h5sdk_toast_open_camera_error));
this.mUploadFile.onReceiveValue(null);
return;
case 2003:
if (iArr[0] == 0) {
AppUtils.openSystemMicrophone(this, 2, 2003);
return;
}
ToastUtil.show(((H5BaseFragment) this).mActivity, getResources().getString(R.string.h5sdk_toast_open_audio_error));
this.mUploadFile.onReceiveValue(null);
return;
default:
super.onRequestPermissionsResult(i, strArr, iArr);
return;
}
}
@Override
public void onResume() {
if (this.isInTabbar) {
if (!isHidden()) {
loadIndexUrl();
}
} else {
loadIndexUrl();
}
AgentWeb agentWeb = this.mAgentWeb;
if (agentWeb != null) {
agentWeb.getWebLifeCycle().onResume();
resumeJS();
}
super.onResume();
}
@Override
public void onViewCreated(View view, @Nullable Bundle bundle) {
parseArgs();
super.onViewCreated(view, bundle);
initView(view);
initWebview(view);
}
public void onlineCallback() {
excuteWebviewJs("var e = document.createEvent('HTMLEvents');var evt = 'online';e.initEvent(evt, false, true);document.dispatchEvent(e);");
}
public void pauseJS() {
if (this.mAgentWeb == null) {
return;
}
if (this.lastInactiveTime <= 0 || Math.abs(System.currentTimeMillis() - this.lastInactiveTime) >= 500) {
excuteWebviewJs("var e = document.createEvent('HTMLEvents');var evt = 'pause';e.initEvent(evt, false, true);document.dispatchEvent(e);");
}
}
public void readyCallback() {
this.hasToDoListener = false;
this.hasSecretaryListener = false;
this.hasNoticeListener = false;
this.hasAppStatusListener = false;
excuteWebviewJs("var e = document.createEvent('HTMLEvents');var evt = 'plusready';e.initEvent(evt, false, true);document.dispatchEvent(e);");
}
public void refreshUrl(String str) {
if (this.preAgentWeb == null || !StringUtils.areNotEmpty(str)) {
return;
}
this.mAgentWeb = this.preAgentWeb.go(str);
}
@Override
protected void restoreView() {
}
public void resumeJS() {
if (this.mAgentWeb == null) {
return;
}
if (this.lastActiveTime <= 0 || Math.abs(System.currentTimeMillis() - this.lastActiveTime) >= 500) {
excuteWebviewJs("var e = document.createEvent('HTMLEvents');var evt = 'resume';e.initEvent(evt, false, true);document.dispatchEvent(e);");
}
}
@Override
protected void saveCurrentView() {
}
void setCheckSsl() {
if (set) {
return;
}
set = true;
try {
SSLContext sSLContext = SSLContext.getInstance("TLS");
sSLContext.init(null, new TrustManager[]{new TrustAllManager()}, new SecureRandom());
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
@Override
public boolean verify(String str, SSLSession sSLSession) {
return ZlaWebFragment.this.checkSsl;
}
});
HttpsURLConnection.setDefaultSSLSocketFactory(sSLContext.getSocketFactory());
} catch (Exception unused) {
}
}
public void setFileChooserInfo(ValueCallback<Uri[]> valueCallback, String str) {
this.mUploadFile = valueCallback;
this.mTmpFilePath = str;
}
@Override
public void setListener() {
}
public void setProgressText(String str) {
getmProgressDialog().setProgressText(str);
}
public void setZWebViewLoadListener(ZWebViewLoadListener zWebViewLoadListener) {
this.zWebViewLoadListener = zWebViewLoadListener;
}
public boolean syncCookie(String str, String str2) {
String str3 = this.TAG;
ZZLog.d(str3, "url = " + str + "; cookie = " + str2, new Object[0]);
if (Build.VERSION.SDK_INT >= 21) {
CookieManager.getInstance().setAcceptThirdPartyCookies(this.preAgentWeb.get().getWebCreator().getWebView(), true);
CookieManager.getInstance().flush();
}
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(true);
cookieManager.removeSessionCookie();
cookieManager.removeAllCookie();
cookieManager.setCookie(str, str2);
String cookie = cookieManager.getCookie(str);
String str4 = this.TAG;
ZZLog.d(str4, "newCookie : " + cookie, new Object[0]);
CookieSyncManager.getInstance().sync();
return !TextUtils.isEmpty(cookie);
}
public void tabHiden() {
}
public void tabShow() {
excuteWebviewJs("var e = document.createEvent('HTMLEvents');var evt = 'tabshow';e.initEvent(evt, false, true);document.dispatchEvent(e);");
}
public void updateFileChooserInfo(String str) {
this.mTmpFilePath = str;
}
}