火跃
火跃
  • 发布:2020-10-13 13:57
  • 更新:2020-10-26 10:58
  • 阅读:828

【报Bug】setScreenBrightness出现闪退,getScreenBrightness获取值大于1

分类:HTML5+

产品分类: HTML5+

HBuilderX版本号: 2.8.13

手机系统: Android

手机系统版本号: Android 10

手机厂商: 小米

手机机型: Redmi K20 Pro

打包方式: 云端

示例代码:

uni.getScreenBrightness({  
  success: function(res) {  
  bright=parseFloat(res.value);  
console.log(bright)  
 }  
});  

uni.setScreenBrightness({  
value: bright,  
success: function(res) {  
console.log('设置屏幕亮度成功');  
}  
});  

操作步骤:

uni.getScreenBrightness({  
  success: function(res) {  
  bright=parseFloat(res.value);  
console.log(bright)  
 }  
});  

uni.setScreenBrightness({  
value: 0.5,  
success: function(res) {  
console.log('设置屏幕亮度成功');  
}  
});  

预期结果:

bright应该小于1
亮度设置成功

实际结果:

bright应该大于1
app闪退

bug描述:

使用uni.getScreenBrightness()获取的值大于1

使用uni.setScreenBrightness()设置亮度时出现
App Hide
App Show

2020-10-13 13:57 负责人:DCloud_Android_DQQ 分享
已邀请:
DCloud_Android_DQQ

DCloud_Android_DQQ

