Merge branch 'master' into release_robosweeper-d_100-sweeper_220830_1.0.0.1_merge

# Conflicts:
#	app_ipc_monitoring/src/main/java/com/zhidao/adas/client/ui/MainActivity.java
#	core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/MoGoAutopilotProvider.kt
#	core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/adapter/MoGoAdasListenerImpl.kt
#	core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/adapter/MoGoAdasMsgConnectStatusListenerImpl.kt
#	core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/TrafficDataView.java
#	core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapPointCloudSubscriber.kt
#	core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoAutopilotProvider.kt
#	gradle.properties
#	libraries/mogo-adas-data/src/main/proto/message_pad.proto
#	libraries/mogo-adas-data/src/main/proto/special_vehicle_task_cmd.proto
#	libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasChannel.java
#	libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasManager.java
#	libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/IAdasNetCommApi.java
#	libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/MessageType.java
This commit is contained in:
aibingbing
2022-09-26 19:16:37 +08:00
266 changed files with 9667 additions and 771 deletions

View File

@@ -0,0 +1,160 @@
package com.mogo.functions.test
import android.os.*
import androidx.test.core.app.*
import androidx.test.ext.junit.runners.*
import androidx.test.filters.*
import com.mogo.eagle.core.function.hmi.ui.*
import com.mogo.eagle.core.function.main.*
import com.mogo.eagle.core.function.v2x.events.*
import com.mogo.v2x.event.V2XEvent.RoadAI
import kotlinx.coroutines.*
import org.junit.*
import org.junit.runner.*
import roadwork.Road.*
import java.util.concurrent.*
import java.util.concurrent.TimeUnit.MILLISECONDS
import java.util.concurrent.TimeUnit.SECONDS
import kotlin.Result
@RunWith(AndroidJUnit4::class)
@LargeTest
class RoadAITest {
lateinit var launch: ActivityScenario<MainLauncherActivity>
@Before
fun before() {
launch = ActivityScenario.launch(MainLauncherActivity::class.java)
}
@Test
fun test() = runBlocking(Dispatchers.Default) {
ensureMoGoHmiFragmentShow()
val nanos = System.nanoTime()
val child =
RW_PB
.newBuilder()
.setHeader(
Header
.newBuilder()
.setFrameId("rw")
.setModuleName("ai_cloud")
.setStamp(Time.newBuilder()
.setSec(TimeUnit.NANOSECONDS.convert(nanos, SECONDS).toInt())
.setNsec(180000000)
.build())
.build())
.setRoadwork(
Roadwork_PB
.newBuilder()
.setId("4e47e17d-4950-4c80-9b02-29a450e54b50")
.setScore(95)
.setDetectTime(nanos)
.setPoiType(100061)
.setType(1006)
.setCenter(
Center_PB
.newBuilder()
.setRoad(Road_PB
.newBuilder()
.setRoadId("200091")
.setLaneNo("-2")
.setTileId("556834853")
.setBearing(156)
.build())
.setPoint(GPSPoint_PB
.newBuilder()
.setLat(26.819533419884188)
.setLon(112.57506466334905)
.build())
.build())
.addPolygon(0, GPSPoint_PB
.newBuilder()
.setLat(26.819544927961125)
.setLon(112.57503948748804)
.build())
.addPolygon(1, GPSPoint_PB
.newBuilder()
.setLat(26.81953162903423)
.setLon(112.57503758421541)
.build())
.addPolygon(2, GPSPoint_PB
.newBuilder()
.setLat(26.81952255026517)
.setLon(112.5750496963295)
.build())
.addPolygon(3, GPSPoint_PB
.newBuilder()
.setLat(26.819517691652617)
.setLon(112.57507582382465)
.build())
.addPolygon(4, GPSPoint_PB
.newBuilder()
.setLat(26.819521911807858)
.setLon(112.57508983920647)
.build())
.addPolygon(5, GPSPoint_PB
.newBuilder()
.setLat(26.819535210732194)
.setLon(112.57509174248064)
.build())
.addPolygon(6, GPSPoint_PB
.newBuilder()
.setLat(26.81954428950259)
.setLon(112.5750796303722)
.build())
.addPolygon(7, GPSPoint_PB
.newBuilder()
.setLat(26.819549148117684)
.setLon(112.57505350287552)
.build())
.addRoad(0, Road_PB
.newBuilder()
.setRoadId("200090")
.setLaneNo("-2")
.setTileId("556834853")
.setBearing(154)
.build())
.addRoad(1, Road_PB
.newBuilder()
.setRoadId("200091")
.setLaneNo("-2")
.setTileId("556834853")
.setBearing(156)
.build())
.build())
.build()
val event = RoadAI(data = child)
while (true) {
delay(1000)
V2XEventManager.onAck(event)
}
}
private suspend fun ensureMoGoHmiFragmentShow(): MoGoHmiFragment = suspendCancellableCoroutine {
launch.onActivity { itx ->
val executor = Executors.newSingleThreadScheduledExecutor()
executor.scheduleAtFixedRate({
var find =
itx.supportFragmentManager.fragments.find { it is MoGoHmiFragment } as? MoGoHmiFragment
while (find == null) {
find =
itx.supportFragmentManager.fragments.find { it is MoGoHmiFragment } as? MoGoHmiFragment
}
while (!find.isResumed) {
Thread.sleep(500)
}
it.resumeWith(Result.success(find))
try {
Thread.sleep(500)
executor.shutdownNow()
} catch (e: Throwable) {
e.printStackTrace()
}
}, 50, 500, MILLISECONDS)
}
}
}

