This commit is contained in:
wangcongtao
2020-09-18 10:01:53 +08:00
225 changed files with 1038 additions and 623 deletions

View File

@@ -4,7 +4,6 @@ import android.content.Intent
import android.util.Log
import com.google.gson.Gson
import com.mogo.commons.AbsMogoApplication
import com.mogo.commons.debug.DebugConfig
import com.mogo.utils.TipToast
import com.zhidao.cosupload.DbPriorityConfig
import com.zhidao.cosupload.callback.CosStatusCallback
@@ -14,7 +13,10 @@ import com.zhidao.roadcondition.event.GetImageSuccessEvent
import com.zhidao.roadcondition.event.LatLngStickyEventBus
import com.zhidao.roadcondition.model.proxy.INFO_TYPE_IMG
import com.zhidao.roadcondition.model.proxy.INFO_TYPE_VIDEO
import com.zhidao.roadcondition.util.*
import com.zhidao.roadcondition.util.CarNet_Cos_Upload
import com.zhidao.roadcondition.util.LocationUtil
import com.zhidao.roadcondition.util.deletePicFile
import com.zhidao.roadcondition.util.trackNormalEvent
/**
* @description cos上传操作
@@ -24,10 +26,8 @@ import com.zhidao.roadcondition.util.*
*/
class CosStatusController : CosStatusCallback {
val TAG: String = this.javaClass.simpleName
//存储单次请求的视频和缩略图url
var videoAndThumbMap: MutableMap<String, String> = mutableMapOf()
//图片上传的eventId
lateinit var mPicEventId: String
private var isRetry = false //是否重试上传过图片
@@ -80,46 +80,40 @@ class CosStatusController : CosStatusCallback {
Log.d(TAG, "uploadCosFailed = $localPath")
trackUploadCos(2)
//语音播报 1上报路况2交通检查3封路 默认 mType 应该为null
// if (CarCorderController.mType.equals(TANLU_ROAD_CONGESTION) || CarCorderController.mType.equals(
// TANLU_TRAFFIC_CHECK
// ) || CarCorderController.mType.equals(TANLU_ROAD_CLOSURE)
// || CarCorderController.mType.equals(TANLU_ROAD_CURRENT) || CarCorderController.mType.equals(
// TANLU_ROAD_PONDING
// ) || CarCorderController.mType.equals(TANLU_ROAD_ICING)
// || CarCorderController.mType.equals(TANLU_ROAD_HEAVY_FOG) || CarCorderController.mType.equals(
// TANLU_ROAD_ACCIDENT
// ) || CarCorderController.mType.equals(TANLU_ROAD_WORK)
// ) {
if (CarCorderController.mType.equals(TANLU_ROAD_CONGESTION) || CarCorderController.mType.equals(
TANLU_TRAFFIC_CHECK
) || CarCorderController.mType.equals(TANLU_ROAD_CLOSURE)
|| CarCorderController.mType.equals(TANLU_ROAD_CURRENT) || CarCorderController.mType.equals(
TANLU_ROAD_PONDING
) || CarCorderController.mType.equals(TANLU_ROAD_ICING)
|| CarCorderController.mType.equals(TANLU_ROAD_HEAVY_FOG) || CarCorderController.mType.equals(
TANLU_ROAD_ACCIDENT
) || CarCorderController.mType.equals(TANLU_ROAD_WORK)
) {
// VoiceController.speakVoice("cos上报失败")
Log.d(TAG, "uploadCosFailed mType = $mType")
Log.d(TAG, "uploadCosFailed mType = $mType")
if (entity?.isCustom && mFromType != UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO) {
sendGetInfoFailedReceiver("100")
}
}
if (!isRetry) {
isRetry = true
taskAsync(5_000) {
//去掉重试
try {
uploadFile(mutableListOf(localPath as String), entity, mType, mainInfoId, mFromType, mLongitude, mLatitude)
} catch (e: Exception) {
e.printStackTrace()
}
}
// taskAsync(30_000) { //去掉重试
// try {
// uploadFile(mutableListOf(localPath as String), entity, mType)
// } catch (e: Exception) {
// e.printStackTrace()
// }
// }
} else {
//重试一次,如果还失败就提示
if (entity?.isCustom && mFromType != UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO) {
if(DebugConfig.isLauncher()) {
// 只有Launcher上报的时候失败会提示独立app不会提示
sendGetInfoFailedReceiver("100")
}
}
if (localPath!!.endsWith("mp4") || localPath!!.contains("Thumbnail")) {
CosCallbackMapController.uploadFailed?.invoke()
}
CosCallbackMapController.unregisterCallback(localPath)
InformationUploadController.release(entity?.id)
deletePicFile(localPath)
// deletePicFile(localPath)
}
}
override fun uploadCosCompleted(
@@ -165,7 +159,7 @@ class CosStatusController : CosStatusCallback {
trackUploadCos(5)
}
} else {
//上传图片成功, 如果是上报路况,直接上传
//上传图片成功, 如果是上报路况,直接上传TODO
Log.d(TAG, "uploadCosCompleted 分享成功 ---- mType = $mType")
sendInformationDirectly(
INFO_TYPE_IMG,
@@ -218,9 +212,9 @@ class CosStatusController : CosStatusCallback {
latitude = latitude
) { success ->
CosCallbackMapController.unregisterCallbacks(map)
CosCallbackMapController.mainService?.let {
CosCallbackMapController.mainService?.sendCustomResult(success)
}
// CosCallbackMapController.mainService?.let {
// CosCallbackMapController.mainService?.sendCustomResult(success)
// }
Log.d(TAG, "type = $type ----success = $success")
if (success) {
//分享成功并打点如果是上报拥堵需要takeVideo
@@ -237,6 +231,7 @@ class CosStatusController : CosStatusCallback {
TipToast.shortTip("分享失败,请检查网络")
}
}
}
}
}
@@ -251,5 +246,6 @@ class CosStatusController : CosStatusCallback {
AbsMogoApplication.getApp().applicationContext
)
}
}

View File

@@ -66,11 +66,11 @@ class MainService : Service() {
private var mLatitude: Double = 0.0
//发送主动上报结果广播给外部
fun sendCustomResult(result: Boolean) {
var intent = Intent(customResultAction)
intent.putExtra("isSuccess", result)
sendBroadcast(intent)
}
// fun sendCustomResult(result: Boolean) {
// var intent = Intent(customResultAction)
// intent.putExtra("isSuccess", result)
// sendBroadcast(intent)
// }
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
Log.d(TAG, "onStartCommand -----------> ")