乐健体育 v3.9.1版本的 MD5 值为:87ae8a64955cdd0e43f3559ee8984d75

以下内容为反编译后的 PlusModule.java 源代码,内容仅作参考


package io.dcloud.feature.weex.extend;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import androidx.annotation.RequiresApi;
import androidx.core.app.NotificationManagerCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.taobao.weex.R;
import com.taobao.weex.WXSDKInstance;
import com.taobao.weex.WXSDKManager;
import com.taobao.weex.annotation.JSMethod;
import com.taobao.weex.bridge.JSCallback;
import com.taobao.weex.bridge.SimpleJSCallback;
import com.taobao.weex.bridge.WXBridgeManager;
import com.taobao.weex.common.Constants;
import com.taobao.weex.common.WXModule;
import com.taobao.weex.el.parse.Operators;
import com.taobao.weex.ui.component.DCWXInput;
import com.taobao.weex.ui.component.WXImage;
import io.dcloud.application.DCLoudApplicationImpl;
import io.dcloud.common.DHInterface.IActivityHandler;
import io.dcloud.common.DHInterface.IApp;
import io.dcloud.common.DHInterface.ICallBack;
import io.dcloud.common.DHInterface.IWebview;
import io.dcloud.common.adapter.ui.AdaUniWebView;
import io.dcloud.common.adapter.ui.webview.WebResUtil;
import io.dcloud.common.adapter.ui.webview.WebViewFactory;
import io.dcloud.common.adapter.util.AndroidResources;
import io.dcloud.common.adapter.util.DeviceInfo;
import io.dcloud.common.adapter.util.EventActionInfo;
import io.dcloud.common.adapter.util.Logger;
import io.dcloud.common.adapter.util.PermissionUtil;
import io.dcloud.common.constant.AbsoluteConst;
import io.dcloud.common.constant.IntentConst;
import io.dcloud.common.ui.blur.DCBlurDraweeView;
import io.dcloud.common.util.BaseInfo;
import io.dcloud.common.util.IOUtil;
import io.dcloud.common.util.PdrUtil;
import io.dcloud.common.util.StringUtil;
import io.dcloud.common.util.ThreadPool;
import io.dcloud.common.util.language.LanguageUtil;
import io.dcloud.feature.internal.sdk.SDK;
import io.dcloud.feature.uniapp.bridge.UniJSCallback;
import io.dcloud.feature.weex.WXBaseWrapper;
import io.dcloud.feature.weex.WXServiceWrapper;
import io.dcloud.feature.weex.WeexInstanceMgr;
import io.dcloud.weex.WXDotDataUtil;
import io.src.dcloud.adapter.DCloudAdapterUtil;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
public class PlusModule extends WXModule {
    private String EVENTS_DOCUMENT_EXECUTE = "javascript:!function(){(window.__html5plus__&&__html5plus__.isReady?__html5plus__:navigator.plus&&navigator.plus.isReady?navigator.plus:window.plus)||window.__load__plus__&&window.__load__plus__();var _=document.createEvent(\"HTMLEvents\");_.initEvent(\"%s\",!1,!0),_.targetId=\"%s\",_.originId=\"%s\",_.data=%s,document.dispatchEvent(_)}();";
    public ArrayList<JsData> chs = new ArrayList<>();

    public class JsData {
        public String data;
        public String value;

        public JsData(String str, String str2) {
            this.data = str;
            this.value = str2;
        }
    }

    private void runChData() {
        if (this.chs.isEmpty()) {
            return;
        }
        ArrayList arrayList = new ArrayList();
        Iterator<JsData> it = this.chs.iterator();
        while (it.hasNext()) {
            JsData next = it.next();
            exec(next.data, next.value);
            arrayList.add(next);
        }
        this.chs.removeAll(arrayList);
    }

