add speed

This commit is contained in:
lixiaopeng
2020-11-04 17:45:33 +08:00
parent d948fc7652
commit 706749aa80
6 changed files with 55 additions and 26 deletions

View File

@@ -21,5 +21,6 @@ data class InformationBody(
val isShare: Boolean, // 是否分享给附近车机
val direction: Float,
val poiType: String, //类型分类
val mainInfoId: Long //事件id
val mainInfoId: Long, //事件id
val speed: Float //车速
)

View File

@@ -35,6 +35,7 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
var mFromType: String = ""
private var mLongitude: Double = 0.0
private var mLatitude: Double = 0.0
var mSpeed: Float = 0f
private var getVideoFailed: (() -> Unit)? = null
private var interceptors: ArrayList<TakePhotoInterceptor> = ArrayList(1)
@@ -72,7 +73,8 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
mainInfoId: Long,
fromType: String,
longitude: Double,
latitude: Double
latitude: Double,
speed: Float
) {
Log.d(TAG, "takePhoto ---------- type = $type --- mType = $mType ---fromType = $fromType")
this.mType = type
@@ -80,6 +82,7 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
this.mFromType = fromType
this.mLongitude = longitude
this.mLatitude = latitude
this.mSpeed = speed
CustomStatusHandler.offerPhotoStatus(isCustom)
zdCarCoderController.takePhoto(photoType, cameraId, haveVoice)
trackGetPhoto(1)
@@ -98,14 +101,16 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
mainInfoId: Long,
fromType: String,
longitude: Double,
latitude: Double
latitude: Double,
speed: Float
) {
Log.d(TAG, "takeVideo -------- isCustom = $isCustom ---mFromType = $mFromType ---type = $type" )
Log.d(TAG, "takeVideo -------- isCustom = $isCustom ---mFromType = $mFromType ---type = $type ---speed = $speed" )
this.mType = type
this.mainInfoId = mainInfoId
this.mFromType = fromType
this.mLongitude = longitude
this.mLatitude = latitude
this.mSpeed = speed
if (DebugConfig.getCarMachineType() == 0) { //自研车机
outputVideoPath = getCompressVideoPath()
CustomStatusHandler.offerVideoStatus(TakeEntity(isCustom, id,fromType))
@@ -128,7 +133,8 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
entity,
mainInfoId,
mLongitude,
mLatitude
mLatitude,
mSpeed
)
//地图上打点
@@ -189,7 +195,8 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
entity,
mainInfoId,
mLongitude,
mLatitude
mLatitude,
mSpeed
)
}
// }
@@ -232,7 +239,7 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
if (!TextUtils.isEmpty(mType)) {
Log.d(TAG, "onTakePhotoSuccess mType != null")
CosStatusController().uploadFile(mutableListOf(photoPath as String), entity, mType, mainInfoId, mFromType, mLongitude,
mLatitude)
mLatitude, mSpeed)
} else {
Log.d(TAG, "onTakePhotoSuccess mType == null")
Log.d(
@@ -249,7 +256,8 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
mainInfoId,
mFromType,
mLongitude,
mLatitude
mLatitude,
mSpeed
)
}
}
@@ -264,7 +272,8 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
mainInfoId,
mFromType,
mLongitude,
mLatitude
mLatitude,
mSpeed
)
}
}
@@ -361,7 +370,8 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
entity,
mainInfoId,
mLongitude,
mLatitude
mLatitude,
mSpeed
)
//地图上打点
@@ -402,7 +412,8 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
mainInfoId,
mFromType,
mLongitude,
mLatitude
mLatitude,
mSpeed
)
//删除压缩前的视频
deletePicFile(videoPath)

View File

