Merge branch 'qa_1.1.3'

This commit is contained in:
wangcongtao
2020-09-03 16:48:02 +08:00
70 changed files with 1379 additions and 185 deletions

View File

@@ -110,13 +110,27 @@ android {
// 是否使用高德sdk自定义导航
buildConfigField 'boolean', 'USE_CUSTOM_NAVI', 'false'
}
// f系列-分体机
f80x {
applicationId rootProject.ext.android.fLauncherApplicationId
dimension "product"
// 使用思必驰语音
buildConfigField 'int', 'AIType', '2'
buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'false'
// 车机类型主要用于区分自研车机还是别人家的车机自研车机类型为0
buildConfigField 'int', 'CAR_MACHINE_TYPE', '0'
buildConfigField 'boolean', 'ROAD_EVENT_ANIMATED', 'true'
manifestPlaceholders = [AMAP_API_VALUE: rootProject.ext.android.fLauncherAmapApiValue]
// 是否使用高德sdk自定义导航
buildConfigField 'boolean', 'USE_CUSTOM_NAVI', 'false'
}
// e系列采用Launcher方案
e8xx {
applicationId rootProject.ext.android.launcherApplicationId
dimension "product"
// 使用思必驰语音
buildConfigField 'int', 'AIType', '2'
buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'true'
buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'false'
// 车机类型主要用于区分自研车机还是别人家的车机自研车机类型为0
buildConfigField 'int', 'CAR_MACHINE_TYPE', '0'
buildConfigField 'boolean', 'ROAD_EVENT_ANIMATED', 'true'
@@ -130,7 +144,7 @@ android {
dimension "product"
// 使用思必驰语音
buildConfigField 'int', 'AIType', '2'
buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'true'
buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'false'
// 车机类型主要用于区分自研车机还是别人家的车机自研车机类型为0
buildConfigField 'int', 'CAR_MACHINE_TYPE', '0'
buildConfigField 'boolean', 'ROAD_EVENT_ANIMATED', 'true'
@@ -144,7 +158,7 @@ android {
dimension "product"
// 使用思必驰语音
buildConfigField 'int', 'AIType', '2'
buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'true'
buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'false'
// 车机类型主要用于区分自研车机还是别人家的车机自研车机类型为0
buildConfigField 'int', 'CAR_MACHINE_TYPE', '0'
buildConfigField 'boolean', 'ROAD_EVENT_ANIMATED', 'false'
@@ -158,7 +172,7 @@ android {
dimension "product"
// 使用思必驰语音
buildConfigField 'int', 'AIType', '2'
buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'true'
buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'false'
// 车机类型主要用于区分自研车机还是别人家的车机自研车机类型为0
buildConfigField 'int', 'CAR_MACHINE_TYPE', '0'
buildConfigField 'boolean', 'ROAD_EVENT_ANIMATED', 'false'
@@ -172,7 +186,21 @@ android {
dimension "product"
// 使用同行者语音
buildConfigField 'int', 'AIType', '1'
buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'true'
buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'false'
// 车机类型主要用于区分自研车机还是别人家的车机自研车机类型为0
buildConfigField 'int', 'CAR_MACHINE_TYPE', '0'
buildConfigField 'boolean', 'ROAD_EVENT_ANIMATED', 'false'
manifestPlaceholders = [AMAP_API_VALUE: rootProject.ext.android.commonIndependentAmapApiValue]
// 是否使用高德sdk自定义导航
buildConfigField 'boolean', 'USE_CUSTOM_NAVI', 'false'
}
// d系列 2 + 32
d80x {
applicationId rootProject.ext.android.independentApplicationId
dimension "product"
// 使用同行者语音
buildConfigField 'int', 'AIType', '1'
buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'false'
// 车机类型主要用于区分自研车机还是别人家的车机自研车机类型为0
buildConfigField 'int', 'CAR_MACHINE_TYPE', '0'
buildConfigField 'boolean', 'ROAD_EVENT_ANIMATED', 'false'
@@ -186,7 +214,7 @@ android {
dimension "product"
// 使用同行者语音
buildConfigField 'int', 'AIType', '1'
buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'true'
buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'false'
// 车机类型主要用于区分自研车机还是别人家的车机自研车机类型为0
buildConfigField 'int', 'CAR_MACHINE_TYPE', '0'
buildConfigField 'boolean', 'ROAD_EVENT_ANIMATED', 'false'
@@ -251,8 +279,6 @@ dependencies {
implementation rootProject.ext.dependencies.mogologlib
if (Boolean.valueOf(RELEASE)) {
launcherImplementation rootProject.ext.dependencies.modulemainlauncher
independentImplementation rootProject.ext.dependencies.modulemainindependent
implementation rootProject.ext.dependencies.mogocommons
implementation rootProject.ext.dependencies.modulecommon
implementation rootProject.ext.dependencies.modulesearch
@@ -270,8 +296,6 @@ dependencies {
implementation rootProject.ext.dependencies.mogomodulewidgets
implementation rootProject.ext.dependencies.mogomoduleback
} else {
launcherImplementation project(':main-extensions:mogo-module-main-launcher')
independentImplementation project(':main-extensions:mogo-module-main-independent')
implementation project(':foudations:mogo-commons')
implementation project(':modules:mogo-module-common')
implementation project(':modules:mogo-module-search')
@@ -289,6 +313,7 @@ dependencies {
implementation project(':modules:mogo-module-back')
}
apply from: "./functions/perform.gradle"
apply from: "./functions/baseservices.gradle"
apply from: "./functions/socketpush.gradle"
apply from: "./functions/gpssimulator.gradle"

View File

@@ -7,10 +7,12 @@ project.dependencies {
d82xImplementation rootProject.ext.dependencies.mogobaseserviceapk
em1Implementation rootProject.ext.dependencies.mogobaseserviceapk
d8xxImplementation rootProject.ext.dependencies.mogobaseserviceapk
d80xImplementation rootProject.ext.dependencies.mogobaseserviceapk
em4Implementation rootProject.ext.dependencies.mogobaseserviceapk
e8xxImplementation rootProject.ext.dependencies.mogobaseserviceapk
e8xxImplementation rootProject.ext.dependencies.mogobaseserviceapk
f8xxImplementation rootProject.ext.dependencies.mogobaseserviceapk
f80xImplementation rootProject.ext.dependencies.mogobaseserviceapk
em3Implementation rootProject.ext.dependencies.mogobaseserviceapk
} else {
bydautoImplementation project(':foudations:mogo-base-services-sdk')
@@ -18,9 +20,11 @@ project.dependencies {
d82xImplementation project(':foudations:mogo-base-services-apk')
em1Implementation project(':foudations:mogo-base-services-apk')
d8xxImplementation project(':foudations:mogo-base-services-apk')
d80xImplementation project(':foudations:mogo-base-services-apk')
em4Implementation project(':foudations:mogo-base-services-apk')
e8xxImplementation project(':foudations:mogo-base-services-apk')
f8xxImplementation project(':foudations:mogo-base-services-apk')
f80xImplementation project(':foudations:mogo-base-services-apk')
em3Implementation project(':foudations:mogo-base-services-apk')
}
}

View File

@@ -7,10 +7,12 @@ project.dependencies {
bydautoImplementation rootProject.ext.dependencies.moduleleftpanel
d8xxImplementation rootProject.ext.dependencies.moduleleftpanelnoop
d80xImplementation rootProject.ext.dependencies.moduleleftpanelnoop
em4Implementation rootProject.ext.dependencies.moduleleftpanelnoop
e8xxImplementation rootProject.ext.dependencies.moduleleftpanelnoop
e8xxImplementation rootProject.ext.dependencies.moduleleftpanelnoop
f8xxImplementation rootProject.ext.dependencies.moduleleftpanelnoop
f80xImplementation rootProject.ext.dependencies.moduleleftpanelnoop
em3Implementation rootProject.ext.dependencies.moduleleftpanelnoop
} else {
d82xImplementation project(':modules:mogo-module-left-panel')
@@ -18,9 +20,11 @@ project.dependencies {
bydautoImplementation project(':modules:mogo-module-left-panel')
d8xxImplementation project(':modules:mogo-module-left-panel-noop')
d80xImplementation project(':modules:mogo-module-left-panel-noop')
em4Implementation project(':modules:mogo-module-left-panel-noop')
e8xxImplementation project(':modules:mogo-module-left-panel-noop')
f8xxImplementation project(':modules:mogo-module-left-panel-noop')
f80xImplementation project(':modules:mogo-module-left-panel-noop')
em3Implementation project(':modules:mogo-module-left-panel-noop')
}
}

View File

@@ -0,0 +1,11 @@
// 表现:独立 app 和 launcher
project.dependencies {
if (Boolean.valueOf(RELEASE)) {
launcherImplementation rootProject.ext.dependencies.modulemainlauncher
independentImplementation rootProject.ext.dependencies.modulemainindependent
} else {
launcherImplementation project(':main-extensions:mogo-module-main-launcher')
independentImplementation project(':main-extensions:mogo-module-main-independent')
}
}

View File

@@ -2,8 +2,8 @@
afterEvaluate {
def independent = ["em3", "em1", "d8xx", "d82x", "bydauto"]
def launcher = ["f8xx", "em4"]
def independent = ["em3", "em1", "d80x", "d82x", "bydauto"]
def launcher = ["f80x", "em4"]
it.getTasks().iterator().forEachRemaining {
def task = it

View File

@@ -12,6 +12,7 @@
android:label="@string/app_shell_name"
android:supportsRtl="true"
android:theme="@style/AppTheme.App"
android:resizeableActivity="false"
tools:replace="android:label">
<meta-data
android:name="com.amap.api.v2.apikey"
@@ -28,6 +29,8 @@
<activity
android:name="com.zhidao.boot.persistent.lib.PersistentAliveActivity"
android:screenOrientation="landscape"
android:resizeableActivity="false"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
</application>

View File

@@ -75,8 +75,8 @@ public class MogoApplication extends AbsMogoApplication {
MogoModulePaths.addBaseModule( new MogoModule( ServiceConst.PATH_REFRESH_STRATEGY, ServiceConst.PATH_REFRESH_STRATEGY ) );
MogoModulePaths.addBaseModule( new MogoModule( V2XConst.PATH_V2X_UI, V2XConst.MODULE_NAME ) );
MogoModulePaths.addBaseModule(new MogoModule(MogoServicePaths.PATH_MOGO_MONITOR,
"MogoMonitor"));
MogoModulePaths.addBaseModule(new MogoModule( MogoServicePaths.PATH_STRATEGY_SHARE,"StrategyShare"));
MogoModulePaths.addBaseModule(new MogoModule(MogoServicePaths.PATH_MOGO_MONITOR, "MogoMonitor"));
MogoModulePaths.addModule( new MogoModule( V2XConst.PATH_EVENT_PANEL, V2XConst.MODULE_NAME_EVENT_PANEL ) );
MogoModulePaths.addModule( new MogoModule( PushUIConstants.PATH, PushUIConstants.NAME ) );

View File

@@ -3,7 +3,6 @@ apply from: "config.gradle"
apply from: "javadoc.gradle"
buildscript {
ext.kotlin_version = '1.3.61'
repositories {
maven {
url 'http://maven.aliyun.com/nexus/content/groups/public/'
@@ -19,7 +18,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.71'
classpath "com.alibaba:arouter-register:1.0.2"
classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:2.0.4'
// NOTE: Do not place your application dependencies here; they belong

View File

@@ -1,6 +1,6 @@
ext {
time = ""
kotlin_version = "1.3.71"
android = [
// applicationId : "com.mogo.launcher",
// zhidadoApplicationId: "com.zhidao.launcher",
@@ -20,8 +20,8 @@ ext {
dependencies = [
// androidx
androidxappcompat : "androidx.appcompat:appcompat:1.0.2",
androidxccorektx : "androidx.core:core-ktx:1.2.0",
androidxappcompat : "androidx.appcompat:appcompat:1.1.0",
androidxccorektx : "androidx.core:core-ktx:1.3.0",
androidxconstraintlayout : "androidx.constraintlayout:constraintlayout:1.1.3",
boostmultidex : "com.bytedance.boost_multidex:boost_multidex:1.0.1",
androidxviewpager2 : "androidx.viewpager2:viewpager2:1.0.0",
@@ -141,7 +141,7 @@ ext {
accountsdk : "com.zhidao.accountservice:account-sdk:1.0.11",
// crash
crashSdk : "com.zhidaoauto.crash.log:library:1.0.5",
kotlinstdlibjdk7 : "org.jetbrains.kotlin:kotlin-stdlib-jdk7",
kotlinstdlibjdk7 : "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${kotlin_version}",
//探路
videoarmv7 : "com.shuyu:gsyVideoPlayer-armv7a:7.1.2",
@@ -196,6 +196,8 @@ ext {
androidxroomktx : "androidx.room:room-ktx:2.2.3",
//
mogomodulewidgets : "com.mogo.module:module-widgets:${MOGO_MODULE_WIDGETS_VERSION}",
mogomodulewidgets : "com.mogo.module:module-widgets:${MOGO_MODULE_WIDGETS_VERSION}",
kotlingradleplugin : "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}"
]
}

View File

@@ -61,7 +61,7 @@ class PassportManager implements IMogoPassportManager {
@Override
public void onFailure( int code, String msg ) {
Logger.d( TAG, "fail" );
Logger.d( TAG, "fail code= %s, msg=%s", code, msg );
if ( callback != null ) {
callback.onError( code, msg );
}

View File

@@ -69,7 +69,7 @@ class PassportManager implements IMogoPassportManager {
@Override
public void onFailure( int code ) {
Logger.d( TAG, "fail" );
Logger.d( TAG, "fail: code = %s", code );
if ( callback != null ) {
callback.onError( code, "getTicket error." );
}
@@ -79,6 +79,7 @@ class PassportManager implements IMogoPassportManager {
@Override
public void onFailure( int code, String msg ) {
Logger.d( TAG, "onFailure: code = %s, msg = %s", code, msg );
if ( callback != null ) {
callback.onError( code, "login: " + msg );
}

View File

@@ -193,7 +193,7 @@ public class DebugConfig {
/**
* 是否支持临时激活小智
*/
private static boolean sActiveAIAssistFlag = true;
private static boolean sActiveAIAssistFlag = false;
public static boolean isActiveAIAssistFlag() {
return sActiveAIAssistFlag;

View File

@@ -41,7 +41,6 @@ public abstract class MvpFragment<V extends IView, P extends Presenter<V>> exten
viewGroup.removeView( mRootView );
}
}
mRootView = inflater.inflate(getLayoutId(), container, false);
return mRootView;
}
@@ -90,7 +89,7 @@ public abstract class MvpFragment<V extends IView, P extends Presenter<V>> exten
@Nullable
protected <T extends View> T findViewById(int id) {
if (mRootView == null) {
mRootView = getView().findViewById(id);
mRootView = getView();
}
if (mRootView != null) {
return (T) mRootView.findViewById(id);

View File

@@ -4,7 +4,6 @@ import android.content.Context;
import com.amap.api.maps.AMap;
import com.amap.api.maps.CameraUpdateFactory;
import com.amap.api.maps.LocationSource;
import com.amap.api.maps.model.Marker;
import com.amap.api.maps.model.MarkerOptions;
import com.amap.api.maps.model.Polyline;
@@ -14,7 +13,6 @@ import com.mogo.map.IMogoMap;
import com.mogo.map.IMogoUiSettings;
import com.mogo.map.impl.amap.marker.AMapInfoWindowAdapter;
import com.mogo.map.impl.amap.marker.AMapMarkerWrapper;
import com.mogo.map.impl.amap.navi.NaviClient;
import com.mogo.map.impl.amap.overlay.AMapPolylineWrapper;
import com.mogo.map.impl.amap.uicontroller.AMapUIController;
import com.mogo.map.impl.amap.utils.ObjectUtils;

View File

@@ -9,6 +9,7 @@ import com.amap.api.maps.model.Polyline;
import com.amap.api.navi.AMapNavi;
import com.amap.api.navi.enums.AimLessMode;
import com.amap.api.navi.enums.NaviType;
import com.amap.api.navi.model.AMapNaviPath;
import com.amap.api.navi.model.NaviLatLng;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.debug.DebugConfig;
@@ -30,6 +31,7 @@ import com.mogo.utils.storage.SharedPrefsMgr;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* @author congtaowang
@@ -48,10 +50,9 @@ public class NaviClient implements IMogoNavi {
private final Context mContext;
private AMapNavi mAMapNavi;
private final NaviListenerAdapter mAMapNaviListener;
private NaviListenerAdapter mAMapNaviListener;
private final AimlessModeListenerAdapter mAimlessModeListener;
private AimlessModeListenerAdapter mAimlessModeListener;
/**
* 导航策略配置
@@ -77,10 +78,23 @@ public class NaviClient implements IMogoNavi {
private NaviClient( Context context ) {
mContext = context;
mAMapNavi = AMapNavi.getInstance( context );
if ( DebugConfig.isUseCustomNavi() ) {
// 按需初始化导航组件
initAMapNavi();
}
}
/**
* 初始化导航组件
*/
private void initAMapNavi() {
if ( mAMapNavi != null ) {
return;
}
mAMapNavi = AMapNavi.getInstance( mContext );
mAMapNavi.setEmulatorNaviSpeed( 120 );
mAMapNavi.setUseInnerVoice( DebugConfig.isUseCustomNavi(), true );
mAMapNaviListener = new NaviListenerAdapter( context, mAMapNavi, this );
mAMapNavi.setUseInnerVoice( DebugConfig.isUseCustomNavi(), false );
mAMapNaviListener = new NaviListenerAdapter( mContext, this );
mAimlessModeListener = new AimlessModeListenerAdapter() {
};
mAMapNavi.addAMapNaviListener( mAMapNaviListener );
@@ -165,10 +179,28 @@ public class NaviClient implements IMogoNavi {
}
}
public void stopAMapNavi() {
if ( mAMapNavi != null ) {
mAMapNavi.stopNavi();
}
}
public void selectAMapRouteId( int routeId ) {
if ( mAMapNavi != null ) {
mAMapNavi.selectRouteId( routeId );
}
}
public Map< Integer, AMapNaviPath > getAMapNaviPaths() {
if ( mAMapNavi != null ) {
return mAMapNavi.getNaviPaths();
}
return null;
}
@Override
public void startNavi( boolean isRealNavi ) {
if ( mAMapNaviListener.isStopped() ) {
if ( mAMapNaviListener != null && mAMapNaviListener.isStopped() ) {
return;
}
mIsRealNavi = isRealNavi;
@@ -243,6 +275,9 @@ public class NaviClient implements IMogoNavi {
@Override
public boolean setBroadcastMode( int mode ) {
if ( checkAMapNavi() ) {
return false;
}
return mAMapNavi.setBroadcastMode( mode );
}
@@ -300,6 +335,9 @@ public class NaviClient implements IMogoNavi {
@Override
public void startAimlessMode() {
if ( checkAMapNavi() ) {
return;
}
if ( mAimlessModeStatus && !isNaviing() ) {
mAMapNavi.startAimlessMode( AimLessMode.CAMERA_AND_SPECIALROAD_DETECTED );
mAimlessStatus = true;
@@ -312,6 +350,9 @@ public class NaviClient implements IMogoNavi {
@Override
public void stopAimlessMode() {
if ( checkAMapNavi() ) {
return;
}
mAMapNavi.stopAimlessMode();
mAimlessStatus = false;
Logger.d( TAG, "关闭巡航成功" );
@@ -341,6 +382,15 @@ public class NaviClient implements IMogoNavi {
@Override
public void setUseExtraGPSData( boolean use ) {
// 如果使用平台模拟位置变化,需要用到导航组件
if ( use ) {
initAMapNavi();
} else {
destroyAMapNavi();
}
if ( checkAMapNavi() ) {
return;
}
Logger.d( TAG, "设置外部gps源状态 %s", use );
mAMapNavi.setIsUseExtraGPSData( use );
if ( AMapWrapper.getAMap() == null ) {
@@ -364,8 +414,22 @@ public class NaviClient implements IMogoNavi {
AMapWrapper.getAMap().setMyLocationEnabled( true );
}
/**
* 销毁导航组件
*/
private void destroyAMapNavi() {
if ( mAMapNavi != null ) {
mAMapNavi.removeAMapNaviListener( mAMapNaviListener );
mAMapNavi.removeAimlessModeListener( mAimlessModeListener );
mAMapNavi.destroy();
}
}
@Override
public void setExtraGPSData( double lon, double lat, float speed, float accuracy, float bearing, long timestamp ) {
if ( checkAMapNavi() ) {
return;
}
if ( !mAMapNavi.getIsUseExtraGPSData() ) {
Logger.d( TAG, "拒绝外部GPS数据" );
return;

View File

@@ -6,15 +6,10 @@ import android.os.Trace;
import android.text.TextUtils;
import com.amap.api.maps.model.Polyline;
import com.amap.api.navi.AMapNavi;
import com.amap.api.navi.AimlessModeListener;
import com.amap.api.navi.enums.AimLessMode;
import com.amap.api.navi.enums.CameraType;
import com.amap.api.navi.enums.CarEnterCameraStatus;
import com.amap.api.navi.enums.NaviType;
import com.amap.api.navi.model.AMapCalcRouteResult;
import com.amap.api.navi.model.AMapNaviCameraInfo;
import com.amap.api.navi.model.AMapNaviInfo;
import com.amap.api.navi.model.AMapNaviLocation;
import com.amap.api.navi.model.NaviInfo;
import com.mogo.commons.voice.AIAssist;
@@ -27,7 +22,6 @@ import com.mogo.map.navi.MogoNaviListenerHandler;
import com.mogo.map.navi.MogoTraffic;
import com.mogo.map.navi.OnCalculatePathItemClickInteraction;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.WorkThreadHandler;
import com.mogo.utils.logger.Logger;
import java.util.List;
@@ -43,7 +37,6 @@ public class NaviListenerAdapter extends AMapNaviListenerAdapter {
private static final String TAG = "NaviListenerAdapter";
private Context mContext;
private AMapNavi mAMapNavi;
private NaviClient mClient;
/**
* 导航状态true - 导航 onStartNavi(int) 被调用, false - 到达目的地、手动挺固执
@@ -60,11 +53,10 @@ public class NaviListenerAdapter extends AMapNaviListenerAdapter {
*/
private NaviOverlayHelper mNaviOverlayHelper;
public NaviListenerAdapter( Context mContext, AMapNavi mAMapNavi, NaviClient client ) {
public NaviListenerAdapter( Context mContext, NaviClient client ) {
this.mContext = mContext;
this.mAMapNavi = mAMapNavi;
this.mClient = client;
mNaviOverlayHelper = new NaviOverlayHelper( mAMapNavi, AMapWrapper.getAMap(), mContext );
mNaviOverlayHelper = new NaviOverlayHelper( AMapWrapper.getAMap(), mContext );
}
public void setNaviing( boolean mIsNaviing ) {
@@ -240,16 +232,15 @@ public class NaviListenerAdapter extends AMapNaviListenerAdapter {
mNaviOverlayHelper.clearCalculatedOverlay();
setStopped( true );
setNaviing( false );
mAMapNavi.stopNavi();
mClient.stopAMapNavi();
MogoNaviListenerHandler.getInstance().onStopNavi();
AMapMessageManager.getInstance().postNaviStopped();
}
public void handleClickedPolyline( Polyline polyline ) {
if ( mNaviOverlayHelper != null ) {
mNaviOverlayHelper.handleClickedPolyline( polyline, isNaviing() );
mAMapNavi.selectRouteId( mNaviOverlayHelper.getSelectedPathId() );
mClient.selectAMapRouteId( mNaviOverlayHelper.getSelectedPathId() );
mNaviOverlayHelper.showBoundsWithSettingBounds();
}
}

View File

@@ -14,7 +14,6 @@ import com.amap.api.maps.model.LatLngBounds;
import com.amap.api.maps.model.Marker;
import com.amap.api.maps.model.MarkerOptions;
import com.amap.api.maps.model.Polyline;
import com.amap.api.navi.AMapNavi;
import com.amap.api.navi.model.AMapNaviLocation;
import com.amap.api.navi.model.AMapNaviPath;
import com.amap.api.navi.model.NaviInfo;
@@ -55,7 +54,6 @@ public class NaviOverlayHelper implements OnCalculatePathItemClickInteraction {
*/
public static final float AMAP_ROUTE_OVERLAY_TRANSPARENCY_UNSELECTED = 0.3f;
private AMapNavi mAMapNavi;
private AMap mAMap;
private Context mContext;
// 规划的路线显示边距
@@ -73,8 +71,7 @@ public class NaviOverlayHelper implements OnCalculatePathItemClickInteraction {
*/
private List< Marker > mMarkers = new ArrayList<>();
public NaviOverlayHelper( AMapNavi mAMapNavi, AMap mAMap, Context mContext ) {
this.mAMapNavi = mAMapNavi;
public NaviOverlayHelper( AMap mAMap, Context mContext ) {
this.mAMap = mAMap;
this.mContext = mContext;
calculateBoundArea();
@@ -125,7 +122,7 @@ public class NaviOverlayHelper implements OnCalculatePathItemClickInteraction {
*/
private List< CalculatePathItem > getSortedPaths() {
checkAMapInstance();
final Map< Integer, AMapNaviPath > pathMap = mAMapNavi.getNaviPaths();
final Map< Integer, AMapNaviPath > pathMap = NaviClient.getInstance( mContext ).getAMapNaviPaths();
if ( pathMap == null || pathMap.isEmpty() ) {
return null;
}
@@ -219,7 +216,7 @@ public class NaviOverlayHelper implements OnCalculatePathItemClickInteraction {
mSelectedCalculatePathItem = item;
//wrapper.setStartBitmap( R.drawable.ic_navi_start )
// .setEndBitmap( R.drawable.ic_navi_target );
mAMapNavi.selectRouteId( item.getId() );
NaviClient.getInstance( mContext ).selectAMapRouteId( item.getId() );
Logger.d( TAG, "renderPathOverlay set default path" );
}
wrapper.addToMap();
@@ -435,7 +432,7 @@ public class NaviOverlayHelper implements OnCalculatePathItemClickInteraction {
@Override
public void onItemClicked( String tagId ) {
handleClickedPolyline( tagId );
mAMapNavi.selectRouteId( getSelectedPathId() );
NaviClient.getInstance( mContext ).selectAMapRouteId( getSelectedPathId() );
showBounds( mBoundRect );
}

View File

@@ -3,6 +3,8 @@ package com.zhidao.mogo.tanlu.api;
import android.content.Context;
import android.util.ArrayMap;
import androidx.annotation.NonNull;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.commons.analytics.AnalyticsUtils;
@@ -42,9 +44,10 @@ public class MogoTanluApiProvider implements IMogoTanluProvider {
properties.put("from", params.getFromType());
AnalyticsUtils.track("v2x_share_type", properties);
MainService.Companion.launchService(context, new UploadParams(params.getEventType(),
params.getFromType(), params.getDuration()));
params.getFromType(), params.getDuration(), params.getParentId(),
params.getLocation().lat, params.getLocation().lon));
}else{
throw new IllegalArgumentException("TanluUploadParams 不允许为空");
Logger.e(MODULE_NAME,"params为空无法上报情报");
}
}

View File

@@ -39,13 +39,10 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.3.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.zhidaoauto.common:service:1.0.4.10'
implementation rootProject.ext.dependencies.kotlinstdlibjdk7
implementation rootProject.ext.dependencies.androidxappcompat
implementation rootProject.ext.dependencies.androidxccorektx
implementation rootProject.ext.dependencies.aiassist
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.6.0'
implementation 'com.zhidaoauto.controller:api:1.0.8'
@@ -53,6 +50,7 @@ dependencies {
implementation 'com.zhidao.video:video-processor:1.0.2.1'
implementation 'com.foundation.utils:common-utils:1.0.7'
implementation rootProject.ext.dependencies.eventbus
compileOnly rootProject.ext.dependencies.mogocommons
implementation rootProject.ext.dependencies.eventbus
implementation rootProject.ext.dependencies.coroutinescore

View File

@@ -9,7 +9,6 @@ import com.mogo.utils.NetworkUtils
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.BuildConfig
import com.zhidao.roadcondition.constant.*
import com.zhidao.roadcondition.event.GetImageSuccessEvent
import com.zhidao.roadcondition.event.LatLngStickyEventBus
@@ -34,6 +33,8 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
var mType: String = "" //1 上报拥堵, 2 封路和查车
var mainInfoId: Long = 0
var mFromType: String = ""
private var mLongitude: Double = 0.0
private var mLatitude: Double = 0.0
private var getVideoFailed: (() -> Unit)? = null
private var interceptors: ArrayList<TakePhotoInterceptor> = ArrayList(1)
@@ -69,12 +70,16 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
isCustom: Boolean = false,
type: String,
mainInfoId: Long,
fromType: String
fromType: String,
longitude: Double,
latitude: Double
) {
Log.d(TAG, "takePhoto ---------- type = $type --- mType = $mType ---fromType = $fromType")
this.mType = type
this.mainInfoId = mainInfoId
this.mFromType = fromType
this.mLongitude = longitude
this.mLatitude = latitude
CustomStatusHandler.offerPhotoStatus(isCustom)
zdCarCoderController.takePhoto(photoType, cameraId, haveVoice)
trackGetPhoto(1)
@@ -91,13 +96,16 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
id: Long = 0L,
type: String,
mainInfoId: Long,
fromType: String
fromType: String,
longitude: Double,
latitude: Double
) {
Log.d(TAG, "takeVideo -------- type = $type")
Log.d(TAG, "takeVideo -------- isCustom = $isCustom ---mFromType = $mFromType")
Log.d(TAG, "takeVideo -------- isCustom = $isCustom ---mFromType = $mFromType ---type = $type" )
this.mType = type
this.mainInfoId = mainInfoId
this.mFromType = fromType
this.mLongitude = longitude
this.mLatitude = latitude
if (DebugConfig.getCarMachineType() == 0) { //自研车机
outputVideoPath = getCompressVideoPath()
CustomStatusHandler.offerVideoStatus(TakeEntity(isCustom, id))
@@ -118,7 +126,9 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
videoAndThumbMap,
mType,
entity,
mainInfoId
mainInfoId,
mLongitude,
mLatitude
)
//地图上打点
@@ -177,7 +187,9 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
mutableMapOf("pic" to "" as String),
mType,
entity,
mainInfoId
mainInfoId,
mLongitude,
mLatitude
);
}
}
@@ -219,7 +231,8 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
if (!TextUtils.isEmpty(mType)) {
Log.d(TAG, "onTakePhotoSuccess mType != null")
CosStatusController().uploadFile(mutableListOf(photoPath as String), entity, mType, mainInfoId, mFromType)
CosStatusController().uploadFile(mutableListOf(photoPath as String), entity, mType, mainInfoId, mFromType, mLongitude,
mLatitude)
} else {
Log.d(TAG, "onTakePhotoSuccess mType == null")
Log.d(
@@ -234,7 +247,9 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
entity,
mType,
mainInfoId,
mFromType
mFromType,
mLongitude,
mLatitude
)
}
}
@@ -247,7 +262,9 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
entity,
mType,
mainInfoId,
mFromType
mFromType,
mLongitude,
mLatitude
)
}
}
@@ -279,12 +296,6 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
getStrategyType("video")
)
var speed = LocationUtil.getInstance().getSpeed()
//TODO
if (BuildConfig.DEBUG) {
//获取视频以及缩略图成功,开始上报
compressVideo(videoPath, thumbnailPath, entity)
return
}
if (entity?.isCustom) {
compressVideo(videoPath, thumbnailPath, entity)
@@ -336,7 +347,9 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
videoAndThumbMap,
mType,
entity,
mainInfoId
mainInfoId,
mLongitude,
mLatitude
)
//地图上打点
@@ -375,7 +388,9 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
entity,
mType,
mainInfoId,
mFromType
mFromType,
mLongitude,
mLatitude
)
//删除压缩前的视频
deletePicFile(videoPath)

View File

@@ -38,16 +38,21 @@ class CosStatusController : CosStatusCallback {
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
//上传文件
fun uploadFile(picPath: MutableList<String>, entity: TakeEntity, type: String, mainInfoId: Long, fromType: String) {
fun uploadFile(picPath: MutableList<String>, entity: TakeEntity, type: String, mainInfoId: Long,
fromType: String, longitude: Double, latitude: Double) {
CosCallbackMapController.registerCallback(picPath, this)
// CosLogger.setLogStatus(true)
this.entity = entity
this.mType = type
this.mainInfoId = mainInfoId
this.mFromType = fromType;
this.mFromType = fromType
this.mLongitude = longitude
this.mLatitude = latitude
Log.d(TAG, "uploadFile type===$type ---- mainInfoId =$mainInfoId ----mFromType = $mFromType ---- picPath = $picPath ")
trackUploadCos(3)
if (picPath.contains("backPic")) return
@@ -161,7 +166,9 @@ class CosStatusController : CosStatusCallback {
mutableMapOf("pic" to downloadUrl as String),
mType,
entity,
mainInfoId
mainInfoId,
mLongitude,
mLatitude
)
// }
}
@@ -177,7 +184,7 @@ class CosStatusController : CosStatusCallback {
// CosCallbackMapController.mainService?.sendCustomResult(it)
// }
// } else {
sendInformationDirectly(type, map, mType, entity, mainInfoId)
sendInformationDirectly(type, map, mType, entity, mainInfoId, mLongitude, mLatitude)
// }
}
@@ -189,7 +196,9 @@ class CosStatusController : CosStatusCallback {
map: Map<String, String>,
poiType: String,
entity: TakeEntity,
mainInfoId: Long
mainInfoId: Long,
longitude: Double,
latitude: Double
) {
Log.d(TAG, "sendInformationDirectly isCustomSend = ${entity?.isCustom}")
Log.d(TAG, "sendInformationDirectly poiType= $poiType ---- mainInfoId= $mainInfoId")
@@ -198,7 +207,9 @@ class CosStatusController : CosStatusCallback {
url = map,
isCustom = entity?.isCustom,
poiType = poiType,
mainInfoId = mainInfoId
mainInfoId = mainInfoId,
longitude = longitude,
latitude = latitude
) { success ->
CosCallbackMapController.unregisterCallbacks(map)
CosCallbackMapController.mainService?.let {

View File

@@ -62,6 +62,8 @@ class MainService : Service() {
var params: UploadParams? = null
var mainInfoId: Long = 0
private var mLongitude: Double = 0.0
private var mLatitude: Double = 0.0
//发送主动上报结果广播给外部
fun sendCustomResult(result: Boolean) {
@@ -87,14 +89,16 @@ class MainService : Service() {
params?.let {
shareType = it.eventType
fromType = it.fromType
mainInfoId = 0 //TODO
Log.d(TAG, "onStartCommand shareType = $shareType")
mainInfoId = it.parentId
mLongitude = it.lon
mLatitude = it.lat
Log.d(TAG, "onStartCommand shareType = $shareType --fromType = $fromType --mainInfoId = $mainInfoId -- mLongitude = $mLongitude --mLatitude = $mLatitude --it.duration = ${it.duration} ")
if (shareType == TANLU_ROAD_CONGESTION || shareType == TANLU_TRAFFIC_CHECK || shareType == TANLU_ROAD_CLOSURE || shareType == TANLU_ROAD_CURRENT
|| shareType == TANLU_ROAD_PONDING || shareType == TANLU_ROAD_ICING || shareType == TANLU_ROAD_HEAVY_FOG
|| shareType == TANLU_ROAD_ACCIDENT || shareType == TANLU_ROAD_WORK
) {
// takePhoto(1, false, true)
if (!fromType.equals(UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO)) { // 是策略触发,不提示
if (fromType != UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO) { // 是策略触发,不提示
takeVideo(it.duration, isCustom = true, id = id)
} else {
takeVideo(it.duration)
@@ -131,7 +135,7 @@ class MainService : Service() {
override fun onReceive(p0: Context?, p1: Intent) {
val id = p1.getLongExtra("id", 0L)
if (p1.action == sendInformationAction) {
takeVideo(10, isCustom = true, id = id)
takeVideo(DEFAULT_VIDEO_DURATION, isCustom = true, id = id)
}
}
}
@@ -181,7 +185,7 @@ class MainService : Service() {
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true, priority = 98)
fun getImageEvent(getImageSuccessEvent: GetImageSuccessEvent) {
var info = LocationUtil.getInstance().getLocationInfo()
Log.e("MainService", "getImageEvent long = ${info.longitude} ----> lat= ${info.latitude}")
Log.d("MainService", "getImageEvent long = ${info.longitude} ----> lat= ${info.latitude}")
Log.d(
"MainService",
"getImageEvent url = " + getImageSuccessEvent.getImageUrl() + ">>>>type =" + getImageSuccessEvent.getType()
@@ -250,7 +254,7 @@ class MainService : Service() {
}
if (videoType == 1) {
takeVideo(10)
takeVideo(DEFAULT_VIDEO_DURATION)
} else if (videoType == 2) {
postVideoAlarmTask(true)
}
@@ -278,7 +282,7 @@ class MainService : Service() {
Observable.intervalRange(0, 1, 0, 2_000, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer {
CarCorderController.takePhoto(1, 1, false, isCustom, TANLU_ROAD_CURRENT, mainInfoId, fromType)
CarCorderController.takePhoto(1, 1, false, isCustom, TANLU_ROAD_CURRENT, mainInfoId, fromType, mLongitude, mLatitude)
})
// }
@@ -297,7 +301,7 @@ class MainService : Service() {
Log.d("MainService", "takeVideo --------1---->")
// if (isAuthorization(BaseApplication.getAppContext())) {
// log(TAG, "takeVideo --------2---->")
CarCorderController.takeVideo(1, duration, isCustom, id, if (isCustom) shareType else TANLU_ROAD_CURRENT, mainInfoId, fromType)
CarCorderController.takeVideo(1, duration, isCustom, id, if (isCustom) shareType else TANLU_ROAD_CURRENT, mainInfoId, fromType, mLongitude, mLatitude)
// }
postVideoAlarmTask(isInterval)

View File

@@ -227,16 +227,20 @@ class MainServiceController {
isShare:Boolean = false,
poiType:String,
mainInfoId:Long,
longitude: Double,
latitude: Double,
customSend: ((Boolean) -> Unit)? = null
) {
Log.d(TAG, " sendInformationMessage poiType = $poiType");
Log.d(TAG, " sendInformationMessage poiType = $poiType")
//删除测试数据
var locationInfo = LocationUtil.getInstance().getLocationInfo();
var locationInfo = LocationUtil.getInstance().getLocationInfo()
if (locationInfo.address.isNullOrEmpty()) {
geoLocation(type, url, locationInfo, isCustom,trafficInfoType, isShare, customSend,poiType,mainInfoId)
Log.d(TAG, " sendInformationMessage locationInfo.address = $locationInfo.address")
trackUploadGeo(1)
geoLocation(type, url, locationInfo, isCustom,trafficInfoType, isShare, customSend,poiType,mainInfoId,longitude,latitude)
} else {
postInformationMessage(
getInformationBody(type, url, locationInfo, isCustom, trafficInfoType, isShare,poiType,mainInfoId),
getInformationBody(type, url, locationInfo, isCustom, trafficInfoType, isShare,poiType,mainInfoId,longitude,latitude),
customSend
)
}
@@ -253,19 +257,21 @@ class MainServiceController {
isShare: Boolean,
customSend: ((Boolean) -> Unit)? = null,
poiType: String,
mainInfoId: Long
mainInfoId: Long,
longitude: Double,
latitude: Double
) {
Log.d(TAG, " geoLocation -- poiType = $poiType");
LocationUtil.getInstance()
.geoCodeLocation(locationInfo.toLatLngPoint(), { locInfo: LocationInfo ->
postInformationMessage(
getInformationBody(type, url, locationInfo, isCustom, trafficInfoType, isShare, poiType,mainInfoId),
getInformationBody(type, url, locationInfo, isCustom, trafficInfoType, isShare, poiType,mainInfoId,longitude,latitude),
customSend
)
}, {
//转换失败的情况下再重试一次
geoRetryed = if (!geoRetryed) {
geoLocation(type, url, locationInfo, isCustom, trafficInfoType, isShare, customSend, poiType,mainInfoId)
geoLocation(type, url, locationInfo, isCustom, trafficInfoType, isShare, customSend, poiType,mainInfoId,longitude,latitude)
true
} else {
false
@@ -306,4 +312,11 @@ class MainServiceController {
)
}
//上传
private fun trackUploadGeo(type: Int) {
trackNormalEvent(
CarNet_Geo, mutableMapOf("type" to type)
)
}
}

View File

@@ -2,29 +2,37 @@ package com.zhidao.roadcondition.service
import android.os.Parcel
import android.os.Parcelable
import com.mogo.map.MogoLatLng
class UploadParams(val eventType:String,val fromType:String,val duration:Int) : Parcelable {
class UploadParams(val eventType: String, val fromType: String, val duration: Int, val parentId: Long, val lat: Double, val lon: Double) : Parcelable {
constructor(parcel: Parcel) : this(
parcel.readString()!!,
parcel.readString()!!,
parcel.readInt())
parcel.readInt(),
parcel.readLong(),
parcel.readDouble(),
parcel.readDouble()
)
override fun writeToParcel(parcel: Parcel, flags: Int) {
parcel.writeString(eventType)
parcel.writeString(fromType)
parcel.writeInt(duration)
parcel.writeLong(parentId)
parcel.writeDouble(lat)
parcel.writeDouble(lon)
}
override fun describeContents(): Int {
return 0
}
override fun toString(): String {
return "UploadParams(eventType='$eventType', fromType='$fromType', duration=$duration)"
return "UploadParams(eventType='$eventType', fromType='$fromType', duration=$duration, parentId='$parentId', lat=$lat, lon=$lon)"
}
companion object CREATOR : Parcelable.Creator<UploadParams> {
override fun createFromParcel(parcel: Parcel): UploadParams {
return UploadParams(parcel)

View File

@@ -33,6 +33,8 @@ const val CarNet_Servers_Upload:String = "CarNet_Servers_Upload" //上传服务
const val CarNet_Voice_Search:String = "CarNet_Voice_Search" //语音搜索路况,type=1 成功,type=2 失败
const val CarNet_USER_SHOW:String = "CarNet_user_show" //情报展示时长,showtime 加载列表时长
const val CarNet_USER_LOAD:String = "CarNet_user_load" //情报加载时长,type=1 视频2图片
const val CarNet_Geo:String = "CarNet_Geo_Location" //上传服务端, type=1开始 ,type=2 成功, type=3 失败
const val CarNet_live_broadcast = "CarNet_live_broadcast" // 地图页面点击直播(在线可直播车机)
//自定义埋点

View File

@@ -183,12 +183,14 @@ class LocationUtil private constructor() {
geocoderSearch.setOnGeocodeSearchListener(object : GeocodeSearch.OnGeocodeSearchListener {
override fun onRegeocodeSearched(p0: RegeocodeResult?, p1: Int) {
if (p1 == 1000) {
trackUploadGeo(2);
var regeocodeAddress = p0?.regeocodeAddress
regeocodeAddress?.let {
var locInfo = regeocodeAddress.toLocInfo(regeocodeAddress, latlngPoint)
locGeoCode.invoke(locInfo)
}
} else {
trackUploadGeo(3);
onError.invoke("geoCode -> $p1")
}
}
@@ -198,6 +200,13 @@ class LocationUtil private constructor() {
})
}
//上传
private fun trackUploadGeo(type: Int) {
trackNormalEvent(
CarNet_Geo, mutableMapOf("type" to type)
)
}
fun getSpeed():Float{
return speed
}

View File

@@ -4,6 +4,7 @@ import com.google.gson.JsonArray
import com.google.gson.JsonObject
import com.mogo.commons.AbsMogoApplication
import com.mogo.commons.network.Utils
import com.zhidao.roadcondition.constant.TANLU_ROAD_CURRENT
import com.zhidao.roadcondition.model.InformationBody
import com.zhidao.roadcondition.model.LocationInfo
import com.zhidao.roadcondition.model.proxy.INFO_TYPE_IMG
@@ -29,7 +30,9 @@ fun getInformationBody(
trafficInfoType:String = "",
isShare:Boolean,
poiType: String,
mainInfoId: Long
mainInfoId: Long,
longitude: Double,
latitude: Double
): InformationBody {
var jsonArray = JsonArray()
var type: Int
@@ -54,8 +57,8 @@ fun getInformationBody(
locationInfo.cityCode,
locationInfo.cityName,
System.currentTimeMillis(),
locationInfo.latitude,
locationInfo.longitude,
if (latitude == 0.0) locationInfo.latitude else latitude,
if (longitude == 0.0) locationInfo.longitude else longitude,
locationInfo.provinceName,
Utils.getSn(),
locationInfo.street,

View File

@@ -22,7 +22,7 @@ const val PARAM_ACTIVE_STATUS = "PARAM_ACTIVE_STATUS"
const val LAST_ENTER_TIME = "LAST_ENTER_TIME"
const val PIC_NUMBER = "PIC_NUMBER" //图片拍摄张数
const val VIDEO_DURATION_DEFAULT = 15_000L //视频拍摄时长
const val VIDEO_DURATION_DEFAULT = 10_000L //视频拍摄时长
const val PIC_NUMBER_DEFAULT = 1L //图片拍摄张数
const val TIME_QUANTUM = "time_quantum" //时间段

View File

@@ -7,7 +7,7 @@
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize"
android:enabled="true"
android:launchMode="singleInstance"
android:resizeableActivity="true"
android:resizeableActivity="false"
android:resumeWhilePausing="true"
android:screenOrientation="landscape"
android:stateNotNeeded="true"

View File

@@ -1,14 +1,16 @@
package com.zhidao.mogo.module.main.independent;
import android.annotation.TargetApi;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import androidx.annotation.Nullable;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.module.common.map.CustomNaviInterrupter;
import com.mogo.module.main.MainActivity;
import com.mogo.utils.TipToast;
/**
* 针对独立应用形式,做单独定制
@@ -47,8 +49,19 @@ public class MainIndependentActivity extends MainActivity {
if ( mCoverUpLayout.getVisibility() != View.VISIBLE ) {
mServiceApis.getAdasControllerApi().setUseAlgorithm( true );
}
if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.N){
fixInMultiWindowMode();
}
}
@TargetApi( Build.VERSION_CODES.N )
private void fixInMultiWindowMode(){
if ( isInMultiWindowMode() ) {
TipToast.shortTip( R.string.module_main_un_support_multi_window_mode );
}
}
@Override
protected void onPause() {
super.onPause();

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="module_main_un_support_multi_window_mode">应用不支持分屏</string>
</resources>

View File

@@ -8,7 +8,7 @@
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize"
android:enabled="true"
android:launchMode="singleInstance"
android:resizeableActivity="true"
android:resizeableActivity="false"
android:resumeWhilePausing="true"
android:screenOrientation="landscape"
android:stateNotNeeded="true"

View File

@@ -20,7 +20,6 @@ import com.mogo.service.intent.IMogoIntentListener;
public class MainLauncherActivity extends MainActivity implements IMogoIntentListener {
protected boolean mIsHomeKeyDown = false;
@Override
protected void onCreate( @Nullable Bundle savedInstanceState ) {
super.onCreate( savedInstanceState );

View File

@@ -26,7 +26,7 @@
android:name=".AppsListActivity"
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize"
android:launchMode="singleTask"
android:resizeableActivity="true"
android:resizeableActivity="false"
android:resumeWhilePausing="true"
android:screenOrientation="landscape"
android:stateNotNeeded="true"

View File

@@ -25,7 +25,13 @@ public class AppsAdapter extends BaseAdapter {
private List< AppInfo > mAppInfos;
public AppsAdapter( List< AppInfo > appInfos ) {
this.mAppInfos = new ArrayList<>( appInfos );
this.mAppInfos = new ArrayList<>();
for ( AppInfo appInfo : appInfos ) {
if ( appInfo == null ) {
continue;
}
mAppInfos.add( appInfo );
}
}
@Override

View File

@@ -10,7 +10,7 @@
android:id="@+id/module_apps_id_app_icon"
android:layout_width="@dimen/module_apps_navigation_icon_width"
android:scaleType="fitXY"
android:src="@drawable/module_apps_ic_im"
android:src="@drawable/module_apps_ic_default_icon"
android:layout_height="@dimen/module_apps_navigation_icon_height" />
<TextView

View File

@@ -74,6 +74,10 @@ class MogoMainAuthorize private constructor() : MogoAuthorizeManagerImpl(), IMog
}
private fun pushLayoutToMainWindow(tag: String) {
if(mContext == null){
Logger.d(TAG, "Because of mContext has no init, the application has in background now")
return
}
if (authorizeDialog == null) {
authorizeDialog = AuthorizeDialog(tag, mContext!!)
authorizeDialog!!.setOnDismissListener {

View File

@@ -671,6 +671,7 @@ public class TopViewAnimHelper {
viewCaches.remove(child);
IMogoTopViewStatusListener listener = statusListenerMap.remove(child);
if (listener != null) {
listener.beforeViewRemoveAnim(child);
listener.onViewRemoved(child);
}
}

View File

@@ -42,11 +42,11 @@ class MogoMainService extends Service implements IMogoLocationListener {
Logger.d(TAG, "基本服务启动");
mServiceApis = (IMogoServiceApis) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation();
initAndStartLocation();
initGpsSimulatorListener();
UiThreadHandler.postDelayed(() -> {
loadBaseModules();
startTanluService();
initADAS();
initGpsSimulatorListener();
}, 2_000L
);
}

View File

@@ -6,7 +6,13 @@ class MogoMonitorConst {
public static final int LOG_PUSH_TYPE = 500000;
/**
* 开始抓日志
*/
public static final int START_CATCH_LOG = 1;
/**
* 结束抓日志
*/
public static final int STOP_CATCH_LOG = 2;
/**
* 本应用设置,打开日志

View File

@@ -49,6 +49,7 @@ dependencies {
implementation rootProject.ext.dependencies.androidxcardview
kapt rootProject.ext.dependencies.aroutercompiler
implementation rootProject.ext.dependencies.rxandroid
implementation rootProject.ext.dependencies.kotlinstdlibjdk7
if (Boolean.valueOf(RELEASE)) {
@@ -66,7 +67,6 @@ dependencies {
implementation project(':modules:mogo-module-common')
implementation project(':modules:mogo-module-gps-simulator')
}
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'com.zhidaoauto.voice.controller:api:1.0.2'
}

View File

@@ -33,6 +33,7 @@ import com.mogo.module.common.MogoModulePaths;
import com.mogo.module.common.map.MapCenterPointStrategy;
import com.mogo.module.common.map.Scene;
import com.mogo.module.service.intent.IntentHandlerFactory;
import com.mogo.module.service.launchercard.LauncherCardRefresher;
import com.mogo.module.service.marker.MapMarkerManager;
import com.mogo.module.service.network.RefreshCallback;
import com.mogo.module.service.network.RefreshModel;
@@ -303,6 +304,7 @@ public class MogoServices implements IMogoMapListener,
restartAutoRefreshAtTime( 2_000L );
}
mIsMainPageFirstResume = false;
LauncherCardRefresher.getInstance( mContext ).stop();
} else {
unregisterInternalUnWakeupWords();
stopAutoRefreshStrategy();
@@ -384,6 +386,7 @@ public class MogoServices implements IMogoMapListener,
mIntentManager.registerIntentListener( ServiceConst.COMMAND_BACK, this );
mIntentManager.registerIntentListener( MogoReceiver.ACTION_AUTO_NAVI_RECEIVER, this );
mIntentManager.registerIntentListener( MogoReceiver.ACTION_AUTO_NAVI_SEND, this );
mIntentManager.registerIntentListener( MogoReceiver.ACTION_MOGO, this );
mADASController = MarkerServiceHandler.getADASController();
mLauncher = MarkerServiceHandler.getLauncher();
@@ -397,7 +400,6 @@ public class MogoServices implements IMogoMapListener,
if ( DebugConfig.isLaunchLocationService() ) {
initLocationServiceProcess( context );
}
}
private void initLocationServiceProcess( Context context ) {
@@ -478,6 +480,7 @@ public class MogoServices implements IMogoMapListener,
filter.addAction( Intent.ACTION_CLOSE_SYSTEM_DIALOGS );
filter.addAction( MogoReceiver.ACTION_AUTO_NAVI_RECEIVER );
filter.addAction( MogoReceiver.ACTION_AUTO_NAVI_SEND );
filter.addAction( MogoReceiver.ACTION_MOGO );
try {
context.getApplicationContext().registerReceiver( mAIAssistReceiver, filter );
Logger.i( TAG, "register voice receiver." );

View File

@@ -6,6 +6,7 @@ import android.content.Intent;
import com.mogo.module.common.utils.CarSeries;
import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.module.service.ServiceConst;
import com.mogo.module.service.launchercard.LauncherCardRefresher;
import com.mogo.module.service.receiver.AccStatusReceiver;
import com.mogo.utils.TipToast;
import com.mogo.utils.logger.Logger;
@@ -69,6 +70,11 @@ class AccStatusIntentHandler implements IntentHandler {
}
Logger.d( TAG, "acc status: %s", state );
MarkerServiceHandler.getMogoStatusManager().setAccStatus( ServiceConst.TYPE, accOn );
if ( state == ACC_ON ) {
LauncherCardRefresher.getInstance( context ).start();
} else if ( state == ACC_OFF ) {
LauncherCardRefresher.getInstance( context ).stop();
}
}
}
}

View File

@@ -37,6 +37,7 @@ public class IntentHandlerFactory {
mHandlers.put( MogoReceiver.ACTIION_ADAS, ADASStatusIntentHandler.getInstance() );
mHandlers.put( MogoReceiver.ACTION_VOICE_READY, new AIAssistIntentHandler() );
mHandlers.put( ServiceConst.COMMAND_BACK, WholeVoiceCommandIntentHandler.getInstance() );
mHandlers.put( MogoReceiver.ACTION_MOGO, new MogoControllerIntentHandler() );
}
private static final class InstanceHolder {

View File

@@ -0,0 +1,37 @@
package com.mogo.module.service.intent;
import android.content.Context;
import android.content.Intent;
import com.mogo.utils.logger.LogLevel;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.NetConfig;
public
/**
* @author congtaowang
* @since 2020/8/17
*
* 描述
*/
class MogoControllerIntentHandler implements IntentHandler {
public static final String KEY_OPER = "oper";
public static final int TYPE_OPER_OPEN_LOG = 1;
public static final int TYPE_OPER_CLOSE_LOG = 2;
@Override
public void handle( Context context, Intent intent ) {
int oper = intent.getIntExtra( KEY_OPER, 0 );
switch ( oper ) {
case TYPE_OPER_OPEN_LOG:
Logger.init( LogLevel.DEBUG );
NetConfig.instance().setLoggable( true );
break;
case TYPE_OPER_CLOSE_LOG:
Logger.init( LogLevel.OFF );
NetConfig.instance().setLoggable( false );
break;
}
}
}

View File

@@ -0,0 +1,57 @@
package com.mogo.module.service.launchercard;
public class LauncherCardRefreshStrategy {
private long interval; // 间隔时间
private static LauncherCardRefreshType type = LauncherCardRefreshType.OnlineCar;
private LauncherCardRefreshStrategy next;
private int msgType;// 触发的消息类型
public LauncherCardRefreshStrategy( long interval, LauncherCardRefreshStrategy next, int msgType ) {
this.interval = interval;
this.next = next;
this.msgType = msgType;
}
public int getMsgType() {
return msgType;
}
public long getInterval() {
return interval;
}
public LauncherCardRefreshType getType() {
if ( type == LauncherCardRefreshType.ExploreWay ) {
type = LauncherCardRefreshType.OnlineCar;
} else {
type = LauncherCardRefreshType.ExploreWay;
}
return type;
}
public void next(){
getType();
}
public int getLimit() {
return type.limit;
}
public String getDesc() {
return type.desc;
}
public int getRadius() {
return 2_000;
}
public LauncherCardRefreshStrategy getNext() {
if ( next == null ) {
return this;
}
return next;
}
}

View File

@@ -0,0 +1,15 @@
package com.mogo.module.service.launchercard;
public enum LauncherCardRefreshType {
ExploreWay( 50, "道路事件" ),
OnlineCar( 20, "车友" );
public int limit;
public String desc;
LauncherCardRefreshType( int limit, String desc ) {
this.limit = limit;
this.desc = desc;
}
}

View File

@@ -0,0 +1,534 @@
package com.mogo.module.service.launchercard;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.commons.network.ParamsProvider;
import com.mogo.commons.network.SubscribeImpl;
import com.mogo.commons.voice.AIAssist;
import com.mogo.map.MogoLatLng;
import com.mogo.map.location.MogoLocation;
import com.mogo.module.common.entity.MarkerResponse;
import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.module.service.R;
import com.mogo.module.service.network.RefreshCallback;
import com.mogo.module.service.network.RefreshModel;
import com.mogo.module.service.network.ZhidaoRefreshModel;
import com.mogo.module.service.network.bean.LauncherCardAdvertisementData;
import com.mogo.service.passport.IMogoTicketCallback;
import com.mogo.utils.AppUtils;
import com.mogo.utils.NetworkUtils;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.RequestOptions;
import com.mogo.utils.storage.SharedPrefsMgr;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
public
/**
* @author congtaowang
* @since 2020/8/17
*
* 描述
*/
class LauncherCardRefresher {
private static final String TAG = "LauncherCardRefresher";
public static final String KEY_LauncherCardTipCounter = "LauncherCardTipCounter";
public static final String KEY_LauncherCardTipLastTipTime = "LauncherCardTipLastTipTime";
private static volatile LauncherCardRefresher sInstance;
// 刷新道路事件/车友
public static final int MSG_EXPLORER_WAY_OR_ONLINE_CAR_DATA = 2020;
// 开始引导策略
public static final int MSG_INDUCE = 2019;
// 刷新卡片默认显示内容
public static final int MSG_REFRESH_DEFAULT_CARD = 2021;
// 刷新卡片广告
public static final int MSG_REFRESH_ADVERTISEMENT = 2022;
// 加载网络配置数据
public static final int MSG_LOAD_NET_CONFIG = 2023;
// 默认播报
public static final int MSG_START_LOOP_DEFAULT_CARD = 2024;
public static final long ONE_MINUTE = 60 * 1000L;
public static final long ONE_DAY = 24 * 60 * ONE_MINUTE;
private String mLaunchTTSText;
private long mDefaultTTSPlayInterval = 30 * ONE_MINUTE;
private LauncherCardAdvertisementData.LauncherCardAdvertisement mDefaultLauncherCardConfig;
private List< LauncherCardAdvertisementData.LauncherCardAdvertisement > mAdvertisements;
/**
* 默认播报/后台配置播报次数限制
*/
private int mDefaultConfigCounter = 0;
/**
* 因为缓存ticket失效导致失败的情况需要重新请求ticket然后再次获取数据这里重试3次
*/
private int mRefreshTicketCounter = 0;
private LauncherCardRefresher( Context context ) {
mContext = context;
mRefreshModel = new RefreshModel( mContext );
mZhidaoRefreshModel = new ZhidaoRefreshModel( mContext );
}
public static LauncherCardRefresher getInstance( Context context ) {
if ( sInstance == null ) {
synchronized ( LauncherCardRefresher.class ) {
if ( sInstance == null ) {
sInstance = new LauncherCardRefresher( context );
}
}
}
return sInstance;
}
public synchronized void release() {
sInstance = null;
}
private Object readResolve() {
// 阻止反序列化,必须实现 Serializable 接口
return sInstance;
}
private Handler mHandler = new Handler( Looper.getMainLooper() ) {
@Override
public void handleMessage( Message msg ) {
super.handleMessage( msg );
if ( mRefreshStop ) {
return;
}
switch ( msg.what ) {
case MSG_LOAD_NET_CONFIG:
loadNetworkConfigStrategy();
break;
case MSG_REFRESH_DEFAULT_CARD:
renderDefaultLauncherCardConfig( false );
mRefreshStrategy = mRefreshStrategy.getNext();
restart();
break;
case MSG_INDUCE:
handleInduceStrategy();
break;
case MSG_EXPLORER_WAY_OR_ONLINE_CAR_DATA:
try {
handleRefreshExplorerWayOrOnlineCarMsg();
} catch ( Exception e ) {
Logger.e( TAG, e, "error when refresh launcher card." );
}
break;
case MSG_START_LOOP_DEFAULT_CARD:
renderDefaultLauncherCardConfig( false );
break;
case MSG_REFRESH_ADVERTISEMENT:
int index = msg.arg1;// 当前广告索引
loopRenderAdvertisements( index );
break;
}
}
};
private final Context mContext;
private boolean mRefreshStop = true;
private boolean mStart = false;
private RefreshModel mRefreshModel;
private ZhidaoRefreshModel mZhidaoRefreshModel;
private LauncherCardRefreshStrategy mExplorerWayOrOnlineCarDataStrategy = new LauncherCardRefreshStrategy(
20 * ONE_MINUTE,null, MSG_EXPLORER_WAY_OR_ONLINE_CAR_DATA
);
private LauncherCardRefreshStrategy mInduceStrategy = new LauncherCardRefreshStrategy(
3 * ONE_MINUTE,mExplorerWayOrOnlineCarDataStrategy, MSG_INDUCE
);
private LauncherCardRefreshStrategy mLauncherCardConfigStrategy = new LauncherCardRefreshStrategy(
2 * ONE_MINUTE,mInduceStrategy, MSG_REFRESH_DEFAULT_CARD
);
private LauncherCardRefreshStrategy mRefreshStrategy = mLauncherCardConfigStrategy;
public void start() {
if ( DebugConfig.isLauncher() || DebugConfig.getCarMachineType() == DebugConfig.CAR_MACHINE_TYPE_BYD ) {
return;
}
if ( mStart ) {
return;
}
Logger.d( TAG, "start" );
mLaunchTTSText = mContext.getString( R.string.module_service_open_app_tip );
mDefaultConfigCounter = 0;
mRefreshTicketCounter = 0;
mRefreshStrategy = mLauncherCardConfigStrategy;
// 延时加载数据已保证accOn之后网络恢复正常
long delay = ONE_MINUTE;
if ( NetworkUtils.isConnected( mContext ) ) {
delay = 0L;
}
mHandler.sendEmptyMessageDelayed( MSG_LOAD_NET_CONFIG, delay );
startInduceStrategy();
}
/**
* 引导策略:本地策略 & 网络策略
*/
private void startInduceStrategy() {
mHandler.sendEmptyMessageDelayed( mRefreshStrategy.getMsgType(), mRefreshStrategy.getInterval() );
mRefreshStop = false;
mStart = true;
}
public void stop() {
mRefreshStop = true;
mStart = false;
mHandler.removeMessages( MSG_INDUCE );
mHandler.removeMessages( MSG_EXPLORER_WAY_OR_ONLINE_CAR_DATA );
mHandler.removeMessages( MSG_REFRESH_DEFAULT_CARD );
mHandler.removeMessages( MSG_START_LOOP_DEFAULT_CARD );
mHandler.removeMessages( MSG_REFRESH_ADVERTISEMENT );
mHandler.removeMessages( MSG_LOAD_NET_CONFIG );
Logger.d( TAG, "stop" );
}
private void restart() {
if ( !mStart ) {
return;
}
mRefreshStop = false;
mHandler.removeMessages( mRefreshStrategy.getMsgType() );
mHandler.sendEmptyMessageDelayed( mRefreshStrategy.getMsgType(), mRefreshStrategy.getInterval() );
}
/**
* 开始诱导策略
* 第一次如果有活动,则优先播报活动,否则播报道路事件/车友
* 后面的按各自的时间间隔播报
*/
private void handleInduceStrategy() {
if ( mAdvertisements != null && !mAdvertisements.isEmpty() ) {
loopRenderAdvertisements( 0 );
startNextRefreshStrategy();
} else {
handleRefreshExplorerWayOrOnlineCarMsg();
}
}
private void startNextRefreshStrategy() {
mRefreshStrategy = mRefreshStrategy.getNext();
restart();
}
private void handleRefreshExplorerWayOrOnlineCarMsg() {
MogoLocation location = MarkerServiceHandler.getMogoLocationClient().getLastKnowLocation();
if ( location == null ) {
restart();
return;
}
MogoLatLng latLng = new MogoLatLng( location.getLatitude(), location.getLongitude() );
handleRefreshExplorerWayOrOnlineCarData( latLng, mRefreshStrategy.getType() );
}
private void handleRefreshExplorerWayOrOnlineCarData( MogoLatLng latLng, LauncherCardRefreshType type ) {
mRefreshModel.refreshDataSync( latLng,
mRefreshStrategy.getRadius(),
mRefreshStrategy.getLimit(),
new RefreshCallback< MarkerResponse >() {
@Override
public void onSuccess( MarkerResponse response ) {
notifyRefreshChanged( type, response );
startNextRefreshStrategy();
}
@Override
public void onFail() {
startNextRefreshStrategy();
}
} );
}
private boolean notifyRefreshChanged( LauncherCardRefreshType type, MarkerResponse response ) {
if ( response == null || response.getResult() == null ) {
return false;
}
String tts = mContext.getString( R.string.module_service_launcher_card_tips );
String info = mContext.getString( R.string.module_service_launcher_card_info );
LauncherCardRefreshType target = null;
int size = 0;
if ( type == LauncherCardRefreshType.ExploreWay ) {
if ( response.getResult().getExploreWay() != null && !response.getResult().getExploreWay().isEmpty() ) {
target = type;
size = response.getResult().getExploreWay().size();
} else if ( response.getResult().getOnlineCar() != null && !response.getResult().getOnlineCar().isEmpty() ) {
target = LauncherCardRefreshType.OnlineCar;
size = response.getResult().getOnlineCar().size();
}
} else if ( type == LauncherCardRefreshType.OnlineCar ) {
if ( response.getResult().getOnlineCar() != null && !response.getResult().getOnlineCar().isEmpty() ) {
target = type;
size = response.getResult().getOnlineCar().size();
} else if ( response.getResult().getExploreWay() != null && !response.getResult().getExploreWay().isEmpty() ) {
target = LauncherCardRefreshType.ExploreWay;
size = response.getResult().getExploreWay().size();
}
}
Logger.d( TAG, "返回数据情况:道路事件:%s, 车友: %s", response.getResult().getExploreWay() == null ? 0 : response.getResult().getExploreWay().size(),
response.getResult().getOnlineCar() == null ? 0 : response.getResult().getOnlineCar().size() );
if ( size == 0 ) {
return false;
}
if ( target != type ) {
mRefreshStrategy.next();// 本次请求到的数据类型和播报类型不一致,则下次再次请求本次类型~
}
speakTTS( tts = String.format( tts, size, target.desc ), true );
notifyRefreshChanged( String.format( info, size, target.desc ), size, tts );
return true;
}
private void speakTTS( String msg, boolean checkAppForeground ) {
if ( checkAppForeground ) {
if ( AppUtils.isAppForeground( mContext ) ) {
return;
}
}
Logger.d( TAG, msg );
AIAssist.getInstance( mContext ).speakTTSVoice( msg );
}
private void notifyRefreshChanged( String info, int amount, String tts ) {
Intent intent = new Intent( "com.mogo.launcher.v2x" );
intent.putExtra( "v2x_warning_type", "20000" );
intent.putExtra( "v2x_warining_timeout", 20 * 1000 );
intent.putExtra( "v2x_warning_tts", tts );
intent.putExtra( "v2x_warning_eventCount", amount );
intent.putExtra( "v2x_warning_info", info );
mContext.sendBroadcast( intent );
Logger.d( TAG, "发送广播到桌面卡片." );
}
/**
* 1. 刷新默认卡片样式
* <p>
* 2. 播报默认卡片语音
*
* @param sendConfigOnly 仅发送配置到
*/
private void renderDefaultLauncherCardConfig( boolean sendConfigOnly ) {
if ( mDefaultLauncherCardConfig != null ) {
long curr = System.currentTimeMillis();
if ( mDefaultLauncherCardConfig.endTime > curr && mDefaultLauncherCardConfig.startTime < curr ) {
Intent intent = new Intent( "com.mogo.launcher.v2x.card" );
intent.putExtra( "v2x_card_title", mDefaultLauncherCardConfig.name );
intent.putExtra( "v2x_card_icon", mDefaultLauncherCardConfig.filePath );
intent.putExtra( "v2x_card_content", mDefaultLauncherCardConfig.cardContent );
intent.putExtra( "v2x_card_button_name", mDefaultLauncherCardConfig.buttonContent );
intent.putExtra( "v2x_card_startTime", mDefaultLauncherCardConfig.startTime );
intent.putExtra( "v2x_card_endTime", mDefaultLauncherCardConfig.endTime );
intent.putExtra( "v2x_card_is_default", true );
mContext.sendBroadcast( intent );
Logger.d( TAG, "发送默认配置广播到桌面卡片." );
if ( !TextUtils.isEmpty( mDefaultLauncherCardConfig.content ) ) {
mLaunchTTSText = mDefaultLauncherCardConfig.content;
}
if ( mDefaultLauncherCardConfig.popupNum > 0 ) {
mDefaultTTSPlayInterval = mDefaultLauncherCardConfig.popupNum * ONE_MINUTE;
}
}
}
if ( sendConfigOnly ) {
return;
}
if ( mDefaultConfigCounter++ >= 3 ) {
return;
}
int counter = SharedPrefsMgr.getInstance( mContext ).getInt( KEY_LauncherCardTipCounter, 0 );
if ( counter >= 5 ) {
long lastTipTime = SharedPrefsMgr.getInstance( mContext ).getLong( KEY_LauncherCardTipLastTipTime, 0L );
if ( System.currentTimeMillis() - lastTipTime < 10 * ONE_DAY ) {
return;
} else {
SharedPrefsMgr.getInstance( mContext ).putInt( KEY_LauncherCardTipCounter, 0 );
counter = 0;
SharedPrefsMgr.getInstance( mContext ).putLong( KEY_LauncherCardTipLastTipTime, 0L );
}
}
SharedPrefsMgr.getInstance( mContext ).putInt( KEY_LauncherCardTipCounter, ++counter );
SharedPrefsMgr.getInstance( mContext ).putLong( KEY_LauncherCardTipLastTipTime, System.currentTimeMillis() );
try {
speakTTS( mLaunchTTSText, true );
} catch ( Exception e ) {
e.printStackTrace();
}
startLoopDefaultConfigStrategy();
}
/**
* 请求广告数据
*/
private void loadNetworkConfigStrategy() {
final Map< String, Object > query = new ParamsProvider.Builder( mContext )
.append( "modelType", 30 )
.build();
mZhidaoRefreshModel.getRefreshApiService().getCarAdvertisingList( query )
.subscribeOn( Schedulers.io() )
.observeOn( AndroidSchedulers.mainThread() )
.subscribe( new SubscribeImpl< LauncherCardAdvertisementData >( RequestOptions.create( mContext ) ) {
@Override
public void onError( Throwable e ) {
super.onError( e );
Logger.e( TAG, e, "获取配置失败" );
}
@Override
public void onSuccess( LauncherCardAdvertisementData data ) {
super.onSuccess( data );
if ( data == null || data.result == null ) {
Logger.d( TAG, "carAdvertisingList is empty." );
return;
}
Logger.d( TAG, "获取配置成功" );
handleGotCarAdvertisingList( data.result );
}
@Override
public void onError( String message, int code ) {
super.onError( message, code );
if ( code == 100046 ) {
refreshTicket();
}
Logger.e( TAG, "获取配置失败 msg = %s, code = %s", message, code );
}
} );
}
private void refreshTicket() {
mRefreshTicketCounter++;
Logger.d( TAG, "刷新ticket" );
MarkerServiceHandler.getApis().getPassportManagerApi().requestTicket( new IMogoTicketCallback() {
@Override
public void onTicketGot( String ticket ) {
Logger.d( TAG, "ticket=%s", ticket );
if ( mRefreshTicketCounter < 3 ) {
loadNetworkConfigStrategy();
}
}
@Override
public void onError( int code, String msg ) {
Logger.d( TAG, "code=%s, msg=%s", code, msg );
}
@Override
public void onLoginSuccess( String token, String sn ) {
Logger.d( TAG, "token=%s, sn=%s", token, sn );
}
} );
}
private void handleGotCarAdvertisingList( List< LauncherCardAdvertisementData.LauncherCardAdvertisement > data ) {
if ( data == null ) {
mAdvertisements = null;
return;
}
mAdvertisements = new ArrayList<>();
for ( LauncherCardAdvertisementData.LauncherCardAdvertisement launcherCardAdvertisement : data ) {
if ( launcherCardAdvertisement == null ) {
continue;
}
if ( launcherCardAdvertisement.cardType == LauncherCardAdvertisementData.TYPE_DEFAULT_CONFIG ) {
mDefaultLauncherCardConfig = launcherCardAdvertisement;
renderDefaultLauncherCardConfig( true );
} else if ( launcherCardAdvertisement.cardType == LauncherCardAdvertisementData.TYPE_ACTIVITY ) {
long curr = System.currentTimeMillis();
if ( curr > launcherCardAdvertisement.startTime && curr < launcherCardAdvertisement.endTime ) {
mAdvertisements.add( launcherCardAdvertisement );
} else {
Logger.w( TAG, "广告已过期 %s", launcherCardAdvertisement.cardContent );
}
}
}
if ( !mAdvertisements.isEmpty() && mAdvertisements.size() > 1 ) {
LauncherCardAdvertisementData.LauncherCardAdvertisement[] sorted = new LauncherCardAdvertisementData.LauncherCardAdvertisement[mAdvertisements.size()];
sorted = mAdvertisements.toArray( sorted );
Arrays.sort( sorted, ( ( o1, o2 ) -> {
return o1.sort > o2.sort ? 1 : ( o1.sort == o2.sort ? 0 : -1 );
} ) );
mAdvertisements = Arrays.asList( sorted );
}
}
/**
* 默认播报 / 后台配置默认项播报策略
*/
private void startLoopDefaultConfigStrategy() {
Message msg = Message.obtain();
msg.what = MSG_START_LOOP_DEFAULT_CARD;
mHandler.sendMessageDelayed( msg, mDefaultTTSPlayInterval );
}
private void loopRenderAdvertisements( int index ) {
try {
index = index % mAdvertisements.size();
LauncherCardAdvertisementData.LauncherCardAdvertisement advertisement = mAdvertisements.get( index );
Message msg = Message.obtain();
msg.what = MSG_REFRESH_ADVERTISEMENT;
msg.arg1 = ++index;
mHandler.sendMessageDelayed( msg, advertisement.popupNum * ONE_MINUTE );
renderAdvertisement( advertisement );
} catch ( Exception e ) {
Logger.e( TAG, e, "loopRenderAdvertisements" );
}
}
/**
* 刷新广告
*/
private void renderAdvertisement( LauncherCardAdvertisementData.LauncherCardAdvertisement advertisement ) {
if ( advertisement == null ) {
return;
}
long curr = System.currentTimeMillis();
if ( advertisement.endTime > curr && advertisement.startTime < curr ) {
Intent intent = new Intent( "com.mogo.launcher.v2x.card" );
intent.putExtra( "v2x_card_title", advertisement.name );
intent.putExtra( "v2x_card_icon", advertisement.filePath );
intent.putExtra( "v2x_card_content", advertisement.cardContent );
intent.putExtra( "v2x_card_button_name", advertisement.buttonContent );
intent.putExtra( "v2x_card_startTime", advertisement.startTime );
intent.putExtra( "v2x_card_endTime", advertisement.endTime );
intent.putExtra( "v2x_card_activity_id", advertisement.id );
intent.putExtra( "v2x_card_timeout", 20 * 1000 );
intent.putExtra( "v2x_card_is_default", false );
mContext.sendBroadcast( intent );
if ( !AppUtils.isAppForeground( mContext ) ) {
speakTTS( advertisement.content, true );
}
Logger.d( TAG, "发送广告配置广播到桌面卡片." );
}
}
}

View File

@@ -7,12 +7,10 @@ import com.mogo.module.service.network.bean.DemoUserInfoEntity;
import java.util.Map;
import io.reactivex.Observable;
import io.reactivex.Single;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.QueryMap;
/**
* @author congtaowang
@@ -26,14 +24,17 @@ public interface RefreshApiService {
@POST( "/yycp-launcherSnapshot/launcherSnapshot/querySnapshotAsync" )
Observable< BaseData > refreshData( @FieldMap Map< String, Object > parameters );
@FormUrlEncoded
@POST( "/yycp-launcherSnapshot/launcherSnapshot/querySnapshotSync" )
Observable< MarkerResponse > refreshDataSync( @FieldMap Map< String, Object > parameters );
@FormUrlEncoded
@POST( "/yycp-launcherSnapshot/user/queryOnLineCarWithRoute" )
Observable<MarkerResponse> queryOnLineCarWithRoute(@FieldMap Map< String, Object > parameters );
Observable< MarkerResponse > queryOnLineCarWithRoute( @FieldMap Map< String, Object > parameters );
/**
* 查询演示车用户信息
*/
@GET("/yycp-launcherSnapshot/mock/getMockUserInfos")
@GET( "/yycp-launcherSnapshot/mock/getMockUserInfos" )
Observable< DemoUserInfoEntity > getMockUsers();
}

View File

@@ -17,6 +17,7 @@ import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.RequestOptions;
import com.mogo.utils.network.utils.GsonUtil;
import java.util.List;
import java.util.Map;
import io.reactivex.android.schedulers.AndroidSchedulers;
@@ -47,6 +48,10 @@ public class RefreshModel {
this.mRefreshApiService = network.create( RefreshApiService.class, getNetHost() );
}
public RefreshApiService getRefreshApiService() {
return mRefreshApiService;
}
public static String getNetHost() {
switch ( DebugConfig.getNetMode() ) {
case DebugConfig.NET_MODE_DEV:
@@ -105,6 +110,52 @@ public class RefreshModel {
}
}
public void refreshDataSync( MogoLatLng latLng, int radius, int limit, final RefreshCallback callback ) {
if ( mRefreshApiService != null ) {
final Map< String, Object > query = new ParamsProvider.Builder( mContext ).build();
final RefreshBody refreshBody = new RefreshBody();
refreshBody.limit = limit;
refreshBody.location = new RefreshBody.LatLon( latLng.lat, latLng.lng );
refreshBody.radius = radius;
refreshBody.dataType.add( ServiceConst.CARD_TYPE_ROAD_CONDITION );
refreshBody.dataType.add( ServiceConst.CARD_TYPE_USER_DATA );
String data = GsonUtil.jsonFromObject( refreshBody );
query.put( "data", data );
Logger.d( TAG, data );
mRefreshApiService.refreshDataSync( query )
.subscribeOn( Schedulers.io() )
.observeOn( AndroidSchedulers.mainThread() )
.subscribe( new SubscribeImpl< MarkerResponse >( RequestOptions.create( mContext ) ) {
@Override
public void onSuccess( MarkerResponse o ) {
super.onSuccess( o );
if ( callback != null ) {
callback.onSuccess( o );
}
}
@Override
public void onError( Throwable e ) {
super.onError( e );
if ( callback != null ) {
callback.onFail();
}
}
@Override
public void onError( String message, int code ) {
super.onError( message, code );
if ( callback != null ) {
callback.onFail();
}
}
} );
}
}
/**
* 查询车辆 及路线
*

View File

@@ -0,0 +1,28 @@
package com.mogo.module.service.network;
import com.mogo.module.service.network.bean.LauncherCardAdvertisementData;
import java.util.Map;
import io.reactivex.Observable;
import retrofit2.http.GET;
import retrofit2.http.QueryMap;
/**
* @author congtaowang
* @since 2020-01-03
* <p>
* 接口描述
*/
public interface ZhidaoApiService {
/**
* 获取桌面卡片配置
*
* @param parameters
* @return
*/
@GET( "/marketing/advertisingPosition/getCarAdvertisingList" )
Observable< LauncherCardAdvertisementData > getCarAdvertisingList( @QueryMap Map< String, Object > parameters );
}

View File

@@ -0,0 +1,66 @@
package com.mogo.module.service.network;
import android.content.Context;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.commons.data.BaseData;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.commons.network.ParamsProvider;
import com.mogo.commons.network.SubscribeImpl;
import com.mogo.commons.network.Utils;
import com.mogo.map.MogoLatLng;
import com.mogo.module.common.entity.MarkerResponse;
import com.mogo.module.service.ServiceConst;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.network.IMogoNetwork;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.RequestOptions;
import com.mogo.utils.network.utils.GsonUtil;
import java.util.Map;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
/**
* @author congtaowang
* @since 2020-01-03
* <p>
* 使用智道的域名
*/
public class ZhidaoRefreshModel {
private static final String TAG = "RefreshModel";
public static final String HOST_DEV = "http://carlife-test.zhidaohulian.com";
public static final String HOST_TEST = "http://carlife-test.zhidaohulian.com";
public static final String HOST_DEMO = "http://carlife-test.zhidaohulian.com";
public static final String HOST_PRODUCT = "https://api.zhidaohulian.com";
private final Context mContext;
private ZhidaoApiService mRefreshApiService;
public ZhidaoRefreshModel( Context context ) {
this.mContext = context;
IMogoNetwork network = ( IMogoNetwork ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_NETWORK ).navigation( context );
this.mRefreshApiService = network.create( ZhidaoApiService.class, getNetHost() );
}
public ZhidaoApiService getRefreshApiService() {
return mRefreshApiService;
}
public static String getNetHost() {
switch ( DebugConfig.getNetMode() ) {
case DebugConfig.NET_MODE_DEV:
return HOST_DEV;
case DebugConfig.NET_MODE_QA:
return HOST_TEST;
case DebugConfig.NET_MODE_DEMO:
return HOST_DEMO;
default:
return HOST_PRODUCT;
}
}
}

View File

@@ -0,0 +1,47 @@
package com.mogo.module.service.network.bean;
import com.mogo.commons.data.BaseData;
import java.util.List;
public
/**
* @author congtaowang
* @since 2020/8/24
*
* 描述
*/
class LauncherCardAdvertisementData extends BaseData {
// 启动展示
public static final int TYPE_DEFAULT_CONFIG = 1;
// 活动
public static final int TYPE_ACTIVITY = 2;
public List< LauncherCardAdvertisement > result;
/**
* 卡片名称 name
* 卡片类型 fileType 1-启动展示、2-活动播报
* 卡片样式 filePath
* 卡片文案 cardContent
* 按钮文案 url
* 语音文案 content
* 活动期限 是时间戳 ,还是标准时间 startTime endTime Date类型
* 播报频次间隔popupNum
* 活动展示顺序 sort
*/
public static class LauncherCardAdvertisement {
public String id;
public String name;
public int cardType;
public String filePath;
public String cardContent;
public String buttonContent;
public String content;
public int sort;
public long startTime;
public long endTime;
public int popupNum; // 间隔时间:分钟
}
}

View File

@@ -6,6 +6,7 @@ import android.content.Intent;
import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.module.service.intent.IntentHandlerFactory;
import com.mogo.utils.logger.Logger;
public
/**
@@ -15,6 +16,8 @@ public
* 描述
*/
class AccStatusReceiver extends BroadcastReceiver {
private static final String TAG = "AccStatusReceiver";
// 诺威达 acc 状态
public static final String PARAM_ACC_STATUS = "extra_mcu_state";
@@ -24,6 +27,7 @@ class AccStatusReceiver extends BroadcastReceiver {
@Override
public void onReceive( Context context, Intent intent ) {
Logger.d(TAG, "收到诺威达acc广播");
MarkerServiceHandler.init( context );
IntentHandlerFactory.getInstance().handle( context, intent.getAction(), intent );
}

View File

@@ -58,6 +58,8 @@ public class MogoReceiver extends BroadcastReceiver {
// 接受高德发过来的广播
public static final String ACTION_AUTO_NAVI_SEND = "AUTONAVI_STANDARD_BROADCAST_SEND";
public static final String ACTION_MOGO = "com.mogo.ACTION";
private IMogoIntentManager mMogoIntentManager;
public MogoReceiver(Context context) {

View File

@@ -1,4 +1,7 @@
<resources>
<string name="app_name">mogo-module-service</string>
<string name="module_service_app_entrance_text">辅助\n驾驶</string>
<string name="module_service_launcher_card_tips">你的周围有%d个%s请点击查看你也可以对我说打开蘑菇出行</string>
<string name="module_service_launcher_card_info">周围有%d个%s</string>
<string name="module_service_open_app_tip">建议开启蘑菇出行,守护你的每一段行程,你可以直接对我说,打开蘑菇出行</string>
</resources>

View File

@@ -1,6 +1,7 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.alibaba.arouter'
android {
@@ -38,7 +39,7 @@ dependencies {
implementation rootProject.ext.dependencies.androidxccorektx
implementation rootProject.ext.dependencies.androidxconstraintlayout
implementation rootProject.ext.dependencies.arouter
annotationProcessor rootProject.ext.dependencies.aroutercompiler
kapt rootProject.ext.dependencies.aroutercompiler
implementation rootProject.ext.dependencies.rxjava
implementation rootProject.ext.dependencies.rxandroid

View File

@@ -186,37 +186,41 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo
intentManager.registerIntentListener(UNWAKE_UPLOAD_ROAD_CONDITION, this);
// 免唤醒词注册
AIAssist.getInstance(context).registerUnWakeupCommand(UNWAKE_UPLOAD_ROAD_BLOCK,
CMD_UPLOAD_BLOCK, this);
AIAssist.getInstance(context).registerUnWakeupCommand(UNWAKE_UPLOAD_TRAFFIC_CHECK,
CMD_TRAFFIC_CHECK, this);
AIAssist.getInstance(context).registerUnWakeupCommand(UNWAKE_UPLOAD_ROAD_CLOSURE,
CMD_ROAD_CLOSURE, this);
AIAssist.getInstance(context).registerUnWakeupCommand(UNWAKE_CANCEL_SHARE,
CMD_CANCEL_SHARE, this);
if (DebugConfig.getAIType() == DebugConfig.AI_TYPE_TXZ) {
// 使用同行者语义你的话,增加如下免唤醒词
AIAssist.getInstance(context).registerUnWakeupCommand(UNWAKE_UPLOAD_ACCIDENT,
CMD_UPLOAD_ACCIDENT, this);
AIAssist.getInstance(context).registerUnWakeupCommand(UNWAKE_UPLOAD_REAL_TIME_TRAFFIC,
UPLOAD_REAL_TIME_TRAFFIC, this);
AIAssist.getInstance(context).registerUnWakeupCommand(UNWAKE_UPLOAD_SEEK_HELP,
UPLOAD_SEEK_HELP, this);
AIAssist.getInstance(context).registerUnWakeupCommand(UNWAKE_UPLOAD_STAGNANT_WATER,
UPLOAD_STAGNANT_WATER, this);
AIAssist.getInstance(context).registerUnWakeupCommand(UNWAKE_UPLOAD_ROAD_ICY,
UPLOAD_ROAD_ICY, this);
AIAssist.getInstance(context).registerUnWakeupCommand(UNWAKE_UPLOAD_DENSE_FOG,
UPLOAD_DENSE_FOG, this);
AIAssist.getInstance(context).registerUnWakeupCommand(UNWAKE_UPLOAD_ROAD_CONSTRUCTION,
UPLOAD_ROAD_CONSTRUCTION, this);
}
// AIAssist.getInstance(context).registerUnWakeupCommand(UNWAKE_UPLOAD_ROAD_BLOCK,
// CMD_UPLOAD_BLOCK, this);
// AIAssist.getInstance(context).registerUnWakeupCommand(UNWAKE_UPLOAD_TRAFFIC_CHECK,
// CMD_TRAFFIC_CHECK, this);
// AIAssist.getInstance(context).registerUnWakeupCommand(UNWAKE_UPLOAD_ROAD_CLOSURE,
// CMD_ROAD_CLOSURE, this);
// AIAssist.getInstance(context).registerUnWakeupCommand(UNWAKE_CANCEL_SHARE,
// CMD_CANCEL_SHARE, this);
// if (DebugConfig.getAIType() == DebugConfig.AI_TYPE_TXZ) {
// // 使用同行者语义你的话,增加如下免唤醒词
// AIAssist.getInstance(context).registerUnWakeupCommand(UNWAKE_UPLOAD_ACCIDENT,
// CMD_UPLOAD_ACCIDENT, this);
// AIAssist.getInstance(context).registerUnWakeupCommand(UNWAKE_UPLOAD_REAL_TIME_TRAFFIC,
// UPLOAD_REAL_TIME_TRAFFIC, this);
// AIAssist.getInstance(context).registerUnWakeupCommand(UNWAKE_UPLOAD_SEEK_HELP,
// UPLOAD_SEEK_HELP, this);
// AIAssist.getInstance(context).registerUnWakeupCommand(UNWAKE_UPLOAD_STAGNANT_WATER,
// UPLOAD_STAGNANT_WATER, this);
// AIAssist.getInstance(context).registerUnWakeupCommand(UNWAKE_UPLOAD_ROAD_ICY,
// UPLOAD_ROAD_ICY, this);
// AIAssist.getInstance(context).registerUnWakeupCommand(UNWAKE_UPLOAD_DENSE_FOG,
// UPLOAD_DENSE_FOG, this);
// AIAssist.getInstance(context).registerUnWakeupCommand(UNWAKE_UPLOAD_ROAD_CONSTRUCTION,
// UPLOAD_ROAD_CONSTRUCTION, this);
// }
if(!DebugConfig.isLauncher()) {
ServiceApisManager.serviceApis.getStatusManagerApi().registerStatusChangedListener(TAG, StatusDescriptor.MAIN_PAGE_RESUME, new IMogoStatusChangedListener() {
@Override
public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) {
if (!isTrue) {
AIAssist.getInstance(mContext).unregisterUnWakeupCommand(UNWAKE_UPLOAD_REAL_TIME_TRAFFIC,ShareControl.this);
dismissShareDialog();
}else{
AIAssist.getInstance(mContext).registerUnWakeupCommand(UNWAKE_UPLOAD_REAL_TIME_TRAFFIC,
UPLOAD_REAL_TIME_TRAFFIC, ShareControl.this);
}
}
});

View File

@@ -0,0 +1,27 @@
package com.mogo.module.share
import android.content.Context
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.module.share.constant.ACCIDENT_STRATEGY_SHARE_PUSH_TYPE
import com.mogo.module.share.constant.S_TAG
import com.mogo.module.share.strategyreceiver.AccidentStrategyReceiver
import com.mogo.service.IMogoServiceApis
import com.mogo.service.MogoServicePaths
import com.mogo.utils.logger.Logger
/**
* 策略上报入口服务端策略上报Push的接收地接收后再调用tanlu相关接口进行视频抓取
*
* @author tongchenfei
*/
@Route(path = MogoServicePaths.PATH_STRATEGY_SHARE)
class StrategyShareProvider : IProvider {
override fun init(context: Context?) {
Logger.d(S_TAG, "策略上报Provider初始化====")
val apis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(context) as IMogoServiceApis
// 注册事故
apis.getSocketManagerApi(context).registerOnMessageListener(ACCIDENT_STRATEGY_SHARE_PUSH_TYPE, AccidentStrategyReceiver(apis))
}
}

View File

@@ -0,0 +1,4 @@
package com.mogo.module.share.constant
const val S_TAG = "StrategyShare"
const val ACCIDENT_STRATEGY_SHARE_PUSH_TYPE = 401013

View File

@@ -4,6 +4,8 @@ import android.content.Context
import android.content.Intent
import com.mogo.commons.debug.DebugConfig
import com.mogo.commons.voice.AIAssist
import com.mogo.map.MogoLatLng
import com.mogo.map.location.MogoLocation
import com.mogo.module.share.ShareControl
import com.mogo.module.share.dialog.LaucherShareDialog
import com.mogo.service.tanlu.TanluUploadParams
@@ -23,6 +25,9 @@ object UploadHelper {
if(DebugConfig.getAIType() == DebugConfig.AI_TYPE_TXZ||forcePlayVoice) {
AIAssist.getInstance(context).speakTTSVoice("感谢分享,正在上传")
}
val location = ServiceApisManager.serviceApis.mapServiceApi.getSingletonLocationClient(context).lastKnowLocation
val latLon = MogoLatLng(location.latitude, location.longitude)
type.location = latLon
Logger.d("UploadHelper", "upload ----> $type")
ServiceApisManager.serviceApis.tanluApi.uploadRoadCondition(type)
// val intent = Intent()

View File

@@ -0,0 +1,11 @@
package com.mogo.module.share.strategyreceiver
data class AccidentStrategyPushWrapper(
/**
* 策略类型1代表事故
*/
val type: Int,
/**
* 触发点的事件id
*/
val id: Long, val lat: Double, val lon: Double)

View File

@@ -0,0 +1,25 @@
package com.mogo.module.share.strategyreceiver
import com.mogo.map.MogoLatLng
import com.mogo.module.share.constant.S_TAG
import com.mogo.service.IMogoServiceApis
import com.mogo.service.connection.IMogoOnMessageListener
import com.mogo.service.tanlu.IMogoTanluProvider
import com.mogo.service.tanlu.TanluUploadParams
import com.mogo.utils.logger.Logger
/**
* 车辆经过事故事件,上报视频
* @author tong
*/
class AccidentStrategyReceiver(private val apis: IMogoServiceApis):IMogoOnMessageListener<AccidentStrategyPushWrapper> {
override fun target(): Class<AccidentStrategyPushWrapper> = AccidentStrategyPushWrapper::class.java
override fun onMsgReceived(obj: AccidentStrategyPushWrapper?) {
obj?.let {
Logger.d(S_TAG, "Accident strategy share onMessageReceived: $obj")
// 调用探路接口上报现在只接入了事故事件上报这一种策略上报所以poiType固定为TypeAccident
apis.tanluApi.uploadRoadCondition(TanluUploadParams(IMogoTanluProvider.TYPE_ACCIDENT, IMogoTanluProvider.UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO, it.id, MogoLatLng(it.lat, it.lon)))
}
}
}

View File

@@ -42,13 +42,9 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.3.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation rootProject.ext.dependencies.androidxccorektx
implementation rootProject.ext.dependencies.kotlinstdlibjdk7
implementation rootProject.ext.dependencies.androidxrecyclerview
implementation rootProject.ext.dependencies.androidxappcompat
implementation rootProject.ext.dependencies.arouter
annotationProcessor rootProject.ext.dependencies.aroutercompiler

View File

@@ -205,7 +205,7 @@ public class V2XShareEventsFragment extends MvpFragment<V2XShareEventsFragment,
@Override
public void onFail(String msg) {
loadingView.stopWithError(msg, View.INVISIBLE);
loadingView.stopWithError("网络异常,点击刷新重试", View.INVISIBLE);
}
});
}

View File

@@ -79,22 +79,20 @@ public class V2XSeekHelpDialog extends ConstraintLayout implements View.OnClickL
void onClickRight();
}
private boolean isShown;
private WindowManagerView windowManager;
public void show() {
try {
Logger.d(TAG, "使用windowManager实现");
if (!isShown) {
if ( windowManager == null ) {
windowManager = new WindowManagerView.Builder(
V2XServiceManager.getMogoEntranceButtonController().getButton(ButtonIndex.BUTTON2).getContext()
).contentView(this).build();
windowManager.show();
isShown = true;
AIAssist.getInstance(V2XUtils.getApp()).speakTTSVoice("确定要解除求助状态吗");
unRegisterVoiceCmd();
registerVoiceCmd();
}
AIAssist.getInstance(V2XUtils.getApp()).speakTTSVoice("确定要解除求助状态吗");
unRegisterVoiceCmd();
registerVoiceCmd();
windowManager.show();
} catch (Exception e) {
e.printStackTrace();
}
@@ -111,10 +109,10 @@ public class V2XSeekHelpDialog extends ConstraintLayout implements View.OnClickL
};
public void dismiss() {
if (isShown && windowManager != null) {
if (windowManager != null) {
windowManager.dismiss();
isShown = false;
}
windowManager = null;
}
//放弃求助

View File

@@ -2,11 +2,14 @@ package com.mogo.module.widgets;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.WindowManager;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.commons.voice.AIAssist;
import com.mogo.commons.voice.IMogoVoiceCmdCallBack;
import com.mogo.module.common.wm.WindowManagerView;
import com.mogo.utils.CommonUtils;
import com.mogo.utils.LaunchUtils;
@@ -23,9 +26,10 @@ public
* <p>
* 描述
*/
class AutoNaviIntentHandler {
class AutoNaviIntentHandler implements IMogoVoiceCmdCallBack {
private static final String TAG = "AutoNaviIntentHandler";
public static final String OPEN = "OPEN_APP";
private static volatile AutoNaviIntentHandler sInstance;
@@ -94,26 +98,34 @@ class AutoNaviIntentHandler {
.position( ResourcesHelper.getDimensionPixelSize( context, R.dimen.module_widgets_app_entrance_x ), ResourcesHelper.getDimensionPixelSize( AbsMogoApplication.getApp(), R.dimen.module_widgets_app_entrance_y ) )
.showInWindowManager();
mWindowManagerView.attachTouchEvent( view -> {
try {
if ( DebugConfig.isLauncher() ) {
MogoWidgetManger.getInstance().getApis().getLauncherApi().backToLauncher( context );
} else {
LaunchUtils.launchByPkg( context, "com.mogo.launcher.app" );
}
if ( mProperties.isEmpty() ) {
mProperties.put( "appname", CommonUtils.getAppName( context ) );
mProperties.put( "appversion", CommonUtils.getVersionName( context ) );
mProperties.put( "from", 9 );
}
MogoWidgetManger.getInstance().getApis().getAnalyticsApi().track( "appenterfront", mProperties );
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
}
enterApp( context );
} );
}
try {
if ( mWindowManagerView.isShowing() ) {
return;
}
mWindowManagerView.show();
MogoWidgetManger.getInstance().getApis().getAnalyticsApi().track( "NAVI_button_show", null );
AIAssist.getInstance( context ).registerUnWakeupCommand( OPEN, new String[]{"切换到辅助驾驶模式"}, this );
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
}
}
private void enterApp( Context context ) {
try {
if ( DebugConfig.isLauncher() ) {
MogoWidgetManger.getInstance().getApis().getLauncherApi().backToLauncher( context );
} else {
LaunchUtils.launchByPkg( context, "com.mogo.launcher.app" );
}
if ( mProperties.isEmpty() ) {
mProperties.put( "appname", CommonUtils.getAppName( context ) );
mProperties.put( "appversion", CommonUtils.getVersionName( context ) );
mProperties.put( "from", 9 );
}
MogoWidgetManger.getInstance().getApis().getAnalyticsApi().track( "appenterfront", mProperties );
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
}
@@ -125,6 +137,7 @@ class AutoNaviIntentHandler {
}
try {
mWindowManagerView.dismiss();
AIAssist.getInstance( AbsMogoApplication.getApp() ).unregisterUnWakeupCommand( OPEN, this );
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
}
@@ -145,5 +158,13 @@ class AutoNaviIntentHandler {
intent.putExtra( "EXTRA_REQUEST_AUTO_STATE", 1 );
context.sendBroadcast( intent );
}
@Override
public void onCmdSelected( String cmd ) {
if ( TextUtils.equals( OPEN, cmd ) ) {
Logger.d(TAG, "recognized open command.");
enterApp( AbsMogoApplication.getApp() );
}
}
}

View File

@@ -238,4 +238,10 @@ public class MogoServicePaths {
*/
@Deprecated
public static final String PATH_TANLU_API = "/tanlulib/api";
/**
* 策略上报
*/
@Deprecated
public static final String PATH_STRATEGY_SHARE = "/share/strategy";
}

View File

@@ -1,5 +1,7 @@
package com.mogo.service.tanlu;
import com.mogo.map.MogoLatLng;
/**
* 探路事件上报参数封装
* @author tongchenfei
@@ -22,6 +24,15 @@ public class TanluUploadParams {
*/
private int duration = IMogoTanluProvider.DEFAULT_VIDEO_DURATION;
/**
* 针对策略上报新增字段用于车辆经过事故事件上报时记录经过的事故事件id
*/
private long parentId = 0;
/**
* 针对策略上报新增字段,用于车辆经过事故事件上报时,记录触发围栏时的经纬度坐标
*/
private MogoLatLng location = new MogoLatLng(0, 0);
public TanluUploadParams(String eventType){
this(eventType, IMogoTanluProvider.UPLOAD_FROM_USER);
}
@@ -37,6 +48,21 @@ public class TanluUploadParams {
this.fromType = fromType;
}
/**
* 针对策略上报新增构造方法方便传入parentId和location
* @param eventType 事件类型
* @param fromType 触发类型,是手动还是被动
* @param parentId 经过事件id
* @param location 触发围栏的坐标
*/
public TanluUploadParams(String eventType, String fromType, long parentId,
MogoLatLng location) {
this.eventType = eventType;
this.fromType = fromType;
this.parentId = parentId;
this.location = location;
}
public String getEventType() {
return eventType;
}
@@ -61,12 +87,30 @@ public class TanluUploadParams {
this.duration = duration;
}
public long getParentId() {
return parentId;
}
public void setParentId(long parentId) {
this.parentId = parentId;
}
public MogoLatLng getLocation() {
return location;
}
public void setLocation(MogoLatLng location) {
this.location = location;
}
@Override
public String toString() {
return "TanluUploadParams{" +
"eventType='" + eventType + '\'' +
", fromType='" + fromType + '\'' +
", duration=" + duration +
", parentId='" + parentId + '\'' +
", location=" + location +
'}';
}
}