    @JSMethod(uiThread = true)
    public void evalJSFiles(String str, final JSCallback jSCallback) {
        final HashMap hashMap = new HashMap();
        if (str == null) {
            if (jSCallback != null) {
                hashMap.put("type", -1);
                hashMap.put("msg", DCLoudApplicationImpl.self().getContext().getString(R.string.dcloud_feature_weex_msg_param_empty));
                jSCallback.invoke(hashMap);
                return;
            }
            return;
        }
        final JSONArray parseArray = JSON.parseArray(str);
        if (parseArray != null) {
            ThreadPool.self().addThreadTask(new Runnable() {
                @Override
                public void run() {
                    IWebview findWebview = WeexInstanceMgr.self().findWebview(PlusModule.this.mWXSDKInstance);
                    if (findWebview == null) {
                        if (jSCallback != null) {
                            hashMap.put("type", -1);
                            hashMap.put("msg", DCLoudApplicationImpl.self().getContext().getString(R.string.dcloud_feature_weex_msg_page_destroyed));
                            jSCallback.invoke(hashMap);
                            return;
                        }
                        return;
                    }
                    byte obtainRunningAppMode = findWebview.obtainApp().obtainRunningAppMode();
                    String str2 = "";
                    for (int i2 = 0; i2 < parseArray.size(); i2++) {
                        String string = parseArray.getString(i2);
                        File file = new File(string);
                        InputStream inputStream = null;
                        if (file.exists()) {
                            try {
                                inputStream = new FileInputStream(file);
                            } catch (FileNotFoundException e2) {
                                e2.printStackTrace();
                            }
                        } else {
                            if (!string.startsWith("/storage") && obtainRunningAppMode == 1) {
                                string = findWebview.obtainApp().convert2AbsFullPath(findWebview.obtainFullUrl(), string);
                                if (string.startsWith(Operators.DIV)) {
                                    string = string.substring(1, string.length());
                                }
                            } else {
                                string = findWebview.obtainApp().convert2WebviewFullPath(findWebview.obtainFullUrl(), string);
                            }
                            inputStream = WebResUtil.getEncryptionInputStream(string, findWebview.obtainApp());
                        }
                        if (inputStream != null) {
                            try {
                                String str3 = new String(IOUtil.toString(inputStream));
                                if (!TextUtils.isEmpty(str3)) {
                                    str2 = str2 + str3;
                                }
                            } catch (Exception unused) {
                            }
                        } else if (jSCallback != null) {
                            hashMap.put("type", -1);
                            hashMap.put("msg", string + DCLoudApplicationImpl.self().getContext().getString(R.string.dcloud_feature_weex_msg_cannot_find_file_by_path));
                            jSCallback.invoke(hashMap);
                        }
                    }
                    if (TextUtils.isEmpty(str2)) {
                        return;
                    }
                    WXBridgeManager.getInstance().syncExecJsOnInstanceWithResult(PlusModule.this.mWXSDKInstance.getInstanceId(), str2, -1);
                    if (jSCallback != null) {
                        hashMap.put("type", 1);
                        jSCallback.invoke(hashMap);
                    }
                }
            }, true);
        } else if (jSCallback != null) {
            hashMap.put("type", -1);
            hashMap.put("msg", DCLoudApplicationImpl.self().getContext().getString(R.string.dcloud_feature_weex_msg_param_invalid));
            jSCallback.invoke(hashMap);
        }
    }

    @JSMethod(uiThread = true)
    public void exec(String str, String str2) {
        WXSDKInstance wXSDKInstance = this.mWXSDKInstance;
        if (wXSDKInstance == null || !wXSDKInstance.isDestroy()) {
            IWebview findWebview = WeexInstanceMgr.self().findWebview(this.mWXSDKInstance);
            if (findWebview instanceof AdaUniWebView) {
                ((AdaUniWebView) findWebview).prompt(str, str2);
            }
        }
    }

    @JSMethod(uiThread = false)
    public String execSync(String str, String str2) {
        WXSDKInstance wXSDKInstance = this.mWXSDKInstance;
        if (wXSDKInstance == null || !wXSDKInstance.isDestroy()) {
            IWebview findWebview = WeexInstanceMgr.self().findWebview(this.mWXSDKInstance);
            return findWebview instanceof AdaUniWebView ? ((AdaUniWebView) findWebview).prompt(str, str2) : "";
        }
        return "";
    }

