+++ /dev/null
-{
- "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
public <init>(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.** { *; }
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">
+
<activity android:name=".view.SystemUpdateActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
<intent-filter>
- <action android:name="android.intent.action.MEDIA_MOUNTED" />
- <data android:scheme="file" />
+ <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>
<service
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
+import android.net.ConnectivityManager
import android.util.Log
import com.ic.icfotaclient.utils.Constants
serviceIntent.action = Constants.CMD_ACTION_BOOT_COMPLETED
context?.startService(serviceIntent)
}
+ ConnectivityManager.CONNECTIVITY_ACTION -> {
+ //去检查更新
+ val serviceIntent = Intent(context, OtaService::class.java)
+ serviceIntent.action = Constants.CMD_ACTION_NET_WORK_CONNECTED
+ context?.startService(serviceIntent)
+ }
}
}
}
\ No newline at end of file
*/
class OtaService : Service(), ViewModelStoreOwner, LifecycleOwner {
- companion object{
+ companion object {
const val TAG = "OtaService"
}
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)
})
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)
}
}
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
}
//如果已经更新了,那么通知一下服务器
otaViewModel?.checkHasUpdated()
}
+ Constants.CMD_ACTION_NET_WORK_CONNECTED -> {
+ //去检查更新
+ otaViewModel?.checkHasUpdated()
+ }
}
return super.onStartCommand(intent, flags, startId)
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)
return VersionInfoUtils.getSystemVersion()
}
+ /**
+ * 获取IMEI号
+ */
fun getImeiCode(): String? {
return VersionInfoUtils.getIMEI()
}
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
//转一下
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)
}
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
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/"
val gson = Gson()
otaInfo = gson.fromJson<ICOtaInfo>(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,