浏览代码

A133分机增加自动熄屏设置

weizhengliang 1 月之前
父节点
当前提交
7dd865cbb0

+ 21 - 2
android_bed/src/main/java/com/wdkl/app/ncs/callingbed/activity/CallingbedActivity.kt

@@ -1,5 +1,6 @@
 package com.wdkl.app.ncs.callingbed.activity
 
+import android.app.zhyl.ZhylManager
 import android.bluetooth.BluetoothGatt
 import android.bluetooth.BluetoothGattCharacteristic
 import android.content.*
@@ -350,8 +351,8 @@ class CallingbedActivity :BaseActivity<BedCallingbedActivityPresenter, Callingbe
         //禁止下拉状态栏
         Utils.setStatusBarDisable(activity, Utils.STATUS_BAR_DISABLE_EXPAND)
 
-        //保持屏幕常亮
-        //AppTool.Setting.setScreenOffTimeOut(applicationContext, 35)
+        //默认保持屏幕常亮
+        AppTool.Setting.setScreenOffTimeOut(applicationContext, Int.MAX_VALUE)
 
         presenter.loadServerInfo()
 
@@ -3036,6 +3037,16 @@ class CallingbedActivity :BaseActivity<BedCallingbedActivityPresenter, Callingbe
                 AppTool.Time.delay(2000) {
                     SerialPortHelper.setSosLight("0")
                 }
+
+                if (Build.PRODUCT == "ceres_b3") {
+                    //白天设置屏幕常亮并亮屏
+                    AppTool.Setting.setScreenOffTimeOut(applicationContext, Int.MAX_VALUE)
+                    try {
+                        ZhylManager.getInstance(BaseApplication.appContext).disp_setScreenWakeUp()
+                    } catch (e: Exception) {
+                        e.printStackTrace()
+                    }
+                }
             }
             Constant.day_state = 0
         } else {
@@ -3052,6 +3063,14 @@ class CallingbedActivity :BaseActivity<BedCallingbedActivityPresenter, Callingbe
                 AppTool.Time.delay(2000) {
                     SerialPortHelper.setSosLight("1")
                 }
+
+                if (Build.PRODUCT == "ceres_b3") {
+                    //夜晚自动熄屏
+                    AppTool.Setting.setScreenOffTimeOut(
+                        applicationContext,
+                        SettingConfig.getSleepTime(BaseApplication.appContext) * 60
+                    )
+                }
             }
             Constant.day_state = 1
         }

+ 2 - 1
common/src/main/code/com/wdkl/ncs/android/lib/base/BaseActivity.kt

@@ -101,7 +101,8 @@ abstract class BaseActivity<PresenterType : BaseContract.BasePresenter, DataBind
         super.onCreate(savedInstanceState)
         requestWindowFeature(Window.FEATURE_NO_TITLE)
 
-        if (BuildConfig.device_type.equals("4") && BuildConfig.isandroid_bed.toBoolean()) {
+        if (BuildConfig.isandroid_bed.toBoolean()
+            && (BuildConfig.device_type.equals("4") || Build.PRODUCT == "ceres_b3")) {
             //系统决定休眠时间
             window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN or
                     WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or

+ 11 - 3
common/src/main/code/com/wdkl/ncs/android/lib/utils/AppTool.kt

@@ -288,10 +288,18 @@ object AppTool {
         fun setScreenOffTimeOut(context: Context, timeout: Int) {
             try {
                 if (!"rk3128".equals(Build.MODEL) && !"rk3368".equals(Build.MODEL)) {
-                    Settings.System.putInt(
+                    if (timeout < Int.MAX_VALUE) {
+                        Settings.System.putInt(
                             context.contentResolver,
-                            Settings.System.SCREEN_OFF_TIMEOUT, timeout*1000
-                    )
+                            Settings.System.SCREEN_OFF_TIMEOUT, timeout * 1000
+                        )
+                    } else {
+                        //永不休眠
+                        Settings.System.putInt(
+                            context.contentResolver,
+                            Settings.System.SCREEN_OFF_TIMEOUT, Int.MAX_VALUE
+                        )
+                    }
                 }
             } catch (e: java.lang.Exception) {
                 e.printStackTrace()