    @JSMethod(uiThread = false)
    public JSONObject getAppAuthorizeSetting() {
        Context context = this.mWXSDKInstance.getContext();
        JSONObject jSONObject = new JSONObject();
        boolean checkPermissions = PermissionUtil.checkPermissions(context, new String[]{"android.permission.CAMERA"});
        String str = IApp.AUTHORITY_AUTHORIZED;
        Object obj = checkPermissions ? IApp.AUTHORITY_AUTHORIZED : IApp.AUTHORITY_DENIED;
        String str2 = "config error";
        if (!checkPermissions && !PermissionUtil.hasDefinedInManifest(context, "android.permission.CAMERA")) {
            obj = "config error";
        }
        jSONObject.put("cameraAuthorized", obj);
        boolean checkPermissions2 = PermissionUtil.checkPermissions(context, new String[]{"android.permission.ACCESS_COARSE_LOCATION"});
        Object obj2 = checkPermissions2 ? IApp.AUTHORITY_AUTHORIZED : IApp.AUTHORITY_DENIED;
        if (!checkPermissions2 && !PermissionUtil.hasDefinedInManifest(context, "android.permission.ACCESS_COARSE_LOCATION")) {
            obj2 = "config error";
        }
        jSONObject.put("locationAuthorized", obj2);
        boolean checkPermissions3 = PermissionUtil.checkPermissions(context, new String[]{"android.permission.ACCESS_FINE_LOCATION"});
        String str3 = checkPermissions2 ? "reduced" : "unsupported";
        if (checkPermissions2 && checkPermissions3) {
            str3 = "full";
        }
        jSONObject.put("locationAccuracy", (Object) str3);
        boolean checkPermissions4 = PermissionUtil.checkPermissions(context, new String[]{"android.permission.RECORD_AUDIO"});
        String str4 = checkPermissions4 ? IApp.AUTHORITY_AUTHORIZED : IApp.AUTHORITY_DENIED;
        if (checkPermissions4 || PermissionUtil.hasDefinedInManifest(context, "android.permission.RECORD_AUDIO")) {
            str2 = str4;
        }
        jSONObject.put("microphoneAuthorized", (Object) str2);
        if (!NotificationManagerCompat.from(context).areNotificationsEnabled()) {
            str = IApp.AUTHORITY_DENIED;
        }
        jSONObject.put("notificationAuthorized", (Object) str);
        jSONObject.put("albumAuthorized", (Object) Constants.Name.UNDEFINED);
        jSONObject.put("bluetoothAuthorized", (Object) Constants.Name.UNDEFINED);
        jSONObject.put("locationReducedAccuracy", (Object) Constants.Name.UNDEFINED);
        jSONObject.put("notificationAlertAuthorized", (Object) Constants.Name.UNDEFINED);
        jSONObject.put("notificationBadgeAuthorized", (Object) Constants.Name.UNDEFINED);
        jSONObject.put("notificationSoundAuthorized", (Object) Constants.Name.UNDEFINED);
        return jSONObject;
    }

    @JSMethod(uiThread = false)
    public int getAppState() {
        IActivityHandler iActivityHandler;
        IWebview findWebview = WeexInstanceMgr.self().findWebview(this.mWXSDKInstance);
        if (findWebview == null || (iActivityHandler = DCloudAdapterUtil.getIActivityHandler(findWebview.getActivity())) == null) {
            return 0;
        }
        return iActivityHandler.getActivityState();
    }

    @JSMethod(uiThread = false)
    public Object getConfigInfo() {
        IWebview findWebview = WeexInstanceMgr.self().findWebview(this.mWXSDKInstance);
        if (findWebview instanceof AdaUniWebView) {
            return ((AdaUniWebView) findWebview).getConfigInfo();
        }
        return null;
    }

    @JSMethod(uiThread = false)
    public JSONObject getDotData() {
        JSONObject deviceInfo = WXDotDataUtil.getDeviceInfo();
        if (BaseInfo.SyncDebug) {
            deviceInfo.put("maxMemory", (Object) ((Runtime.getRuntime().maxMemory() / 1048576) + "M"));
            deviceInfo.put("totalMemory", (Object) ((Runtime.getRuntime().totalMemory() / 1048576) + "M"));
            deviceInfo.put("appRuningTitme", (Object) Long.valueOf(BaseInfo.splashCloseTime - BaseInfo.startTime));
        }
        return deviceInfo;
    }