1 getScreenBrightness获取值大于1 。 问题已确认。小米手机 rom,数据异常。已处理。稍后版本更新。
2 设置亮度崩溃。提供一下 崩溃日志和系统版本。 以及复现代码

  • 火跃 (作者)

            handletouchmove: function(event) {  
    this.isSeek = true;
    console.log('handletouchmove', event.changedTouches[0])
    // if (this.flag !== 0) {
    // return;
    // }
    let currentX = event.changedTouches[0].pageX;
    let currentY = event.changedTouches[0].pageY;
    let tx = currentX - this.lastX;
    let ty = currentY - this.lastY;
    let text = '';
    this.mindex = -1;
    //左右方向滑动
    if (Math.abs(tx) > Math.abs(ty)) {
    var totalWidth=this.isFullScreen ? this.systemInfo.screenHeight : this.systemInfo.screenWidth
    this.isSeek = true;
    var changValue = Math.round(this.maxProgress * Math.abs(tx) / totalWidth);
    if(changValue>0.1){
    console.log('changValue:' + changValue)
    this.flag = 'time';
    if (tx < 0) {
    this.playedProgress -= changValue;
    this.videoPlayedTime = this.numToSecond(this.playedProgress);
    } else if (tx > 0) {
    this.playedProgress += changValue;
    this.videoPlayedTime = this.numToSecond(this.playedProgress);
    }
    }
    }else {//上下方向滑动
    if(this.isFullScreen){
    var totalWidth=this.systemInfo.screenWidth
    this.flag = currentX < totalWidth/2 ? 'bright' : 'volume';
    var changValue = ty / totalWidth;
    if(Math.abs(changValue)>0.1){
    changValue=parseInt(-changValue*10000)/10000;
    if(this.flag == 'bright'){
    if(_self.bright==0){
    uni.getScreenBrightness({
    success: function(res) {
    _self.bright=parseFloat(res.value);
    }
    });
    if(_self.bright>1){
    _self.bright=0.5;
    }
    }
    console.log('屏幕亮度值:',_self.bright,changValue);
    _self.bright=Math.min(1,Math.max(0,parseFloat(_self.bright+changValue)));
    uni.setScreenBrightness({
    value: _self.bright,
    success: function(res) {
    console.log('设置屏幕亮度成功');
    },
    fail: function(res) {
    console.log('设置屏幕亮度失败:', res);
    }
    });
    }else{
    var volume=Math.min(1,Math.max(0,parseFloat(plus.device.getVolume()+changValue)));
    console.log('声音值:',plus.device.getVolume(),volume,changValue);
    plus.device.setVolume(volume);
    }
    }
    }
    }
    //将当前坐标进行保存以进行下一次计算
    if(Math.abs(changValue)>0.1){
    this.lastX = currentX;
    this.lastY = currentY;
    }
    },
    handletouchstart: function(event) {
    console.log('handletouchstart', event)
    this.startX = this.lastX = event.changedTouches[0].pageX;
    this.startY = this.lastY = event.changedTouches[0].pageY;
    },

    2020-10-13 15:29

  • 火跃 (作者)

    2020-10-13 13:42:23.394 [INFO:] node "D:/Program Files/HBuilderX/plugins/node/node.exe"

    2020-10-13 13:42:23.395 [INFO:] args ("--max-old-space-size=2048", "D:/Program Files/HBuilderX/plugins/uniapp-cli/bin/uniapp-cli.js")

    2020-10-13 13:44:24.463 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 13:44:45.992 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 13:44:48.823 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 13:47:52.824 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 13:47:53.983 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 13:48:21.591 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 13:48:23.590 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 13:49:28.951 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 13:49:30.075 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 13:51:36.811 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 13:51:39.483 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 13:51:41.184 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 13:57:24.003 [INFO:] [Update] do check update...

    2020-10-13 13:57:25.019 [INFO:] indexFileURL: "http://update.dcloud.net.cn/hbuilderx/alpha/win32/update/index.json?tmp=50245019"

    2020-10-13 13:57:25.538 [INFO:] [Update] No update.

    2020-10-13 13:57:25.766 [WARNING:] QLayout: Attempting to add QLayout "" to MsgItemWidget "MsgItem", which already has a layout

    2020-10-13 13:58:33.732 [WARNING:] QProcess: Destroyed while process ("D:\Program Files\HBuilderX\plugins\jre\bin\java.exe") is still running.

    2020-10-13 13:58:34.112 [WARNING:] uniapp compiled errorOccurred====== "进程已崩溃"

    2020-10-13 14:05:32.256 [WARNING:] server json is error: "illegal value"

    2020-10-13 15:14:46.772 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:14:47.280 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:14:47.794 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:14:55.262 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:14:56.171 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:14:56.809 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:14:57.326 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:15:00.669 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:15:04.614 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:15:05.332 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:15:07.716 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:15:08.576 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:15:15.481 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:15:43.815 [INFO:] [RunWeApp] appid: "UNI95000D0" mp_appid: "" name: "cgjoy视频点播"

    2020-10-13 15:15:45.738 [INFO:] node "D:/Program Files/HBuilderX/plugins/node/node.exe"

    2020-10-13 15:15:45.739 [INFO:] args ("--max-old-space-size=2048", "D:/Program Files/HBuilderX/plugins/uniapp-cli/bin/uniapp-cli.js")

    2020-10-13 15:16:34.638 [WARNING:] QPainter::begin: Paint device returned engine == 0, type: 2

    2020-10-13 15:16:34.639 [WARNING:] QPainter::setPen: Painter not active

    2020-10-13 15:16:34.640 [WARNING:] QPainter::setBrush: Painter not active

    2020-10-13 15:17:38.592 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:17:39.121 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:17:43.138 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:17:47.420 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:17:47.936 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:17:51.949 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:18:56.715 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:19:01.013 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:19:14.200 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:19:18.278 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:19:18.796 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:19:31.177 [WARNING:] uniapp compiled errorOccurred====== "进程已崩溃"

    2020-10-13 15:19:32.815 [INFO:] node "D:/Program Files/HBuilderX/plugins/node/node.exe"

    2020-10-13 15:19:32.816 [INFO:] args ("--max-old-space-size=2048", "D:/Program Files/HBuilderX/plugins/uniapp-cli/bin/uniapp-cli.js")

    2020-10-13 15:19:41.801 [INFO:] node "D:/Program Files/HBuilderX/plugins/node/node.exe"

    2020-10-13 15:19:41.805 [INFO:] args ("--max-old-space-size=2048", "D:/Program Files/HBuilderX/plugins/uniapp-cli/bin/uniapp-cli.js")

    2020-10-13 15:20:52.060 [WARNING:] uniapp compiled errorOccurred====== "进程已崩溃"

    2020-10-13 15:20:53.390 [INFO:] [RunWeApp] appid: "UNI95000D0" mp_appid: "" name: "cgjoy视频点播"

    2020-10-13 15:20:55.041 [INFO:] node "D:/Program Files/HBuilderX/plugins/node/node.exe"

    2020-10-13 15:20:55.042 [INFO:] args ("--max-old-space-size=2048", "D:/Program Files/HBuilderX/plugins/uniapp-cli/bin/uniapp-cli.js")

    2020-10-13 15:21:57 [LanguageServerProcess] source dir:C:\Users\huoyue\Documents\HBuilderProjects\Polyv云点播插件示例\unpackage\dist\dev\app-plus/

    2020-10-13 15:27:23.842 [WARNING:] uniapp compiled errorOccurred====== "进程已崩溃"

    2020-10-13 15:27:36.309 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:27:40.262 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:27:42.608 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:27:45.621 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:27:46.528 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:27:47.824 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:27:48.482 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:27:49.233 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:27:50.858 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:27:52.996 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:27:53.873 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:27:57.684 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:27:58.201 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:28:03.059 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:28:04.013 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:28:06.121 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:28:12.420 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:28:19.495 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:28:21.838 [WARNING:] QPainter::begin: Paint device returned engine == 0, type: 2

    2020-10-13 15:28:21.839 [WARNING:] QPainter::setPen: Painter not active

    2020-10-13 15:28:21.840 [WARNING:] QPainter::setBrush: Painter not active

    2020-10-13 15:28:25.474 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:28:28.184 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:28:28.762 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:28:31.904 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:28:33.083 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:28:34.417 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:28:36.232 [WARNING:] Request Timeout( 200 )!!! when: "textDocument/openHelp"

    2020-10-13 15:30

  • 火跃 (作者)

    功能就是一个视频播放器,左边上下滑动调节亮度,右边上下滑动调节声音,声音正常,亮度闪退

    2020-10-13 15:33

[已删除]

[已删除]

承接H5、小程序、APP、PC端网站等外包,主要技术栈为vue、uni-app,有意请加微信:13070273424(我是前端,有单子的服务端可找我合作,或者完全丢给我,我这也有一个小团队)

DCloud_Android_DQQ

DCloud_Android_DQQ

hbuilder x 2.9.5 小米系列手机获取亮度 异常的问题已修复

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