Merge branch 'dev' into dev_custom_map
This commit is contained in:
@@ -7,9 +7,11 @@ 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
|
||||
f8xxImplementation rootProject.ext.dependencies.mogobaseserviceapk
|
||||
f80xImplementation rootProject.ext.dependencies.mogobaseserviceapk
|
||||
em3Implementation rootProject.ext.dependencies.mogobaseserviceapk
|
||||
} else {
|
||||
bydautoImplementation project(':foudations:mogo-base-services-sdk')
|
||||
@@ -17,9 +19,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')
|
||||
}
|
||||
}
|
||||
@@ -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')
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class MogoApplication extends AbsMogoApplication {
|
||||
MogoModulePaths.addModule( new MogoModule( CallChatConstant.PROVIDER, CallChatConstant.MODULE_NAME ) );
|
||||
}
|
||||
MogoModulePaths.addModule( new MogoModule( TanluApiConst.MODULE_PATH, TanluApiConst.MODULE_NAME ) );
|
||||
MogoModulePaths.addModule( new MogoModule( TanluConstants.TAG, TanluConstants.MODEL_NAME ) );
|
||||
MogoModulePaths.addBaseModule( new MogoModule( TanluConstants.TAG, TanluConstants.MODEL_NAME ) );
|
||||
MogoModulePaths.addModule( new MogoModule( MogoServicePaths.PATH_SHARE, "ShareControl" ) );
|
||||
|
||||
MogoModulePaths.addModule( new MogoModule( LeftPanelConst.PATH_NAME, LeftPanelConst.MODULE_NAME ) );
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -297,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)
|
||||
|
||||
@@ -98,10 +98,11 @@ class MainService : Service() {
|
||||
|| shareType == TANLU_ROAD_ACCIDENT || shareType == TANLU_ROAD_WORK
|
||||
) {
|
||||
// takePhoto(1, false, true)
|
||||
if (fromType != UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO) { // 是策略触发,不提示
|
||||
takeVideo(it.duration, isCustom = true, id = id)
|
||||
} else {
|
||||
if (fromType == UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO || fromType == UPLOAD_FROM_STRATEGY_BLOCK_AUTO) {
|
||||
// 如果是策略上报,isCustom = false
|
||||
takeVideo(it.duration)
|
||||
} else {
|
||||
takeVideo(it.duration, isCustom = true, id = id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ fun getInformationBody(
|
||||
isShare:Boolean,
|
||||
poiType: String,
|
||||
mainInfoId: Long,
|
||||
latitude: Double,
|
||||
longitude: Double
|
||||
longitude: Double,
|
||||
latitude: Double
|
||||
): InformationBody {
|
||||
var jsonArray = JsonArray()
|
||||
var type: Int
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -37,6 +37,8 @@ public class SchemeIntent implements IMogoStatusChangedListener {
|
||||
|
||||
public static final String TYPE_NAVI = "navi";
|
||||
|
||||
public static final String TYPE_SEARCH_ROAD_CONDITION = "search-road-condition";
|
||||
|
||||
public static final String TYPE_LAUNCH = "launch";
|
||||
|
||||
private IMogoServiceApis mApis;
|
||||
@@ -122,10 +124,24 @@ public class SchemeIntent implements IMogoStatusChangedListener {
|
||||
case TYPE_LAUNCH:
|
||||
handleLaunchIntent( target );
|
||||
break;
|
||||
case TYPE_SEARCH_ROAD_CONDITION:
|
||||
handleSearchRoadCondition(target);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void handleSearchRoadCondition(Uri target) {
|
||||
if (mApis == null) {
|
||||
return;
|
||||
}
|
||||
mApis.getTanluUiApi().searchRoadCondition(target.getQueryParameter("intentStr"),
|
||||
target.getQueryParameter("data"), target.getQueryParameter("city"),
|
||||
target.getQueryParameter("keywords"));
|
||||
}
|
||||
|
||||
private void handleSwitchCardIntent( String type ) {
|
||||
CardSwitchLiveData.getInstance().postValue( new CardInfo( type, true ) );
|
||||
}
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
|
||||
@@ -481,6 +481,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
filter.addAction( MogoReceiver.ACTION_AUTO_NAVI_RECEIVER );
|
||||
filter.addAction( MogoReceiver.ACTION_AUTO_NAVI_SEND );
|
||||
filter.addAction( MogoReceiver.ACTION_MOGO );
|
||||
filter.addAction(MogoReceiver.ACTION_TXZ_BLOCK_SEARCH);
|
||||
try {
|
||||
context.getApplicationContext().registerReceiver( mAIAssistReceiver, filter );
|
||||
Logger.i( TAG, "register voice receiver." );
|
||||
|
||||
@@ -32,6 +32,10 @@ public class LauncherCardRefreshStrategy {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void next(){
|
||||
getType();
|
||||
}
|
||||
|
||||
public int getLimit() {
|
||||
return type.limit;
|
||||
}
|
||||
|
||||
@@ -5,10 +5,12 @@ 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.commons.voice.VoicePreemptType;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.module.common.entity.MarkerResponse;
|
||||
@@ -16,10 +18,21 @@ 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.utils.AppUtils;
|
||||
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
|
||||
@@ -37,13 +50,32 @@ class LauncherCardRefresher {
|
||||
|
||||
private static volatile LauncherCardRefresher sInstance;
|
||||
|
||||
// 刷新道路事件/车友
|
||||
public static final int MSG_REFRESH = 2020;
|
||||
public static final int MSG_TTS_TIP = 2021;
|
||||
public static final long ONE_MINUTE = 15 * 1000L;
|
||||
// 刷新卡片默认显示内容
|
||||
public static final int MSG_REFRESH_DEFAULT_CARD = 2021;
|
||||
// 刷新卡片广告
|
||||
public static final int MSG_REFRESH_ADVERTISEMENT = 2022;
|
||||
// 开始刷新广告数据
|
||||
public static final int MSG_START_REFRESH_ADVERTISEMENT = 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 = 3 * ONE_MINUTE;
|
||||
private LauncherCardAdvertisementData.LauncherCardAdvertisement mDefaultLauncherCardConfig;
|
||||
private List< LauncherCardAdvertisementData.LauncherCardAdvertisement > mAdvertisements;
|
||||
|
||||
/**
|
||||
* 默认播报/后台配置播报次数限制
|
||||
*/
|
||||
private int mDefaultConfigCounter = 0;
|
||||
|
||||
private LauncherCardRefresher( Context context ) {
|
||||
mContext = context;
|
||||
mRefreshModel = new RefreshModel( mContext );
|
||||
mZhidaoRefreshModel = new ZhidaoRefreshModel( mContext );
|
||||
}
|
||||
|
||||
public static LauncherCardRefresher getInstance( Context context ) {
|
||||
@@ -81,11 +113,23 @@ class LauncherCardRefresher {
|
||||
Logger.e( TAG, e, "error when refresh launcher card." );
|
||||
}
|
||||
break;
|
||||
case MSG_TTS_TIP:
|
||||
playTTS();
|
||||
case MSG_REFRESH_DEFAULT_CARD:
|
||||
renderDefaultLauncherCardConfig();
|
||||
// 开启广告
|
||||
startLoopRenderAdvertisements();
|
||||
mRefreshStrategy = mRefreshStrategy.getNext();
|
||||
restart();
|
||||
break;
|
||||
case MSG_START_LOOP_DEFAULT_CARD:
|
||||
renderDefaultLauncherCardConfig();
|
||||
break;
|
||||
case MSG_REFRESH_ADVERTISEMENT:
|
||||
int index = msg.arg1;// 当前广告索引
|
||||
loopRenderAdvertisements( index );
|
||||
break;
|
||||
case MSG_START_REFRESH_ADVERTISEMENT:
|
||||
startAdvertisementsStrategy();
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -94,16 +138,17 @@ class LauncherCardRefresher {
|
||||
private boolean mRefreshStop = true;
|
||||
private boolean mStart = false;
|
||||
private RefreshModel mRefreshModel;
|
||||
private ZhidaoRefreshModel mZhidaoRefreshModel;
|
||||
private LauncherCardRefreshStrategy mRefreshStrategy = new LauncherCardRefreshStrategy(
|
||||
2 * ONE_MINUTE,
|
||||
new LauncherCardRefreshStrategy(
|
||||
3 * ONE_MINUTE,
|
||||
new LauncherCardRefreshStrategy(
|
||||
20 * ONE_MINUTE,
|
||||
5 * ONE_MINUTE,
|
||||
null,
|
||||
MSG_REFRESH ),
|
||||
MSG_REFRESH ),
|
||||
MSG_TTS_TIP
|
||||
MSG_REFRESH_DEFAULT_CARD
|
||||
);
|
||||
|
||||
public void start() {
|
||||
@@ -113,33 +158,29 @@ class LauncherCardRefresher {
|
||||
if ( mStart ) {
|
||||
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 ) {
|
||||
stop();
|
||||
return;
|
||||
} else {
|
||||
SharedPrefsMgr.getInstance( mContext ).putInt( KEY_LauncherCardTipCounter, 0 );
|
||||
counter = 0;
|
||||
SharedPrefsMgr.getInstance( mContext ).putLong( KEY_LauncherCardTipLastTipTime, 0L );
|
||||
}
|
||||
}
|
||||
mHandler.sendEmptyMessageDelayed( mRefreshStrategy.getMsgType(), mRefreshStrategy.getInterval() );
|
||||
Logger.d( TAG, "start" );
|
||||
mLaunchTTSText = mContext.getString( R.string.module_service_open_app_tip );
|
||||
startExplorerWayStrategy();
|
||||
// 延时一分钟加载数据,已保证accOn之后网络恢复正常
|
||||
mHandler.sendEmptyMessageDelayed( MSG_START_REFRESH_ADVERTISEMENT, ONE_MINUTE );
|
||||
mDefaultConfigCounter = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 道路事件和车友播报
|
||||
*/
|
||||
private void startExplorerWayStrategy() {
|
||||
mHandler.sendEmptyMessageDelayed( mRefreshStrategy.getMsgType(), mRefreshStrategy.getInterval() );
|
||||
mRefreshStop = false;
|
||||
mStart = true;
|
||||
|
||||
SharedPrefsMgr.getInstance( mContext ).putInt( KEY_LauncherCardTipCounter, ++counter );
|
||||
SharedPrefsMgr.getInstance( mContext ).putLong( KEY_LauncherCardTipLastTipTime, System.currentTimeMillis() );
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
mRefreshStop = true;
|
||||
mStart = false;
|
||||
mHandler.removeMessages( MSG_REFRESH );
|
||||
mHandler.removeMessages( MSG_TTS_TIP );
|
||||
mHandler.removeMessages( MSG_REFRESH_DEFAULT_CARD );
|
||||
mHandler.removeMessages( MSG_START_LOOP_DEFAULT_CARD );
|
||||
Logger.d( TAG, "stop" );
|
||||
}
|
||||
|
||||
@@ -149,57 +190,27 @@ class LauncherCardRefresher {
|
||||
}
|
||||
mRefreshStop = false;
|
||||
mHandler.removeMessages( MSG_REFRESH );
|
||||
mHandler.removeMessages( MSG_TTS_TIP );
|
||||
mHandler.sendEmptyMessageDelayed( mRefreshStrategy.getMsgType(), mRefreshStrategy.getInterval() );
|
||||
}
|
||||
|
||||
private void handleRefreshMsg() {
|
||||
if ( mRefreshModel == null ) {
|
||||
mRefreshModel = new RefreshModel( mContext );
|
||||
}
|
||||
MogoLocation location = MarkerServiceHandler.getMogoLocationClient().getLastKnowLocation();
|
||||
if ( location == null ) {
|
||||
restart();
|
||||
return;
|
||||
}
|
||||
MogoLatLng latLng = new MogoLatLng( location.getLatitude(), location.getLongitude() );
|
||||
if ( mRefreshStrategy.getType() == LauncherCardRefreshType.ExploreWay ) {
|
||||
handleRefreshExplorerWayData( latLng );
|
||||
} else {
|
||||
handleRefreshOnlineCarData( latLng );
|
||||
}
|
||||
handleRefreshData( latLng, mRefreshStrategy.getType() );
|
||||
}
|
||||
|
||||
private void handleRefreshExplorerWayData( MogoLatLng latLng ) {
|
||||
private void handleRefreshData( MogoLatLng latLng, LauncherCardRefreshType type ) {
|
||||
mRefreshModel.refreshDataSync( latLng,
|
||||
mRefreshStrategy.getRadius(),
|
||||
mRefreshStrategy.getLimit(),
|
||||
new RefreshCallback< MarkerResponse >() {
|
||||
@Override
|
||||
public void onSuccess( MarkerResponse response ) {
|
||||
notifyLauncherCard( LauncherCardRefreshType.ExploreWay, response );
|
||||
mRefreshStrategy = mRefreshStrategy.getNext();
|
||||
restart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail() {
|
||||
mRefreshStrategy = mRefreshStrategy.getNext();
|
||||
restart();
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
private void handleRefreshOnlineCarData( MogoLatLng latLng ) {
|
||||
mRefreshModel.queryOnLineCarWithRoute( latLng,
|
||||
false,
|
||||
true,
|
||||
mRefreshStrategy.getRadius(),
|
||||
mRefreshStrategy.getLimit(),
|
||||
new RefreshCallback< MarkerResponse >() {
|
||||
@Override
|
||||
public void onSuccess( MarkerResponse response ) {
|
||||
notifyLauncherCard( LauncherCardRefreshType.OnlineCar, response );
|
||||
notifyRefreshChanged( type, response );
|
||||
mRefreshStrategy = mRefreshStrategy.getNext();
|
||||
restart();
|
||||
}
|
||||
@@ -213,39 +224,57 @@ class LauncherCardRefresher {
|
||||
}
|
||||
|
||||
|
||||
private boolean notifyLauncherCard( LauncherCardRefreshType type, MarkerResponse response ) {
|
||||
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() ) {
|
||||
return false;
|
||||
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();
|
||||
}
|
||||
int size = response.getResult().getExploreWay().size();
|
||||
speakTTS( tts = String.format( tts, size, mRefreshStrategy.getDesc() ) );
|
||||
notifyLauncherCard( String.format( info, size, mRefreshStrategy.getDesc() ), size, tts );
|
||||
} else {
|
||||
if ( response.getResult().getOnlineCar() == null || response.getResult().getOnlineCar().isEmpty() ) {
|
||||
return false;
|
||||
} 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();
|
||||
}
|
||||
int size = response.getResult().getOnlineCar().size();
|
||||
speakTTS( tts = String.format( tts, size, mRefreshStrategy.getDesc() ) );
|
||||
notifyLauncherCard( String.format( info, size, mRefreshStrategy.getDesc() ), size , tts);
|
||||
}
|
||||
|
||||
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 ) {
|
||||
if ( AppUtils.isAppForeground( mContext ) ) {
|
||||
return;
|
||||
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 notifyLauncherCard( String info, int amount, String tts ) {
|
||||
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 );
|
||||
@@ -256,11 +285,191 @@ class LauncherCardRefresher {
|
||||
Logger.d( TAG, "发送广播到桌面卡片." );
|
||||
}
|
||||
|
||||
private void playTTS() {
|
||||
/**
|
||||
* 1. 刷新默认卡片样式
|
||||
* <p>
|
||||
* 2. 播报默认卡片语音
|
||||
*/
|
||||
private void renderDefaultLauncherCardConfig() {
|
||||
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 );
|
||||
mContext.sendBroadcast( intent );
|
||||
Logger.d( TAG, "发送默认配置广播到桌面卡片." );
|
||||
if ( !TextUtils.isEmpty( mDefaultLauncherCardConfig.content ) ) {
|
||||
mLaunchTTSText = mDefaultLauncherCardConfig.content;
|
||||
}
|
||||
if ( mDefaultLauncherCardConfig.popupNum > 0 ) {
|
||||
mDefaultTTSPlayInterval = mDefaultLauncherCardConfig.popupNum * ONE_MINUTE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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_MINUTE ) {
|
||||
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 {
|
||||
AIAssist.getInstance( mContext ).speakTTSVoice( mContext.getString( R.string.module_service_open_app_tip ) );
|
||||
speakTTS( mLaunchTTSText, true );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
startLoopDefaultConfigStrategy();
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求广告数据
|
||||
*/
|
||||
private void startAdvertisementsStrategy() {
|
||||
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 );
|
||||
Logger.e( TAG, "获取配置失败 msg = %s, code = %s", message, code );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
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;
|
||||
} 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()];
|
||||
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 startLoopRenderAdvertisements() {
|
||||
Message msg = Message.obtain();
|
||||
if ( mAdvertisements == null || mAdvertisements.isEmpty() ) {
|
||||
return;
|
||||
} else {
|
||||
try {
|
||||
LauncherCardAdvertisementData.LauncherCardAdvertisement advertisement = mAdvertisements.get( 0 );
|
||||
msg.what = MSG_REFRESH_ADVERTISEMENT;
|
||||
msg.arg1 = 1;
|
||||
mHandler.sendMessageDelayed( msg, advertisement.popupNum * ONE_MINUTE );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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 );
|
||||
mContext.sendBroadcast( intent );
|
||||
if ( !AppUtils.isAppForeground( mContext ) ) {
|
||||
speakTTS( advertisement.content, true );
|
||||
}
|
||||
Logger.d( TAG, "发送广告配置广播到桌面卡片." );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -32,12 +30,11 @@ public interface RefreshApiService {
|
||||
|
||||
@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();
|
||||
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
@@ -113,6 +118,7 @@ public class RefreshModel {
|
||||
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 );
|
||||
|
||||
@@ -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 );
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
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 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; // 间隔时间:分钟
|
||||
}
|
||||
}
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
@@ -60,6 +60,9 @@ public class MogoReceiver extends BroadcastReceiver {
|
||||
|
||||
public static final String ACTION_MOGO = "com.mogo.ACTION";
|
||||
|
||||
// 同行者 查询xxx堵不堵发送的广播
|
||||
public static final String ACTION_TXZ_BLOCK_SEARCH = "com.zhidao.roadcondition.roadinfo";
|
||||
|
||||
private IMogoIntentManager mMogoIntentManager;
|
||||
|
||||
public MogoReceiver(Context context) {
|
||||
|
||||
@@ -185,32 +185,10 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo
|
||||
intentManager.registerIntentListener(VOICE_CMD_NO_REPLY_SHARE_DIALOG_CLOSE, this);
|
||||
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(mContext).registerUnWakeupCommand(UNWAKE_UPLOAD_REAL_TIME_TRAFFIC,
|
||||
UPLOAD_REAL_TIME_TRAFFIC, ShareControl.this);
|
||||
|
||||
if(!DebugConfig.isLauncher()) {
|
||||
ServiceApisManager.serviceApis.getStatusManagerApi().registerStatusChangedListener(TAG, StatusDescriptor.MAIN_PAGE_RESUME, new IMogoStatusChangedListener() {
|
||||
@Override
|
||||
@@ -385,6 +363,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case VOICE_CMD_PUB_ROAD_CONDITION:
|
||||
String obCondition =
|
||||
new JSONObject(intent.getStringExtra("data")).opt("obj").toString();
|
||||
|
||||
@@ -7,6 +7,7 @@ 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.module.share.strategyreceiver.BlockStrategy
|
||||
import com.mogo.service.IMogoServiceApis
|
||||
import com.mogo.service.MogoServicePaths
|
||||
import com.mogo.utils.logger.Logger
|
||||
@@ -18,10 +19,17 @@ import com.mogo.utils.logger.Logger
|
||||
*/
|
||||
@Route(path = MogoServicePaths.PATH_STRATEGY_SHARE)
|
||||
class StrategyShareProvider : IProvider {
|
||||
override fun init(context: Context?) {
|
||||
private lateinit var blockStrategy: BlockStrategy
|
||||
override fun init(context: Context) {
|
||||
Logger.d(S_TAG, "策略上报Provider初始化====")
|
||||
val apis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(context) as IMogoServiceApis
|
||||
blockStrategy = BlockStrategy(context, apis)
|
||||
// 注册事故
|
||||
apis.getSocketManagerApi(context).registerOnMessageListener(ACCIDENT_STRATEGY_SHARE_PUSH_TYPE, AccidentStrategyReceiver(apis))
|
||||
apis.registerCenterApi.registerMogoLocationListener(MogoServicePaths.PATH_STRATEGY_SHARE){
|
||||
// Logger.d(S_TAG,"定位发生变化,准备记录速度: ${it.speed}")
|
||||
|
||||
blockStrategy.recordSpeed(it.speed * 3.6F)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.mogo.module.share.bean
|
||||
|
||||
import com.mogo.commons.data.BaseData
|
||||
|
||||
data class AverateSpeedResponse(var result:Result):BaseData()
|
||||
data class Result(var upload:Boolean,var poiType:String)
|
||||
@@ -80,6 +80,5 @@ public class ShareConstants {
|
||||
/**
|
||||
* 这个是实时路况,不是拥堵,拥堵放在了extention模块里面处理
|
||||
*/
|
||||
public static final String VOICE_CMD_PUB_ROAD_CONDITION = "com.zhidao.pathfinder.report" +
|
||||
".roadCondition";
|
||||
public static final String VOICE_CMD_PUB_ROAD_CONDITION = "com.zhidao.pathfinder.report.roadCondition";
|
||||
}
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
package com.mogo.module.share.constant
|
||||
|
||||
const val S_TAG = "StrategyShare"
|
||||
|
||||
/**
|
||||
* 目前两个策略上报(事故,拥堵)都是走的这个push
|
||||
*/
|
||||
const val ACCIDENT_STRATEGY_SHARE_PUSH_TYPE = 401013
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.mogo.module.share.net
|
||||
|
||||
import com.mogo.commons.data.BaseData
|
||||
import com.mogo.module.share.bean.AverateSpeedResponse
|
||||
import io.reactivex.Observable
|
||||
import okhttp3.RequestBody
|
||||
import retrofit2.http.*
|
||||
|
||||
/**
|
||||
@@ -14,4 +16,11 @@ interface ShareApiService {
|
||||
@FormUrlEncoded
|
||||
@POST("/yycp-realtimeLocations/vehicleTypeManage/car/updateVehicleType/v1")
|
||||
fun sendHelpSignal(@FieldMap param: Map<String, String>): Observable<BaseData>
|
||||
|
||||
/**
|
||||
* 拥堵策略,上报平均速度
|
||||
*/
|
||||
@Headers("Content-type:application/json;charset=UTF-8")
|
||||
@POST("/deva/car/path/no/poiStrategyCheck/v1")
|
||||
fun sendAverageSpeedForBlockStrategy(@Body request:RequestBody,@Query("sn") sn:String):Observable<AverateSpeedResponse>
|
||||
}
|
||||
@@ -1,11 +1,26 @@
|
||||
package com.mogo.module.share.strategyreceiver
|
||||
|
||||
|
||||
|
||||
data class AccidentStrategyPushWrapper(
|
||||
/**
|
||||
* 策略类型,1代表事故
|
||||
* 策略类型,[TYPE_ACCIDENT],[TYPE_BLOCK]
|
||||
*/
|
||||
val type: Int,
|
||||
/**
|
||||
* 触发点的事件id
|
||||
*/
|
||||
val id: Long, val lat: Double, val lon: Double)
|
||||
val id: Long, val lat: Double, val lon: Double){
|
||||
|
||||
companion object{
|
||||
/**
|
||||
* 服务端下发push,通知收集事故视频
|
||||
*/
|
||||
const val TYPE_ACCIDENT = 1
|
||||
|
||||
/**
|
||||
* 服务端下发push,通知收集拥堵
|
||||
*/
|
||||
const val TYPE_BLOCK = 2
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.mogo.module.share.strategyreceiver
|
||||
|
||||
import com.mogo.map.MogoLatLng
|
||||
import com.mogo.module.share.constant.S_TAG
|
||||
import com.mogo.module.share.strategyreceiver.AccidentStrategyPushWrapper.Companion.TYPE_ACCIDENT
|
||||
import com.mogo.module.share.strategyreceiver.AccidentStrategyPushWrapper.Companion.TYPE_BLOCK
|
||||
import com.mogo.service.IMogoServiceApis
|
||||
import com.mogo.service.connection.IMogoOnMessageListener
|
||||
import com.mogo.service.tanlu.IMogoTanluProvider
|
||||
@@ -12,14 +14,22 @@ import com.mogo.utils.logger.Logger
|
||||
* 车辆经过事故事件,上报视频
|
||||
* @author tong
|
||||
*/
|
||||
class AccidentStrategyReceiver(private val apis: IMogoServiceApis):IMogoOnMessageListener<AccidentStrategyPushWrapper> {
|
||||
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)))
|
||||
when (obj.type) {
|
||||
TYPE_ACCIDENT -> {
|
||||
// 收集事故视频
|
||||
apis.tanluApi.uploadRoadCondition(TanluUploadParams(IMogoTanluProvider.TYPE_ACCIDENT, IMogoTanluProvider.UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO, it.id, MogoLatLng(it.lat, it.lon)))
|
||||
}
|
||||
TYPE_BLOCK -> {
|
||||
// 收集拥堵视频
|
||||
apis.tanluApi.uploadRoadCondition(TanluUploadParams(IMogoTanluProvider.TYPE_BLOCK, IMogoTanluProvider.UPLOAD_FROM_STRATEGY_CLOUD_CHECK, it.id, MogoLatLng(it.lat, it.lon)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.mogo.module.share.strategyreceiver
|
||||
|
||||
import android.content.Context
|
||||
import android.os.SystemClock
|
||||
import android.util.ArrayMap
|
||||
import com.mogo.commons.network.SubscribeImpl
|
||||
import com.mogo.commons.network.Utils
|
||||
import com.mogo.map.MogoLatLng
|
||||
import com.mogo.module.share.bean.AverateSpeedResponse
|
||||
import com.mogo.module.share.constant.HttpConstant
|
||||
import com.mogo.module.share.manager.ServiceApisManager
|
||||
import com.mogo.module.share.net.ShareApiService
|
||||
import com.mogo.service.IMogoServiceApis
|
||||
import com.mogo.service.tanlu.IMogoTanluProvider
|
||||
import com.mogo.service.tanlu.TanluUploadParams
|
||||
import com.mogo.utils.DeviceIdUtils
|
||||
import com.mogo.utils.logger.Logger
|
||||
import com.mogo.utils.network.RequestOptions
|
||||
import com.mogo.utils.network.utils.GsonUtil
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.RequestBody
|
||||
|
||||
|
||||
/**
|
||||
* 速度记录间隔,单位是毫秒
|
||||
*/
|
||||
private const val SPEED_RECORD_TIME_INTERVAL = 2 * 60 * 1000L
|
||||
|
||||
/**
|
||||
* 停车标志位阈值,单位是次,两秒一次
|
||||
*/
|
||||
private const val STOP_FLAG_THRESHOLD = 30
|
||||
private const val TAG = "BlockUploadStrategy"
|
||||
|
||||
/**
|
||||
* 用于计算拥堵策略
|
||||
*/
|
||||
class BlockStrategy(private val context: Context, private val apis: IMogoServiceApis) {
|
||||
private var startRecordTime: Long = 0
|
||||
private var speedCacheList = ArrayList<Float>()
|
||||
|
||||
/**
|
||||
* 停车标志位,当速度为0时加1,超过[STOP_FLAG_THRESHOLD]判定为停车,不认为是拥堵,这组数据无效
|
||||
*/
|
||||
private var stopFlag = 0
|
||||
|
||||
/**
|
||||
* 拥堵速度计算上报策略
|
||||
* 计算[SPEED_RECORD_TIME_INTERVAL]内的平均速度,并上报
|
||||
*
|
||||
* 定义的此方法是每两秒钟调用一次, 两分钟为一段进行计算 |--两分钟--|--两分钟--|--两分钟--|
|
||||
*
|
||||
* 里面有一个小策略,使用了一个停车标志位,如果速度为0,停车标志位加一,一个两分钟时间段内,
|
||||
* 停车标志为累加超过[STOP_FLAG_THRESHOLD]判定为停车,不是拥堵,舍弃掉整个两分钟数据,不进行上报,
|
||||
* 否则上报服务端,返回是否抓取视频
|
||||
*
|
||||
* @param speed 当前速度,单位需要是Km/h
|
||||
*/
|
||||
fun recordSpeed(speed: Float) {
|
||||
val current = SystemClock.uptimeMillis()
|
||||
if (startRecordTime == 0L) {
|
||||
// 数据初始化
|
||||
startRecordTime = current
|
||||
stopFlag = 0
|
||||
speedCacheList.clear()
|
||||
}
|
||||
|
||||
speedCacheList.add(speed)
|
||||
|
||||
if (speed == 0F) {
|
||||
stopFlag++
|
||||
} else {
|
||||
stopFlag = 0
|
||||
}
|
||||
|
||||
if (current - startRecordTime >= SPEED_RECORD_TIME_INTERVAL) {
|
||||
// 到达时间限制,上报速度,数据清空
|
||||
if (stopFlag < STOP_FLAG_THRESHOLD) {
|
||||
// 停车标志位小于阈值,判定不是停车,计算平均值,进行上报
|
||||
var sum = 0F
|
||||
speedCacheList.forEach {
|
||||
sum += it
|
||||
}
|
||||
val ave = sum / speedCacheList.size
|
||||
Logger.d(TAG, "平均速度为: $ave")
|
||||
// 上报平均速度
|
||||
uploadAverageSpeed(ave)
|
||||
} else {
|
||||
Logger.d(TAG, "判定为停车,不进行上报")
|
||||
}
|
||||
startRecordTime = 0
|
||||
}
|
||||
}
|
||||
|
||||
private fun uploadAverageSpeed(average: Float) {
|
||||
val params = ArrayMap<String, Any>()
|
||||
params["speed"] = average.toInt()
|
||||
val body = RequestBody.create(MediaType.parse("Content-type:application/json;charset=UTF-8"), GsonUtil.jsonFromObject(params))
|
||||
val disposable = apis.networkApi.create(ShareApiService::class.java, HttpConstant.getNetHost()).sendAverageSpeedForBlockStrategy(body, Utils.getSn()).subscribeOn(Schedulers.io()).subscribe(object : SubscribeImpl<AverateSpeedResponse>(RequestOptions.create(context)) {
|
||||
override fun onSuccess(response: AverateSpeedResponse?) {
|
||||
super.onSuccess(response)
|
||||
response?.let {
|
||||
Logger.d(TAG, "收到服务端返回结果: $it")
|
||||
// 收到服务端回调,视情况进行视频上报
|
||||
if (it.result.upload) {
|
||||
val p = TanluUploadParams(it.result.poiType, IMogoTanluProvider.UPLOAD_FROM_STRATEGY_BLOCK_AUTO)
|
||||
val location = ServiceApisManager.serviceApis.mapServiceApi.getSingletonLocationClient(context).lastKnowLocation
|
||||
val latLon = MogoLatLng(location.latitude, location.longitude)
|
||||
p.location = latLon
|
||||
apis.tanluApi.uploadRoadCondition(p)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -51,13 +51,21 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.androidxconstraintlayout
|
||||
implementation rootProject.ext.dependencies.rxjava
|
||||
implementation rootProject.ext.dependencies.rxandroid
|
||||
|
||||
compileOnly rootProject.ext.dependencies.mogomap
|
||||
compileOnly rootProject.ext.dependencies.mogoutils
|
||||
compileOnly rootProject.ext.dependencies.mogocommons
|
||||
compileOnly rootProject.ext.dependencies.mogoserviceapi
|
||||
compileOnly rootProject.ext.dependencies.modulecommon
|
||||
compileOnly rootProject.ext.dependencies.moduleshare
|
||||
if (Boolean.valueOf(RELEASE)) {
|
||||
compileOnly rootProject.ext.dependencies.mogomap
|
||||
compileOnly rootProject.ext.dependencies.mogoutils
|
||||
compileOnly rootProject.ext.dependencies.mogocommons
|
||||
compileOnly rootProject.ext.dependencies.mogoserviceapi
|
||||
compileOnly rootProject.ext.dependencies.modulecommon
|
||||
compileOnly rootProject.ext.dependencies.moduleshare
|
||||
}else{
|
||||
compileOnly project(":libraries:mogo-map")
|
||||
compileOnly project(":foudations:mogo-utils")
|
||||
compileOnly project(":foudations:mogo-commons")
|
||||
compileOnly project(":services:mogo-service-api")
|
||||
compileOnly project(":modules:mogo-module-common")
|
||||
compileOnly project(":modules:mogo-module-share")
|
||||
}
|
||||
compileOnly rootProject.ext.dependencies.carcallprovider
|
||||
|
||||
implementation rootProject.ext.dependencies.videoarmv7
|
||||
|
||||
@@ -64,7 +64,10 @@ public class TanluConstants {
|
||||
//打开探路 唤醒
|
||||
public static final String OPEN_ROADCONDITION_AWAKE_COMMAND = "system.application.operation";
|
||||
|
||||
//xx堵不堵 唤醒
|
||||
// 同行者 xx堵不堵 唤醒
|
||||
public static final String TXZ_SPECIFIEDROAD_SEARCH = "com.zhidao.roadcondition.roadinfo";
|
||||
|
||||
//思必驰 xx堵不堵 唤醒
|
||||
public static final String SPECIFIEDROAD_SEARCH = "com.zhidao.pathfinder.specifiedroad.search";
|
||||
//播放 免唤醒
|
||||
public static final String PLAY_VIDEO = "com.zhidao.tanlu.play";
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.module.tanlu.fragment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
@@ -16,8 +17,17 @@ import com.mogo.service.module.IMogoModuleLifecycle;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
import com.mogo.service.module.ModuleType;
|
||||
import com.mogo.module.tanlu.constant.TanluConstants;
|
||||
import com.mogo.service.tanlu.IMogoTanluUiProvider;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.SingleEmitter;
|
||||
import io.reactivex.SingleOnSubscribe;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-24
|
||||
@@ -25,77 +35,35 @@ import com.mogo.utils.logger.Logger;
|
||||
* 描述
|
||||
*/
|
||||
@Route( path = TanluConstants.TAG )
|
||||
public class TanluCardViewProvider implements IMogoModuleProvider {
|
||||
public class TanluCardViewProvider implements IMogoTanluUiProvider {
|
||||
|
||||
private static final String TAG = "TanluCardViewProvider";
|
||||
private TanluCardViewFragment fragment;
|
||||
|
||||
@Override
|
||||
public Fragment createFragment( Context context, Bundle data ) {
|
||||
fragment = new TanluCardViewFragment();
|
||||
fragment.setArguments( data );
|
||||
Logger.i( TAG, "createFragment" );
|
||||
return fragment;
|
||||
}
|
||||
|
||||
private TanluListWindow tanluListWindow;
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
Logger.d(TAG, "init --------------> 1");
|
||||
TanluServiceManager.init( context );
|
||||
TanluServiceManager.getDataManager().registerDataListener( TanluConstants.MODEL_NAME, DataSetChangedAdapter.getInstance() );
|
||||
|
||||
TanluListWindow tanluListWindow = new TanluListWindow(context);
|
||||
tanluListWindow = new TanluListWindow(context);
|
||||
tanluListWindow.initWindow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModuleName() {
|
||||
return "CARD_TYPE_ROAD_CONDITION";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoModuleLifecycle getCardLifecycle() {
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View createView( Context context ) {
|
||||
// don't
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMapListener getMapListener() {
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return ModuleType.TYPE_CARD_FRAGMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoNaviListener getNaviListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoLocationListener getLocationListener() {
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMarkerClickListener getMarkerClickListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAppPackage() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAppName() {
|
||||
return "探路";
|
||||
public void searchRoadCondition(String intentStr, String data, String city, String keywords) {
|
||||
Disposable disposable = Single.create((SingleOnSubscribe<Intent>) emitter -> {
|
||||
Logger.d(TAG, "searchRoadCondition---> intentStr: " + intentStr + " data: " + data + " " +
|
||||
"city: " + city + " keywords: " + keywords);
|
||||
Intent intent = new Intent(intentStr);
|
||||
intent.putExtra("data", data);
|
||||
intent.putExtra("city", city);
|
||||
intent.putExtra("keywords", keywords);
|
||||
Thread.sleep(3000);
|
||||
emitter.onSuccess(intent);
|
||||
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(intent -> {
|
||||
Logger.d(TAG, "searchRoadCondition---go real share");
|
||||
tanluListWindow.realShare(intentStr, intent);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Rect;
|
||||
import android.net.Uri;
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
@@ -117,6 +118,7 @@ import static com.mogo.module.tanlu.constant.ConstKt.VOICE_COMMAND_QUERY_ROAD_CL
|
||||
import static com.mogo.module.tanlu.constant.ConstKt.VOICE_COMMAND_QUERY_TRAFFIC_CHECK;
|
||||
import static com.mogo.module.tanlu.constant.TanluConstants.PLAY_VIDEO_AWAKEN;
|
||||
import static com.mogo.module.tanlu.constant.TanluConstants.SPECIFIEDROAD_SEARCH;
|
||||
import static com.mogo.module.tanlu.constant.TanluConstants.TXZ_SPECIFIEDROAD_SEARCH;
|
||||
import static com.mogo.module.tanlu.video.VideoInitKt.initVideo;
|
||||
|
||||
/**
|
||||
@@ -477,6 +479,10 @@ public class TanluListWindow extends RelativeLayout implements IMogoMarkerClickL
|
||||
*/
|
||||
private void initListener() {
|
||||
if (mogoIntentManager != null) {
|
||||
// 同行者 xxx堵不堵唤醒词语音注册
|
||||
Logger.d(TAG, "initListener====");
|
||||
mogoIntentManager.registerIntentListener(TXZ_SPECIFIEDROAD_SEARCH,mogoIntentListener);
|
||||
// 通用唤醒词语音注册
|
||||
mogoIntentManager.registerIntentListener(SPECIFIEDROAD_SEARCH, mogoIntentListener);
|
||||
mogoIntentManager.registerIntentListener(PLAY_VIDEO_AWAKEN, mogoIntentListener);
|
||||
mogoIntentManager.registerIntentListener(VOICE_COMMAND_QUERY_TRAFFIC_CHECK, mogoIntentListener);
|
||||
@@ -497,75 +503,97 @@ public class TanluListWindow extends RelativeLayout implements IMogoMarkerClickL
|
||||
/**
|
||||
* 唤醒语音
|
||||
*/
|
||||
private IMogoIntentListener mogoIntentListener = new IMogoIntentListener() {
|
||||
@Override
|
||||
public void onIntentReceived(String intentStr, Intent intent) {
|
||||
String data = intent.getStringExtra("data");
|
||||
Logger.d(TAG, "唤醒 mogoIntentListener intentStr =" + intentStr + ">>data =" + data);
|
||||
VoiceCmdData voiceData = null;
|
||||
switch (intentStr) {
|
||||
case VOICE_COMMAND_QUERY_TRAFFIC_CHECK:
|
||||
// 搜索交通检查
|
||||
Logger.d(TAG, "搜索交通检查");
|
||||
voiceData = Utils.parseTOVoiceCmdData(data);
|
||||
voiceData.setObj(TYPE_NAME_TRAFFIC_CHECK);
|
||||
break;
|
||||
case VOICE_COMMAND_QUERY_ROAD_CLOSED:
|
||||
// 搜索封路
|
||||
Logger.d(TAG, "搜索封路");
|
||||
voiceData = Utils.parseTOVoiceCmdData(data);
|
||||
voiceData.setLocation(voiceData.getObj());
|
||||
voiceData.setObj(TYPE_NAME_CLOSURE);
|
||||
break;
|
||||
case SPECIFIEDROAD_SEARCH:
|
||||
// 拥堵和路况
|
||||
Logger.d(TAG, "拥堵和路况");
|
||||
voiceData = Utils.parseTOVoiceCmdData(data);
|
||||
voiceData.setObj(TYPE_NAME_BLOCK);
|
||||
break;
|
||||
case VOICE_COMMAND_NOVELTY_QUERY:
|
||||
Logger.d(TAG, "其他");
|
||||
voiceData = Utils.parseTOVoiceCmdData(data);
|
||||
break;
|
||||
case PLAY_VIDEO_AWAKEN:
|
||||
Logger.d(TAG, "mogoIntentListener 播放路况 唤醒 ----> ");
|
||||
delayTime();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (voiceData != null) {
|
||||
mTanluModelData.queryRodeInfo(voiceData, new RoadInfoCallback() {
|
||||
@Override
|
||||
public void onQueryRoadInfoSuccess(@NotNull List<? extends MarkerExploreWay> roadInfoList) {
|
||||
if (roadInfoList == null || (roadInfoList != null && roadInfoList.size() <= 0)) {
|
||||
speakFailVoice("未找到其他车主分享的路况信息");
|
||||
moveToMarcker(currentLat, currentLon);
|
||||
return;
|
||||
}
|
||||
Logger.d(TAG, "onQueryRoadInfoSuccess roadInfoList.size() = " + roadInfoList.size()
|
||||
+ " >>currentLat = " + currentLat + " -->currentLon = " + currentLon);
|
||||
initData(null, (List<MarkerExploreWay>) roadInfoList);
|
||||
addMarkersAction((List<MarkerExploreWay>) roadInfoList, currentLat, currentLon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onQueryRoadInfoFail(@NotNull String msg, int code) {
|
||||
Logger.e(TAG, "onQueryRoadInfoFail ----- msg = " + msg);
|
||||
speakFailVoice(searchfaileVoiceStrings[2]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocatSuccess(double lat, double lon) {
|
||||
currentLat = lat;
|
||||
currentLon = lon;
|
||||
}
|
||||
});
|
||||
}
|
||||
private IMogoIntentListener mogoIntentListener = (intentStr, intent) -> {
|
||||
if (TanluServiceManager.getMogoStatusManager().isMainPageOnResume()) {
|
||||
// 直接执行相关查询操作
|
||||
Logger.d(TAG, "智慧出行在前台,可直接分享--->");
|
||||
realShare(intentStr, intent);
|
||||
}else{
|
||||
// 需要打开智慧驾驶,然后执行操作
|
||||
Logger.d(TAG, "智慧出行没在前台,需要打开 --->");
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
String data = intent.getStringExtra("data") == null ? "" : intent.getStringExtra("data");
|
||||
String city = intent.getStringExtra("city") == null ? "" : intent.getStringExtra("city");
|
||||
String keywords = intent.getStringExtra("keywords") == null ? "" : intent.getStringExtra("keywords");
|
||||
intent.setData(Uri.parse("mogo://launcher/main/switch2?type=search-road-condition" +
|
||||
"&intentStr=" + intentStr + "&data=" + data + "&city=" + city + "&keywords=" + keywords));
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
};
|
||||
|
||||
public void realShare(String intentStr, Intent intent){
|
||||
String data = intent.getStringExtra("data");
|
||||
Logger.d(TAG, "唤醒 mogoIntentListener intentStr =" + intentStr + ">>data =" + data);
|
||||
VoiceCmdData voiceData = null;
|
||||
switch (intentStr) {
|
||||
case VOICE_COMMAND_QUERY_TRAFFIC_CHECK:
|
||||
// 搜索交通检查
|
||||
Logger.d(TAG, "搜索交通检查");
|
||||
voiceData = Utils.parseTOVoiceCmdData(data);
|
||||
voiceData.setObj(TYPE_NAME_TRAFFIC_CHECK);
|
||||
break;
|
||||
case VOICE_COMMAND_QUERY_ROAD_CLOSED:
|
||||
// 搜索封路
|
||||
Logger.d(TAG, "搜索封路");
|
||||
voiceData = Utils.parseTOVoiceCmdData(data);
|
||||
voiceData.setLocation(voiceData.getObj());
|
||||
voiceData.setObj(TYPE_NAME_CLOSURE);
|
||||
break;
|
||||
case SPECIFIEDROAD_SEARCH:
|
||||
// 拥堵和路况
|
||||
Logger.d(TAG, "拥堵和路况");
|
||||
voiceData = Utils.parseTOVoiceCmdData(data);
|
||||
voiceData.setObj(TYPE_NAME_BLOCK);
|
||||
break;
|
||||
case VOICE_COMMAND_NOVELTY_QUERY:
|
||||
Logger.d(TAG, "其他");
|
||||
voiceData = Utils.parseTOVoiceCmdData(data);
|
||||
break;
|
||||
case PLAY_VIDEO_AWAKEN:
|
||||
Logger.d(TAG, "mogoIntentListener 播放路况 唤醒 ----> ");
|
||||
delayTime();
|
||||
break;
|
||||
case TXZ_SPECIFIEDROAD_SEARCH:
|
||||
Logger.d(TAG, "同行者--xx堵不堵--唤醒--->");
|
||||
String keyWords = intent.getStringExtra("keywords");
|
||||
String city = intent.getStringExtra("city");
|
||||
voiceData = new VoiceCmdData("", city + keyWords, TYPE_NAME_BLOCK);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (voiceData != null) {
|
||||
mTanluModelData.queryRodeInfo(voiceData, new RoadInfoCallback() {
|
||||
@Override
|
||||
public void onQueryRoadInfoSuccess(@NotNull List<? extends MarkerExploreWay> roadInfoList) {
|
||||
if (roadInfoList == null || (roadInfoList != null && roadInfoList.size() <= 0)) {
|
||||
speakFailVoice("未找到其他车主分享的路况信息");
|
||||
moveToMarcker(currentLat, currentLon);
|
||||
return;
|
||||
}
|
||||
Logger.d(TAG, "onQueryRoadInfoSuccess roadInfoList.size() = " + roadInfoList.size()
|
||||
+ " >>currentLat = " + currentLat + " -->currentLon = " + currentLon);
|
||||
initData(null, (List<MarkerExploreWay>) roadInfoList);
|
||||
addMarkersAction((List<MarkerExploreWay>) roadInfoList, currentLat, currentLon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onQueryRoadInfoFail(@NotNull String msg, int code) {
|
||||
Logger.e(TAG, "onQueryRoadInfoFail ----- msg = " + msg);
|
||||
speakFailVoice(searchfaileVoiceStrings[2]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocatSuccess(double lat, double lon) {
|
||||
currentLat = lat;
|
||||
currentLon = lon;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加marker
|
||||
*/
|
||||
@@ -1058,7 +1086,7 @@ public class TanluListWindow extends RelativeLayout implements IMogoMarkerClickL
|
||||
|
||||
if (!NetworkUtils.isConnected(getContext())) { //没有网络
|
||||
TipToast.shortTip("分享失败,请检查网络");
|
||||
} else {
|
||||
} else if(TanluServiceManager.getMogoStatusManager().isMainPageOnResume()) {
|
||||
float bearing = TanluServiceManager.getLocationClient().getLastKnowLocation().getBearing(); //角度
|
||||
Logger.d(TAG, "onMarkerInfo event.type = " + event.type + " >>event.lat = " + event.lat + " >>event.lon = " + event.lon + " >>event.imageUrl =" + event.imageUrl);
|
||||
String poiType = event.type;
|
||||
|
||||
@@ -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() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.mogo.service.statusmanager.IMogoMsgCenter;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.service.strategy.IMogoRefreshStrategyController;
|
||||
import com.mogo.service.tanlu.IMogoTanluProvider;
|
||||
import com.mogo.service.tanlu.IMogoTanluUiProvider;
|
||||
import com.mogo.service.windowview.IMogoTopViewManager;
|
||||
import com.mogo.service.windowview.IMogoWindowManager;
|
||||
|
||||
@@ -257,4 +258,9 @@ public interface IMogoServiceApis extends IProvider {
|
||||
* @return
|
||||
*/
|
||||
IMogoMonitorProvider getMogoMonitorApi();
|
||||
/**
|
||||
* 获取探路ui服务
|
||||
* @return
|
||||
*/
|
||||
IMogoTanluUiProvider getTanluUiApi();
|
||||
}
|
||||
|
||||
@@ -244,4 +244,10 @@ public class MogoServicePaths {
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String PATH_STRATEGY_SHARE = "/share/strategy";
|
||||
|
||||
/**
|
||||
* 探路ui
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String PATH_TANLU_UI_API = "/tanlu/ui";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.mogo.service.tanlu;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
|
||||
/**
|
||||
* 探路相关ui provider
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public interface IMogoTanluUiProvider extends IProvider {
|
||||
/**
|
||||
* 搜索道路事件接口,当前只在应用在后台时,收到搜索相关唤醒词指令,需跳转前台时使用
|
||||
* @param intentStr action
|
||||
* @param data 思必驰相关事件
|
||||
* @param city 同行者-xx堵不堵-北京
|
||||
* @param keywords 同行者-xx堵不堵-中关村
|
||||
*/
|
||||
void searchRoadCondition(String intentStr, String data, String city, String keywords);
|
||||
}
|
||||
@@ -40,6 +40,7 @@ import com.mogo.service.statusmanager.IMogoMsgCenter;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.service.strategy.IMogoRefreshStrategyController;
|
||||
import com.mogo.service.tanlu.IMogoTanluProvider;
|
||||
import com.mogo.service.tanlu.IMogoTanluUiProvider;
|
||||
import com.mogo.service.windowview.IMogoTopViewManager;
|
||||
import com.mogo.service.windowview.IMogoWindowManager;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
@@ -218,6 +219,11 @@ public class MogoServiceApis implements IMogoServiceApis {
|
||||
return getApiInstance(IMogoMonitorProvider.class,MogoServicePaths.PATH_MOGO_MONITOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoTanluUiProvider getTanluUiApi(){
|
||||
return getApiInstance(IMogoTanluUiProvider.class, MogoServicePaths.PATH_TANLU_UI_API);
|
||||
}
|
||||
|
||||
private static < T extends IProvider > T getApiInstance(Class< T > clazz, String path ) {
|
||||
T inst = SingletonsHolder.get( clazz );
|
||||
if ( inst == null ) {
|
||||
|
||||
Reference in New Issue
Block a user