    @JSMethod
    public void getHostInfo(JSCallback jSCallback) {
        JSONObject parseObject;
        if (jSCallback == null) {
            return;
        }
        JSONObject jSONObject = new JSONObject();
        IWebview findWebview = WeexInstanceMgr.self().findWebview(this.mWXSDKInstance);
        if (findWebview != null && findWebview.obtainApp() != null) {
            String obtainAppInfo = findWebview.obtainApp().obtainAppInfo();
            if (PdrUtil.isEmpty(obtainAppInfo)) {
                jSCallback.invoke(jSONObject);
                return;
            }
            if (PdrUtil.isUniMPHostForUniApp()) {
                if (SDK.isUniMP) {
                    if (!PdrUtil.isEmpty(SDK.mHostInfo) && (parseObject = JSON.parseObject(SDK.mHostInfo)) != null) {
                        jSONObject.putAll(parseObject);
                    }
                } else {
                    JSONObject parseObject2 = JSON.parseObject(obtainAppInfo);
                    if (parseObject2 != null) {
                        jSONObject.putAll(parseObject2);
                    }
                }
            }
            jSONObject.put("nativeName", (Object) AndroidResources.appName);
            jSONObject.put("nativeAppid", (Object) AndroidResources.packageName);
            jSONObject.put("nativeVersionName", (Object) AndroidResources.versionName);
            jSONObject.put("nativeVersionCode", (Object) Integer.valueOf(AndroidResources.versionCode));
            jSCallback.invoke(jSONObject);
            return;
        }
        jSCallback.invoke(jSONObject);
    }

    @JSMethod(uiThread = false)
    @RequiresApi(api = 21)
    public String getLanguage() {
        WXSDKInstance wXSDKInstance = this.mWXSDKInstance;
        return (wXSDKInstance == null || wXSDKInstance.getContext() == null) ? "" : LanguageUtil.getCurrentLocaleLanguage(this.mWXSDKInstance.getContext());
    }

    @JSMethod(uiThread = false)
    public Object getRedirectInfo() {
        JSONObject parseObject;
        IWebview findWebview = WeexInstanceMgr.self().findWebview(this.mWXSDKInstance);
        JSONObject jSONObject = null;
        if (findWebview != null) {
            if (Boolean.valueOf(findWebview.obtainApp().obtainConfigProperty(IApp.ConfigProperty.UNI_RESTART_TO_DIRECT)).booleanValue() && (parseObject = JSON.parseObject(findWebview.obtainApp().obtainConfigProperty(AbsoluteConst.JSON_KEY_DEBUG_REFRESH))) != null && parseObject.containsKey("arguments")) {
                try {
                    jSONObject = JSON.parseObject(parseObject.getString("arguments"));
                } catch (Exception e2) {
                    e2.printStackTrace();
                }
                findWebview.obtainApp().setConfigProperty(AbsoluteConst.JSON_KEY_DEBUG_REFRESH, "");
            }
            JSONObject parseObject2 = JSON.parseObject(findWebview.obtainApp().obtainConfigProperty(IntentConst.UNIMP_RUN_EXTRA_INFO));
            if (parseObject2 != null) {
                if (jSONObject == null) {
                    jSONObject = new JSONObject();
                }
                jSONObject.putAll(parseObject2);
                findWebview.obtainApp().setConfigProperty(IntentConst.UNIMP_RUN_EXTRA_INFO, "");
            }
        }
        return jSONObject;
    }

    @JSMethod(uiThread = true)
    public void getSystemInfo(UniJSCallback uniJSCallback) {
        uniJSCallback.invoke(getSystemInfoSync());
    }

