将测试场景使用命令行adb 进行测试,不再推荐使用测试面板V2XTestConsoleWindow.java
TestPanelBroadcastReceiver.java // 使用命令行触发各种测试场景演示 adb shell am broadcast -a com.v2x.test_panel_control --ei sceneType 1
This commit is contained in:
1
.idea/gradle.xml
generated
1
.idea/gradle.xml
generated
@@ -90,6 +90,7 @@
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveModulePerSourceSet" value="false" />
|
||||
<option name="useQualifiedModuleNames" value="true" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
|
||||
@@ -45,9 +45,7 @@ public class V2XConst {
|
||||
/**
|
||||
* V2X 测试控制面板广播Action
|
||||
*/
|
||||
public static final String BROADCAST_TEST_PANEL_CONTROL_ACTION = "com.v2x.com.v2x.test_panel_control";
|
||||
public static final String BROADCAST_TEST_PANEL_CONTROL_EXTRA_KEY = "TextPanelOpenStatus";
|
||||
public static final String BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY = "TextPanelOpenType";
|
||||
public static final String BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY = "sceneType";
|
||||
|
||||
|
||||
public static final String BROADCAST_SCENE_ACTION = "com.v2x.scene_local_broadcast";
|
||||
|
||||
@@ -4,10 +4,26 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import com.mogo.module.common.entity.MarkerExploreWay;
|
||||
import com.mogo.module.common.entity.V2XMessageEntity;
|
||||
import com.mogo.module.common.entity.V2XPushMessageEntity;
|
||||
import com.mogo.module.common.entity.V2XRoadEventEntity;
|
||||
import com.mogo.module.common.entity.V2XWarningEntity;
|
||||
import com.mogo.module.v2x.V2XConst;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.scenario.scene.test.V2XTestConsoleWindow;
|
||||
import com.mogo.module.v2x.entity.net.V2XOptimalRouteDataRes;
|
||||
import com.mogo.module.v2x.entity.net.V2XSpecialCarRes;
|
||||
import com.mogo.module.v2x.scenario.scene.livecar.V2XVoiceCallLiveBiz;
|
||||
import com.mogo.module.v2x.utils.TestOnLineCarUtils;
|
||||
import com.mogo.module.v2x.utils.V2XSQLiteUtils;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidao.carchattingprovider.MogoDriverInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static android.text.style.TtsSpan.GENDER_MALE;
|
||||
|
||||
/**
|
||||
* V2X 测试面板广播接收,目的是可以通过广播调用起来面板
|
||||
@@ -17,22 +33,147 @@ import com.mogo.utils.logger.Logger;
|
||||
public class TestPanelBroadcastReceiver extends BroadcastReceiver {
|
||||
private static final String TAG = V2XConst.MODULE_NAME + "_TestPanelBroadcastReceiver";
|
||||
|
||||
private Context mContext;
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
try {
|
||||
boolean textPanelOpenStatus = intent.getBooleanExtra(V2XConst.BROADCAST_TEST_PANEL_CONTROL_EXTRA_KEY, false);
|
||||
int textPanelOpenType = intent.getIntExtra(V2XConst.BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY, 0);
|
||||
Logger.d(TAG, "textPanelOpenStatus:" + textPanelOpenStatus);
|
||||
Logger.d(TAG, "textPanelOpenType:" + textPanelOpenType);
|
||||
if (textPanelOpenStatus) {
|
||||
V2XServiceManager
|
||||
.getIMogoWindowManager()
|
||||
.addView(V2XTestConsoleWindow.getInstance(context, textPanelOpenType), 0, 0, false);
|
||||
} else {
|
||||
V2XServiceManager
|
||||
.getIMogoWindowManager()
|
||||
.removeView(V2XTestConsoleWindow.getInstance(context, textPanelOpenType));
|
||||
this.mContext = context;
|
||||
int sceneType = intent.getIntExtra(V2XConst.BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY, 0);
|
||||
Logger.d(TAG, "textPanelOpenType:" + sceneType);
|
||||
|
||||
// 分发场景
|
||||
dispatchSceneTest(sceneType);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分发处理场景
|
||||
*
|
||||
* @param sceneType 场景类型
|
||||
*/
|
||||
private void dispatchSceneTest(int sceneType) {
|
||||
Logger.d(TAG, "sceneType=" + sceneType);
|
||||
if (sceneType == 0) {//打开用户信息
|
||||
MogoDriverInfo mogoDriverInfo = new MogoDriverInfo();
|
||||
mogoDriverInfo.setAge(24);
|
||||
mogoDriverInfo.setGender(GENDER_MALE);
|
||||
mogoDriverInfo.setSn("12345678");
|
||||
mogoDriverInfo.setUserName("测试");
|
||||
mogoDriverInfo.setUserHead("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1600872867592&di=994e371880ca6ae2814f553e0d0e4139&imgtype=0&src=http%3A%2F%2Fp3.ssl.cdn.btime.com%2Ft014c5d8a1e5cef12ba.jpg%3Fsize%3D506x543");
|
||||
if (V2XServiceManager.getCarsChattingProvider() != null) {
|
||||
V2XServiceManager.getCarsChattingProvider().showUserWindow("CAR_CALL_USER_TO_" + V2XConst.MODULE_NAME, mogoDriverInfo, mContext);
|
||||
}
|
||||
} else if (sceneType == 1) {// 触发道路事件
|
||||
V2XMessageEntity<V2XRoadEventEntity> v2XMessageEntity =
|
||||
TestOnLineCarUtils.getV2XScenarioRoadEventData();
|
||||
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
|
||||
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
|
||||
|
||||
|
||||
// 存储本地,出行动态作展示
|
||||
saveLocalStory(V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_WARNING,
|
||||
v2XMessageEntity.getContent().getNoveltyInfo());
|
||||
} else if (sceneType == 2) {//车路云—场景预警-V1.0 碰撞预警
|
||||
V2XMessageEntity<V2XWarningEntity> v2XMessageEntity =
|
||||
TestOnLineCarUtils.getV2XScenarioPushFrontWarningEventData();
|
||||
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
|
||||
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
|
||||
} else if (sceneType == 3) {//触发H5推送事件
|
||||
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity =
|
||||
TestOnLineCarUtils.getV2XScenarioPushEventData();
|
||||
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
|
||||
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
|
||||
} else if (sceneType == 4) {//触发H5推送直播事件
|
||||
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity =
|
||||
TestOnLineCarUtils.getV2XScenarioPushLiveEventData();
|
||||
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
|
||||
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
|
||||
} else if (sceneType == 5) {//H5推送触发V2X动画
|
||||
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity =
|
||||
TestOnLineCarUtils.getV2XScenarioAnimationEventData();
|
||||
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
|
||||
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
|
||||
} else if (sceneType == 6) {//查看前车直播
|
||||
V2XVoiceCallLiveBiz.getInstance().getFrontCarLive();
|
||||
} else if (sceneType == 7) {//查看前车直播
|
||||
V2XVoiceCallLiveBiz.getInstance().getOpenRoadCameraLive();
|
||||
} else if (sceneType == 8) {//触发疲劳驾驶
|
||||
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity =
|
||||
TestOnLineCarUtils.getV2XScenarioFatigueDrivingData();
|
||||
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
|
||||
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
|
||||
} else if (sceneType == 9) {//触发他人发起道路求助事件
|
||||
V2XMessageEntity<List<V2XSpecialCarRes.V2XMarkerEntity>> v2XMessageEntity =
|
||||
TestOnLineCarUtils.getV2XScenarioSeekHelpData();
|
||||
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
|
||||
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
|
||||
} else if (sceneType == 10) {//触发事件UGC
|
||||
V2XMessageEntity<V2XRoadEventEntity> v2XMessageEntity =
|
||||
TestOnLineCarUtils.getV2XScenarioRoadEventUGCData();
|
||||
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
|
||||
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
|
||||
} else if (sceneType == 11) {//触发违章停车事件
|
||||
V2XMessageEntity<List<MarkerExploreWay>> v2XMessageEntity =
|
||||
TestOnLineCarUtils.getV2XIllegalParkData();
|
||||
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
|
||||
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
|
||||
} else if (sceneType == 12) {//车路云场景预警-右侧
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_ADAS_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_ADAS_EXTRA_KEY, "right");
|
||||
mContext.sendBroadcast(intent);
|
||||
} else if (sceneType == 13) {//车路云场景预警-左侧
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_ADAS_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_ADAS_EXTRA_KEY, "left");
|
||||
mContext.sendBroadcast(intent);
|
||||
} else if (sceneType == 14) {//行人预警,行人路线预测 车路云预警-前方行人
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_ADAS_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_ADAS_EXTRA_KEY, "pedestrians");
|
||||
mContext.sendBroadcast(intent);
|
||||
} else if (sceneType == 15) {// 交通状况查询
|
||||
V2XServiceManager.getIMogoTrafficUploadProvider().verifyCurrentTrafficStatus();
|
||||
} else if (sceneType == 16) {//触发基于目的地预测的线路推荐
|
||||
V2XServiceManager.getV2XRefreshModel().queryRoadData("F803EB2046PZD00149");
|
||||
} else if (sceneType == 17) {//最优路线推荐
|
||||
V2XMessageEntity<V2XOptimalRouteDataRes> v2XMessageEntity =
|
||||
TestOnLineCarUtils.getV2XOptimalRoute();
|
||||
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
|
||||
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 存储本地数据
|
||||
*
|
||||
* @param v2XRoadEventEntity 要存储的场景
|
||||
*/
|
||||
public void saveLocalStory(int scenarioType, MarkerExploreWay v2XRoadEventEntity) {
|
||||
try {
|
||||
V2XSQLiteUtils.saveLocalStory(scenarioType, v2XRoadEventEntity, v2XRoadEventEntity.hashCode());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ import static android.text.style.TtsSpan.GENDER_MALE;
|
||||
* desc : 用来测试的控制台 Window
|
||||
* version: 1.0
|
||||
*/
|
||||
@Deprecated
|
||||
public class V2XTestConsoleWindow extends ConstraintLayout {
|
||||
private static V2XTestConsoleWindow mV2XTestConsoleWindow;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user