From: TrillGates Date: Thu, 28 Jan 2021 12:11:06 +0000 (+0800) Subject: fixed progourd issues. X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=665f32a603bbb8e2e19037adb80aa84d2037d9ed;p=icfotaclient.git fixed progourd issues. --- diff --git a/app/FotaBrand8541e/release/FotaBrand8541e_V1_202101260957_release.apk b/app/FotaBrand8541e/release/FotaBrand8541e_V1_202101260957_release.apk deleted file mode 100644 index 8bc451b..0000000 Binary files a/app/FotaBrand8541e/release/FotaBrand8541e_V1_202101260957_release.apk and /dev/null differ diff --git a/app/FotaBrand8541e/release/output-metadata.json b/app/FotaBrand8541e/release/output-metadata.json deleted file mode 100644 index d1b542f..0000000 --- a/app/FotaBrand8541e/release/output-metadata.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "version": 2, - "artifactType": { - "type": "APK", - "kind": "Directory" - }, - "applicationId": "com.ic.icfotaclient", - "variantName": "processFotaBrand8541eReleaseResources", - "elements": [ - { - "type": "SINGLE", - "filters": [], - "versionCode": 1, - "versionName": "1.0", - "outputFile": "FotaBrand8541e_V1_202101260957_release.apk" - } - ] -} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 41f2508..4b586eb 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -59,6 +59,15 @@ public (android.content.Context, android.util.AttributeSet, int); } +# 抛出异常时保留代码行号 +-keepattributes SourceFile,LineNumberTable + +# 保留枚举类不被混淆 +-keepclassmembers enum * { + public static **[] values(); + public static ** valueOf(java.lang.String); +} + ################################## 项目类 ################################## -keep class com.facebook.** { *; } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index bfc13b6..4d5a66e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -25,7 +25,9 @@ android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" - android:theme="@style/Theme.ICFotaClient"> + android:theme="@style/Theme.ICFotaClient" + android:usesCleartextTraffic="true"> + @@ -47,8 +49,7 @@ - - + { + //去检查更新 + val serviceIntent = Intent(context, OtaService::class.java) + serviceIntent.action = Constants.CMD_ACTION_NET_WORK_CONNECTED + context?.startService(serviceIntent) + } } } } \ No newline at end of file diff --git a/app/src/main/java/com/ic/icfotaclient/presenter/OtaService.kt b/app/src/main/java/com/ic/icfotaclient/presenter/OtaService.kt index d60a162..1c8a8d3 100644 --- a/app/src/main/java/com/ic/icfotaclient/presenter/OtaService.kt +++ b/app/src/main/java/com/ic/icfotaclient/presenter/OtaService.kt @@ -20,7 +20,7 @@ import com.ic.icfotaclient.utils.VersionInfoUtils */ class OtaService : Service(), ViewModelStoreOwner, LifecycleOwner { - companion object{ + companion object { const val TAG = "OtaService" } @@ -30,11 +30,11 @@ class OtaService : Service(), ViewModelStoreOwner, LifecycleOwner { override fun onCreate() { super.onCreate() - Log.d(TAG,"on service created...") + Log.d(TAG, "on service created...") OtaViewModelCreator.initOtaViewModelStoreOwner(this) //观察数据变化 otaViewModel?.otaInfo?.observe(this, Observer { - Log.d(TAG,"on ota info change...$it") + Log.d(TAG, "on ota info change...$it") //更新数据 mRemoteCallback?.onCheckResult(it) }) @@ -60,13 +60,13 @@ class OtaService : Service(), ViewModelStoreOwner, LifecycleOwner { override fun getImeiCode() { val imei = VersionInfoUtils.getIMEI() - Log.d(TAG,"imei == > $imei") + Log.d(TAG, "imei == > $imei") mRemoteCallback?.onImeiCodeGet(imei) } override fun getVersionCode() { val versionCode = VersionInfoUtils.getSystemVersion() - Log.d(TAG,"versionCode == > $versionCode") + Log.d(TAG, "versionCode == > $versionCode") mRemoteCallback?.onVersionCodeGet(versionCode) } } @@ -75,7 +75,7 @@ class OtaService : Service(), ViewModelStoreOwner, LifecycleOwner { override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { //判断指令是啥 val action = intent?.action - Log.d(TAG,"onStartCommand action -- > $action") + Log.d(TAG, "onStartCommand action -- > $action") if (TextUtils.isEmpty(action)) { return START_NOT_STICKY } @@ -92,6 +92,10 @@ class OtaService : Service(), ViewModelStoreOwner, LifecycleOwner { //如果已经更新了,那么通知一下服务器 otaViewModel?.checkHasUpdated() } + Constants.CMD_ACTION_NET_WORK_CONNECTED -> { + //去检查更新 + otaViewModel?.checkHasUpdated() + } } return super.onStartCommand(intent, flags, startId) @@ -99,7 +103,7 @@ class OtaService : Service(), ViewModelStoreOwner, LifecycleOwner { private fun checkVersion(from: VersionCheckFrom) { val checkNetWork = otaViewModel?.checkNetWork() - Log.d(TAG,"checkNetWork == > $checkNetWork") + Log.d(TAG, "checkNetWork == > $checkNetWork") if (checkNetWork == true) { //连接上了,那么就去检查更新 otaViewModel?.checkUpdate(from) diff --git a/app/src/main/java/com/ic/icfotaclient/presenter/OtaViewModel.kt b/app/src/main/java/com/ic/icfotaclient/presenter/OtaViewModel.kt index 9483500..e77de84 100644 --- a/app/src/main/java/com/ic/icfotaclient/presenter/OtaViewModel.kt +++ b/app/src/main/java/com/ic/icfotaclient/presenter/OtaViewModel.kt @@ -282,6 +282,9 @@ class OtaViewModel : ViewModel() { return VersionInfoUtils.getSystemVersion() } + /** + * 获取IMEI号 + */ fun getImeiCode(): String? { return VersionInfoUtils.getIMEI() } diff --git a/app/src/main/java/com/ic/icfotaclient/repository/CarOtaRepository.kt b/app/src/main/java/com/ic/icfotaclient/repository/CarOtaRepository.kt index e5d0552..cc29b4f 100644 --- a/app/src/main/java/com/ic/icfotaclient/repository/CarOtaRepository.kt +++ b/app/src/main/java/com/ic/icfotaclient/repository/CarOtaRepository.kt @@ -11,10 +11,7 @@ import com.ic.icfotaclient.utils.CarOtaApiUtils import com.ic.icfotaclient.utils.VersionInfoUtils import com.ota.fw.IDownloadEvent import com.ota.fw.SysInfo -import java.io.BufferedInputStream -import java.io.BufferedOutputStream -import java.io.FileInputStream -import java.io.FileOutputStream +import java.io.* /** * 科洛达的Repository @@ -73,8 +70,14 @@ class CarOtaRepository : AbstractOtaRepository() { //转一下 Log.d(TAG, "download == > ${download.file}") val targetFile = VersionInfoUtils.getFlashPath() - Log.d(OtaViewModel.TAG, "copy finished to target path == > $targetFile") - val fis = FileInputStream(targetFile); + val file = File(targetFile) + if (!file.parentFile.exists()) { + file.parentFile.mkdirs() + } + if (!file.exists()) { + file.createNewFile() + } + val fis = FileInputStream(download.file); val fos = FileOutputStream(targetFile) //复制到对应的目录下进行 val bis = BufferedInputStream(fis) @@ -88,6 +91,7 @@ class CarOtaRepository : AbstractOtaRepository() { } fis.close() fos.close() + Log.d(OtaViewModel.TAG, "copy finished to target path == > $targetFile") val downloadInfo = DownloadInfo(download.file.path, 0L) downloadInfo.path = targetFile return downloadInfo diff --git a/app/src/main/java/com/ic/icfotaclient/utils/Constants.kt b/app/src/main/java/com/ic/icfotaclient/utils/Constants.kt index 2230469..ca6b1f1 100644 --- a/app/src/main/java/com/ic/icfotaclient/utils/Constants.kt +++ b/app/src/main/java/com/ic/icfotaclient/utils/Constants.kt @@ -2,6 +2,7 @@ package com.ic.icfotaclient.utils object Constants { const val CMD_ACTION_BOOT_COMPLETED = "cmd_action_boot_completed" + const val CMD_ACTION_NET_WORK_CONNECTED = "cmd_action_net_work_connected" const val CMD_ACTION_ACTIVITY_START = "cmd_action_activity_start" const val OTA_URL = "https://api.ota.limios.net/conn/api/v1/" diff --git a/app/src/main/java/com/ic/icfotaclient/utils/ICOtaApiUtils.kt b/app/src/main/java/com/ic/icfotaclient/utils/ICOtaApiUtils.kt index 551cb1c..1e20ae3 100644 --- a/app/src/main/java/com/ic/icfotaclient/utils/ICOtaApiUtils.kt +++ b/app/src/main/java/com/ic/icfotaclient/utils/ICOtaApiUtils.kt @@ -98,6 +98,10 @@ object ICOtaApiUtils { val gson = Gson() otaInfo = gson.fromJson(json, ICOtaInfo::class.java) if (otaInfo != null) { + if (otaInfo!!.UptoDate) { + Log.d(TAG, "no update package in ic server.") + return null + } return OtaInfo( otaInfo!!.AutoUpdate, otaInfo!!.description,