<JetCodeStyleSettings>
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
<value>
- <package name="java.util" withSubpackages="false" static="false" />
- <package name="kotlinx.android.synthetic" withSubpackages="true" static="false" />
- <package name="io.ktor" withSubpackages="true" static="false" />
+ <package name="java.util" alias="false" withSubpackages="false" />
+ <package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
+ <package name="io.ktor" alias="false" withSubpackages="true" />
+ </value>
+ </option>
+ <option name="PACKAGES_IMPORT_LAYOUT">
+ <value>
+ <package name="" alias="false" withSubpackages="true" />
+ <package name="java" alias="false" withSubpackages="true" />
+ <package name="javax" alias="false" withSubpackages="true" />
+ <package name="kotlin" alias="false" withSubpackages="true" />
+ <package name="" alias="true" withSubpackages="true" />
</value>
</option>
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
+++ /dev/null
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-# Module name should match apk name to be installed
-LOCAL_MODULE := ICFotaClient
-LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := FotaBrand8521e_V1_202103081958_debug.apk
-LOCAL_MODULE_CLASS := APPS
-LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
-
-# icfota
-LOCAL_OVERRIDES_PACKAGES := icfota
-
-LOCAL_PRIVILEGED_MODULE := true
-LOCAL_CERTIFICATE := platform
-LOCAL_DEX_PREOPT := false
-
-include $(BUILD_PREBUILT)
+++ /dev/null
-{
- "version": 2,
- "artifactType": {
- "type": "APK",
- "kind": "Directory"
- },
- "applicationId": "com.ic.icfotaclient",
- "variantName": "processFotaBrand8521eDebugResources",
- "elements": [
- {
- "type": "SINGLE",
- "filters": [],
- "versionCode": 1,
- "versionName": "1.0",
- "outputFile": "FotaBrand8521e_V1_202103081958_debug.apk"
- }
- ]
-}
\ No newline at end of file
"kind": "Directory"
},
"applicationId": "com.ic.icfotaclient",
- "variantName": "processFotaBrand8541eReleaseResources",
+ "variantName": "processFotaBrand8521eReleaseResources",
"elements": [
{
"type": "SINGLE",
"filters": [],
"versionCode": 1,
"versionName": "1.0",
- "outputFile": "FotaBrand8541e_V1_202103181928_release.apk"
+ "outputFile": "FotaBrand8521e_V1_202106281712_release.apk"
}
]
}
\ No newline at end of file
parcel.readLong(),
parcel.readLong(),
TODO("serverInc")
- ) {
- }
+ )
enum class ServerInc {
IN_CAR,
private fun checkRemote() {
App.sHandler.postDelayed({
checkVersion(VersionCheckFrom.BOOT_CHECK)
-
}, Constants.TIME_DELAY_BOOT)
}
}
Log.d(TAG, "batteryPct == > $batteryPct")
//进行电量检查
- if (batteryPct!! >= 50.0f) {
+ if (batteryPct!! >= 30.0f) {
currentActionState.postValue(UpdateActionState.UPDATING)
//保存一个SP值,升级完了检查,用于通知服务器更新成功了.
//这里后面要改成我们自己的升级,而不是apk的升级方式
object ICOtaApiUtils {
- val TAG = "ICOtaApiUtils"
+ private const val TAG = "ICOtaApiUtils"
+ private var isBackUpHost = false
+
+ private val backupUrl by lazy {
+ val backupUri = URI(getRemoteUriBackup())
+ Log.d(TAG, "backupUri == > $backupUri")
+ backupUri.toString()
+ }
fun checkIcVersion(): OtaInfo? {
val uri = URI(getRemoteUri())
val url = uri.toString()
+ Log.d(TAG, "uri == > $uri")
+ isBackUpHost = false
return getUpdateInfo(url)
}
private fun getUpdateInfo(
url: String?
): OtaInfo? {
+ Log.d(TAG, "getUpdateInfo url is $url")
if (okHttpClient == null) {
initOkHttp()
}
val request: Request = Request.Builder().url(url).build()
-
- val execute = okHttpClient?.newCall(request)?.execute()
+ val newCall = okHttpClient?.newCall(request)
+ val response = newCall?.execute()
+ Log.d(TAG, "execute == > $response")
//解析数据
- if (execute != null && execute.code() == HttpURLConnection.HTTP_OK) {
- val body = execute.body() ?: return null
+ val code = response?.code()
+ Log.d(TAG, "code == > $code")
+ if (response != null && code == HttpURLConnection.HTTP_OK) {
+ val body = response.body() ?: return null
val json = body.string()
Log.d(TAG, "result == > $json")
val gson = Gson()
- otaInfo = gson.fromJson<ICOtaInfo>(json, ICOtaInfo::class.java)
+ otaInfo = gson.fromJson(json, ICOtaInfo::class.java)
if (otaInfo != null) {
if (otaInfo!!.UptoDate) {
Log.d(TAG, "no update package in ic server.")
- return null
+ if (!isBackUpHost) {
+ isBackUpHost = true
+ return getUpdateInfo(backupUrl)
+ }
}
return OtaInfo(
otaInfo!!.AutoUpdate,
)
}
}
+ Log.d(TAG, "no update info...")
return null
}
+
private fun getRemoteUri(): String? {
var server: String = getRemoteHost()
val productname: String? = VersionInfoUtils.getOtaProductName()
return actionUrl
}
+ private fun getRemoteUriBackup(): String? {
+ var server: String? = getRemoteHostBackup()
+ val productname: String? = VersionInfoUtils.getOtaProductName()
+ val pkgversion: String? = VersionInfoUtils.getSystemVersion()
+ val imei: String? = VersionInfoUtils.getIMEI()
+ //为了兼容之前的只设置ip和端口的设置方式
+ var actionUrl =
+ "$server/ota.jsp?product=$productname&pkgver=$pkgversion&imei=$imei"
+ if (server != null) {
+ if (server.contains("/")) { //此时说明不是ip地址,而是个url
+ actionUrl = "$server?product=$productname&pkgver=$pkgversion&imei=$imei"
+ }
+ }
+ if (!actionUrl.startsWith("http://") && !actionUrl.startsWith("https://")) {
+ actionUrl = "http://$actionUrl"
+ }
+ return actionUrl
+ }
+
+ private fun getRemoteHostBackup(): String? {
+ var remoteHost: String? = SysPropUtils.get("persist.sys.ota.host2", null)
+ if (remoteHost == null || remoteHost.isEmpty() || remoteHost == "unknown") {
+ remoteHost = "server-git:8089"
+ }
+ return remoteHost
+ }
private fun getRemoteHost(): String {
var remoteHost: String? =
val currentActionState = OtaViewModelCreator.getOtaViewModel(null)?.currentActionState
val tipsWifiConnect = OtaViewModelCreator.getOtaViewModel(null)?.isTipsWifiConnect
if (checkNetWork != true ||
- currentActionState?.value == UpdateActionState.LAST_VERSION
+ currentActionState?.value == UpdateActionState.LAST_VERSION ||
+ currentActionState?.value == UpdateActionState.BATTERY_LEVEL_NOT_ENOUGH
|| tipsWifiConnect?.value == true
) {
super.onBackPressed()
<string name="check_has_update_text">Check has update</string>
<string name="update_text">Update</string>
<string name="no_network_text">Unable to reach the server</string>
- <string name="battery_level_tips_text">Please make the power is above 50%</string>
+ <string name="battery_level_tips_text">Please make the power is above 30%</string>
<string name="error_tips_text">Error , please try again</string>
<string name="verify_package_text">Checking</string>
<string name="inject_update_seed_text">Inject upgrade seeds</string>
<string name="check_has_update_text">检查是否有更新</string>
<string name="update_text">马上升级</string>
<string name="no_network_text">无法触及到服务器</string>
- <string name="battery_level_tips_text">请确保电量50%以上</string>
+ <string name="battery_level_tips_text">请确保电量30%以上</string>
<string name="error_tips_text">资源准备失败,请重启尝试</string>
<string name="verify_package_text">正在校验升级包</string>
<string name="inject_update_seed_text">注入升级种子</string>
<string name="check_has_update_text">Check has update</string>
<string name="update_text">Update</string>
<string name="no_network_text">Unable to reach the server</string>
- <string name="battery_level_tips_text">Please make the power is above 50%</string>
+ <string name="battery_level_tips_text">Please make the power is above 30%</string>
<string name="error_tips_text">Error , please try again</string>
<string name="verify_package_text">Checking</string>
<string name="inject_update_seed_text">Inject upgrade seeds</string>