diff --git a/app/functions/och.gradle b/app/functions/och.gradle index d1e7d70339..ad51544f40 100644 --- a/app/functions/och.gradle +++ b/app/functions/och.gradle @@ -1,11 +1,39 @@ // 网约车服务:仅小巴车、出租车渠道用 project.dependencies { - f8xxImplementation rootProject.ext.dependencies.mogoochnoop - f80xImplementation rootProject.ext.dependencies.mogoochnoop - f8AmapImplementation rootProject.ext.dependencies.mogoochnoop - - fochtaxiImplementation rootProject.ext.dependencies.mogoochtaxi - fochbusImplementation rootProject.ext.dependencies.mogoochbus + f8xxImplementation (rootProject.ext.dependencies.mogoochnoop){ + exclude group: 'com.mogo.commons' //by group + exclude group: 'com.mogo.map' //by group + exclude group: 'com.mogo.eagle.core' //by group + exclude group: 'com.mogo.eagle.core.function' //by group + } + f80xImplementation (rootProject.ext.dependencies.mogoochnoop){ + exclude group: 'com.mogo.commons' //by group + exclude group: 'com.mogo.module' //by group + exclude group: 'com.mogo.map' //by group + exclude group: 'com.mogo.eagle.core' //by group + exclude group: 'com.mogo.eagle.core.function' //by group + } + f8AmapImplementation (rootProject.ext.dependencies.mogoochnoop){ + exclude group: 'com.mogo.commons' //by group + exclude group: 'com.mogo.module' //by group + exclude group: 'com.mogo.map' //by group + exclude group: 'com.mogo.eagle.core' //by group + exclude group: 'com.mogo.eagle.core.function' //by group + } + fochtaxiImplementation (rootProject.ext.dependencies.mogoochtaxi){ + exclude group: 'com.mogo.commons' //by group + exclude group: 'com.mogo.module' //by group + exclude group: 'com.mogo.map' //by group + exclude group: 'com.mogo.eagle.core' //by group + exclude group: 'com.mogo.eagle.core.function' //by group + } + fochbusImplementation (rootProject.ext.dependencies.mogoochbus){ + exclude group: 'com.mogo.commons' //by group + exclude group: 'com.mogo.module' //by group + exclude group: 'com.mogo.map' //by group + exclude group: 'com.mogo.eagle.core' //by group + exclude group: 'com.mogo.eagle.core.function' //by group + } fPadLenovoImplementation (rootProject.ext.dependencies.mogoochnoop){ exclude group: 'com.mogo.commons' //by group diff --git a/core/function-impl/mogo-core-function-main/build.gradle b/core/function-impl/mogo-core-function-main/build.gradle index e43f3f083b..27e4e6518e 100644 --- a/core/function-impl/mogo-core-function-main/build.gradle +++ b/core/function-impl/mogo-core-function-main/build.gradle @@ -69,7 +69,6 @@ dependencies { api rootProject.ext.dependencies.mogoservice api rootProject.ext.dependencies.moduleV2x api rootProject.ext.dependencies.moduleshare - api rootProject.ext.dependencies.tanluupload api rootProject.ext.dependencies.mogomonitor api rootProject.ext.dependencies.moduleextensions api rootProject.ext.dependencies.modulemap @@ -103,7 +102,6 @@ dependencies { api project(':modules:mogo-module-service') api project(':modules:mogo-module-v2x') api project(':modules:mogo-module-share') - api project(':modules:tanlulib') api project(':modules:mogo-module-monitor') api project(':modules:mogo-module-extensions') api project(':modules:mogo-module-map') diff --git a/modules.txt b/modules.txt index c82c7173fb..9754fd7cae 100644 --- a/modules.txt +++ b/modules.txt @@ -38,7 +38,6 @@ :modules:mogo-module-main :modules:mogo-module-push-base :modules:mogo-module-push -:modules:tanlulib :modules:mogo-module-monitor :core:function-impl:mogo-core-function-autopilot :core:function-impl:mogo-core-function-hmi diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/service/MogoMainService.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/service/MogoMainService.java index 56bec93b55..7ecc522cca 100644 --- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/service/MogoMainService.java +++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/service/MogoMainService.java @@ -91,7 +91,6 @@ class MogoMainService extends Service implements IMogoLocationListener { private void startTanluService() { UiThreadHandler.postDelayed(() -> { - Logger.d(TAG, "startTanluService ---------- "); if (mServiceApis != null) { mServiceApis.getTanluApi().startTanluService(); } diff --git a/modules/mogo-module-share/build.gradle b/modules/mogo-module-share/build.gradle index 3eb1ba5945..65fa5fa567 100644 --- a/modules/mogo-module-share/build.gradle +++ b/modules/mogo-module-share/build.gradle @@ -37,6 +37,10 @@ android { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } + + kotlinOptions { + jvmTarget = "1.8" + } } dependencies { @@ -46,7 +50,7 @@ dependencies { implementation rootProject.ext.dependencies.androidxrecyclerview implementation rootProject.ext.dependencies.androidxccorektx implementation rootProject.ext.dependencies.androidxconstraintlayout - + implementation rootProject.ext.dependencies.okhttpinterceptor implementation rootProject.ext.dependencies.arouter kapt rootProject.ext.dependencies.aroutercompiler @@ -54,21 +58,26 @@ dependencies { implementation rootProject.ext.dependencies.rxandroid implementation rootProject.ext.dependencies.mogoaicloudtanlu + implementation rootProject.ext.dependencies.analytics + implementation rootProject.ext.dependencies.eventbus + implementation rootProject.ext.dependencies.coroutinescore + implementation rootProject.ext.dependencies.coroutinesandroid +// implementation rootProject.ext.dependencies.retrofit +// implementation rootProject.ext.dependencies.retrofitconvertergson + implementation 'com.zhidaoauto.controller:api:1.0.8' + if (Boolean.valueOf(USE_MAVEN_PACKAGE)) { implementation rootProject.ext.dependencies.mogoutils implementation rootProject.ext.dependencies.mogocommons implementation rootProject.ext.dependencies.modulecommon implementation rootProject.ext.dependencies.moduleservice - implementation rootProject.ext.dependencies.mogo_core_utils implementation rootProject.ext.dependencies.mogo_core_data - } else { implementation project(":foudations:mogo-utils") implementation project(":foudations:mogo-commons") implementation project(':modules:mogo-module-common') implementation project(':modules:mogo-module-service') - implementation project(':core:mogo-core-utils') implementation project(':core:mogo-core-data') } diff --git a/modules/mogo-module-share/src/main/AndroidManifest.xml b/modules/mogo-module-share/src/main/AndroidManifest.xml index 06a62d3d0f..2337826536 100644 --- a/modules/mogo-module-share/src/main/AndroidManifest.xml +++ b/modules/mogo-module-share/src/main/AndroidManifest.xml @@ -3,5 +3,10 @@ + + + diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/MogoTanluApiProvider.java b/modules/mogo-module-share/src/main/java/com/mogo/module/share/MogoTanluApiProvider.java similarity index 73% rename from modules/tanlulib/src/main/java/com/zhidao/roadcondition/MogoTanluApiProvider.java rename to modules/mogo-module-share/src/main/java/com/mogo/module/share/MogoTanluApiProvider.java index 9212b2821c..84d747a050 100644 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/MogoTanluApiProvider.java +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/MogoTanluApiProvider.java @@ -1,4 +1,4 @@ -package com.zhidao.roadcondition; +package com.mogo.module.share; import android.content.Context; import android.util.ArrayMap; @@ -7,23 +7,23 @@ import com.alibaba.android.arouter.facade.annotation.Route; import com.mogo.commons.analytics.AnalyticsUtils; import com.mogo.eagle.core.data.map.MogoLocation; import com.mogo.module.common.MogoApisHandler; +import com.mogo.module.share.service.MainService; +import com.mogo.module.share.service.UploadParams; import com.mogo.service.share.IMogoTanluProvider; import com.mogo.service.share.TanluUploadParams; import com.mogo.utils.logger.Logger; -import com.zhidao.roadcondition.service.MainService; -import com.zhidao.roadcondition.service.UploadParams; import java.util.Map; -import static com.zhidao.roadcondition.constant.ConstKt.API_MODULE_NAME; -import static com.zhidao.roadcondition.constant.ConstKt.API_MODULE_PATH; +import static com.mogo.eagle.core.data.constants.MogoServicePaths.PATH_TANLU_API; +import static com.mogo.module.share.constant.StrategyShareConstKt.S_TAG; /** * 探路api * * @author tongchenfei */ -@Route(path = API_MODULE_PATH) +@Route(path = PATH_TANLU_API) public class MogoTanluApiProvider implements IMogoTanluProvider { private Context context; @@ -34,8 +34,8 @@ public class MogoTanluApiProvider implements IMogoTanluProvider { */ @Override public void uploadRoadCondition(TanluUploadParams params) { - if(params!=null) { - Logger.d(API_MODULE_NAME, "uploadRoadCondition: " + params); + if (params != null) { + Logger.d(S_TAG, "uploadRoadCondition: " + params); Map properties = new ArrayMap<>(); properties.put("type", params.getEventType()); properties.put("from", params.getFromType()); @@ -44,8 +44,8 @@ public class MogoTanluApiProvider implements IMogoTanluProvider { MainService.Companion.launchService(context, new UploadParams(params.getEventType(), params.getFromType(), params.getDuration(), params.getParentId(), params.getLocation().lat, params.getLocation().lon, location.getAddress(), location.getBearing(), location.getAdCode(), location.getCityCode())); - }else{ - Logger.e(API_MODULE_NAME,"params为空,无法上报情报"); + } else { + Logger.e(S_TAG, "params为空,无法上报情报"); } } @@ -54,13 +54,13 @@ public class MogoTanluApiProvider implements IMogoTanluProvider { */ @Override public void startTanluService() { - Logger.d(API_MODULE_NAME, "startTanluService"); + Logger.d(S_TAG, "startTanluService"); MainService.Companion.launchService(context, null); } @Override public void init(Context context) { this.context = context; - Logger.d(API_MODULE_NAME,"新TanluApi模块 init===="); + Logger.d(S_TAG, "新TanluApi模块 init===="); } } diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/StrategyShareProvider.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/StrategyShareProvider.kt index e624b17f29..ff2b6955a4 100644 --- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/StrategyShareProvider.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/StrategyShareProvider.kt @@ -3,30 +3,38 @@ package com.mogo.module.share import android.content.Context +import android.util.ArrayMap import com.alibaba.android.arouter.facade.annotation.Route import com.alibaba.android.arouter.facade.template.IProvider import com.alibaba.android.arouter.launcher.ARouter +import com.mogo.commons.analytics.AnalyticsUtils +import com.mogo.eagle.core.data.constants.MogoServicePaths +import com.mogo.eagle.core.network.utils.GsonUtil +import com.mogo.module.common.MogoApisHandler import com.mogo.module.share.adas.AdasFrontCarDistanceY import com.mogo.module.share.constant.ACCIDENT_STRATEGY_SHARE_PUSH_TYPE import com.mogo.module.share.constant.S_TAG +import com.mogo.module.share.service.MainService.Companion.launchService +import com.mogo.module.share.service.UploadParams import com.mogo.module.share.strategyreceiver.AccidentStrategyReceiver import com.mogo.module.share.strategyreceiver.BlockStrategy import com.mogo.service.IMogoServiceApis -import com.mogo.eagle.core.data.constants.MogoServicePaths -import com.mogo.eagle.core.network.utils.GsonUtil +import com.mogo.service.share.TanluUploadParams import com.mogo.utils.logger.Logger import org.json.JSONObject /** * 策略上报入口,服务端策略上报Push的接收地,接收后再调用tanlu相关接口进行视频抓取 * - * @author tongchenfei + * @author lixiaopeng */ @Route(path = MogoServicePaths.PATH_STRATEGY_SHARE) class StrategyShareProvider : IProvider { private lateinit var blockStrategy: BlockStrategy + private var mContext: Context? = null override fun init(context: Context) { + mContext = context Logger.d(S_TAG, "策略上报Provider初始化====") val apis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(context) as IMogoServiceApis blockStrategy = BlockStrategy(context, apis) @@ -58,5 +66,4 @@ class StrategyShareProvider : IProvider { // } } - } \ No newline at end of file diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/BaseDataComapt.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/BaseDataCompat.kt similarity index 99% rename from modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/BaseDataComapt.kt rename to modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/BaseDataCompat.kt index b64bb56ffc..3aea267196 100644 --- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/BaseDataComapt.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/BaseDataCompat.kt @@ -2,4 +2,5 @@ package com.mogo.module.share.bean import com.mogo.eagle.core.data.BaseData + data class BaseDataCompat(var result:T?): BaseData() \ No newline at end of file diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/base/BaseRepository.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/BaseRepository.kt similarity index 63% rename from modules/tanlulib/src/main/java/com/zhidao/roadcondition/base/BaseRepository.kt rename to modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/BaseRepository.kt index 7b7c1f4d4c..27fe51ae50 100644 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/base/BaseRepository.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/BaseRepository.kt @@ -1,6 +1,4 @@ -package com.zhidao.roadcondition.base - -import com.zhidao.roadcondition.model.BaseResponse +package com.mogo.module.share.bean open class BaseRepository { diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/BaseResponse.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/BaseResponse.kt similarity index 58% rename from modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/BaseResponse.kt rename to modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/BaseResponse.kt index 2010545738..1cb49ca6b1 100644 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/BaseResponse.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/BaseResponse.kt @@ -1,11 +1,12 @@ -package com.zhidao.roadcondition.model +package com.mogo.module.share.bean + +import com.mogo.module.share.constant.HttpConstant -import com.zhidao.roadcondition.constant.HttpConstants class BaseResponse(val code: Int, val msg: String, val result: T) { fun isSuccess(baseUrl: String): Boolean { return when (baseUrl) { - HttpConstants.getBaseUrl() -> true + HttpConstant.getNetHost() -> true else -> false } } diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/CityStrategy.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/CityStrategy.kt similarity index 98% rename from modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/CityStrategy.kt rename to modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/CityStrategy.kt index 1730027756..983432691a 100644 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/CityStrategy.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/CityStrategy.kt @@ -1,4 +1,4 @@ -package com.zhidao.roadcondition.model +package com.mogo.module.share.bean class CityStrategy(video: Video, pic: Pic) { var video: Video? = video diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/InformationBody.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/InformationBody.kt similarity index 94% rename from modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/InformationBody.kt rename to modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/InformationBody.kt index 950b41f760..fea9941f1d 100644 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/InformationBody.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/InformationBody.kt @@ -1,4 +1,4 @@ -package com.zhidao.roadcondition.model +package com.mogo.module.share.bean data class InformationBody( val data: String, diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/LocationInfo.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/LocationInfo.kt similarity index 97% rename from modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/LocationInfo.kt rename to modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/LocationInfo.kt index 72df4112cc..8966c5038b 100644 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/LocationInfo.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/LocationInfo.kt @@ -1,4 +1,4 @@ -package com.zhidao.roadcondition.model +package com.mogo.module.share.bean import com.mogo.eagle.core.data.map.MogoLatLng diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/Results.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/Results.kt new file mode 100644 index 0000000000..098ddadb32 --- /dev/null +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/Results.kt @@ -0,0 +1,3 @@ +package com.mogo.module.share.bean + +class Results(var cityStrategy: CityStrategy) \ No newline at end of file diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/StrategyServiceModel.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/StrategyServiceModel.kt similarity index 52% rename from modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/StrategyServiceModel.kt rename to modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/StrategyServiceModel.kt index 92e0a59301..cbace185d8 100644 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/StrategyServiceModel.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/StrategyServiceModel.kt @@ -1,12 +1,10 @@ -package com.zhidao.roadcondition.model +package com.mogo.module.share.bean -import android.util.Log import com.google.gson.Gson import com.mogo.cloud.passport.MoGoAiCloudClientConfig import com.mogo.module.common.constants.HostConst -import com.zhidao.roadcondition.base.BaseRepository -import com.zhidao.roadcondition.net.HttpClient -import com.zhidao.roadcondition.util.LocationUtil +import com.mogo.module.share.net.HttpClient +import com.mogo.module.share.utils.LocationUtil class StrategyServiceModel : BaseRepository() { @@ -26,12 +24,4 @@ class StrategyServiceModel : BaseRepository() { } } - suspend fun uploadInformation(informationBody: InformationBody): BaseResponse { - return apiCall { - val informationBodyStr = Gson().toJson(informationBody) - Log.d("MainServiceController", "uploadInformation informationBody = $informationBodyStr") - HttpClient.getInstance(HostConst.DEVA_HOST).getHttpApi() - .uploadInformation(mapOf("sn" to MoGoAiCloudClientConfig.getInstance().getSn(), "data" to informationBodyStr)) - } - } } \ No newline at end of file diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/VoiceCmdData.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/VoiceCmdData.kt index 5532eb7524..33370c5357 100644 --- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/VoiceCmdData.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/VoiceCmdData.kt @@ -1,6 +1,5 @@ package com.mogo.module.share.bean -import com.mogo.module.share.constant.* import com.mogo.module.share.constant.ShareConstants.* diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/event/GetImageSuccessEvent.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/event/GetImageSuccessEvent.kt similarity index 91% rename from modules/tanlulib/src/main/java/com/zhidao/roadcondition/event/GetImageSuccessEvent.kt rename to modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/event/GetImageSuccessEvent.kt index 155c3ebea5..5bf69ce159 100644 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/event/GetImageSuccessEvent.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/event/GetImageSuccessEvent.kt @@ -1,4 +1,4 @@ -package com.zhidao.roadcondition.event +package com.mogo.module.share.bean.event /** diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/event/LatLngStickyEventBus.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/event/LatLngStickyEventBus.kt similarity index 89% rename from modules/tanlulib/src/main/java/com/zhidao/roadcondition/event/LatLngStickyEventBus.kt rename to modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/event/LatLngStickyEventBus.kt index e134c22d73..a087c35452 100644 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/event/LatLngStickyEventBus.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/event/LatLngStickyEventBus.kt @@ -1,4 +1,4 @@ -package com.zhidao.roadcondition.event +package com.mogo.module.share.bean.event import org.greenrobot.eventbus.EventBus diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/constant/ShareConstants.java b/modules/mogo-module-share/src/main/java/com/mogo/module/share/constant/ShareConstants.java index e9abfd429b..d0736ea534 100644 --- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/constant/ShareConstants.java +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/constant/ShareConstants.java @@ -29,6 +29,7 @@ public class ShareConstants { public static final String TAG = "/tanlu/ui"; public static final String NAVI_INFO = "navi_info"; public static final String MODEL_NAME = "CARD_TYPE_ROAD_CONDITION"; + public static final String TANLU = "TanLu"; /** * 免唤醒词上报拥堵 diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/constant/StrategyShareConst.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/constant/StrategyShareConst.kt index 5866b734f9..aa47aea15f 100644 --- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/constant/StrategyShareConst.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/constant/StrategyShareConst.kt @@ -5,4 +5,44 @@ const val S_TAG = "StrategyShare" /** * 目前两个策略上报(事故,拥堵)都是走的这个push */ -const val ACCIDENT_STRATEGY_SHARE_PUSH_TYPE = 401013 \ No newline at end of file +const val ACCIDENT_STRATEGY_SHARE_PUSH_TYPE = 401013 + +const val TANLU_ROAD_CURRENT = "10015" //实时路况 + +/** + * 默认视频抓取时长,单位是秒 + */ +const val DEFAULT_VIDEO_DURATION = 10 + +/** + * 数据策略:交通事故上报 + */ +const val UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO = "5" + +/** + * 数据策略:已有事件云端校验 + */ +const val UPLOAD_FROM_STRATEGY_CLOUD_CHECK = "4" + +/** + * 数据策略:拥堵自动上报 + */ +const val UPLOAD_FROM_STRATEGY_BLOCK_AUTO = "3" + +/** + * 策略上报集合 + */ +val STRATEGY_UPLOAD_TYPE_ARRAY = arrayOf(UPLOAD_FROM_STRATEGY_BLOCK_AUTO, + UPLOAD_FROM_STRATEGY_CLOUD_CHECK, UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO) + +val AlarmTypePic: Int = 1 //定时任务类型 1照片 +val AlarmTypeVideo: Int = 2 //定时任务类型 2视频 + +val alarmBroadAction: String = "com.zhidao.roadCondition.AlarmBroadCast" //定时广播 +val sendInformationAction: String = "com.zhidao.roadCondition.SendInformation" //主动上报广播 +val customResultAction: String = "com.zhidao.roadCondition.CustomResult" //主动上报结果广播 + +const val INFO_TYPE_IMG = 0 //图片 +const val INFO_TYPE_VIDEO = 1 +const val INFO_TYPE_VOICE = 2 +const val INFO_TYPE_WORD = 3 diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/net/HttpApi.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/net/HttpApi.kt new file mode 100644 index 0000000000..bf687dbc40 --- /dev/null +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/net/HttpApi.kt @@ -0,0 +1,16 @@ +package com.mogo.module.share.net + +import com.mogo.module.share.bean.BaseResponse +import com.mogo.module.share.bean.Results +import retrofit2.http.* + +/** + * 接口声明 + */ +interface HttpApi { + //获取城市策略 + @FormUrlEncoded + @POST("yycp-geo-fence-carService/car/carStrategy/no/getCityStrategy/v1") + suspend fun getCityStrategy(@FieldMap cityStrategy: Map): BaseResponse + +} \ No newline at end of file diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/net/HttpClient.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/net/HttpClient.kt similarity index 95% rename from modules/tanlulib/src/main/java/com/zhidao/roadcondition/net/HttpClient.kt rename to modules/mogo-module-share/src/main/java/com/mogo/module/share/net/HttpClient.kt index 814a7e21c4..e89ea83ec9 100644 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/net/HttpClient.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/net/HttpClient.kt @@ -1,8 +1,8 @@ -package com.zhidao.roadcondition.net +package com.mogo.module.share.net import com.mogo.commons.AbsMogoApplication import com.mogo.eagle.core.network.NetConfig -import com.zhidao.roadcondition.constant.HttpConstants +import com.mogo.module.share.constant.HttpConstant import okhttp3.Cache import okhttp3.Dns import okhttp3.OkHttpClient @@ -24,7 +24,7 @@ class HttpClient private constructor(baseUrl: String) { private var baseUrlClientMap = HashMap() fun getInstance(): HttpClient { - val baseUrl = HttpConstants.getBaseUrl() + val baseUrl = HttpConstant.getNetHost() var httpClient = baseUrlClientMap[baseUrl] if (httpClient == null) { synchronized(HttpClient::class.java) { diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/net/ShareLsApiService.java b/modules/mogo-module-share/src/main/java/com/mogo/module/share/net/ShareLsApiService.java deleted file mode 100644 index 68aca43ab5..0000000000 --- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/net/ShareLsApiService.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.mogo.module.share.net; - -import com.mogo.module.share.bean.BaseDataCompat; -import com.mogo.module.share.bean.RoadInfos; - -import java.util.Map; - -import io.reactivex.Observable; -import retrofit2.http.FieldMap; -import retrofit2.http.FormUrlEncoded; -import retrofit2.http.POST; - -public interface ShareLsApiService { - /** - * 查询(搜索)道路事件信息 - * 接口文档:http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=42305842 - * 文档中有些参数暂时没有用到,包括radius,limit - * - * @return - */ -// @FormUrlEncoded -// @POST("/yycp-launcherSnapshot/launcherSnapshot/searchRoadEventsSync") -// Observable> queryRoadInfos(@FieldMap Map params); - -} diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/CarCorderController.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/service/CarCorderController.kt similarity index 67% rename from modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/CarCorderController.kt rename to modules/mogo-module-share/src/main/java/com/mogo/module/share/service/CarCorderController.kt index 7c30cbfcc9..80bc2002e3 100644 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/CarCorderController.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/service/CarCorderController.kt @@ -1,7 +1,6 @@ -package com.zhidao.roadcondition.service +package com.mogo.module.share.service import android.text.TextUtils -import android.util.Log import com.hw.videoprocessor.VideoProcessor import com.mogo.cloud.network.BaseData import com.mogo.cloud.passport.MoGoAiCloudClientConfig @@ -11,17 +10,19 @@ import com.mogo.cloud.tanlu.bean.UploadInfo import com.mogo.cloud.tanlu.bean.UploadResult import com.mogo.commons.AbsMogoApplication import com.mogo.commons.debug.DebugConfig +import com.mogo.module.share.bean.event.GetImageSuccessEvent +import com.mogo.module.share.bean.event.LatLngStickyEventBus +import com.mogo.module.share.constant.STRATEGY_UPLOAD_TYPE_ARRAY +import com.mogo.module.share.constant.ShareConstants.TANLU +import com.mogo.module.share.utils.* +import com.mogo.module.share.utils.StrategyPreferenceUtil.Companion.getStrategyMaxSpeed +import com.mogo.module.share.utils.StrategyPreferenceUtil.Companion.getStrategyMinSpeed +import com.mogo.module.share.utils.StrategyPreferenceUtil.Companion.getStrategyType import com.mogo.utils.NetworkUtils +import com.mogo.utils.logger.Logger import com.zhidao.auto.carcorder.callback.TakePhotoCallback import com.zhidao.auto.carcorder.callback.TakeVideoCallback import com.zhidao.auto.carcorder.controller.ZdCarCoderController -import com.zhidao.roadcondition.constant.STRATEGY_UPLOAD_TYPE_ARRAY -import com.zhidao.roadcondition.event.GetImageSuccessEvent -import com.zhidao.roadcondition.event.LatLngStickyEventBus -import com.zhidao.roadcondition.util.* -import com.zhidao.roadcondition.util.StrategyPreferenceUtil.Companion.getStrategyMaxSpeed -import com.zhidao.roadcondition.util.StrategyPreferenceUtil.Companion.getStrategyMinSpeed -import com.zhidao.roadcondition.util.StrategyPreferenceUtil.Companion.getStrategyType import java.io.File import kotlin.math.abs @@ -32,7 +33,6 @@ import kotlin.math.abs * @since 2019-10-30 */ object CarCorderController : TakePhotoCallback, TakeVideoCallback { - const val TAG: String = "CarCorderController" private lateinit var zdCarCoderController: ZdCarCoderController private var outputVideoPath: String = "" private var mType: String = "" //1 上报拥堵, 2 封路和查车 @@ -49,24 +49,11 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { private var getVideoFailed: (() -> Unit)? = null - private var interceptors: ArrayList = ArrayList(1) fun getVideoFailed(getVideoFailed: (() -> Unit)) { this.getVideoFailed = getVideoFailed } - fun registerTakePhotoInterceptor(interceptor: TakePhotoInterceptor) { - interceptor.apply { - interceptors.add(this) - } - } - - fun unregisterTakePhotoInterceptor(interceptor: TakePhotoInterceptor) { - interceptor.apply { - interceptors.remove(interceptor) - } - } - fun initCarCorderController() { try { zdCarCoderController = @@ -96,7 +83,7 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { areaCode: String, cityCode: String ) { - Log.d(TAG, "takePhoto ---------- type = $type --- mType = $mType ---fromType = $fromType") + Logger.d(TANLU, "takePhoto ---------- type = $type --- mType = $mType ---fromType = $fromType") this.mType = type this.mainInfoId = mainInfoId this.mFromType = fromType @@ -133,7 +120,7 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { areaCode: String, cityCode: String ) { - Log.d(TAG, "takeVideo -------- isCustom = $isCustom ---mFromType = $mFromType ---type = $type ---speed = $speed") + Logger.d(TANLU, "takeVideo -------- isCustom = $isCustom ---mFromType = $mFromType ---type = $type ---speed = $speed") this.mType = type this.mainInfoId = mainInfoId this.mFromType = fromType @@ -151,26 +138,7 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { zdCarCoderController.takeVideo(cameraId, duration) trackGetVideo(1) } else { //比亚迪 - Log.d(TAG, "takeVideo ------ isnet = " + NetworkUtils.isConnected(AbsMogoApplication.getApp().applicationContext)) -// if (!NetworkUtils.isConnected(AbsMogoApplication.getApp().applicationContext)) { -// TipToast.shortTip("分享失败,请检查网络") -// } else { - //失败了,传空地址,发起请求 -// videoAndThumbMap["video"] = "" -// videoAndThumbMap["thumb"] = "" - -// CosStatusController().sendInformationDirectly( -// INFO_TYPE_VIDEO, -// videoAndThumbMap, -// mType, -// entity, -// mainInfoId, -// mLongitude, -// mLatitude, -// mSpeed, -// mFromType -// ) - + Logger.d(TANLU, "takeVideo ------ isnet = " + NetworkUtils.isConnected(AbsMogoApplication.getApp().applicationContext)) getInfo("", mAddress, mLongitude, mLatitude, mType, mDirection, mAreaCode, mCityCode, 1, mFromType, CarCorderController.mainInfoId)?.let { uploadRoadInfo(it) } //地图上打点 @@ -188,31 +156,15 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { fun release() { zdCarCoderController.release() - interceptors.clear() } //拍照失败回调 override fun onTakePhotoFail(photoType: Int, camera: Int) { trackGetPhoto(3) - interceptors.forEach { - it.onTakePhotoFail(photoType, camera) - } val isCustom = CustomStatusHandler.pollPhotoStatus() - Log.e(TAG, "onTakePhotoFail -----mType = $mType --- isCustom = $isCustom") + Logger.e(TANLU, "onTakePhotoFail -----mType = $mType --- isCustom = $isCustom") //获取图片失败也上报,图片不打点 if (isCustom) { -// CosStatusController().sendInformationDirectly( -// INFO_TYPE_IMG, -// mutableMapOf("pic" to ""), -// mType, -// entity, -// mainInfoId, -// mLongitude, -// mLatitude, -// mSpeed, -// mFromType -// ) - getInfo("", mAddress, mLongitude, mLatitude, mType, mDirection, mAreaCode, mCityCode, 0, mFromType, mainInfoId)?.let { uploadRoadInfo(it) } } @@ -222,7 +174,7 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { //拍照成功回调返回图片本地路径 override fun onTakePhotoSuccess(photoType: Int, camera: Int, photoPath: String?) { trackGetPhoto(2) - Log.d(TAG, "onTakePhotoSuccess -----mType = $mType --- mainInfoId = $mainInfoId") + Logger.d(TANLU, "onTakePhotoSuccess -----mType = $mType --- mainInfoId = $mainInfoId") val isCustom = CustomStatusHandler.pollPhotoStatus() if (!isCustom) { @@ -230,10 +182,6 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { } var interceptor = false - interceptors.forEach { - interceptor = it.intercept() - it.onTakePhotoSuccess(photoType, camera, photoPath) - } if (interceptor) { return } @@ -253,34 +201,20 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { val speed = LocationUtil.getInstance().getSpeed() if (!TextUtils.isEmpty(mType)) { - Log.d(TAG, "onTakePhotoSuccess mType != null") -// CosStatusController().uploadFile(mutableListOf(photoPath as String), entity, mType, mainInfoId, mFromType, mLongitude, -// mLatitude, mSpeed) - + Logger.d(TANLU, "onTakePhotoSuccess mType != null") if (photoPath != null) { getInfo(photoPath, mAddress, mLongitude, mLatitude, mType, mDirection, mAreaCode, mCityCode, 0, mFromType, mainInfoId)?.let { uploadRoadInfo(it) } } } else { - Log.d(TAG, "onTakePhotoSuccess mType == null") - Log.d( - TAG, + Logger.d(TANLU, "onTakePhotoSuccess mType == null") + Logger.d( + TANLU, "onTakePhotoSuccess maxSpeedPic = $maxSpeedPic ---> speed = $speed ---->minSpeedPic= $minSpeedPic" ) if (maxSpeedPic == -1) { if (speed >= (abs(minSpeedPic) / 3.6f)) { - Log.d(TAG, "onTakePhotoSuccess abs =" + (abs(minSpeedPic) / 3.6f)) -// CosStatusController().uploadFile( -// mutableListOf(photoPath as String), -// entity, -// mType, -// mainInfoId, -// mFromType, -// mLongitude, -// mLatitude, -// mSpeed -// ) - + Logger.d(TANLU, "onTakePhotoSuccess abs =" + (abs(minSpeedPic) / 3.6f)) if (photoPath != null) { getInfo(photoPath, mAddress, mLongitude, mLatitude, mType, mDirection, mAreaCode, mCityCode, 0, mFromType, mainInfoId)?.let { uploadRoadInfo(it) } } @@ -288,36 +222,23 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { } if (minSpeedPic > 0 && maxSpeedPic > 0) { - Log.d(TAG, "onTakePhotoSuccess minSpeedPic > 0 -- speed = $speed") + Logger.d(TANLU, "onTakePhotoSuccess minSpeedPic > 0 -- speed = $speed") if ((speed >= (minSpeedPic / 3.6f)) && speed <= (maxSpeedPic / 3.6f)) { -// CosStatusController().uploadFile( -// mutableListOf(photoPath as String), -// entity, -// mType, -// mainInfoId, -// mFromType, -// mLongitude, -// mLatitude, -// mSpeed -// ) - if (photoPath != null) { getInfo(photoPath, mAddress, mLongitude, mLatitude, mType, mDirection, mAreaCode, mCityCode, 0, mFromType, mainInfoId)?.let { uploadRoadInfo(it) } } - } } } } - //获取视频成功 override fun onTakeVideoSuccess(camera: Int, videoPath: String?) { val thumbnailPath = AbsMogoApplication.getApp().applicationContext.filesDir.parent + File.separator + "Thumbnail${System.currentTimeMillis()}.jpg" val isSuccess = getVideoThumbnail(videoPath!!, thumbnailPath) - Log.d( - TAG, + Logger.d( + TANLU, "getVideo onTakeVideoSuccess===$videoPath -----> isSuccess= $isSuccess ----> mType = $mType --- mainInfoId = $mainInfoId" ) @@ -349,12 +270,12 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { compressVideo(videoPath, thumbnailPath, it) } else { - Log.d( - TAG, + Logger.d( + TANLU, "onTakeVideoSuccess maxSpeedVideo = $maxSpeedVideo --->speed= $speed + minSpeedVideo = $minSpeedVideo" ) if (maxSpeedVideo == -1) { - Log.d(TAG, "onTakeVideoSuccess 111 abs =" + (abs(minSpeedVideo) / 3.6f)) + Logger.d(TANLU, "onTakeVideoSuccess 111 abs =" + (abs(minSpeedVideo) / 3.6f)) if (speed >= (abs(minSpeedVideo) / 3.6f)) { //获取视频以及缩略图成功,开始上报 compressVideo(videoPath, thumbnailPath, it) @@ -362,7 +283,7 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { } if (minSpeedVideo > 0 && maxSpeedVideo > 0) { - Log.d(TAG, "onTakeVideoSuccess minSpeedVideo > 0 -- speed = $speed") + Logger.d(TANLU, "onTakeVideoSuccess minSpeedVideo > 0 -- speed = $speed") if ((speed >= (minSpeedVideo / 3.6f)) && speed <= (maxSpeedVideo / 3.6f)) { compressVideo(videoPath, thumbnailPath, it) } else { @@ -371,7 +292,6 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { } } } - trackGetVideo(2) } } @@ -380,35 +300,6 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { //获取视频失败 override fun onTakeVideoFail(camera: Int) { -// trackGetVideo(3) -// Log.e(TAG, "getVideo onTakeVideoFail") -// getVideoFailed?.invoke() -// val entity = CustomStatusHandler.pollVideoStatus() -// -// entity?.let { -// InformationUploadController.release(it.id) -// Log.e(TAG, "getVideo onTakeVideoFail entity?.isCustom =" + it.isCustom) -//// if (it.isCustom) { -//// sendGetInfoFailedReceiver(mType) -//// } -// } - - //失败了,传空地址,发起请求 -// videoAndThumbMap["video"] = "" -// videoAndThumbMap["thumb"] = "" - -// CosStatusController().sendInformationDirectly( -// INFO_TYPE_VIDEO, -// videoAndThumbMap, -// mType, -// entity, -// mainInfoId, -// mLongitude, -// mLatitude, -// mSpeed, -// mFromType -// ) - getInfo("", mAddress, mLongitude, mLatitude, mType, mDirection, mAreaCode, mCityCode, 1, mFromType, mainInfoId)?.let { uploadRoadInfo(it) } //地图上打点 @@ -425,8 +316,8 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { * 压缩视频并且上传 */ private fun compressVideo(videoPath: String, thumbnailPath: String, entity: TakeEntity) { - Log.d( - TAG, + Logger.d( + TANLU, "outputVideoPath = " + outputVideoPath + ">> videoPath=" + videoPath + " isCustom = ${entity.isCustom}" ) val startTime = System.currentTimeMillis() @@ -441,24 +332,12 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { .bitrate(2000 * 1024) .frameRate(25) .process() - Log.d(TAG, "compress cost time =" + (System.currentTimeMillis() - startTime)) -// CosStatusController().uploadFile( -// mutableListOf(outputVideoPath, thumbnailPath), -// entity, -// mType, -// mainInfoId, -// mFromType, -// mLongitude, -// mLatitude, -// mSpeed -// ) - + Logger.d(TANLU, "compress cost time =" + (System.currentTimeMillis() - startTime)) getInfo(outputVideoPath, mAddress, mLongitude, mLatitude, mType, mDirection, mAreaCode, mCityCode, 1, mFromType, mainInfoId)?.let { uploadRoadInfo(it) } - //删除压缩前的视频 deletePicFile(videoPath) } catch (e: Exception) { - Log.e(TAG, "compressVideo e = $e") + Logger.e(TANLU, "compressVideo e = $e") //删除压缩前的视频 deletePicFile(videoPath) e.printStackTrace() @@ -473,16 +352,16 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { MogoUploadManager.getInstance(AbsMogoApplication.getApp().applicationContext).uploadInfo(info, object : ITanluUploadCallback { override fun onSuccess(result: BaseData) { if (result.result != null) { - Log.d(TAG, "result =" + result.result); + Logger.d(TANLU, "result =" + result.result) } } override fun onFailure(code: Int) { - + Logger.e(TANLU, "onFailure code = $code") } override fun onError(e: Throwable) { - + Logger.e(TANLU, "onError e = $e") } }) } @@ -509,29 +388,16 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { } override fun onTakePhotoCancel(photoType: Int, camera: Int) { - Log.d(TAG, "onTakePhotoCancel -----photoType = $photoType") + Logger.d(TANLU, "onTakePhotoCancel -----photoType = $photoType") } override fun onTakeVideoCancel(camera: Int) { - Log.d(TAG, "onTakeVideoCancel -----camera = $camera") + Logger.d(TANLU, "onTakeVideoCancel -----camera = $camera") //失败了,传空地址,发起请求 videoAndThumbMap["video"] = "" videoAndThumbMap["thumb"] = "" -// CosStatusController().sendInformationDirectly( -// INFO_TYPE_VIDEO, -// videoAndThumbMap, -// mType, -// entity, -// mainInfoId, -// mLongitude, -// mLatitude, -// mSpeed, -// mFromType -// ) - getInfo("", mAddress, mLongitude, mLatitude, mType, mDirection, mAreaCode, mCityCode, 1, mFromType, mainInfoId)?.let { uploadRoadInfo(it) } - } //获取图片 diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/CustomStatusHandler.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/service/CustomStatusHandler.kt similarity index 91% rename from modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/CustomStatusHandler.kt rename to modules/mogo-module-share/src/main/java/com/mogo/module/share/service/CustomStatusHandler.kt index 9078589718..13393f297a 100644 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/CustomStatusHandler.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/service/CustomStatusHandler.kt @@ -1,9 +1,9 @@ -package com.zhidao.roadcondition.service +package com.mogo.module.share.service import java.util.* /** - * @author congtaowang + * @author lixiaopeng * @since 2019-11-25 * * 拍照、拍视频手动、被动状态队列 diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/MainService.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/service/MainService.kt similarity index 80% rename from modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/MainService.kt rename to modules/mogo-module-share/src/main/java/com/mogo/module/share/service/MainService.kt index 29b6cb025a..2ef1939bd5 100644 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/MainService.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/service/MainService.kt @@ -1,4 +1,4 @@ -package com.zhidao.roadcondition.service +package com.mogo.module.share.service import android.app.AlarmManager import android.app.PendingIntent @@ -8,7 +8,6 @@ import android.content.Context 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 @@ -16,21 +15,19 @@ import com.mogo.commons.debug.DebugConfig import com.mogo.module.common.MogoApisHandler import com.mogo.service.IMogoServiceApis import com.mogo.eagle.core.data.constants.MogoServicePaths +import com.mogo.module.share.bean.event.GetImageSuccessEvent +import com.mogo.module.share.bean.event.LatLngStickyEventBus import com.mogo.utils.logger.Logger import com.mogo.utils.storage.SharedPrefsMgr import com.zhidao.cosupload.manager.CosUploadManagerImpl -import com.zhidao.roadcondition.BuildConfig -import com.zhidao.roadcondition.constant.DEFAULT_VIDEO_DURATION -import com.zhidao.roadcondition.constant.TANLU_ROAD_CURRENT -import com.zhidao.roadcondition.constant.UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO -import com.zhidao.roadcondition.constant.UPLOAD_FROM_STRATEGY_BLOCK_AUTO -import com.zhidao.roadcondition.event.GetImageSuccessEvent -import com.zhidao.roadcondition.event.LatLngStickyEventBus -import com.zhidao.roadcondition.util.* -import com.zhidao.roadcondition.util.StrategyPreferenceUtil.Companion.clearStrategyType -import com.zhidao.roadcondition.util.StrategyPreferenceUtil.Companion.getStrategyFrequency -import com.zhidao.roadcondition.util.StrategyPreferenceUtil.Companion.getStrategyInterval -import com.zhidao.roadcondition.util.StrategyPreferenceUtil.Companion.getStrategyType +import com.mogo.module.share.BuildConfig +import com.mogo.module.share.constant.* +import com.mogo.module.share.constant.ShareConstants.TANLU +import com.mogo.module.share.utils.* +import com.mogo.module.share.utils.StrategyPreferenceUtil.Companion.clearStrategyType +import com.mogo.module.share.utils.StrategyPreferenceUtil.Companion.getStrategyFrequency +import com.mogo.module.share.utils.StrategyPreferenceUtil.Companion.getStrategyInterval +import com.mogo.module.share.utils.StrategyPreferenceUtil.Companion.getStrategyType import io.reactivex.Observable import io.reactivex.android.schedulers.AndroidSchedulers import org.greenrobot.eventbus.Subscribe @@ -45,9 +42,8 @@ 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") + Logger.d(TANLU, "launch type = $params") putExtra("params", params) } context.startService(intent) @@ -60,8 +56,6 @@ class MainService : Service() { //是否已经获取过策略 var isGetStrategies: Boolean = false - private val TAG: String = this.javaClass.simpleName - //1是一次性,2是周期性 private var picType: Int = 0 private var videoType: Int = 0 @@ -75,11 +69,11 @@ class MainService : Service() { private var mLongitude: Double = 0.0 private var mLatitude: Double = 0.0 private lateinit var serviceApis: IMogoServiceApis - private var mAddress: String = "" private var mDirection: Float = 0f private var mAreaCode: String = "" private var mCityCode: String = "" + private var id: Long = System.currentTimeMillis() override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { @@ -94,7 +88,7 @@ class MainService : Service() { if (serviceApis.mapServiceApi.getSingletonLocationClient(this) != null && serviceApis.mapServiceApi.getSingletonLocationClient(this).lastKnowLocation != null) { speed = serviceApis.mapServiceApi.getSingletonLocationClient(this).lastKnowLocation.speed - Log.d(TAG, "onStartCommand speed = $speed") + Logger.d(TANLU, "onStartCommand speed = $speed") } if (intent != null) { @@ -110,7 +104,7 @@ class MainService : Service() { mAreaCode = it.areaCode mCityCode = it.cityCode - Log.d(TAG, "onStartCommand shareType = $shareType --fromType = $fromType --mainInfoId = $mainInfoId -- mLongitude = $mLongitude --mLatitude = $mLatitude --it.duration = ${it.duration} ") + Logger.d(TANLU, "onStartCommand shareType = $shareType --fromType = $fromType --mainInfoId = $mainInfoId -- mLongitude = $mLongitude --mLatitude = $mLatitude --it.duration = ${it.duration} ") if (fromType == UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO || fromType == UPLOAD_FROM_STRATEGY_BLOCK_AUTO) { // 如果是策略上报,isCustom = false takeVideo(it.duration) @@ -119,7 +113,7 @@ class MainService : Service() { } } } else { - Log.e(TAG, "intent == null ") + Logger.e(TANLU, "intent == null ") } return super.onStartCommand(intent, flags, startId) @@ -128,7 +122,7 @@ class MainService : Service() { //定时任务回调广播 private var mAlarmBroadCast: BroadcastReceiver = object : BroadcastReceiver() { override fun onReceive(p0: Context?, p1: Intent) { - Log.d(TAG, "receive alarm!!!!!!!!!!AlarmType===${p1.getIntExtra("AlarmType", 1)}") + Logger.d(TANLU, "receive alarm!!!!!!!!!!AlarmType===${p1.getIntExtra("AlarmType", 1)}") if (p1.action == alarmBroadAction) { if (p1.getIntExtra("AlarmType", 1) == AlarmTypePic) { //拍照 @@ -164,7 +158,6 @@ class MainService : Service() { LocationUtil.getInstance().initLocation() initLocationListener() - loadConfigurations() LatLngStickyEventBus.getInstance().register(this) trackNormalEvent(CarNet_MainService_Start, null) } @@ -174,45 +167,23 @@ class MainService : Service() { CarCorderController.initCarCorderController() mainServiceHttpModel = MainServiceController() registReceiver() -// CosStatusController().registerCos(this) - CosCallbackMapController.init(this) +// CosCallbackMapController.init(this) } - /** - * 加载各种配置 - */ - private fun loadConfigurations() { -// mainServiceHttpModel.getAuthorization() -// mainServiceHttpModel.getNeedAuth { authStatus -> -// // isNeedAuth = authStatus -// } -// mainServiceHttpModel.getSplashConfig() - } - - private var id: Long = System.currentTimeMillis() - /** * 获取图片成功 */ @Subscribe(threadMode = ThreadMode.MAIN, sticky = true, priority = 98) fun getImageEvent(getImageSuccessEvent: GetImageSuccessEvent) { val info = LocationUtil.getInstance().getLocationInfo() - Log.d("MainService", "getImageEvent long = ${info.longitude} ----> lat= ${info.latitude}") - Log.d( - "MainService", + Logger.d(TANLU, "getImageEvent long = ${info.longitude} ----> lat= ${info.latitude}") + Logger.d(TANLU, "getImageEvent url = " + getImageSuccessEvent.getImageUrl() + ">>>>type =" + getImageSuccessEvent.getType() ) if (!DebugConfig.isMapBased()) { MogoApisHandler.getInstance().apis.statusManagerApi.setUploadingStatus("CARD_TYPE_ROAD_CONDITION", false) } - -// sendMarkerInfoReceiver( -// info.latitude, -// info.longitude, -// getImageSuccessEvent.getImageUrl(), -// getImageSuccessEvent.getType() -// ) } @@ -221,7 +192,7 @@ class MainService : Service() { */ private fun initLocationListener() { val isOpen = SharedPrefsMgr.getInstance(AbsMogoApplication.getApp().applicationContext).getBoolean("KEY_SERVER_REPORTSTRATEGY_SWITCH", false) - Logger.d("EntrancePresenter", " initLocationListener ---- isOpen = $isOpen") + Logger.d(TANLU, " initLocationListener ---- isOpen = $isOpen") //开始开始监听速度,只要超过一次5公里每小时则即开始获取策略进行本地上报 只有release才加此判断,qa环境方便测试 LocationUtil.getInstance().setonSpeedlistenner(object : LocationUtil.SpeedListener { override fun onSpeedGet(speed: Float) { @@ -230,7 +201,7 @@ class MainService : Service() { mainServiceHttpModel.initStrategies { handleReportStrategy() } - Log.d("MainService", "initLocationListener more than 5 start upload speed = $speed") + Logger.d(TANLU, "initLocationListener more than 5 start upload speed = $speed") isGetStrategies = true } } @@ -253,7 +224,7 @@ class MainService : Service() { "video", getStrategyType("video") ) - Log.d("MainService", "handleReportStrategy picType = $picType ---videoType = $videoType") + Logger.d(TANLU, "handleReportStrategy picType = $picType ---videoType = $videoType") shareType = TANLU_ROAD_CURRENT if (picType == 1) { takePhoto() @@ -275,14 +246,11 @@ class MainService : Service() { intentFilter.addAction("com.zhidao.takevideo.test") intentFilter.addAction("com.zhidao.takepic.test") registerReceiver(mAlarmBroadCast, intentFilter) - //注册主动上报广播 -// var customSendIntentFilter = IntentFilter(sendInformationAction) -// registerReceiver(mCustomSendBroadCast, customSendIntentFilter) } //获取图片 private fun takePhoto(isInterval: Boolean = false, isCustom: Boolean = false) { - Log.d("MainService", "takePhoto -----1----->") + Logger.d(TANLU, "takePhoto -----1----->") //判断是否授权 // if (isAuthorization(BaseApplication.getAppContext())) { //目前不支持连拍,只能定时2秒拍一张 第一期每次只拍一张 @@ -305,7 +273,7 @@ class MainService : Service() { isCustom: Boolean = false, id: Long = 0 ) { - Log.d("MainService", "takeVideo --------1----> fromType = $fromType --isCustom = $isCustom") + Logger.d(TANLU, "takeVideo --------1----> fromType = $fromType --isCustom = $isCustom") // if (isAuthorization(BaseApplication.getAppContext())) { CarCorderController.takeVideo(1, duration, isCustom, id, shareType, mainInfoId, fromType, mLongitude, mLatitude, speed, mAddress, mDirection, mAreaCode, mCityCode) // } @@ -322,8 +290,7 @@ class MainService : Service() { intent.putExtra("number", getLong(PIC_NUMBER, PIC_NUMBER_DEFAULT)) intent.putExtra("AlarmType", AlarmTypePic) val pendingIntent = PendingIntent.getBroadcast(this, AlarmTypePic, intent, 0) - Log.d( - "MainService", + Logger.d(TANLU, "postPhotoAlarmTask time =" + getStrategyInterval( AbsMogoApplication.getApp().applicationContext, "pic", @@ -355,8 +322,7 @@ class MainService : Service() { videoIntent.putExtra("AlarmType", AlarmTypeVideo) val videoPendingIntent = PendingIntent.getBroadcast(this, AlarmTypeVideo, videoIntent, 0) - Log.d( - "MainService", + Logger.d(TANLU, "postVideoAlarmTask time =" + getStrategyInterval( AbsMogoApplication.getApp().applicationContext, "video", @@ -381,7 +347,7 @@ class MainService : Service() { unregisterReceiver(mAlarmBroadCast) // unregisterReceiver(mCustomSendBroadCast) CarCorderController.release() - CosCallbackMapController.release() +// CosCallbackMapController.release() LatLngStickyEventBus.getInstance().unregister(this) LatLngStickyEventBus.getInstance().removeAllStickyEvents() trackNormalEvent(CarNet_MainService_Destory, null) diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/service/MainServiceController.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/service/MainServiceController.kt new file mode 100644 index 0000000000..9b11decda4 --- /dev/null +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/service/MainServiceController.kt @@ -0,0 +1,259 @@ +package com.mogo.module.share.service + +import com.mogo.commons.AbsMogoApplication +import com.mogo.eagle.core.network.request +import com.mogo.module.share.bean.* +import com.mogo.module.share.constant.ShareConstants +import com.mogo.module.share.constant.ShareConstants.TANLU +import com.mogo.module.share.utils.CarNet_Get_Strategy +import com.mogo.module.share.utils.StrategyPreferenceUtil.Companion.setStrategyFrequency +import com.mogo.module.share.utils.StrategyPreferenceUtil.Companion.setStrategyInterval +import com.mogo.module.share.utils.StrategyPreferenceUtil.Companion.setStrategyMaxSpeed +import com.mogo.module.share.utils.StrategyPreferenceUtil.Companion.setStrategyMinSpeed +import com.mogo.module.share.utils.StrategyPreferenceUtil.Companion.setStrategyType +import com.mogo.module.share.utils.StrategyPreferenceUtil.Companion.setStrategyValidity +import com.mogo.module.share.utils.trackNormalEvent +import com.mogo.utils.logger.Logger +import kotlinx.coroutines.launch +import kotlinx.coroutines.runBlocking + +class MainServiceController { + + companion object { +// const val TAG = "MainServiceController" + } + + //逆地理编码是否重试 + private var geoRetry = false + private var mFromType: String = "" + private var mPoiType: String = "" + + private val strategyModel by lazy { StrategyServiceModel() } + + fun initStrategies(initFinish: (() -> Unit)? = null) { + request> { + loader { + strategyModel.getCityStrategy() + } + onSuccess { + it.result.let { strategy -> + trackNormalEvent(CarNet_Get_Strategy, null) + Logger.d(TANLU, "pic =" + strategy.cityStrategy.pic) + Logger.d(TANLU, "video =" + strategy.cityStrategy.video) + syncStrategiesData(strategy.cityStrategy) + initFinish?.invoke() + } + } + onError { + reInitStrategies() + Logger.e(TANLU, "initStrategies onError ${it.message}") + } + } + } + + private fun reInitStrategies() = runBlocking { + launch { + initStrategies() + } + } + + /** + * 将数据同步到sharePreference中 + */ + private fun syncStrategiesData(strategy: CityStrategy) { + if (strategy.pic != null && strategy.video!=null) { + setStrategyType(AbsMogoApplication.getApp().applicationContext, strategy.pic!!.strategyType, "pic") + setStrategyType(AbsMogoApplication.getApp().applicationContext, strategy.video!!.strategyType, "video") + setStrategyFrequency( + AbsMogoApplication.getApp().applicationContext, + strategy.pic!!.strategyType, + "pic", + strategy.pic!!.reportType + ) + setStrategyFrequency( + AbsMogoApplication.getApp().applicationContext, + strategy.video!!.strategyType, + "video", + strategy.video!!.reportType + ) + setStrategyInterval( + AbsMogoApplication.getApp().applicationContext, + strategy.pic!!.strategyType, + "pic", + strategy.pic!!.reportTimeInterval * 60 * 1000L + ) + setStrategyInterval( + AbsMogoApplication.getApp().applicationContext, + strategy.video!!.strategyType, + "video", + strategy.video!!.reportTimeInterval * 60 * 1000L + ) + setStrategyValidity( + AbsMogoApplication.getApp().applicationContext, + strategy.pic!!.strategyType, + "pic", + strategy.pic!!.infoTimeout + ) + setStrategyValidity( + AbsMogoApplication.getApp().applicationContext, + strategy.video!!.strategyType, + "video", + strategy.video!!.infoTimeout + ) + setStrategyMaxSpeed( + AbsMogoApplication.getApp().applicationContext, + strategy.pic!!.strategyType, + "pic", + strategy.pic!!.getMaxSpeed() + ) + setStrategyMaxSpeed( + AbsMogoApplication.getApp().applicationContext, + strategy.video!!.strategyType, + "video", + strategy.video!!.getMaxSpeed() + ) + setStrategyMinSpeed( + AbsMogoApplication.getApp().applicationContext, + strategy.pic!!.strategyType, + "pic", + strategy.pic!!.minSpeed + ) + setStrategyMinSpeed( + AbsMogoApplication.getApp().applicationContext, + strategy.video!!.strategyType, + "video", + strategy.video!!.minSpeed + ) + } else { + Logger.d(TANLU, "strategy Data is null") + } + } + + //上传情报数据 +// fun sendInformationMessage( +// fromType: String, +// type: Int, +// url: Map, +// isCustom: Boolean = false, +// trafficInfoType:String = "", +// isShare:Boolean = false, +// poiType:String, +// mainInfoId:Long, +// speed: Float, +// longitude: Double, +// latitude: Double, +// customSend: ((Boolean) -> Unit)? = null +// ) { +// Log.d(TAG, " sendInformationMessage poiType = $poiType -- fromType = $fromType") +// mFromType = fromType +// mPoiType = poiType +// +// val locationInfo = LocationUtil.getInstance().getLocationInfo() +// if (locationInfo.address.isEmpty()) { +// Log.d(TAG, " sendInformationMessage locationInfo.address = $locationInfo.address") +// trackUploadGeo(1) +// 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, speed, mFromType), +// customSend +// ) +// } +// } + + + //如果address为空则逆地理编码 +// private fun geoLocation( +// type: Int, +// url: Map, +// locationInfo: LocationInfo, +// isCustom: Boolean, +// trafficInfoType:String, +// isShare: Boolean, +// customSend: ((Boolean) -> Unit)? = null, +// poiType: String, +// mainInfoId: Long, +// speed: Float, +// longitude: Double, +// latitude: Double +// ) { +// Log.d(TAG, " geoLocation -- poiType = $poiType") +// LocationUtil.getInstance() +// .geoCodeLocation(locationInfo.toLatLngPoint(), { +// Log.d(TAG, "geoLocation -------start -->") +// postInformationMessage( +// getInformationBody(type, url, locationInfo, isCustom, trafficInfoType, isShare, poiType,mainInfoId,longitude,latitude, speed, mFromType), +// customSend +// ) +// }, { +// //转换失败的情况下再重试一次 +// Log.d(TAG, "geoLocation -------true-->") +// geoRetry = if (!geoRetry) { +// 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,speed, mFromType), +// customSend +// ) +// false +// } +// }) +// } + + +// private fun postInformationMessage( +// informationBody: InformationBody, +// customSend: ((Boolean) -> Unit)? = null +// ) { +// trackUploadServer(3) +// request> { +// loader { +// strategyModel.uploadInformation(informationBody) +// } +// onSuccess { +// Log.i(TAG, "upload success id = " + it.result.id) +// if (mFromType == "6") { +// sendUgcStatusReceiver(it.result.id, mPoiType, mFromType) +// } +// trackUploadServer(1) +// customSend?.invoke(true) +// } +// onError { +// Log.i(TAG, "$it upload message ${it.message}") +// trackUploadServer(2) +// if (mFromType == "6") { +// sendUgcStatusReceiver(0, mPoiType, mFromType) +// } +// customSend?.invoke(false) +// } +// } +// } + +// private fun sendUgcStatusReceiver(id: Long, type: String?, fromType: String?) { +// Log.d(TAG, "sendUgcStatusReceiver id = $id ---type = $type --fromType = $fromType ") +// val intent = Intent() +// intent.action = "com.v2x.ugc.upload.status" +// intent.putExtra("id", id) +// intent.putExtra("type", type) +// intent.putExtra("fromType", fromType) +// AbsMogoApplication.getApp().applicationContext.sendBroadcast(intent) +// } +// +// //上传服务器 +// private fun trackUploadServer(type: Int) { +// trackNormalEvent( +// CarNet_Servers_Upload, mutableMapOf("type" to type) +// ) +// } +// +// //上传 +// private fun trackUploadGeo(type: Int) { +// trackNormalEvent( +// CarNet_Geo, mutableMapOf("type" to type) +// ) +// } + +} \ No newline at end of file diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/UploadParams.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/service/UploadParams.kt similarity index 96% rename from modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/UploadParams.kt rename to modules/mogo-module-share/src/main/java/com/mogo/module/share/service/UploadParams.kt index 4dcef19944..2aad4ab33c 100644 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/UploadParams.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/service/UploadParams.kt @@ -1,8 +1,11 @@ -package com.zhidao.roadcondition.service +package com.mogo.module.share.service import android.os.Parcel import android.os.Parcelable +/** + * 上报参数 + */ class UploadParams(val eventType: String, val fromType: String, val duration: Int, val parentId: Long, val lat: Double, val lon: Double,val addr:String,val direction:Float,val areaCode:String,val cityCode:String) : Parcelable { constructor(parcel: Parcel) : this( parcel.readString()!!, diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/util/AnalyticsUtil.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/utils/AnalyticsUtil.kt similarity index 98% rename from modules/tanlulib/src/main/java/com/zhidao/roadcondition/util/AnalyticsUtil.kt rename to modules/mogo-module-share/src/main/java/com/mogo/module/share/utils/AnalyticsUtil.kt index 4edd0ff980..d107fbb4aa 100644 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/util/AnalyticsUtil.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/utils/AnalyticsUtil.kt @@ -1,4 +1,4 @@ -package com.zhidao.roadcondition.util +package com.mogo.module.share.utils import android.content.Context import com.elegant.analytics.Analytics diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/util/FileUtil.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/utils/FileUtil.kt similarity index 99% rename from modules/tanlulib/src/main/java/com/zhidao/roadcondition/util/FileUtil.kt rename to modules/mogo-module-share/src/main/java/com/mogo/module/share/utils/FileUtil.kt index 4b43c4802e..45bc568d9d 100644 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/util/FileUtil.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/utils/FileUtil.kt @@ -1,4 +1,4 @@ -package com.zhidao.roadcondition.util +package com.mogo.module.share.utils import android.graphics.Bitmap import android.media.MediaMetadataRetriever diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/util/LocationUtil.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/utils/LocationUtil.kt similarity index 97% rename from modules/tanlulib/src/main/java/com/zhidao/roadcondition/util/LocationUtil.kt rename to modules/mogo-module-share/src/main/java/com/mogo/module/share/utils/LocationUtil.kt index 3e3313712c..1fbbeb8f24 100644 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/util/LocationUtil.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/utils/LocationUtil.kt @@ -1,4 +1,4 @@ -package com.zhidao.roadcondition.util +package com.mogo.module.share.utils import android.util.Log import com.mogo.commons.AbsMogoApplication @@ -8,7 +8,8 @@ import com.mogo.map.search.geo.MogoRegeocodeAddress import com.mogo.map.search.geo.MogoRegeocodeResult import com.mogo.map.search.geo.query.MogoRegeocodeQuery import com.mogo.module.common.MogoApisHandler -import com.zhidao.roadcondition.model.LocationInfo +import com.mogo.module.share.bean.LocationInfo + private fun toLocInfo( address: MogoRegeocodeAddress, @@ -120,10 +121,8 @@ class LocationUtil private constructor() { regeocodeQuery.radius = 200 geocoderSearch.getFromLocationAsyn(regeocodeQuery) geocoderSearch.setGeoSearchListener(object : IMogoGeoSearchListener { - - override fun onRegeocodeSearched(regeocodeResult: MogoRegeocodeResult?) { - super.onRegeocodeSearched(regeocodeResult) +// super.onRegeocodeSearched(regeocodeResult) if( regeocodeResult == null ){ trackUploadGeo(3) onError.invoke("geoCode") diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/util/PdUtil.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/utils/PdUtil.kt similarity index 71% rename from modules/tanlulib/src/main/java/com/zhidao/roadcondition/util/PdUtil.kt rename to modules/mogo-module-share/src/main/java/com/mogo/module/share/utils/PdUtil.kt index 1f32b6d9e6..351b509866 100644 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/util/PdUtil.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/utils/PdUtil.kt @@ -1,30 +1,31 @@ -package com.zhidao.roadcondition.util +package com.mogo.module.share.utils import android.util.Log import com.google.gson.JsonArray import com.google.gson.JsonObject import com.mogo.cloud.passport.MoGoAiCloudClientConfig import com.mogo.commons.AbsMogoApplication -import com.zhidao.roadcondition.model.InformationBody -import com.zhidao.roadcondition.model.LocationInfo -import com.zhidao.roadcondition.model.proxy.INFO_TYPE_IMG -import com.zhidao.roadcondition.model.proxy.INFO_TYPE_VIDEO -import com.zhidao.roadcondition.util.StrategyPreferenceUtil.Companion.getStrategyType -import com.zhidao.roadcondition.util.StrategyPreferenceUtil.Companion.getStrategyValidity +import com.mogo.module.share.bean.InformationBody +import com.mogo.module.share.bean.LocationInfo +import com.mogo.module.share.constant.INFO_TYPE_IMG +import com.mogo.module.share.constant.INFO_TYPE_VIDEO +import com.mogo.module.share.utils.StrategyPreferenceUtil.Companion.getStrategyType +import com.mogo.module.share.utils.StrategyPreferenceUtil.Companion.getStrategyValidity + fun getInformationBody( - types: Int, - urls: Map, - locationInfo: LocationInfo, - isCustom: Boolean, - trafficInfoType:String = "", - isShare:Boolean, - poiType: String, - mainInfoId: Long, - longitude: Double, - latitude: Double, - speed: Float, - fromType: String + types: Int, + urls: Map, + locationInfo: LocationInfo, + isCustom: Boolean, + trafficInfoType:String = "", + isShare:Boolean, + poiType: String, + mainInfoId: Long, + longitude: Double, + latitude: Double, + speed: Float, + fromType: String ): InformationBody { val jsonArray = JsonArray() val type: Int diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/util/SharedPreferenceUtil.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/utils/SharedPreferenceUtil.kt similarity index 97% rename from modules/tanlulib/src/main/java/com/zhidao/roadcondition/util/SharedPreferenceUtil.kt rename to modules/mogo-module-share/src/main/java/com/mogo/module/share/utils/SharedPreferenceUtil.kt index 90f9b5460e..dd555263d8 100644 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/util/SharedPreferenceUtil.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/utils/SharedPreferenceUtil.kt @@ -1,4 +1,4 @@ -package com.zhidao.roadcondition.util +package com.mogo.module.share.utils import android.content.Context import androidx.core.content.edit diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/util/StrategyPreferenceUtil.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/utils/StrategyPreferenceUtil.kt similarity index 99% rename from modules/tanlulib/src/main/java/com/zhidao/roadcondition/util/StrategyPreferenceUtil.kt rename to modules/mogo-module-share/src/main/java/com/mogo/module/share/utils/StrategyPreferenceUtil.kt index 9ed8344836..2ee683b24e 100644 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/util/StrategyPreferenceUtil.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/utils/StrategyPreferenceUtil.kt @@ -1,4 +1,4 @@ -package com.zhidao.roadcondition.util +package com.mogo.module.share.utils import android.content.Context import android.util.Log diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/util/TaskCoroutines.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/utils/TaskCoroutines.kt similarity index 57% rename from modules/tanlulib/src/main/java/com/zhidao/roadcondition/util/TaskCoroutines.kt rename to modules/mogo-module-share/src/main/java/com/mogo/module/share/utils/TaskCoroutines.kt index 990f120875..91e42934c3 100644 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/util/TaskCoroutines.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/utils/TaskCoroutines.kt @@ -1,5 +1,6 @@ -package com.zhidao.roadcondition.util +package com.mogo.module.share.utils +import bolts.Task.delay import kotlinx.coroutines.* @ObsoleteCoroutinesApi @@ -8,15 +9,6 @@ internal var ThreadPool = newFixedThreadPoolContext(Runtime.getRuntime().availableProcessors() * 2, "ThreadPool") -/** - * 在主线程中顺序执行,协程函数,一般用于最外层 - * 该函数会阻塞代码继续执行 - */ -//inline fun taskBlockOnMainThread(delayTime: Long = 0, noinline job: suspend () -> Unit) = runBlocking { -// delay(delayTime) -// job() -//} - /** * 并发执行,常用于最外层 * 特点带返回值 diff --git a/modules/tanlulib/.gitignore b/modules/tanlulib/.gitignore deleted file mode 100644 index 796b96d1c4..0000000000 --- a/modules/tanlulib/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/modules/tanlulib/build.gradle b/modules/tanlulib/build.gradle deleted file mode 100644 index f1a262e71c..0000000000 --- a/modules/tanlulib/build.gradle +++ /dev/null @@ -1,94 +0,0 @@ -plugins { - id 'com.android.library' - id 'kotlin-android' - id 'kotlin-android-extensions' - id 'kotlin-kapt' - id 'com.alibaba.arouter' -} - - -android { - compileSdkVersion rootProject.ext.android.compileSdkVersion - // buildToolsVersion rootProject.ext.android.buildToolsVersion - defaultConfig { - minSdkVersion rootProject.ext.android.minSdkVersion - targetSdkVersion rootProject.ext.android.targetSdkVersion - versionCode Integer.valueOf(VERSION_CODE) - versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION") - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - consumerProguardFiles 'consumer-rules.pro' - - //ARouter apt 参数 - kapt { - useBuildCache = false - arguments { - arg("AROUTER_MODULE_NAME", project.getName()) - } - } - } - - buildTypes { - release { - minifyEnabled false - zipAlignEnabled true - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - - kotlinOptions { - jvmTarget = "1.8" - } -} - -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation rootProject.ext.dependencies.kotlinstdlibjdk7 - implementation rootProject.ext.dependencies.androidxappcompat - implementation rootProject.ext.dependencies.androidxccorektx - implementation rootProject.ext.dependencies.aiassist - implementation rootProject.ext.dependencies.okhttpinterceptor - implementation 'com.zhidaoauto.controller:api:1.0.8' - implementation 'com.zhidao.cosupload:cosuploadsdk:1.1.6', { - exclude group: 'com.zhidao.utils', module: 'utils' - } - implementation 'com.zhidao.video:video-processor:1.0.2.1' - implementation rootProject.ext.dependencies.eventbus - implementation rootProject.ext.dependencies.coroutinescore - implementation rootProject.ext.dependencies.coroutinesandroid - implementation rootProject.ext.dependencies.retrofit - implementation rootProject.ext.dependencies.retrofitconvertergson - implementation rootProject.ext.dependencies.gson - implementation rootProject.ext.dependencies.rxjava - implementation rootProject.ext.dependencies.rxandroid - implementation rootProject.ext.dependencies.analytics - - implementation rootProject.ext.dependencies.arouter - kapt rootProject.ext.dependencies.aroutercompiler - - implementation rootProject.ext.dependencies.mogoaicloudtanlu - - - if (Boolean.valueOf(USE_MAVEN_PACKAGE)) { - implementation rootProject.ext.dependencies.mogoutils - implementation rootProject.ext.dependencies.modulecommon - implementation rootProject.ext.dependencies.mogomap - implementation rootProject.ext.dependencies.mogoserviceapi - - implementation rootProject.ext.dependencies.mogo_core_data - } else { - implementation project(":foudations:mogo-utils") - implementation project(':modules:mogo-module-common') - implementation project(':libraries:mogo-map') - implementation project(':services:mogo-service-api') - - implementation project(':core:mogo-core-data') - } -} - -apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString() diff --git a/modules/tanlulib/consumer-rules.pro b/modules/tanlulib/consumer-rules.pro deleted file mode 100644 index 974da8af41..0000000000 --- a/modules/tanlulib/consumer-rules.pro +++ /dev/null @@ -1,4 +0,0 @@ --keep class com.zhidao.roadcondition.model.**{*;} --keep class com.zhidao.roadcondition.service.*{*;} --keep class com.zhidao.roadcondition.ShareRoadReceiver.*{*;} - diff --git a/modules/tanlulib/gradle.properties b/modules/tanlulib/gradle.properties deleted file mode 100644 index 91487d97ef..0000000000 --- a/modules/tanlulib/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -GROUP=com.mogo.module -POM_ARTIFACT_ID=module-tanlu-upload -VERSION_CODE=1 diff --git a/modules/tanlulib/proguard-rules.pro b/modules/tanlulib/proguard-rules.pro deleted file mode 100644 index 0303ba4564..0000000000 --- a/modules/tanlulib/proguard-rules.pro +++ /dev/null @@ -1,27 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile --keep class com.zhidao.roadcondition.model.**{*;} --keep class com.zhidao.roadcondition.service.*{*;} --keep class com.zhidao.roadcondition.ShareRoadReceiver.*{*;} - - - diff --git a/modules/tanlulib/src/main/AndroidManifest.xml b/modules/tanlulib/src/main/AndroidManifest.xml deleted file mode 100644 index a3ea46d784..0000000000 --- a/modules/tanlulib/src/main/AndroidManifest.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/base/BaseIntentService.kt b/modules/tanlulib/src/main/java/com/zhidao/roadcondition/base/BaseIntentService.kt deleted file mode 100644 index ea21766a41..0000000000 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/base/BaseIntentService.kt +++ /dev/null @@ -1,39 +0,0 @@ -package com.zhidao.roadcondition.base - -import android.app.IntentService -import android.content.Intent -import android.os.IBinder - - -open class BaseIntentService : IntentService("BaseIntentService") { - - protected var tag: String = this.javaClass.simpleName - - override fun onHandleIntent(p0: Intent?) { - tag = this.javaClass.simpleName - } - - override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { - return super.onStartCommand(intent, flags, startId) - } - - override fun onCreate() { - super.onCreate() - } - - override fun onStart(intent: Intent?, startId: Int) { - super.onStart(intent, startId) - } - - override fun onBind(intent: Intent?): IBinder? { - return super.onBind(intent) - } - - override fun setIntentRedelivery(enabled: Boolean) { - super.setIntentRedelivery(enabled) - } - - override fun onDestroy() { - super.onDestroy() - } -} \ No newline at end of file diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/constant/Const.kt b/modules/tanlulib/src/main/java/com/zhidao/roadcondition/constant/Const.kt deleted file mode 100644 index 8c7c39ee73..0000000000 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/constant/Const.kt +++ /dev/null @@ -1,87 +0,0 @@ -package com.zhidao.roadcondition.constant - -public val STRATEGY_TYPE_PHOTO: String = "0FOoOuB7" //拍照的策略ID -public val STRATEGY_TYPE_VIDEO: String = "gVCl9VdW" //拍视频的策略ID -public val SOCKET_MSG_TYPE: Int = 0x040001 //长连接消息类型 -public val SOCKET_PRODUCT_LINE: Int = 0x04 //长连接消息产品线id,目前SDK是写死的 - -const val INFORMATION_DATA_SIZE_LIMIT = 50 -const val INFORMATION_DEFAULT_MAP_RADIUS = 10 - -const val REQUESTCODE_MAINACTIVITY = 0 -const val REQUESTCODE_MEDIAACTIVITY = 1 -const val CUSTOM_SEND_CMD = "custom_send_cmd" //主动上报语音命令 -const val VOICE_PREVIOUS_INFO_CMD = "voice_previous_info_cmd" //上一条 -const val VOICE_NEXT_INFO_CMD = "voice_next_info_cmd" //下一条 - -const val SCHEME_SPLASH_TYPE = "channelType" -const val SCHEME_MAIN_TYPE = "type" -const val PARAM_MAIN_PAGE_ACTION = "action" // 判断主页该干什么 - -const val VAL_ACTION_TQZ = "tqz" //通勤族 -const val VAL_ACTION_PLAY_DIRECTLY = "play" //直接播放情报 -const val VAL_ACTION_DHLX = "dhlx" //导航路线 - -const val CONFIG_NEED_AUTH = "0001" //公共配置 是否查询授权 -const val CONFIG_ACTIVE_POSITION = "0002" //公共配置 查询运营位配置 - -//广播action、key -const val AUTONAVI_STANDARD_BROADCAST_SEND = "AUTONAVI_STANDARD_BROADCAST_SEND" -const val AUTONAVI_STANDARD_BROADCAST_ROAD_INFO = "EXTRA_ROAD_INFO" -const val AUTONAVI_STANDARD_BROADCAST_EXTRA_STATE = "EXTRA_STATE" -//EXTRA_STATE -const val AUTO_NAVI_START = 8 //开始导航 -const val AUTO_NAVI_END = 9 //结束导航 - -const val VALUE_DICT_DATA_TYPE = "deva_infomation_type" // dict 数据请求类型:情报类型数据 - -//事件类型 -const val TANLU_TRAFFIC_CHECK = "10002" //交通检查 -const val TANLU_ROAD_CLOSURE = "10003" //封路 -const val TANLU_ROAD_WORK = "10006" //施工 -const val TANLU_ROAD_CONGESTION = "10007" //拥堵 -const val TANLU_ROAD_PONDING = "10008" //积水 -const val TANLU_ROAD_HEAVY_FOG = "10010" //大雾 -const val TANLU_ROAD_ICING = "10011" //积冰 -const val TANLU_ROAD_ACCIDENT = "10013" //事故 -const val TANLU_ROAD_CURRENT = "10015" //实时路况 - -// 上报类型 -/** - * 用户手点上报 - */ -const val UPLOAD_FROM_USER = "1" -/** - * 用户语音上报 - */ -const val UPLOAD_FROM_VOICE = "2" -/** - * 数据策略:拥堵自动上报 - */ -const val UPLOAD_FROM_STRATEGY_BLOCK_AUTO = "3" -/** - * 数据策略:已有事件云端校验 - */ -const val UPLOAD_FROM_STRATEGY_CLOUD_CHECK = "4" -/** - * 数据策略:交通事故上报 - */ -const val UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO = "5" - -/** - * 策略上报集合 - */ -val STRATEGY_UPLOAD_TYPE_ARRAY = arrayOf(UPLOAD_FROM_STRATEGY_BLOCK_AUTO, - UPLOAD_FROM_STRATEGY_CLOUD_CHECK, UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO) -/** - * 默认视频抓取时长,单位是秒 - */ -const val DEFAULT_VIDEO_DURATION = 10 - -const val DEF_NEWS_LABEL = "拥堵" -const val DEF_NEWS_VALUE = "traffic_jam" -const val DEF_NEWS_TYPE = "0" - -const val API_MODULE_NAME = "MogoTanluApi" -const val API_MODULE_PATH = "/tanlulib/api" - diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/constant/HttpConstants.kt b/modules/tanlulib/src/main/java/com/zhidao/roadcondition/constant/HttpConstants.kt deleted file mode 100644 index 53036c37c7..0000000000 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/constant/HttpConstants.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.zhidao.roadcondition.constant - -import com.mogo.commons.debug.DebugConfig - -class HttpConstants { - - companion object { - - const val DEV_BASE_URL_OWNER = "http://dzt-test.zhidaozhixing.com/" - const val RELEASE_BASE_URL_OWNER = "http://dzt.zhidaozhixing.com/" - const val SHOW_BASE_URL_OWNER = "http://dzt-show.zhidaozhixing.com/" - - fun getBaseUrl(): String { - return when (DebugConfig.getNetMode()) { - DebugConfig.NET_MODE_QA -> DEV_BASE_URL_OWNER - DebugConfig.NET_MODE_RELEASE -> RELEASE_BASE_URL_OWNER - DebugConfig.NET_MODE_DEMO -> SHOW_BASE_URL_OWNER - else -> DEV_BASE_URL_OWNER - } - } - - } - -} \ No newline at end of file diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/exception/ApiException.kt b/modules/tanlulib/src/main/java/com/zhidao/roadcondition/exception/ApiException.kt deleted file mode 100644 index 636f3f3ff2..0000000000 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/exception/ApiException.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.zhidao.roadcondition.exception - - -class ApiException : Exception { - - companion object{ - val NETWORK_API_EXCEPTION = ApiException(1, "network is error") - val NULL_REQUEST_DATA_API_EXCEPTION = ApiException(2, "request data is null") - } - - private var code: Int = 0 - private var msg: String = "" - - constructor(code: Int, msg: String) : super(msg) { - this.code = code - this.msg = msg - } - -} \ No newline at end of file diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/BaseRequest.kt b/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/BaseRequest.kt deleted file mode 100644 index 6b27deb2e6..0000000000 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/BaseRequest.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.zhidao.roadcondition.model - -class BaseRequest(var sn: String, var data: T?) { - -} \ No newline at end of file diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/CommonConfig.kt b/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/CommonConfig.kt deleted file mode 100644 index 4c3cea008d..0000000000 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/CommonConfig.kt +++ /dev/null @@ -1,47 +0,0 @@ -package com.zhidao.roadcondition.model - - -class CommonConfig { - - var active:Active //活动配置 -// var promotion:Promotion //Splash页面图片以及语音推广配置 - var auth:Auth //授权配置 - - constructor(active: Active, auth: Auth) { - this.active = active -// this.promotion = promotion - this.auth = auth - } -} - -class Active{ - var imageUrl:String - var webUrl:String - var status:Int - - constructor(imageUrl: String, webUrl: String, status: Int) { - this.imageUrl = imageUrl - this.webUrl = webUrl - this.status = status - } -} - -class Promotion{ - var imageUrl:String - var voiceContent:String - var status:Int - - constructor(imageUrl: String, voiceContent: String, status: Int) { - this.imageUrl = imageUrl - this.voiceContent = voiceContent - this.status = status - } -} - -class Auth{ - var isNeedAuth:Int - - constructor(isNeedAuth: Int) { - this.isNeedAuth = isNeedAuth - } -} \ No newline at end of file diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/InformationResource.kt b/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/InformationResource.kt deleted file mode 100644 index f441d0a300..0000000000 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/InformationResource.kt +++ /dev/null @@ -1,41 +0,0 @@ -package com.zhidao.roadcondition.model - - -/** - * @author congtaowang - * @since 2019-11-22 - * - * 一次情报的数据 - */ -class InformationResource { - - var id: Long - var isCosResourceReady: Boolean = false - var isInformationSelected: Boolean = false - - var sourceType: Int = 0 // 情报载体类型:图片、视频 - var cosParameter: Map? = null // 情报参数 - var informationType: InformationType? = null //情报类型 - var isCustomSend: Boolean = false // 自动上传 - - var callback: ((customSend: Boolean) -> Unit)? = null - - lateinit var newsType: String // 埋点:情报类型 - lateinit var operType: String // 埋点:操作类型 - - constructor(id: Long) { - this.id = id - } - - fun isReady() = isCosResourceReady and isInformationSelected - - fun release() { - cosParameter = null - informationType = null - callback = null - } - - override fun toString(): String { - return "upload information: sourceType=${sourceType}, informationType={${informationType?.dictLabel}, ${informationType?.dictValue}}" - } -} \ No newline at end of file diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/InformationType.kt b/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/InformationType.kt deleted file mode 100644 index 7d4f282af5..0000000000 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/InformationType.kt +++ /dev/null @@ -1,29 +0,0 @@ -package com.zhidao.roadcondition.model - -import com.google.gson.Gson -import com.zhidao.roadcondition.constant.DEF_NEWS_LABEL -import com.zhidao.roadcondition.constant.DEF_NEWS_TYPE -import com.zhidao.roadcondition.constant.DEF_NEWS_VALUE - -/** - * @author congtaowang - * @since 2019-11-18 - * - * 情报类型 - */ -data class InformationType(var dictLabel: String, var dictValue: String, var remark: String) { - companion object { - val def = InformationType(DEF_NEWS_LABEL, DEF_NEWS_VALUE, DEF_NEWS_TYPE) - } - - override fun equals(other: Any?): Boolean { - when (other) { - is InformationType -> return other.dictValue.compareTo(dictValue) == 0 - } - return super.equals(other) - } - - override fun toString(): String { - return Gson().toJson(this) - } -} \ No newline at end of file diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/InformationTypeResult.kt b/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/InformationTypeResult.kt deleted file mode 100644 index a2c39a3837..0000000000 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/InformationTypeResult.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.zhidao.roadcondition.model - -/** - * @author congtaowang - * @since 2019-11-18 - * - * 描述 - */ -data class InformationTypeResult(var types: List) \ No newline at end of file diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/Informations.kt b/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/Informations.kt deleted file mode 100644 index c2fca80dc9..0000000000 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/Informations.kt +++ /dev/null @@ -1,63 +0,0 @@ -package com.zhidao.roadcondition.model - -import android.os.Parcel -import android.os.Parcelable - -class Informations( - var type: Int, - var lon: Double, - var lat: Double, - var addr: String?, - var generateTime: Long, - var cityName: String?, -// var items: ArrayList, - var distance: Int, - var nickName: String?, - var headImgUrl: String? -) : - Parcelable { - - var position = 0 - - constructor(parcel: Parcel) : this( - parcel.readInt(), - parcel.readDouble(), - parcel.readDouble(), - parcel.readString(), - parcel.readLong(), - parcel.readString(), -// parcel.readArrayList(Items::class.java.classLoader) as ArrayList, - parcel.readInt(), - parcel.readString(), - parcel.readString() - ) - - override fun writeToParcel(parcel: Parcel, flags: Int) { - parcel.writeInt(type) - parcel.writeDouble(lon) - parcel.writeDouble(lat) - parcel.writeString(addr) - parcel.writeLong(generateTime) - parcel.writeString(cityName) -// parcel.writeList(items) - parcel.writeInt(distance) - parcel.writeString(nickName) - parcel.writeString(headImgUrl) - } - - override fun describeContents(): Int { - return 0 - } - - companion object CREATOR : Parcelable.Creator { - override fun createFromParcel(parcel: Parcel): Informations { - return Informations(parcel) - } - - override fun newArray(size: Int): Array { - return arrayOfNulls(size) - } - } - - -} \ No newline at end of file diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/Items.kt b/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/Items.kt deleted file mode 100644 index 1d34fab20d..0000000000 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/Items.kt +++ /dev/null @@ -1,33 +0,0 @@ -package com.zhidao.roadcondition.model - -import android.os.Parcel -import android.os.Parcelable - -class Items(var url: String?, var thumbnail: String? = null) : Parcelable { - constructor(parcel: Parcel) : this( - parcel.readString(), - parcel.readString() - ) { - } - - override fun writeToParcel(parcel: Parcel, flags: Int) { - parcel.writeString(url) - parcel.writeString(thumbnail) - } - - override fun describeContents(): Int { - return 0 - } - - companion object CREATOR : Parcelable.Creator { - override fun createFromParcel(parcel: Parcel): Items { - return Items(parcel) - } - - override fun newArray(size: Int): Array { - return arrayOfNulls(size) - } - } - - -} \ No newline at end of file diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/Results.kt b/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/Results.kt deleted file mode 100644 index cce437439f..0000000000 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/Results.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.zhidao.roadcondition.model - -/** - * 城市策略实体 - */ -class Results(var cityStrategy: CityStrategy) \ No newline at end of file diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/UploadResult.kt b/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/UploadResult.kt deleted file mode 100644 index ad4644d0e0..0000000000 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/UploadResult.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.zhidao.roadcondition.model - -/** - * 上报成功返回 - */ -class UploadResult(var id: Long) { - -} \ No newline at end of file diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/proxy/ActiveInfoTypeProxy.kt b/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/proxy/ActiveInfoTypeProxy.kt deleted file mode 100644 index 9fcca8ea88..0000000000 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/proxy/ActiveInfoTypeProxy.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.zhidao.roadcondition.model.proxy - -import androidx.annotation.IntDef - -const val INFO_TYPE_GONE = 0 -const val INFO_TYPE_SHOW = 1 - - -@IntDef(INFO_TYPE_GONE, INFO_TYPE_SHOW) -@Retention(AnnotationRetention.SOURCE) -annotation class ActiveInfoType - -fun isActiveShow(@ActiveInfoType type: Int): Boolean { - return when (type) { - INFO_TYPE_GONE -> false - INFO_TYPE_SHOW -> true - else -> false - } -} \ No newline at end of file diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/proxy/InformationsTypeProxy.kt b/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/proxy/InformationsTypeProxy.kt deleted file mode 100644 index d297bf97c8..0000000000 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/model/proxy/InformationsTypeProxy.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.zhidao.roadcondition.model.proxy - -import androidx.annotation.IntDef - - -const val INFO_TYPE_IMG = 0 //图片 -const val INFO_TYPE_VIDEO = 1 -const val INFO_TYPE_VOICE = 2 -const val INFO_TYPE_WORD = 3 - - -@IntDef(INFO_TYPE_IMG, INFO_TYPE_VIDEO, INFO_TYPE_VOICE, INFO_TYPE_WORD) -@Retention(AnnotationRetention.SOURCE) -annotation class InformationsType diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/net/CoroutineChain.kt b/modules/tanlulib/src/main/java/com/zhidao/roadcondition/net/CoroutineChain.kt deleted file mode 100644 index 3e09016656..0000000000 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/net/CoroutineChain.kt +++ /dev/null @@ -1,71 +0,0 @@ -package com.zhidao.roadcondition.net - -import androidx.lifecycle.Lifecycle -import androidx.lifecycle.LifecycleObserver -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.OnLifecycleEvent -import com.zhidao.roadcondition.exception.ApiException -import kotlinx.coroutines.* -import kotlinx.coroutines.Dispatchers.Main -import java.net.SocketTimeoutException -import java.net.UnknownHostException -import java.util.concurrent.TimeoutException - -/** - * 后续考虑加入Lifecycle管理,暂时不做扩展 - */ -class CoroutineChain { - - internal class CoroutineLifecycleListener(private val deferred: Deferred<*>, private val lifecycle: Lifecycle) : - LifecycleObserver { - @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) - fun cancelCoroutine() { - if (deferred.isActive) { - deferred.cancel() - } - lifecycle.removeObserver(this) - } - } - - infix fun LifecycleOwner.start(start: (() -> Unit)): LifecycleOwner { - start() - return this - } - - infix fun LifecycleOwner.request(loader: suspend () -> T): Deferred { - return request(loader, true) - } - - private fun LifecycleOwner.request(loader: suspend () -> T, needAutoCancel: Boolean = true): Deferred { - val deferred = GlobalScope.async(Dispatchers.IO, start = CoroutineStart.LAZY) { - loader() - } - if (needAutoCancel) { - lifecycle.addObserver(CoroutineLifecycleListener(deferred, lifecycle)) - } - return deferred - } - - fun Deferred.then( - onSuccess: suspend (T) -> Unit, - onError: suspend (java.lang.Exception) -> Unit, - onComplete: (() -> Unit)? = null - ): Job { - return GlobalScope.launch(context = Main) { - try { - val result = this@then.await() - onSuccess(result) - } catch (e: Exception) { - e.printStackTrace() - when (e) { - is UnknownHostException -> onError.invoke(ApiException.NETWORK_API_EXCEPTION) - is TimeoutException -> onError.invoke(ApiException.NETWORK_API_EXCEPTION) - is SocketTimeoutException -> onError.invoke(ApiException.NETWORK_API_EXCEPTION) - else -> onError(e) - } - } finally { - onComplete?.invoke() - } - } - } -} \ No newline at end of file diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/net/CoroutineDSL.kt b/modules/tanlulib/src/main/java/com/zhidao/roadcondition/net/CoroutineDSL.kt deleted file mode 100644 index b1a2764c16..0000000000 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/net/CoroutineDSL.kt +++ /dev/null @@ -1,104 +0,0 @@ -package com.zhidao.roadcondition.net - -import androidx.lifecycle.LifecycleOwner -import com.zhidao.roadcondition.exception.ApiException -import com.zhidao.roadcondition.exception.ApiException.Companion.NETWORK_API_EXCEPTION -import com.zhidao.roadcondition.exception.ApiException.Companion.NULL_REQUEST_DATA_API_EXCEPTION -import com.zhidao.roadcondition.model.BaseResponse -import kotlinx.coroutines.* -import java.net.SocketTimeoutException -import java.net.UnknownHostException -import java.util.concurrent.TimeoutException - -class Request { - private lateinit var loader: suspend () -> T - - private var start: (() -> Unit)? = null - - private var onSuccess: ((T) -> Unit)? = null - - private var onError: ((java.lang.Exception) -> Unit)? = null - - private var onComplete: (() -> Unit)? = null - - private var addLifecycle: LifecycleOwner? = null - - - infix fun loader(loader: suspend () -> T) { - this.loader = loader - } - - infix fun start(start: (() -> Unit)?) { - this.start = start - } - - infix fun onSuccess(onSuccess: ((T) -> Unit)?) { - this.onSuccess = onSuccess - } - - infix fun onError(onError: ((java.lang.Exception) -> Unit)?) { - this.onError = onError - } - - infix fun onComplete(onComplete: (() -> Unit)?) { - this.onComplete = onComplete - } - - infix fun addLifecycle(addLifecycle: LifecycleOwner?) { - this.addLifecycle = addLifecycle - } - - fun request() { - request(addLifecycle) - } - - fun request(addLifecycle: LifecycleOwner?) { - - GlobalScope.launch(context = Dispatchers.Main) { - - start?.invoke() - try { - val deferred = GlobalScope.async(Dispatchers.IO, start = CoroutineStart.LAZY) { - loader() - } - addLifecycle?.apply { - lifecycle.addObserver( - CoroutineChain.CoroutineLifecycleListener( - deferred, - lifecycle - ) - ) - } - val result = deferred.await() - if (result != null && result is BaseResponse<*>) { - if (result.code == 0) { - onSuccess?.invoke(result) - } else { - throw ApiException(result.code, result.msg) - } - } else { - throw NULL_REQUEST_DATA_API_EXCEPTION - } - } catch (e: Exception) { - e.printStackTrace() - //数据打点 - when (e) { - is UnknownHostException -> onError?.invoke(NETWORK_API_EXCEPTION) - is TimeoutException -> onError?.invoke(NETWORK_API_EXCEPTION) - is SocketTimeoutException -> onError?.invoke(NETWORK_API_EXCEPTION) - else -> onError?.invoke(java.lang.Exception(e.message)) - } - } finally { - onComplete?.invoke() - } - } - } -} - -inline fun request(buildRequest: Request.() -> Unit) { - Request().apply(buildRequest).request() -} - -inline fun LifecycleOwner.request(buildRequest: Request.() -> Unit) { - Request().apply(buildRequest).request(this) -} \ No newline at end of file diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/net/HttpApi.kt b/modules/tanlulib/src/main/java/com/zhidao/roadcondition/net/HttpApi.kt deleted file mode 100644 index 1cdd1a7f1f..0000000000 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/net/HttpApi.kt +++ /dev/null @@ -1,22 +0,0 @@ -package com.zhidao.roadcondition.net - -import com.zhidao.roadcondition.model.BaseResponse -import com.zhidao.roadcondition.model.Results -import com.zhidao.roadcondition.model.UploadResult -import retrofit2.http.* - -/** - * 接口声明 - */ -interface HttpApi { - //获取城市策略 - @FormUrlEncoded - @POST("yycp-geo-fence-carService/car/carStrategy/no/getCityStrategy/v1") - suspend fun getCityStrategy(@FieldMap cityStrategy: Map): BaseResponse - - //上报情报数据 - @FormUrlEncoded - @POST("/deva/car/path/no/addInfomation/v2") - suspend fun uploadInformation(@FieldMap information: Map): BaseResponse - -} \ No newline at end of file diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/receiver/ShareRoadReceiver.kt b/modules/tanlulib/src/main/java/com/zhidao/roadcondition/receiver/ShareRoadReceiver.kt deleted file mode 100644 index 263f349f8c..0000000000 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/receiver/ShareRoadReceiver.kt +++ /dev/null @@ -1,18 +0,0 @@ -package com.zhidao.roadcondition.receiver - -import android.content.BroadcastReceiver -import android.content.Context -import android.content.Intent -import android.util.Log - -class ShareRoadReceiver : BroadcastReceiver() { - - override fun onReceive(context: Context, intent: Intent) { - Log.d("MainService", "ShareRoadReceiver ------> intent.action = " + intent.action) - if (intent.action == "com.zhidao.share.roadcondition.action") { - val type = intent.getStringExtra("type") - Log.e("MainService", "ShareRoadReceiver type ----> $type ----> 此方法已经废弃了,无法调起服务") -// MainService.launchService(context, type) - } - } -} diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/CosCallbackMapController.kt b/modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/CosCallbackMapController.kt deleted file mode 100644 index 665d09aeab..0000000000 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/CosCallbackMapController.kt +++ /dev/null @@ -1,79 +0,0 @@ -package com.zhidao.roadcondition.service - -import com.zhidao.cosupload.callback.CosStatusCallback -import com.zhidao.cosupload.callback.CosStatusCallbackManager - -/** - * @author congtaowang - * @since 2019-11-25 - * - */ -object CosCallbackMapController : CosStatusCallback { - - private val map: MutableMap = mutableMapOf() - - var uploadFailed: (() -> Unit)? = null - - var mainService: MainService? = null - fun init(mainService: MainService) { - this.mainService = mainService - CosStatusCallbackManager.getInstance().register(this) - } - - fun uploadFailed(uploadFailed: (() -> Unit)) { - this.uploadFailed = uploadFailed - } - - fun registerCallback(paths: List?, callback: CosStatusCallback) { - paths?.let { list -> - list.forEach { path -> - path?.let { - map[it] = callback - } - } - } - } - - fun unregisterCallback(path: String?) { - path?.let { - map.remove(path) - } - } - - fun unregisterCallbacks(paths: Map?) { - paths?.let { - it.keys.let { keys -> - keys.forEach { path -> - unregisterCallback(path) - } - } - } - } - - override fun onStartUpload(eventId: String?, localPath: String?) { - map[localPath]?.onStartUpload(eventId, localPath) - } - - override fun uploadCosFailed(cosPath: String?, eventId: String?, localPath: String?) { - map[localPath]?.uploadCosFailed(cosPath, eventId, localPath) - } - - override fun uploadCosCompleted( - cosPath: String?, - eventId: String?, - downloadUrl: String?, - localPath: String? - ) { - map[localPath]?.uploadCosCompleted(cosPath, eventId, downloadUrl, localPath) - } - - override fun onProgress(localPath: String?, progress: Float) { - map[localPath]?.onProgress(localPath, progress) - } - - fun release() { - CosStatusCallbackManager.getInstance().unregister(this) - map.clear() - uploadFailed = null - } -} \ No newline at end of file diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/CosStatusController.kt b/modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/CosStatusController.kt deleted file mode 100644 index 1f45c255f7..0000000000 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/CosStatusController.kt +++ /dev/null @@ -1,240 +0,0 @@ -package com.zhidao.roadcondition.service - -import android.content.Intent -import android.os.Environment -import android.util.Log -import com.google.gson.Gson -import com.mogo.commons.AbsMogoApplication -import com.zhidao.cosupload.DbPriorityConfig -import com.zhidao.cosupload.callback.CosStatusCallback -import com.zhidao.cosupload.manager.CosUploadManagerImpl -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 java.io.File - -/** - * @description cos上传操作 - * - * @author lixiaopeng - * @since 2019-10-30 - */ -class CosStatusController : CosStatusCallback { - - companion object{ - const val TAG: String = "CosStatusController" - } - - //存储单次请求的视频和缩略图url - private var videoAndThumbMap: MutableMap = mutableMapOf() - //图片上传的eventId - private lateinit var mPicEventId: String - private var isRetry = false //是否重试上传过图片 - - private var mainServiceHttpModel = MainServiceController() - - private lateinit var entity: TakeEntity - - private var mType: String = "" - private var mainInfoId: Long = 0 - private var mFromType: String = "" - private var mLongitude: Double = 0.0 - private var mLatitude: Double = 0.0 - private var mSpeed: Float = 0f - val moviesDir = Environment.getExternalStoragePublicDirectory( - Environment.DIRECTORY_MOVIES + File.separator - ) - - - //上传文件 - fun uploadFile(picPath: MutableList?, entity: TakeEntity, type: String, mainInfoId: Long, - fromType: String, longitude: Double, latitude: Double, speed: Float) { - CosCallbackMapController.registerCallback(picPath, this) -// CosLogger.setLogStatus(true) - - this.entity = entity - this.mType = type - this.mainInfoId = mainInfoId - this.mFromType = fromType - this.mLongitude = longitude - this.mLatitude = latitude - this.mSpeed = speed - Log.d(TAG, "uploadFile type===$type ---- mainInfoId =$mainInfoId ----mFromType = $mFromType ---- picPath = $picPath --speed = $speed") - trackUploadCos(3) - if(picPath == null){ - return - } - if (picPath.contains("backPic")) return - //参数说明: paths:本地文件路径;(注:上传的本地路径不要重复);config:文件上传的优先级 - mPicEventId = - CosUploadManagerImpl.getInstance(AbsMogoApplication.getApp().applicationContext).eventId - CosUploadManagerImpl.getInstance(AbsMogoApplication.getApp().applicationContext) - .upload(picPath, mPicEventId, DbPriorityConfig.PRIORITY_HIGH) - } - - - override fun onStartUpload(eventId: String?, localPath: String?) { - } - - private fun sendGetInfoFailedReceiver(type: String) { - Log.d(CarCorderController.TAG, "sendGetInfoFailedReceiver ------>") - val intent = Intent() - intent.action = "com.zhidao.roadcondition.getinfo.failed" - intent.putExtra("type", type) - AbsMogoApplication.getApp().applicationContext.sendBroadcast(intent) - } - - override fun uploadCosFailed(cosPath: String?, eventId: String?, localPath: String?) { - Log.d(TAG, "uploadCosFailed = $localPath") - trackUploadCos(2) - //语音播报 1:上报路况,2:交通检查,3:封路 默认 mType 应该为null - if (!isRetry) { - isRetry = true -// taskAsync(30_000) { //去掉重试 -// try { -// uploadFile(mutableListOf(localPath as String), entity, mType) -// } catch (e: Exception) { -// e.printStackTrace() -// } -// } - } else { - if (localPath!!.endsWith("mp4") || localPath.contains("Thumbnail")) { - CosCallbackMapController.uploadFailed?.invoke() - } - CosCallbackMapController.unregisterCallback(localPath) - InformationUploadController.release(entity.id) -// deletePicFile(localPath) - deleteCompressVideoFile(moviesDir.toString()) - } - } - - override fun uploadCosCompleted( - cosPath: String?, - eventId: String?, - downloadUrl: String?, - localPath: String? - ) { - Log.d(TAG, "uploadCosCompleted localPath = $localPath") - Log.d(TAG, "uploadCosCompleted downloadUrl = $downloadUrl") - Log.d(TAG, "uploadCosCompleted cosPath = $cosPath") - trackUploadCos(1) - if (localPath!!.endsWith("mp4") || localPath.contains("Thumbnail")) { - //如果是视频文件或者缩略图文件 - if (localPath.endsWith("mp4")) { - videoAndThumbMap["video"] = downloadUrl!! - Log.i(TAG, "videoAndThumbMap add mp4") - } else { - videoAndThumbMap["thumb"] = downloadUrl!! - Log.i(TAG, "videoAndThumbMap add thumb") - } - Log.d(TAG, "videoAndThumbMap $videoAndThumbMap") - if (videoAndThumbMap.size == 2) { - trackUploadCos(4) - Log.d(TAG, "videoAndThumbMap.size == 2 ") - val locationInfo = LocationUtil.getInstance().getLocationInfo() - val locationStr: String = Gson().toJson(locationInfo) - Log.d(TAG, "locationStr = $locationStr") - //上传录像以及缩略图成功 - sendInformation(INFO_TYPE_VIDEO, videoAndThumbMap) - } else { - trackUploadCos(5) - } - } else { - //上传图片成功, 如果是上报路况,直接上传 - Log.d(TAG, "uploadCosCompleted 分享成功 ---- mType = $mType") - sendInformationDirectly( - INFO_TYPE_IMG, - mutableMapOf("pic" to downloadUrl as String), - mType, - entity, - mainInfoId, - mLongitude, - mLatitude, - mSpeed, - mFromType - ) - } - Log.d(TAG, "delete file: $localPath") - CosCallbackMapController.unregisterCallback(localPath) -// deletePicFile(localPath) - deleteCompressVideoFile(moviesDir.toString()) - } - - private fun sendInformation(type: Int, map: Map) { - Log.d(TAG, "isCustomSend = ${entity.isCustom}") -// if (entity?.isCustom) { -// InformationUploadController.cosResourceReady(type, map, entity?.isCustom, entity?.id) { -// CosCallbackMapController.mainService?.sendCustomResult(it) -// } -// } else { - sendInformationDirectly(type, map, mType, entity, mainInfoId, mLongitude, mLatitude, mSpeed,mFromType) -// } - } - - /** - * 被动上报时直接上报,不用等待、选择情报类型 - */ - fun sendInformationDirectly( - type: Int, - map: Map, - poiType: String, - entity: TakeEntity?, - mainInfoId: Long, - longitude: Double, - latitude: Double, - speed: Float, - fromType: String - ) { - Log.d(TAG, "sendInformationDirectly poiType= $poiType --fromType =$fromType ---- mainInfoId= $mainInfoId --- isCustom = ${entity?.isCustom}") - //开始上传 - entity?.isCustom?.let { - mainServiceHttpModel.sendInformationMessage( - fromType = fromType, - type = type, - url = map, - isCustom = it, - poiType = poiType, - mainInfoId = mainInfoId, - speed = speed, - longitude = longitude, - latitude = latitude - ) { success -> - CosCallbackMapController.unregisterCallbacks(map) -// CosCallbackMapController.mainService?.let { -// CosCallbackMapController.mainService?.sendCustomResult(success) -// } - Log.d(TAG, "type = $type ----success = $success ----fromType = $mFromType ----poiType = $poiType") - if (success) { - //分享成功,并打点,如果是上报拥堵,需要takeVideo - if (type == INFO_TYPE_VIDEO) { - try { - LatLngStickyEventBus.getInstance() - .postSticky(GetImageSuccessEvent("", poiType)) - } catch (e: java.lang.Exception) { - e.printStackTrace() - } - } - } else { - - } - - } - } - } - - - override fun onProgress(localPath: String?, progress: Float) { - } - - //上传COS - private fun trackUploadCos(type: Int) { - trackNormalEvent( - CarNet_Cos_Upload, mutableMapOf("type" to type), - AbsMogoApplication.getApp().applicationContext - ) - } - -} - diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/DelayService.kt b/modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/DelayService.kt deleted file mode 100644 index 25dd79e803..0000000000 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/DelayService.kt +++ /dev/null @@ -1,67 +0,0 @@ -package com.zhidao.roadcondition.service - -import android.app.IntentService -import android.content.Context -import android.content.Intent -import android.os.IBinder -import android.util.Log -import com.zhidao.roadcondition.util.* -import java.io.File -import java.lang.Exception - -class DelayService : IntentService("DelayService") { - - companion object { - - const val TAG = "DelayService" - - fun launchService(context: Context) { - context.startService(Intent(context, DelayService::class.java)) - } - } - - override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { - return super.onStartCommand(intent, flags, startId) - } - - override fun onCreate() { - super.onCreate() - } - - override fun onStart(intent: Intent?, startId: Int) { - super.onStart(intent, startId) - } - - override fun onBind(intent: Intent?): IBinder? { - return super.onBind(intent) - } - - override fun setIntentRedelivery(enabled: Boolean) { - super.setIntentRedelivery(enabled) - } - - override fun onDestroy() { - super.onDestroy() - } - - override fun onHandleIntent(intent: Intent?) { - Log.d(TAG, "start delay ----> ") - - taskAsync(20_000) { - try { - Log.d(TAG, "delay finish, start Service") -// MainService.launchService(this@DelayService, "0") - - //删除一个原始视频(可能没删除的)文件夹下的所有文件(包括子目录内的文件) - val file = File("/mnt/sdcard/DCIM/Camera/video/small/") //输入要删除文件目录的绝对路径 - deleteAllFile(file) - - val compressFile = File("/mnt/sdcard/Movies/") //压缩过的视频 - deleteAllFile(compressFile) - - } catch (e: Exception) { - e.printStackTrace() - } - } - } -} \ No newline at end of file diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/InformationUploadController.kt b/modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/InformationUploadController.kt deleted file mode 100644 index b9a1ab0cb0..0000000000 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/InformationUploadController.kt +++ /dev/null @@ -1,124 +0,0 @@ -package com.zhidao.roadcondition.service - -import android.util.Log -import com.zhidao.roadcondition.model.InformationResource -import com.zhidao.roadcondition.model.InformationType -import com.zhidao.roadcondition.util.* - -/** - * @author congtaowang - * @since 2019-11-20 - * - * 情报上报控制 - */ -object InformationUploadController { - - private val TAG : String = this.javaClass.simpleName - - private var mainServiceHttpModel = MainServiceController() - - private val locker: Any = Any() - - /** - * 情报 - * Long -> 一个情报的id - * InformationResource -> 一个情报的资源 - */ - private val informationCache = mutableMapOf() - - /** - * 情报已上传到cos - */ - fun cosResourceReady( - sourceType: Int, - cosParameter: Map, - isCustomSend: Boolean, - id: Long, - callback: ((customSend: Boolean) -> Unit) - ) { - Log.d(TAG, "cos resource ready. id=${id}") - val ir = getInformationResourceById(id) - ir?.let { - it.isCosResourceReady = true - it.sourceType = sourceType - it.cosParameter = cosParameter - it.isCustomSend = isCustomSend - it.callback = callback -// tryUploadInformation(it) - } - } - - private fun getInformationResourceById(id: Long): InformationResource? { - if (!informationCache.containsKey(id)) { - informationCache[id] = InformationResource(id) - } - return informationCache[id] - } - - /** - * 已选择情报类型 - */ - fun informationSelected( - informationType: InformationType, - newsType: String, - operType: String, - id: Long - ) { - Log.d(TAG, "information type selected id=${id}, type=${informationType}") - val ir = getInformationResourceById(id) - ir?.let { - it.isInformationSelected = true - it.informationType = informationType - it.newsType = newsType - it.operType = operType -// tryUploadInformation(it) - } - } - -// private fun tryUploadInformation(ir: InformationResource?) { -// synchronized(locker) { -// ir?.let { -// if (!it.isReady()) { -// log(TAG, "source isn't ready.") -// return@let -// } -// mainServiceHttpModel.sendInformationMessage( -// it.sourceType, -// it.cosParameter!!, -// it.isCustomSend, -// it.informationType?.dictValue!!, -// isShare = true -// ) { success -> -// log(TAG, "上传成功!" + ir?.toString()) -// trackNormalEvent( -// CarNet_user_upload, -// mutableMapOf( -// TRACK_KEY_TYPE to it.operType, -// TRACK_KEY_NEWS_TYPE to it.newsType -// ) -// ) -// if (it.isCustomSend) { -// it.callback?.invoke(success) -// } -// informationCache.remove(it.id) -// it.release() -// recordUploadTime() -// } -// } -// } -// } - - fun release(id: Long) { - val target = informationCache.remove(id) - target?.release() - } - - private fun recordUploadTime() { - putLong("lastUploadTime", System.currentTimeMillis()) - } - - fun isUpload2Frequently(): Boolean { - val lastUploadTime = getLong("lastUploadTime", 0L) - return System.currentTimeMillis() - lastUploadTime < 10_000L - } -} \ No newline at end of file diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/MainServiceController.kt b/modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/MainServiceController.kt deleted file mode 100644 index eebbff8059..0000000000 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/MainServiceController.kt +++ /dev/null @@ -1,255 +0,0 @@ -package com.zhidao.roadcondition.service - -import android.content.Intent -import android.util.Log -import com.mogo.commons.AbsMogoApplication -import com.zhidao.roadcondition.model.* -import com.zhidao.roadcondition.net.request -import com.zhidao.roadcondition.util.* -import com.zhidao.roadcondition.util.StrategyPreferenceUtil.Companion.setStrategyFrequency -import com.zhidao.roadcondition.util.StrategyPreferenceUtil.Companion.setStrategyInterval -import com.zhidao.roadcondition.util.StrategyPreferenceUtil.Companion.setStrategyMaxSpeed -import com.zhidao.roadcondition.util.StrategyPreferenceUtil.Companion.setStrategyMinSpeed -import com.zhidao.roadcondition.util.StrategyPreferenceUtil.Companion.setStrategyType -import com.zhidao.roadcondition.util.StrategyPreferenceUtil.Companion.setStrategyValidity -import kotlinx.coroutines.launch -import kotlinx.coroutines.runBlocking - -class MainServiceController { - - companion object { - const val TAG = "MainServiceController" - } - - //逆地理编码是否重试 - private var geoRetry = false - private var mFromType: String = "" - private var mPoiType: String = "" - - private val strategyModel by lazy { StrategyServiceModel() } - - fun initStrategies(initFinish: (() -> Unit)? = null) { - request> { - loader { - strategyModel.getCityStrategy() - } - onSuccess { - it.result.let { strategy -> - trackNormalEvent(CarNet_Get_Strategy, null) - Log.d(TAG, "pic =" + strategy.cityStrategy.pic) - Log.d(TAG, "video =" + strategy.cityStrategy.video) - syncStrategiesData(strategy.cityStrategy) - initFinish?.invoke() - } - } - onError { - reInitStrategies() - Log.e(TAG, "initStrategies onError ${it.message}") - } - } - } - - private fun reInitStrategies() = runBlocking { - launch { -// delay(30_000) - initStrategies() - } - } - - //将数据同步到sharePreference中 - private fun syncStrategiesData(strategy: CityStrategy) { - if (strategy.pic != null && strategy.video!=null) { - setStrategyType(AbsMogoApplication.getApp().applicationContext, strategy.pic!!.strategyType, "pic") - setStrategyType(AbsMogoApplication.getApp().applicationContext, strategy.video!!.strategyType, "video") - setStrategyFrequency( - AbsMogoApplication.getApp().applicationContext, - strategy.pic!!.strategyType, - "pic", - strategy.pic!!.reportType - ) - setStrategyFrequency( - AbsMogoApplication.getApp().applicationContext, - strategy.video!!.strategyType, - "video", - strategy.video!!.reportType - ) - setStrategyInterval( - AbsMogoApplication.getApp().applicationContext, - strategy.pic!!.strategyType, - "pic", - strategy.pic!!.reportTimeInterval * 60 * 1000L - ) - setStrategyInterval( - AbsMogoApplication.getApp().applicationContext, - strategy.video!!.strategyType, - "video", - strategy.video!!.reportTimeInterval * 60 * 1000L - ) - setStrategyValidity( - AbsMogoApplication.getApp().applicationContext, - strategy.pic!!.strategyType, - "pic", - strategy.pic!!.infoTimeout - ) - setStrategyValidity( - AbsMogoApplication.getApp().applicationContext, - strategy.video!!.strategyType, - "video", - strategy.video!!.infoTimeout - ) - setStrategyMaxSpeed( - AbsMogoApplication.getApp().applicationContext, - strategy.pic!!.strategyType, - "pic", - strategy.pic!!.getMaxSpeed() - ) - setStrategyMaxSpeed( - AbsMogoApplication.getApp().applicationContext, - strategy.video!!.strategyType, - "video", - strategy.video!!.getMaxSpeed() - ) - setStrategyMinSpeed( - AbsMogoApplication.getApp().applicationContext, - strategy.pic!!.strategyType, - "pic", - strategy.pic!!.minSpeed - ) - setStrategyMinSpeed( - AbsMogoApplication.getApp().applicationContext, - strategy.video!!.strategyType, - "video", - strategy.video!!.minSpeed - ) - } else { - Log.d(TAG, "strategy Data is null") - } - } - - //上传情报数据 - fun sendInformationMessage( - fromType: String, - type: Int, - url: Map, - isCustom: Boolean = false, - trafficInfoType:String = "", - isShare:Boolean = false, - poiType:String, - mainInfoId:Long, - speed: Float, - longitude: Double, - latitude: Double, - customSend: ((Boolean) -> Unit)? = null - ) { - Log.d(TAG, " sendInformationMessage poiType = $poiType -- fromType = $fromType") - mFromType = fromType - mPoiType = poiType - - val locationInfo = LocationUtil.getInstance().getLocationInfo() - if (locationInfo.address.isEmpty()) { - Log.d(TAG, " sendInformationMessage locationInfo.address = $locationInfo.address") - trackUploadGeo(1) - 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, speed, mFromType), - customSend - ) - } - } - - //如果address为空则逆地理编码 - private fun geoLocation( - type: Int, - url: Map, - locationInfo: LocationInfo, - isCustom: Boolean, - trafficInfoType:String, - isShare: Boolean, - customSend: ((Boolean) -> Unit)? = null, - poiType: String, - mainInfoId: Long, - speed: Float, - longitude: Double, - latitude: Double - ) { - Log.d(TAG, " geoLocation -- poiType = $poiType") - LocationUtil.getInstance() - .geoCodeLocation(locationInfo.toLatLngPoint(), { - Log.d(TAG, "geoLocation -------start -->") - postInformationMessage( - getInformationBody(type, url, locationInfo, isCustom, trafficInfoType, isShare, poiType,mainInfoId,longitude,latitude, speed, mFromType), - customSend - ) - }, { - //转换失败的情况下再重试一次 - Log.d(TAG, "geoLocation -------true-->") - geoRetry = if (!geoRetry) { - 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,speed, mFromType), - customSend - ) - false - } - }) - } - - - private fun postInformationMessage( - informationBody: InformationBody, - customSend: ((Boolean) -> Unit)? = null - ) { - trackUploadServer(3) - request> { - loader { - strategyModel.uploadInformation(informationBody) - } - onSuccess { - Log.i(TAG, "upload success id = " + it.result.id) - if (mFromType == "6") { - sendUgcStatusReceiver(it.result.id, mPoiType, mFromType) - } - trackUploadServer(1) - customSend?.invoke(true) - } - onError { - Log.i(TAG, "$it upload message ${it.message}") - trackUploadServer(2) - if (mFromType == "6") { - sendUgcStatusReceiver(0, mPoiType, mFromType) - } - customSend?.invoke(false) - } - } - } - - private fun sendUgcStatusReceiver(id: Long, type: String?, fromType: String?) { - Log.d(TAG, "sendUgcStatusReceiver id = $id ---type = $type --fromType = $fromType ") - val intent = Intent() - intent.action = "com.v2x.ugc.upload.status" - intent.putExtra("id", id) - intent.putExtra("type", type) - intent.putExtra("fromType", fromType) - AbsMogoApplication.getApp().applicationContext.sendBroadcast(intent) - } - - //上传服务器 - private fun trackUploadServer(type: Int) { - trackNormalEvent( - CarNet_Servers_Upload, mutableMapOf("type" to type) - ) - } - - //上传 - private fun trackUploadGeo(type: Int) { - trackNormalEvent( - CarNet_Geo, mutableMapOf("type" to type) - ) - } - -} \ No newline at end of file diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/ServiceConst.kt b/modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/ServiceConst.kt deleted file mode 100644 index 0a1b35eb16..0000000000 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/ServiceConst.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.zhidao.roadcondition.service - -val AlarmTypePic: Int = 1 //定时任务类型 1照片 -val AlarmTypeVideo: Int = 2 //定时任务类型 2视频 - -val alarmBroadAction: String = "com.zhidao.roadCondition.AlarmBroadCast" //定时广播 -val sendInformationAction: String = "com.zhidao.roadCondition.SendInformation" //主动上报广播 -val customResultAction: String = "com.zhidao.roadCondition.CustomResult" //主动上报结果广播 diff --git a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/TakePhotoInterceptor.kt b/modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/TakePhotoInterceptor.kt deleted file mode 100644 index fa46896c04..0000000000 --- a/modules/tanlulib/src/main/java/com/zhidao/roadcondition/service/TakePhotoInterceptor.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.zhidao.roadcondition.service - -import com.zhidao.auto.carcorder.callback.TakePhotoCallback - -/** - * @author congtaowang - * @since 2019-11-19 - * - * 拍照拦截器 - */ -interface TakePhotoInterceptor : TakePhotoCallback { - - fun intercept(): Boolean -} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 6ec0c2896b..715103f943 100644 --- a/settings.gradle +++ b/settings.gradle @@ -54,7 +54,6 @@ include ':libraries:map-autonavi' include ':libraries:mogo-map' // OLD业务模块 -include ':modules:tanlulib' include ':modules:mogo-module-monitor' include ':modules:mogo-module-adas' include ':modules:mogo-module-map'