View File

@@ -31,6 +31,15 @@
android:value="android.startup.provider.config" />
</provider>
<!-- &lt;!&ndash; 暂不使用Shizuku-API &ndash;&gt;-->
<!-- <provider-->
<!-- android:name="rikka.shizuku.ShizukuProvider"-->
<!-- android:authorities="${applicationId}.shizuku"-->
<!-- android:enabled="true"-->
<!-- android:exported="true"-->
<!-- android:multiprocess="false"-->
<!-- android:permission="android.permission.INTERACT_ACROSS_USERS_FULL" />-->
<!-- 配置APP ID -->
<meta-data
android:name="BUGLY_APPID"

View File

@@ -1,9 +1,16 @@
package com.mogo.launcher;
import com.mogo.eagle.core.function.main.MainMoGoApplication;
import android.content.Context;
import androidx.annotation.NonNull;
import com.mogo.eagle.core.utilcode.mogo.logger.LogLevel;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import com.mogo.launcher.crash.CrashSystem;
import com.mogo.thread.ext.core.ThreadManager;
import com.mogo.thread.ext.core.config.ThreadConfig;
import java.util.concurrent.ThreadPoolExecutor;
/**
* @author congtaowang
@@ -13,6 +20,41 @@ import com.mogo.launcher.crash.CrashSystem;
*/
public class MogoApplication extends MainMoGoApplication {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
ThreadConfig.Builder builder = new ThreadConfig.Builder().listener(new ThreadConfig.TaskExecuteListener() {
@Override
public boolean isEnabled() {
return true; // 如果返回true会有后续的回调如果返回false, 不会有后续的回调
}
@Override
public void onExecutorBefore(@NonNull Runnable runnable) {
//每个任务执行前回调
}
@Override
public void onExecutorAfter(@NonNull Runnable runnable) {
//每个任务执行后回调
}
/**
* @param core 线程池的核心数
* @param max 线程池的最大线程数
* @param active 线程池正在活跃的任务数
* @param completed 线程池已完成的任务数
*/
@Override
public void onExecutorStateChanged(@NonNull ThreadPoolExecutor pool, int core, int max, int active, long completed) {
//线程池在执行过程,状态变化回调
//Log.d("POOL", "core:" + core + ";max:" + max + ";active:" + active + ";completed:" + completed);
}
});
builder.loggable(false);
ThreadManager.INSTANCE.init(builder);
}
@Override
protected void initCrashConfig() {
CrashSystem crashSystem = CrashSystem.getInstance(this);

View File

@@ -24,6 +24,7 @@ import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_CLOUD_CONNECT_FAIL
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_CLOUD_CONNECT_LOST
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_CLOUD_CONNECT_SUCCESS
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_HTTP_DNS_CHANGED
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_CLOUD_SHOW
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_CONNECT_STATUS
import com.mogo.eagle.core.data.map.MogoLocation
@@ -37,6 +38,7 @@ import com.mogo.eagle.core.utilcode.util.AppUtils
import com.mogo.eagle.core.utilcode.util.ProcessUtils
import com.mogo.eagle.core.utilcode.util.ThreadPoolService
import com.mogo.eagle.core.utilcode.util.TimeUtils
import com.mogo.map.location.GDLocationClient
import com.mogo.module.common.constants.HostConst
import com.rousetime.android_startup.AndroidStartup
import com.zhjt.mogo_core_function_devatools.env.EnvChangeManager
@@ -59,6 +61,8 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
private var context: Context? = null
private var gotToken = false
override fun callCreateOnMainThread() = true
override fun waitOnMainThread() = false
@@ -73,12 +77,17 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
override fun create(context: Context): Boolean {
this.context = context
if (ProcessUtils.isMainProcess(context)) {
initGDLoc()
initHttpDns()
initCloudClientConfig()
}
return true
}
private fun initGDLoc() {
GDLocationClient.getInstance(context).start()
}
/**
* 初始化 HttpDNS ,这里会通过一个接口获取所有鹰眼中使用的微服务域名以及端口号
* 后续的网络请求会通过 HttpDnsInterceptor 进行拦截替换
@@ -125,10 +134,8 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
//设置长链接的secretKey //todo 通过SHA1和包名找中台服务生成后续包名分渠道,需要做对应操作
clientConfig.secretKey = "YMj2VFDFxJ3Q4gNoZceJ"
// todo 使用旧链路
// clientConfig.setUseOriginSocket(true);
clientConfig.iHttpDnsCurrentLocation = object : IHttpDnsCurrentLocation {
override fun getCurrentLocation(): HttpDnsSimpleLocation? {
override fun getCurrentLocation(): HttpDnsSimpleLocation {
val envConfig = EnvChangeManager.getEnvConfig()
if (envConfig != null) {
return HttpDnsSimpleLocation(envConfig.cityCode, envConfig.lat, envConfig.lon)
@@ -140,13 +147,23 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
mogoLocation = locationClient.lastKnowLocation
}
val httpDnsSimpleLocation =
if (mogoLocation != null && mogoLocation.latitude != 0.0 && mogoLocation.longitude != 0.0
) {
HttpDnsSimpleLocation(
mogoLocation.cityCode,
mogoLocation.latitude,
mogoLocation.longitude
)
if (mogoLocation != null && mogoLocation.latitude != 0.0 && mogoLocation.longitude != 0.0) {
if (mogoLocation.cityCode.isNullOrEmpty() && !GDLocationClient.getInstance(
context
).lastCityCode.isNullOrEmpty()
) {
HttpDnsSimpleLocation(
GDLocationClient.getInstance(context).lastCityCode,
mogoLocation.latitude,
mogoLocation.longitude
)
} else {
HttpDnsSimpleLocation(
mogoLocation.cityCode,
mogoLocation.latitude,
mogoLocation.longitude
)
}
} else {
val ciyCode =
SharedPrefsMgr.getInstance(
@@ -171,7 +188,6 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
// e.printStackTrace();
HttpDnsSimpleLocation("010", 1.0, 1.0)
}
//CallerLogger.INSTANCE.d(M_HMI + TAG, "使用缓存GPS信息" + httpDnsSimpleLocation);
}
return httpDnsSimpleLocation
}
@@ -184,15 +200,19 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
MoGoAiCloudClient.getInstance().init(context, clientConfig).addTokenCallbacks(
object : IMoGoTokenCallback {
override fun onTokenGot(token: String, sn: String) {
CallerLogger.d(SceneConstant.M_HMI + TAG, "onTokenGot ")
clientConfig.token = token
CallerCloudListenerManager.invokeCloudTokenGot(token)
// 异步初始化NetConfig
asyncInit()
// HttpDns ttl回调 --- socketTTL
registerSocketHttpDnsTTL(HostConst.SOCKET_CENTER_DOMAIN)
// 开启每5s/次定位上报
uploadLocPerFiveSecond()
// 由于存在token过期问题在更新后会回调至此处增加二次判定
if(!gotToken){
CallerLogger.d(SceneConstant.M_MAP + TAG, "onTokenGot ")
CallerCloudListenerManager.invokeCloudTokenGot(token)
// 异步初始化NetConfig
asyncInit()
// HttpDns ttl回调 --- socketTTL
registerSocketHttpDnsTTL(HostConst.SOCKET_CENTER_DOMAIN)
// 开启每5s/次定位上报
uploadLocPerFiveSecond()
gotToken = true
}
}
override fun onError(code: Int, msg: String) {
@@ -236,7 +256,15 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
*/
private fun registerSocketHttpDnsTTL(host: String?) {
mogoHttpDns.addressChangedListener(object : OnAddressChangedListener {
override fun onAddressChanged(address: Map<String, String>?) {
@ChainLog(
linkChainLog = CHAIN_LINK_LOG_CONNECT_STATUS,
linkCode = CHAIN_LINK_CLOUD_SHOW,
endpoint = PAD,
nodeAliasCode = CHAIN_ALIAS_CODE_HTTP_DNS_CHANGED,
paramIndexes = [0, 1],
clientPkFileName = "sn"
)
override fun onAddressChanged(cityCode: String, address: Map<String, String>?) {
val dnsCacheIp = mogoHttpDns.getCachedHttpDnsIps(
host,
HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_HTTP
@@ -314,6 +342,18 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
CallerLogger.d(SceneConstant.M_HMI + TAG, "socket-onConnectLost")
DebugConfig.setDownloadSnapshot(false)
}
@ChainLog(
linkChainLog = CHAIN_LINK_LOG_CONNECT_STATUS,
linkCode = CHAIN_LINK_CLOUD_SHOW,
endpoint = PAD,
nodeAliasCode = CHAIN_ALIAS_CODE_CLOUD_CONNECT_LOST,
paramIndexes = [0, 1],
clientPkFileName = "sn"
)
override fun onError(code: String, msg: String?) {
CallerLogger.d(SceneConstant.M_HMI + TAG, "socket-onConnectLost")
}
})
// 开启Socket长链服务
val lat = location.latitude