@@ -41,10 +41,11 @@ class CosStatusController : CosStatusCallback {
private var mFromType: String = ""
private var mLongitude: Double = 0.0
private var mLatitude: Double = 0.0
var mSpeed: Float = 0f
//上传文件
fun uploadFile(picPath: MutableList<String>, entity: TakeEntity, type: String, mainInfoId: Long,
fromType: String, longitude: Double, latitude: Double) {
fromType: String, longitude: Double, latitude: Double, speed: Float) {
CosCallbackMapController.registerCallback(picPath, this)
// CosLogger.setLogStatus(true)
@@ -54,7 +55,8 @@ class CosStatusController : CosStatusCallback {
this.mFromType = fromType
this.mLongitude = longitude
this.mLatitude = latitude
Log.d(TAG, "uploadFile type===$type ---- mainInfoId =$mainInfoId ----mFromType = $mFromType ---- picPath = $picPath ")
this.mSpeed = speed
Log.d(TAG, "uploadFile type===$type ---- mainInfoId =$mainInfoId ----mFromType = $mFromType ---- picPath = $picPath --speed = $speed")
trackUploadCos(3)
if (picPath.contains("backPic")) return
//参数说明: paths本地文件路径上传的本地路径不要重复config文件上传的优先级
@@ -168,7 +170,8 @@ class CosStatusController : CosStatusCallback {
entity,
mainInfoId,
mLongitude,
mLatitude
mLatitude,
mSpeed
)
}
Log.d(TAG, "delete file: ${localPath!!}")
@@ -183,7 +186,7 @@ class CosStatusController : CosStatusCallback {
// CosCallbackMapController.mainService?.sendCustomResult(it)
// }
// } else {
sendInformationDirectly(type, map, mType, entity, mainInfoId, mLongitude, mLatitude)
sendInformationDirectly(type, map, mType, entity, mainInfoId, mLongitude, mLatitude, mSpeed)
// }
}
@@ -197,7 +200,8 @@ class CosStatusController : CosStatusCallback {
entity: TakeEntity?,
mainInfoId: Long,
longitude: Double,
latitude: Double
latitude: Double,
speed: Float
) {
Log.d(TAG, "sendInformationDirectly poiType= $poiType ---- mainInfoId= $mainInfoId")
//开始上传
@@ -209,6 +213,7 @@ class CosStatusController : CosStatusCallback {
isCustom = it,
poiType = poiType,
mainInfoId = mainInfoId,
speed = speed,
longitude = longitude,
latitude = latitude
) { success ->

View File

@@ -9,8 +9,11 @@ import android.content.Intent
import android.content.IntentFilter
import android.os.IBinder
import android.util.Log
import com.alibaba.android.arouter.launcher.ARouter
import com.elegant.analytics.Analytics
import com.mogo.commons.AbsMogoApplication
import com.mogo.service.IMogoServiceApis
import com.mogo.service.MogoServicePaths
import com.mogo.utils.logger.Logger
import com.mogo.utils.storage.SharedPrefsMgr
import com.zhidao.cosupload.manager.CosUploadManagerImpl
@@ -41,6 +44,7 @@ class MainService : Service() {
companion object {
fun launchService(context: Context, params: UploadParams?) {
val intent = Intent(context, MainService::class.java).apply {
Log.e("MainService", "launchService type = $params")
putExtra("params", params)
@@ -63,11 +67,13 @@ class MainService : Service() {
var shareType: String = "type"
var fromType: String = ""
var isCustom: Boolean = false
var speed: Float = 0f
var params: UploadParams? = null
var mainInfoId: Long = 0
private var mLongitude: Double = 0.0
private var mLatitude: Double = 0.0
lateinit var serviceApis: IMogoServiceApis
//发送主动上报结果广播给外部
// fun sendCustomResult(result: Boolean) {
@@ -87,7 +93,9 @@ class MainService : Service() {
.init(BuildConfig.APPLICATION_ID, 0)
//初始化语音
VoiceController.initVoice()
serviceApis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(this) as IMogoServiceApis
speed = serviceApis.getMapServiceApi().getSingletonLocationClient(this).getLastKnowLocation().getSpeed()
Log.d(TAG, "onStartCommand speed = $speed" )
if (intent != null) {
params = intent.getParcelableExtra("params")
params?.let {
@@ -292,7 +300,7 @@ class MainService : Service() {
Observable.intervalRange(0, 1, 0, 2_000, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer {
CarCorderController.takePhoto(1, 1, false, isCustom, TANLU_ROAD_CURRENT, mainInfoId, fromType, mLongitude, mLatitude)
CarCorderController.takePhoto(1, 1, false, isCustom, TANLU_ROAD_CURRENT, mainInfoId, fromType, mLongitude, mLatitude, speed)
})
// }
@@ -311,7 +319,7 @@ class MainService : Service() {
Log.d("MainService", "takeVideo --------1---->")
// if (isAuthorization(BaseApplication.getAppContext())) {
// log(TAG, "takeVideo --------2---->")
CarCorderController.takeVideo(1, duration, isCustom, id, shareType, mainInfoId, fromType, mLongitude, mLatitude)
CarCorderController.takeVideo(1, duration, isCustom, id, shareType, mainInfoId, fromType, mLongitude, mLatitude, speed)
// }
postVideoAlarmTask(isInterval)

View File

@@ -231,6 +231,7 @@ class MainServiceController {
isShare:Boolean = false,
poiType:String,
mainInfoId:Long,
speed: Float,
longitude: Double,
latitude: Double,
customSend: ((Boolean) -> Unit)? = null
@@ -244,10 +245,10 @@ class MainServiceController {
if (locationInfo.address.isNullOrEmpty()) {
Log.d(TAG, " sendInformationMessage locationInfo.address = $locationInfo.address")
trackUploadGeo(1)
geoLocation(type, url, locationInfo, isCustom,trafficInfoType, isShare, customSend,poiType,mainInfoId,longitude,latitude)
geoLocation(type, url, locationInfo, isCustom,trafficInfoType, isShare, customSend,poiType,mainInfoId,speed, longitude,latitude)
} else {
postInformationMessage(
getInformationBody(type, url, locationInfo, isCustom, trafficInfoType, isShare,poiType,mainInfoId,longitude,latitude),
getInformationBody(type, url, locationInfo, isCustom, trafficInfoType, isShare,poiType,mainInfoId,longitude,latitude, speed),
customSend
)
}
@@ -265,6 +266,7 @@ class MainServiceController {
customSend: ((Boolean) -> Unit)? = null,
poiType: String,
mainInfoId: Long,
speed: Float,
longitude: Double,
latitude: Double
) {
@@ -273,20 +275,20 @@ class MainServiceController {
.geoCodeLocation(locationInfo.toLatLngPoint(), { locInfo: LocationInfo ->
Log.d(TAG, "geoLocation -------start -->")
postInformationMessage(
getInformationBody(type, url, locationInfo, isCustom, trafficInfoType, isShare, poiType,mainInfoId,longitude,latitude),
getInformationBody(type, url, locationInfo, isCustom, trafficInfoType, isShare, poiType,mainInfoId,longitude,latitude, speed),
customSend
)
}, {
//转换失败的情况下再重试一次
Log.d(TAG, "geoLocation -------true-->")
geoRetryed = if (!geoRetryed) {
geoLocation(type, url, locationInfo, isCustom, trafficInfoType, isShare, customSend, poiType,mainInfoId,longitude,latitude)
geoLocation(type, url, locationInfo, isCustom, trafficInfoType, isShare, customSend, poiType,mainInfoId,speed, longitude,latitude)
true
} else {
//如果两次都失败,直接上报服务端
Log.d(TAG, "geoLocation ---- postInformationMessage ---false-->")
postInformationMessage(
getInformationBody(type, url, locationInfo, isCustom, trafficInfoType, isShare, poiType,mainInfoId,longitude,latitude),
getInformationBody(type, url, locationInfo, isCustom, trafficInfoType, isShare, poiType,mainInfoId,longitude,latitude,speed),
customSend
)

View File

@@ -32,7 +32,8 @@ fun getInformationBody(
poiType: String,
mainInfoId: Long,
longitude: Double,
latitude: Double
latitude: Double,
speed: Float
): InformationBody {
var jsonArray = JsonArray()
var type: Int
@@ -70,7 +71,8 @@ fun getInformationBody(
isShare,
locationInfo.direction,
poiType,
mainInfoId
mainInfoId,
speed
)
}