om
om
  • 发布:2021-12-13 17:03
  • 更新:2021-12-14 10:34
  • 阅读:349

【报Bug】华为MatePad Pro 12.6英寸 HarmonyOS 2.0.0 plus.navigator.isSimulator() 返回true

分类:HTML5+

产品分类: HTML5+

HBuilderX版本号: 3.2.16

手机系统: Android

手机系统版本号: Android 10

手机厂商: 华为

手机机型: MatePad Pro 12.6英寸 Harmony 2.0.0

打包方式: 云端

示例代码:
<!DOCTYPE html>  
<html>  
    <head>  
        <meta charset="UTF-8" />  
        <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />  
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />  
        <title></title>  
    </head>  
    <body>  
        <div style="margin-top: 120px">  
            <div style="text-align: center"><img width="120px" height="120px" src="img/logo.png" /></div>  
            <div style="margin-top: 30px; font-size: 16px; text-align: center">Loading...</div>  
        </div>  
        <script type="text/javascript">  
            var plusReady = function (callback) {  
                if (window.plus) {  
                    return callback(window.plus);  
                }  
                document.addEventListener(  
                    'plusready',  
                    function () {  
                        callback(window.plus);  
                    },  
                    false  
                );  
            };  

            var quitApp = function () {  
                plusReady(function (plus) {  
                    var IS_IOS = plus.os.name === 'iOS';  
                    if (IS_IOS) {  
                        plus.ios.import('UIApplication').sharedApplication().performSelector('exit');  
                    } else {  
                        plus.runtime.quit();  
                    }  
                });  
            };  

            var isRoot = function () {  
                plusReady(function (plus) {  
                    var IS_IOS = plus.os.name === 'iOS';  
                    if (IS_IOS) {  
                        return plus.navigator.isRoot();  
                    } else {  
                        return isAndroidRoot();  
                    }  

                    function isAndroidRoot() {  
                        if (!IS_IOS) {  
                            return false;  
                        }  
                        var paths = [  
                            '/sbin/su',  
                            '/system/bin/su',  
                            '/system/xbin/su',  
                            '/data/local/xbin/su',  
                            '/data/local/bin/su',  
                            '/system/sd/xbin/su',  
                            '/system/bin/failsafe/su',  
                            '/data/local/su'  
                        ];  
                        var File = plus.android.importClass('java.io.File');  
                        for (var i = 0, l = paths.length; i < l; i++) {  
                            var path = paths[i];  
                            var fd = new File(path);  
                            if (fd.exists()) {  
                                return true;  
                            }  
                        }  
                        return false;  
                    }  
                });  
            };  
        </script>  
        <script type="text/javascript">  
            plusReady(function (plus) {  
                plus.screen.lockOrientation('portrait-primary');  
                var IS_IOS = plus.os.name === 'iOS';  

                if (plus.navigator.isSimulator()) {  
                    return plus.nativeUI.confirm(  
                        '禁止在模拟器中运行!',  
                        function (e) {  
                            console.log(e.index);  
                            quitApp();  
                        },  
                        {  
                            buttons: ['好吧']  
                        }  
                    );  
                }  

                if (isRoot()) {  
                    var notice = IS_IOS ? '您的设备已越狱,请注意防范风险。' : '您的设备已被ROOT,请注意防范风险。';  
                    plus.nativeUI.confirm(notice, function () {}, {  
                        title: '风险提示',  
                        buttons: ['知道了']  
                    });  
                }  
            });  
        </script>  
    </body>  
</html>  

操作步骤:

加载如上html

预期结果:

不弹框

实际结果:

弹框: 禁止在模拟器中运行

bug描述:

华为MatePad Pro 12.6英寸 HarmonyOS 2.0.0 plus.navigator.isSimulator() 返回true

2021-12-13 17:03 负责人:无 分享
已邀请:
FullStack

FullStack - 【插件开发】【专治疑难杂症】【ios上架、马甲包、白包、过审、已成功上架过几百个】【多款插件已上架:https://ext.dcloud.net.cn/publisher?id=22130】【非诚勿扰】QQ:543610866

我手机Harmony 2.0.0系统, 没有这个情况
更新HBX3.3.0 版本看看

该问题目前已经被锁定, 无法添加新回复