carlos 2 сар өмнө
parent
commit
ff3f58e71f

BIN
SikeyCommonService.apk


+ 23 - 23
app/src/main/AndroidManifest.xml

@@ -4,26 +4,26 @@
     android:sharedUserId="android.uid.system">
 
     <!-- android:sharedUserId="android.uid.system" -->
-    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
-    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
+    <!--<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />-->
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
     <uses-permission android:name="android.permission.INTERNET" />
-    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
+   <!-- <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
     <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
-    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
+    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />-->
     <uses-permission android:name="android.permission.WAKE_LOCK" />
     <uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
     <uses-permission android:name="android.permission.BLUETOOTH" />
-    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
-    <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />
+   <!-- <uses-permission android:name="android.permission.READ_PHONE_STATE" />
+    <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />-->
     <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
     <uses-permission android:name="android.permission.VIBRATE" />
     <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
     <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
-    <uses-permission android:name="android.permission.READ_CALL_LOG" />
-    <uses-permission android:name="android.permission.CALL_PHONE" />
+<!--    <uses-permission android:name="android.permission.READ_CALL_LOG" />
+    <uses-permission android:name="android.permission.CALL_PHONE" />-->
     <uses-permission
         android:name="android.permission.WRITE_EXTERNAL_STORAGE"
         tools:ignore="ScopedStorage" /> <!-- suppress DeprecatedClassUsageInspection -->
@@ -142,33 +142,33 @@
             android:theme="@style/Theme.XploraWatch.DisableSwipeDismiss"
             android:exported="true"/>
 
-        <receiver
+<!--        <receiver
             android:name=".modules.callbacks.BootReceiver"
             android:exported="true">
             <intent-filter>
                 <action android:name="android.intent.action.BOOT_COMPLETED" />
             </intent-filter>
-        </receiver>
-        <receiver
+        </receiver>-->
+        <!--<receiver
             android:name=".modules.callbacks.LocalReceiver"
             android:exported="true"
             android:permission="com.xplora.receiver">
             <intent-filter>
-                <action android:name="com.xplora.action.ADD_FRIEND" />
+&lt;!&ndash;                <action android:name="com.xplora.action.ADD_FRIEND" />
                 <action android:name="com.xplora.action.POWER_STATUS" />
                 <action android:name="com.xplora.action.SILENT_BEGIN" />
                 <action android:name="com.xplora.action.SILENT_END" />
                 <action android:name="com.xplora.action.REFRESH_CHAT_LIST" />
                 <action android:name="com.xplora.action.RESET_STEP" />
-                <action android:name="com.xplora.action.ALARM" />
+                <action android:name="com.xplora.action.ALARM" />&ndash;&gt;
                 <action android:name="com.xplora.action.OTA" />
-                <action android:name="com.xplora.action.OTA_CHECK" />
-                <action android:name="com.xplora.action.DELETE_CONTENT" />
+&lt;!&ndash;                <action android:name="com.xplora.action.OTA_CHECK" />&ndash;&gt;
+&lt;!&ndash;                <action android:name="com.xplora.action.DELETE_CONTENT" />
                 <action android:name="com.xplora.action.POSITION" />
-                <action android:name="com.xplora.action.LIVE_TRACKING" />
+                <action android:name="com.xplora.action.LIVE_TRACKING" />&ndash;&gt;
             </intent-filter>
-        </receiver>
-        <receiver
+        </receiver>-->
+<!--        <receiver
             android:name=".modules.callbacks.NotificationReceiver"
             android:enabled="true"
             android:exported="true"
@@ -183,8 +183,8 @@
                 <action android:name="com.xplora.notification.Diagnostic" />
                 <action android:name="com.xplora.notification.ChatFail" />
             </intent-filter>
-        </receiver>
-        <receiver
+        </receiver>-->
+<!--        <receiver
             android:name=".modules.callbacks.CallStatusReceiver"
             android:enabled="true"
             android:exported="true"
@@ -193,10 +193,10 @@
                 <action android:name="com.xplora.call_log" />
                 <action android:name="com.xplora.call.sos" />
             </intent-filter>
