add mix rules.
authorkfl_614 <kfl_614@163.com>
Wed, 16 Dec 2020 08:24:17 +0000 (16:24 +0800)
committerkfl_614 <kfl_614@163.com>
Wed, 16 Dec 2020 08:24:17 +0000 (16:24 +0800)
app/proguard-rules.pro
app/release/output-metadata.json
app/src/main/java/com/ic/temperature/MainActivity.kt
app/src/main/java/com/ic/temperature/utils/IcLog.kt
app/src/main/java/com/ic/temperature/utils/ServiceUtil.kt
app/src/main/java/com/ic/temperature/viewmodel/TemperatureViewModel.kt
app/src/main/res/values/strings.xml
app/version_code.properties

index 481bb43..e314ca4 100644 (file)
 
 # If you keep the line number information, uncomment this to
 # hide the original source file name.
-#-renamesourcefileattribute SourceFile
\ No newline at end of file
+#-renamesourcefileattribute SourceFile
+
+-keep class com.ic.** { *; }
+-keep class com.android.** { *; }
+-keep class android.** { *; }
+
+-dontwarn android.**
\ No newline at end of file
index abc08f9..3ecfb38 100644 (file)
@@ -10,9 +10,9 @@
     {
       "type": "SINGLE",
       "filters": [],
-      "versionCode": 2,
-      "versionName": "202012081519",
-      "outputFile": "ICL02Temperature_V2_202012081519_release.apk"
+      "versionCode": 8,
+      "versionName": "202012161145",
+      "outputFile": "ICL02Temperature_V8_202012161145_release.apk"
     }
   ]
 }
\ No newline at end of file
index 0c0e822..44131ed 100644 (file)
@@ -25,6 +25,8 @@ import com.ic.temperature.viewmodel.TemperatureViewModel
  * public static String KEY_ANTI_EVENT="eventID";
  */
 class MainActivity : AppCompatActivity() {
+
+
     private val viewModel by lazy {
         ViewModelProvider(
             this,
@@ -45,17 +47,19 @@ class MainActivity : AppCompatActivity() {
 
     private var wakeLock: PowerManager.WakeLock? = null
 
-
     private fun initWakeLock() {
+        println("init wake lock...")
         val powerManager: PowerManager = getSystemService(Context.POWER_SERVICE) as PowerManager
         if (wakeLock == null) {
             wakeLock = powerManager.newWakeLock(
                 PowerManager.ACQUIRE_CAUSES_WAKEUP or PowerManager.SCREEN_DIM_WAKE_LOCK,
                 "ic:temperatureWakeLock"
             )
+
             wakeLock?.setReferenceCounted(false)
         }
-        wakeLock?.acquire(10 * 60)
+        //10分钟不释放自己灭屏
+        wakeLock?.acquire(10 * 60 * 1000)
     }
 
     override fun onPause() {
index 1281dd6..ee565e8 100644 (file)
@@ -2,11 +2,11 @@ package com.ic.temperature.utils
 
 import android.util.Log
 
-import com.ic.temperature.BuildConfig;
-
 object IcLog {
     private val DOT = "."
-    private var isDebug: Boolean = BuildConfig.DEBUG
+
+    //private var isDebug: Boolean = BuildConfig.DEBUG
+    private var isDebug: Boolean = true
     private var tagHead = ""
 
     fun v(tag: String, msg: String?) {
index a4a6c4e..d6158cc 100644 (file)
@@ -29,8 +29,12 @@ object ServiceUtil {
     }
 
     fun unBindServiceUtil(context: Context, connection: ServiceConnection?) {
-        if (connection != null) {
-            context.unbindService(connection)
+        try {
+            if (connection != null) {
+                context.unbindService(connection)
+            }
+        } catch (e: Exception) {
+            e.printStackTrace()
         }
     }
 
index a1cc75b..071d1a8 100644 (file)
@@ -46,13 +46,18 @@ class TemperatureViewModel() : ViewModel() {
 
         override fun handleMessage(msg: Message) {
             val viewModelValue = this.viewModel?.get() ?: return
+            val isWearEnoughTime = viewModelValue.checkWearTimeEnough()
             when (msg.what) {
                 UPDATE_TEMPERATURE_FINAL_DATA -> {
                     println("UPDATE_TEMPERATURE_FINAL_DATA...")
                     //最终结果
                     //结束一些loading和文字提示
                     viewModelValue.mShowLoading.postValue(false)
-                    viewModelValue.mCheckTips.postValue(viewModelValue.mContext.getString(R.string.activity_temp_tips_end))
+                    if (isWearEnoughTime) {
+                        viewModelValue.mCheckTips.postValue(viewModelValue.mContext.getString(R.string.activity_temp_tips_end))
+                    } else {
+                        viewModelValue.mCheckTips.postValue(viewModelValue.mContext.getString(R.string.activity_temp_tips_wear_too_short))
+                    }
                     val temperature = msg.obj as Temperature
                     viewModelValue.updateUIData(temperature)
                 }
@@ -98,6 +103,18 @@ class TemperatureViewModel() : ViewModel() {
         )
     }
 
+    /**
+     * 检查佩戴时间,如果时间不够长的话
+     * 提示用户佩戴过短,影响测试结果
+     */
+    private fun checkWearTimeEnough(): Boolean {
+        //persist.sys.ic.antioff_time
+        val isEnough = SystemUtils.getSystemPropertiesString("persist.sys.ic_antiWearEnough", "")
+        IcLog.i(TAG, "isEnough === > $isEnough")
+        return "true".equals(isEnough) || "".equals(isEnough)
+
+    }
+
     /**
      * 是否支持环境温度检测
      */
@@ -244,6 +261,7 @@ class TemperatureViewModel() : ViewModel() {
 
     private fun getRemoteData() {
         IcLog.d(TAG, "getRemoteData...")
+        checkWearTimeEnough()
         repository.getTemperature()
     }
 
index fc564b8..1be575a 100644 (file)
@@ -7,5 +7,6 @@
     <string name="no_wearing_device_tips_text">未配戴设备</string>
     <string name="activity_temp_tips_check">正在测量</string>
     <string name="activity_temp_tips_end">测量完成</string>
+    <string name="activity_temp_tips_wear_too_short">佩戴时间过短\n可能影响结果</string>
     <string name="temperature_default_text">"--.- "</string>
 </resources>
\ No newline at end of file
index 918912e..d43daf8 100644 (file)
@@ -1,2 +1,2 @@
-#Tue Dec 08 15:19:45 CST 2020
-VERSION_CODE=2
+#Wed Dec 16 11:45:35 CST 2020
+VERSION_CODE=8