    @JSMethod(uiThread = false)
    public JSONObject getSystemInfoSync() {
        JSONObject jSONObject = new JSONObject();
        try {
            IWebview findWebview = WeexInstanceMgr.self().findWebview(this.mWXSDKInstance);
            if (findWebview != null && findWebview.obtainApp() != null) {
                jSONObject = JSON.parseObject(findWebview.obtainApp().getSystemInfo());
                boolean booleanValue = DeviceInfo.isSystemNightMode(findWebview.getActivity()).booleanValue();
                String str = DCBlurDraweeView.DARK;
                jSONObject.put("osTheme", booleanValue ? DCBlurDraweeView.DARK : DCBlurDraweeView.LIGHT);
                jSONObject.put("ua", (Object) findWebview.getWebviewProperty("User-Agent"));
                jSONObject.put("browserVersion", (Object) WebViewFactory.getWebViewUserAgentVersion(findWebview.getContext()));
                jSONObject.put("deviceOrientation", (Object) (findWebview.getActivity().getResources().getConfiguration().orientation == 2 ? "landscape" : "portrait"));
                if (SDK.isUniMP) {
                    jSONObject.put("hostPackageName", (Object) findWebview.getContext().getPackageName());
                    jSONObject.put("hostVersion", (Object) AndroidResources.versionName);
                    jSONObject.put("hostName", (Object) AndroidResources.appName);
                    if (!SDK.hostAppThemeDark) {
                        str = DCBlurDraweeView.LIGHT;
                    }
                    jSONObject.put("hostTheme", (Object) str);
                    if (PdrUtil.isUniMPHostForUniApp()) {
                        jSONObject.put("hostLanguage", (Object) LanguageUtil.getDeviceDefLocalLanguage());
                        boolean z = SDK.isUniMP;
                    } else {
                        jSONObject.put("hostLanguage", (Object) LanguageUtil.getDeviceDefLocalLanguage());
                    }
                }
            }
        } catch (Exception unused) {
        }
        return jSONObject;
    }