-        </receiver>
-        <service android:name=".modules.service.MusicDownloadService"
+        </receiver>-->
+<!--        <service android:name=".modules.service.MusicDownloadService"
             android:exported="false"
-            android:permission="android.permission.BIND_JOB_SERVICE"/>
+            android:permission="android.permission.BIND_JOB_SERVICE"/>-->
 
         <!-- 是否测试模式 -->
         <meta-data

+ 2 - 2
app/src/main/java/com/sikey/commonservice/BaseApplication.kt

@@ -56,8 +56,8 @@ class BaseApplication : Application() {
         val netReceiver = NetStateChangeReceiver
         netReceiver.registerObserver(stateObserver)
         netReceiver.registerObserver(otaNetStateObserver)
-        registerReceiver(netReceiver)
-        registerObserver()
+//        registerReceiver(netReceiver)
+//        registerObserver()
         if (SystemProperties.getInt("sys.boot_completed", 0) == 1) {
             onBootCompleted()
         }

+ 10 - 3
app/src/main/java/com/sikey/commonservice/modules/OtaManager.kt

@@ -73,6 +73,12 @@ object OtaManager : OtaStatusObserver, NetworkStateChangeObserver {
             Logger.d(TAG, "check in 12h, do nothing here")
             return
         }
+
+        if(Settings.Global.getInt(globalContext.contentResolver, "ota_permission_checked", 0) != 1) {
+            mStatus = OtaStatus.NEED_SHOW_PERMISSION
+            notifyObservers(null)
+            return
+        }
         when (RsUiStage.getInstance().uiStage) {
             RsUiStage.RS_UI_STAGE_DOWNLOAD_END -> {
                 if (RsOtaManager.getInstance().updateEntity != null) {
@@ -190,7 +196,7 @@ object OtaManager : OtaStatusObserver, NetworkStateChangeObserver {
 
     override fun onCheckSuccess(pkg: RsFwUpdatePackage) {
         lastCheck = System.currentTimeMillis()
-        setOtaCheckAlarm()
+//        setOtaCheckAlarm()
         if (/*pkg.forceUpdate == 1 && */WatchStateChangeImpl.watchBaseInfo.battery < 35
             && (pkg.version != null && pkg.version.isNotEmpty())
         ) {
@@ -218,7 +224,7 @@ object OtaManager : OtaStatusObserver, NetworkStateChangeObserver {
                     checkTime = time
             }
             Logger.w(TAG, "not now !!!! $checkTime")
-            setOtaCheckAlarm(checkTime)
+//            setOtaCheckAlarm(checkTime)
             mStatus = OtaStatus.CHECK_FAIL
             notifyObservers(-1)
             return
@@ -369,5 +375,6 @@ enum class OtaStatus {
     NEED_WIFI,
     DOWNLOADING,
     DOWNLOAD_SUCCESS,
-    DOWNLOAD_FAIL
+    DOWNLOAD_FAIL,
+    NEED_SHOW_PERMISSION
 }

+ 2 - 2
app/src/main/java/com/sikey/commonservice/modules/WatchStateChangeImpl.kt

@@ -315,11 +315,11 @@ object WatchStateChangeImpl : WatchStateChangeObserver, NetworkStateChangeObserv
         if (duelNeedInit()) {
             Logger.d(TAG, "duelNeedInit yes!!!!")
 
-            if (mTicket.isNullOrBlank()) {
+/*            if (mTicket.isNullOrBlank()) {
                 exchangeTicket()
             } else {
                 getBindStatus()
-            }
+            }*/
 
 /*            GlobalScope.launch {
                 if (refreshToken(null)) {

+ 4 - 4
app/src/main/java/com/sikey/commonservice/modules/callbacks/CallStatusReceiver.kt

@@ -41,7 +41,7 @@ class CallStatusReceiver : BroadcastReceiver() {
     @OptIn(DelicateCoroutinesApi::class)
     override fun onReceive(context: Context, intent: Intent) {
         when (intent.action) {
-            ACTION_CALL_LOG -> {
+           /* ACTION_CALL_LOG -> {
                 val now = System.currentTimeMillis() / 1000
                 var number = intent.getStringExtra("incomingNumber")?:""
                 val contacts = DatabaseManager.queryContact()
@@ -81,11 +81,11 @@ class CallStatusReceiver : BroadcastReceiver() {
                         FlowableFactory.getFlowable(HttpApi.Call.LOG, callLog, null)
                     )
                 }
-            }
-            ACTION_SOS -> {
+            }*/
+/*            ACTION_SOS -> {
                 Logger.d("CallStatusReceiver", "sos triggered!!")
                 SosManager.executeSos()
-            }
+            }*/
         }
     }
 }

+ 11 - 11
app/src/main/java/com/sikey/commonservice/modules/callbacks/LocalReceiver.kt

@@ -67,7 +67,7 @@ class LocalReceiver : BroadcastReceiver() {
     override fun onReceive(context: Context, intent: Intent) {
         Logger.d(TAG, "onReceive: ${intent.action}; ${Thread.currentThread()}")
         when (intent.action) {
-            ACTION_POSITION -> {
+            /*ACTION_POSITION -> {
                 SKRetrofitFactory.sendWsHeartbeat()
                 if (watchBaseInfo.activated) {
                     Logger.d(TAG, "activated, do executePosition")
@@ -149,14 +149,14 @@ class LocalReceiver : BroadcastReceiver() {
                     intent.getStringExtra("msgId"),
                     0, 10
                 )
-            }
+            }*/
 
-            ACTION_RESET_STEP -> {
+/*            ACTION_RESET_STEP -> {
                 resetStep()
                 setRestStepAlarm()
-            }
+            }*/
 
-            ACTION_ALARM -> {
+            /*ACTION_ALARM -> {
                 val id = intent.getStringExtra("extra")!!.toInt() - ALARM_ALARM_OFFSET
                 val oldAlarmList = DatabaseManager.queryAlarms()
                 for (alarm in oldAlarmList) {
@@ -195,7 +195,7 @@ class LocalReceiver : BroadcastReceiver() {
                     if (alarm.alarmId == id) {
                         setSilentAlarm(alarm, false)
                         val status = dealNeedToSilent(alarm)
-                        if (/*status == XPAlarmManager.SilentState.NOT_START ||*/ status == XPAlarmManager.SilentState.STARTED) {
+                        if (*//*status == XPAlarmManager.SilentState.NOT_START ||*//* status == XPAlarmManager.SilentState.STARTED) {
                             setSilentStartTimes(id)
                             adjustmentSilentDisableStatus(true)
                         }
@@ -218,17 +218,17 @@ class LocalReceiver : BroadcastReceiver() {
                         }
                     }
                 }
-            }
+            }*/
 
             ACTION_OTA -> {
                 OtaManager.install()
             }
 
-            ACTION_OTA_CHECK -> {
+/*            ACTION_OTA_CHECK -> {
                 OtaManager.forceCheck(false)
-            }
+            }*/
 
-            ACTION_DELETE_CONTENT -> {
+            /*ACTION_DELETE_CONTENT -> {
                 val cid = intent.getStringExtra("cid") ?: ""
                 if (cid.isNotEmpty()) {
                     GlobalScope.launch {
@@ -240,7 +240,7 @@ class LocalReceiver : BroadcastReceiver() {
                         )
                     }
                 }
-            }
+            }*/
         }
     }
 

+ 5 - 0
app/src/main/java/com/sikey/commonservice/ui/activity/OtaCheckActivity.kt

@@ -36,8 +36,10 @@ class OtaCheckActivity : FragmentActivity() {
     private val otaCheckNeedWifiFragment = OtaCheckNeedWifiFragment.newInstance()
     private val otaDownloadingFragment = OtaDownloadingFragment.newInstance()
     private val otaReadyToInstallFragment = OtaReadyToInstallFragment.newInstance()
+    private val otaNeedPermissionFragment = OtaNeedPermissionFragment.newInstance()
     private val viewModel: OtaCheckResultViewModel by shareViewModels("otaInfo")
 
+
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
         setContentView(R.layout.activity_ota_check)
@@ -112,6 +114,9 @@ class OtaCheckActivity : FragmentActivity() {
                     }
                 }
             }
+            OtaStatus.NEED_SHOW_PERMISSION -> {
+                transaction.replace(R.id.content, otaNeedPermissionFragment)
+            }
             else -> {
                 transaction.replace(R.id.content, otaCheckUpToDateFragment)
             }

+ 38 - 0
app/src/main/java/com/sikey/commonservice/ui/fragment/OtaNeedPermissionFragment.kt

@@ -0,0 +1,38 @@
+package com.sikey.commonservice.ui.fragment
+
+import android.os.Bundle
+import android.provider.Settings
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.Button
+import androidx.fragment.app.Fragment
+import com.sikey.commonservice.BaseApplication.Companion.globalContext
+import com.sikey.commonservice.R
+import com.sikey.commonservice.modules.OtaManager
+import com.sikey.commonservice.modules.OtaManager.forceCheck
+
+class OtaNeedPermissionFragment : Fragment() {
+
+    companion object {
+        @JvmStatic
+        fun newInstance() = OtaNeedPermissionFragment()
+    }
+
+    override fun onCreateView(
+        inflater: LayoutInflater, container: ViewGroup?,
+        savedInstanceState: Bundle?
+    ): View? {
+        return inflater.inflate(R.layout.fragment_ota_need_permission, container, false)
+    }
+
+    override fun onStart() {
+        super.onStart()
+        val updateNow = view?.findViewById(R.id.button_sure) as Button
+        updateNow.setOnClickListener {
+            Settings.Global.putInt(globalContext.contentResolver, "ota_permission_checked", 1)
+            forceCheck(true)
+        }
+    }
+
+}

+ 41 - 0
app/src/main/res/layout/fragment_ota_need_permission.xml

@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical"
+    android:layout_marginTop="24dp">
+
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center_horizontal"
+        android:gravity="center"
+        android:lineSpacingExtra="3sp"
+        android:text="联网提示"
+        android:textColor="@color/white"
+        android:textSize="15sp" />
+
+    <TextView
+        android:id="@+id/version"
+        android:layout_width="160dp"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center_horizontal"
+        android:gravity="center"
+        android:layout_marginTop="10dp"
+        android:text="升级包检测以及更新过程中需要连接互联网。"
+        android:textColor="@color/white"
+        android:textSize="12sp" />
+
+    <Button
+        android:id="@+id/button_sure"
+        android:layout_width="100dp"
+        android:layout_height="33dp"
+        android:text="我知道了"
+        android:backgroundTint="@color/xp_green"
+        android:textSize="12sp"
+        android:layout_marginTop="30dp"
+        android:layout_gravity="center_horizontal"
+        style="@style/xp_style_button_all"
+        />
+
+</LinearLayout>

+ 2 - 1
app/src/main/res/layout/fragment_ota_ready_to_install.xml

@@ -56,7 +56,8 @@
         android:layout_width="115dp"
         android:layout_height="31dp"
         android:layout_gravity="center_horizontal"
-        android:layout_marginTop="7dp">
+        android:layout_marginTop="7dp"
+        android:visibility="gone">
         <ImageView
             style="@style/xp_style_button_all"
             android:layout_width="115dp"

+ 1 - 1
app/src/main/res/values-zh-rCN/strings.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
-    <string name="app_name">观看更新</string>
+    <string name="app_name">手表更新</string>
     <string name="check_summary">正在检查新更新</string>
     <string name="ota_title">软件更新</string>
     <string name="up_to_date">你的手表是最新的</string>

+ 1 - 1
app/src/main/res/values-zh-rTW/strings.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
-    <string name="app_name">觀看更新</string>
+    <string name="app_name">更新</string>
     <string name="check_summary">正在檢查新更新</string>
     <string name="ota_title">軟體更新</string>
     <string name="up_to_date">你的手錶是最新的</string>