    @JSMethod(uiThread = false)
    public JSONObject getSystemSetting() {
        Context context = this.mWXSDKInstance.getContext();
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("bluetoothEnabled", (Object) Boolean.valueOf(DeviceInfo.blueToothEnable(context)));
        } catch (Exception e2) {
            e2.printStackTrace();
            jSONObject.put("bluetoothError", (Object) "Missing permissions required by BluetoothAdapter.isEnabled: android.permission.BLUETOOTH");
        }
        jSONObject.put("locationEnabled", (Object) Boolean.valueOf(DeviceInfo.locationEnable(context)));
        jSONObject.put("wifiEnabled", (Object) Boolean.valueOf(DeviceInfo.wifiEnable(context)));
        jSONObject.put("deviceOrientation", (Object) DeviceInfo.deviceOrientation(context));
        return jSONObject;
    }

    @JSMethod(uiThread = false)
    public String getValue(String str) {
        return ((DCWXInput) WXSDKManager.getInstance().getWXRenderManager().getWXComponent(this.mWXSDKInstance.getInstanceId(), str)).getValue();
    }

    @JSMethod(uiThread = true)
    public void log(String str) {
        Logger.d("console", "[LOG] " + str);
    }

    @JSMethod(uiThread = false)
    public void openAppAuthorizeSetting(JSCallback jSCallback) {
        JSONObject jSONObject = new JSONObject();
        try {
            Context context = this.mWXSDKInstance.getContext();
            Intent intent = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS");
            intent.setData(Uri.fromParts("package", context.getPackageName(), null));
            context.startActivity(intent);
            jSONObject.put("type", (Object) WXImage.SUCCEED);
            jSONObject.put("code", (Object) 0);
        } catch (Exception e2) {
            e2.printStackTrace();
            jSONObject.put("type", (Object) Constants.Event.FAIL);
        }
        jSCallback.invoke(jSONObject);
    }

    @JSMethod
    public void postMessage(String str, String str2) {
        WXServiceWrapper findWXServiceWrapper;
        IWebview findWebview = WeexInstanceMgr.self().findWebview(this.mWXSDKInstance);
        String str3 = this.EVENTS_DOCUMENT_EXECUTE;
        Object[] objArr = new Object[4];
        objArr[0] = "uniNViewMessage";
        objArr[1] = "";
        objArr[2] = findWebview != null ? findWebview.obtainFrameId() : "";
        objArr[3] = str;
        String format = StringUtil.format(str3, objArr);
        if (findWebview == null && (findWXServiceWrapper = WeexInstanceMgr.self().findWXServiceWrapper(this.mWXSDKInstance)) != null && !BaseInfo.isWeexUniJs(findWXServiceWrapper.obtanApp())) {
            findWXServiceWrapper.findWebViewToLoadUrL(format, str2);
        } else if (findWebview != null) {
            IWebview findWebview2 = PdrUtil.isEmpty(str2) ? findWebview : WeexInstanceMgr.self().findWebview(findWebview, findWebview.obtainApp(), findWebview.obtainApp().obtainAppId(), str2);
            if (findWebview2 != null) {
                if (findWebview2 instanceof AdaUniWebView) {
                    HashMap hashMap = new HashMap();
                    hashMap.put("targetId", str2);
                    hashMap.put("originId", findWebview.obtainFrameId());
                    try {
                        hashMap.put("data", JSON.parseObject(str));
                    } catch (Exception unused) {
                        hashMap.put("data", str);
                    }
                    ((AdaUniWebView) findWebview2).fireEvent(new EventActionInfo("uniNViewMessage", hashMap));
                    return;
                }
                findWebview2.loadUrl(format);
            }
        }
    }

    @JSMethod
    public void preloadReady(String str) {
        ICallBack preUniMPCallBack = WeexInstanceMgr.self().getPreUniMPCallBack(str);
        if (preUniMPCallBack != null) {
            preUniMPCallBack.onCallBack(1, str);
        }
    }

    @JSMethod(uiThread = false)
    public JSONObject pushDebugData(Object obj) {
        JSONObject jSONObject = new JSONObject();
        jSONObject.put("data", obj);
        return jSONObject;
    }

    @JSMethod(uiThread = true)
    public void sendNativeEvent(String str, Object obj, JSCallback jSCallback) {
        IWebview findWebview = WeexInstanceMgr.self().findWebview(this.mWXSDKInstance);
        if (findWebview == null || findWebview.getActivity() == null || !(findWebview.getActivity() instanceof IActivityHandler)) {
            return;
        }
        Bundle bundle = new Bundle();
        bundle.putString("event", str);
        bundle.putString("dataType", "String");
        if (obj instanceof String) {
            bundle.putString("data", String.valueOf(obj));
        } else if (obj instanceof JSON) {
            bundle.putString("data", ((JSON) obj).toJSONString());
            bundle.putString("dataType", "JSON");
        }
        if (jSCallback instanceof SimpleJSCallback) {
            bundle.putString(SDK.UNIMP_EVENT_CALL_INSTANCEID, this.mWXSDKInstance.getInstanceId());
            bundle.putString(SDK.UNIMP_EVENT_CALLBACKID, ((SimpleJSCallback) jSCallback).getCallbackId());
        }
        ((IActivityHandler) findWebview.getActivity()).callBack(SDK.UNIMP_JS_TO_NATIVE, bundle);
    }

    @JSMethod(uiThread = false)
    public void setDefaultFontSize(String str) {
        int intValue = Integer.valueOf(str).intValue();
        if (intValue > 0) {
            this.mWXSDKInstance.setDefaultFontSize(intValue);
        }
    }

    @JSMethod(uiThread = false)
    @RequiresApi(api = 21)
    public void setLanguage(String str) {
        WXSDKInstance wXSDKInstance = this.mWXSDKInstance;
        if (wXSDKInstance == null || wXSDKInstance.getContext() == null || SDK.isUniMPSDK() || this.mWXSDKInstance.isDestroy() || Build.VERSION.SDK_INT < 21) {
            return;
        }
        if ("auto".equalsIgnoreCase(str)) {
            str = "";
        }
        LanguageUtil.updateLanguage(this.mWXSDKInstance.getContext(), str);
        LocalBroadcastManager.getInstance(this.mWXSDKInstance.getContext()).sendBroadcast(new Intent(LanguageUtil.LanguageBroadCastIntent));
    }

    @JSMethod(uiThread = true)
    public void uniReady() {
        WXBaseWrapper findWXBaseWrapper = WeexInstanceMgr.self().findWXBaseWrapper(this.mWXSDKInstance);
        if (findWXBaseWrapper != null) {
            findWXBaseWrapper.onReady();
        }
    }
}