opt
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.mogo.module.service;
|
||||
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
@@ -8,8 +9,10 @@ import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.os.Process;
|
||||
import android.os.Trace;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -23,6 +26,7 @@ import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.map.model.MogoPoi;
|
||||
import com.mogo.map.navi.IMogoAimlessModeListener;
|
||||
import com.mogo.map.navi.IMogoNavi;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.map.navi.MogoCongestionInfo;
|
||||
import com.mogo.map.navi.MogoNaviInfo;
|
||||
@@ -31,6 +35,7 @@ import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.module.common.MogoModule;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.service.carinfo.CarStateInfo;
|
||||
import com.mogo.module.service.marker.MapMarkerManager;
|
||||
import com.mogo.module.service.network.RefreshCallback;
|
||||
import com.mogo.module.service.network.RefreshModel;
|
||||
@@ -40,9 +45,12 @@ import com.mogo.module.service.refresh.CustomRefreshStrategy;
|
||||
import com.mogo.module.service.refresh.RefreshObject;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.adas.IMogoADASController;
|
||||
import com.mogo.service.cardmanager.IMogoCardManager;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.intent.IMogoIntentManager;
|
||||
import com.mogo.service.launcher.IMogoLauncher;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
import com.mogo.service.module.IMogoActionManager;
|
||||
import com.mogo.service.module.IMogoRegisterCenter;
|
||||
@@ -50,7 +58,9 @@ import com.mogo.service.module.MogoAction;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
@@ -133,6 +143,10 @@ public class MogoServices implements IMogoMapListener,
|
||||
private IMogoStatusManager mStatusManager;
|
||||
private IMogoIntentManager mIntentManager;
|
||||
private IMogoActionManager mActionManager;
|
||||
private IMogoADASController mADASController;
|
||||
private IMogoLauncher mLauncher;
|
||||
private IMogoFragmentManager mFragmentManager;
|
||||
private IMogoNavi mNavi;
|
||||
|
||||
/**
|
||||
* 地图视图初始化
|
||||
@@ -258,6 +272,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
IMogoServiceApis apis = ( IMogoServiceApis ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICE_APIS ).navigation();
|
||||
mMogoMapService = apis.getMapServiceApi();
|
||||
mUiController = mMogoMapService.getMapUIController();
|
||||
mNavi = mMogoMapService.getNavi( context );
|
||||
mStatusManager = apis.getStatusManagerApi();
|
||||
mStatusManager.registerStatusChangedListener( ServiceConst.TYPE, StatusDescriptor.USER_INTERACTED, this );
|
||||
mStatusManager.registerStatusChangedListener( ServiceConst.TYPE, StatusDescriptor.SEARCH_UI, this );
|
||||
@@ -285,7 +300,13 @@ public class MogoServices implements IMogoMapListener,
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_NEXT, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_PREVIOUS, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_SWITCH_CARD, this );
|
||||
mIntentManager.registerIntentListener( MogoReceiver.ACTION_ADAS_STATUS, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_OPERATION, this );
|
||||
|
||||
mADASController = apis.getAdasControllerApi();
|
||||
mLauncher = apis.getLauncherApi();
|
||||
mFragmentManager = apis.getFragmentManagerApi();
|
||||
mCardManager = apis.getCardManagerApi();
|
||||
initWorkThread();
|
||||
}
|
||||
|
||||
@@ -341,6 +362,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
filter.addAction( Intent.ACTION_POWER_DISCONNECTED );
|
||||
// 小智语音
|
||||
filter.addAction( MogoReceiver.ACTION_VOICE_UI );
|
||||
filter.addAction( MogoReceiver.ACTION_ADAS_STATUS );
|
||||
try {
|
||||
context.getApplicationContext().registerReceiver( mAIAssistReceiver, filter );
|
||||
Logger.i( TAG, "register voice receiver." );
|
||||
@@ -642,7 +664,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
stopAutoRefreshStrategy();
|
||||
mRefreshRemainingTime = time;
|
||||
long delay = ServiceConst.DECREASE_INTERVAL;
|
||||
if( mRefreshRemainingTime < ServiceConst.DECREASE_INTERVAL ){
|
||||
if ( mRefreshRemainingTime < ServiceConst.DECREASE_INTERVAL ) {
|
||||
delay = mRefreshRemainingTime;
|
||||
}
|
||||
mHandler.sendEmptyMessageDelayed( ServiceConst.MSG_TYPE_REFRESH_DECREASE, delay );
|
||||
@@ -733,11 +755,33 @@ public class MogoServices implements IMogoMapListener,
|
||||
JSONObject jsonObject = new JSONObject( data );
|
||||
String card = jsonObject.getString( "card" );
|
||||
if ( TextUtils.equals( "多媒体", card ) ) {
|
||||
mCardManager.switch2( ServiceConst.CARD_TYPE_SHARE_MUSIC, true );
|
||||
switchCard2( ServiceConst.CARD_TYPE_SHARE_MUSIC );
|
||||
} else if ( TextUtils.equals( "探路", card ) ) {
|
||||
mCardManager.switch2( ServiceConst.CARD_TYPE_ROAD_CONDITION, true );
|
||||
switchCard2( ServiceConst.CARD_TYPE_ROAD_CONDITION );
|
||||
} else if ( TextUtils.equals( "在线车辆", card ) ) {
|
||||
mCardManager.switch2( ServiceConst.CARD_TYPE_USER_DATA, true );
|
||||
switchCard2( ServiceConst.CARD_TYPE_USER_DATA );
|
||||
}
|
||||
} catch ( JSONException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if ( MogoReceiver.ACTION_ADAS_STATUS.equals( command ) ) {
|
||||
String msg = intent.getStringExtra( "adasMsg" );
|
||||
if ( TextUtils.isEmpty( msg ) ) {
|
||||
return;
|
||||
}
|
||||
CarStateInfo stateInfo = GsonUtil.objectFromJson( msg, CarStateInfo.class );
|
||||
if ( stateInfo != null ) {
|
||||
changeCarHeadstockDirection( stateInfo.getValues().getHeading() );
|
||||
}
|
||||
} else if ( ServiceConst.COMMAND_OPERATION.equals( command ) ) {
|
||||
try {
|
||||
JSONObject object = new JSONObject( intent.getStringExtra( "data" ) );
|
||||
String app = object.optString( "object" );
|
||||
String operation = object.optString( "operation" );
|
||||
if ( TextUtils.equals( app, "车聊聊" ) ) {
|
||||
if ( TextUtils.equals( "打开", operation ) ) {
|
||||
switchCard2( ServiceConst.CARD_TYPE_CARS_CHATTING );
|
||||
}
|
||||
}
|
||||
} catch ( JSONException e ) {
|
||||
e.printStackTrace();
|
||||
@@ -745,6 +789,63 @@ public class MogoServices implements IMogoMapListener,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换卡片
|
||||
*
|
||||
* @param card
|
||||
*/
|
||||
private void switchCard2( String card ) {
|
||||
if ( isBackground( mContext ) ) {
|
||||
mLauncher.backToLauncher( mContext );
|
||||
UiThreadHandler.postDelayed( () -> {
|
||||
if ( mStatusManager.isADASShow() ) {
|
||||
mADASController.closeADAS();
|
||||
}
|
||||
mCardManager.switch2( card, true );
|
||||
}, 2000L );
|
||||
} else {
|
||||
mFragmentManager.clearAll();
|
||||
if ( mStatusManager.isADASShow() ) {
|
||||
mADASController.closeADAS();
|
||||
}
|
||||
mCardManager.switch2( card, true );
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isBackground( Context context ) {
|
||||
ActivityManager activityManager = ( ActivityManager ) context.getSystemService( Context.ACTIVITY_SERVICE );
|
||||
List< ActivityManager.RunningAppProcessInfo > appProcesses = activityManager.getRunningAppProcesses();
|
||||
for ( ActivityManager.RunningAppProcessInfo appProcess : appProcesses ) {
|
||||
if ( appProcess.processName.equals( context.getPackageName() ) ) {
|
||||
if ( appProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND ) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void changeCarHeadstockDirection( double degree ) {
|
||||
if ( mNavi.isNaviing() ) {
|
||||
return;
|
||||
}
|
||||
if ( mStatusManager.isSearchUIShow() ) {
|
||||
return;
|
||||
}
|
||||
if ( !mStatusManager.isMainPageOnResume() ) {
|
||||
return;
|
||||
}
|
||||
if ( mUiController.getCurrentUiMode() != EnumMapUI.NorthUP_2D ) {
|
||||
return;
|
||||
}
|
||||
mUiController.showMyLocation( ( ( float ) degree ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册桌面免唤醒指令
|
||||
*/
|
||||
private void registerInternalUnWakeupWords() {
|
||||
if ( mInternalUnWakeupRegisterStatus ) {
|
||||
return;
|
||||
@@ -754,6 +855,9 @@ public class MogoServices implements IMogoMapListener,
|
||||
AIAssist.getInstance( mContext ).registerUnWakeupCommand( ServiceConst.CMD_UN_WAKE_NEXT, ServiceConst.CMD_UN_WAKE_NEXT_UN_WAKE_WORDS, this );
|
||||
}
|
||||
|
||||
/**
|
||||
* 注销桌面免唤醒指令
|
||||
*/
|
||||
private void unregisterInternalUnWakeupWords() {
|
||||
if ( !mInternalUnWakeupRegisterStatus ) {
|
||||
return;
|
||||
|
||||
@@ -132,5 +132,10 @@ public class ServiceConst {
|
||||
*/
|
||||
public static final String COMMAND_SWITCH_CARD = "com.zhidao.desk.switchCard";
|
||||
|
||||
/**
|
||||
* 打开/关闭车聊聊
|
||||
*/
|
||||
public static final String COMMAND_OPERATION = "system.application.operation";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.mogo.module.service.carinfo;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @des 车辆状态
|
||||
* @date 2020/3/12
|
||||
*/
|
||||
public class CarStateInfo implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* action : “state”
|
||||
* values : {"lon":116.8,"lat":39.4,"alt":22.3,"heading":87.5,"acceleration":0.5,"yaw_rate":0.3}
|
||||
*/
|
||||
|
||||
private String action;
|
||||
private ValuesBean values;
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public ValuesBean getValues() {
|
||||
return values;
|
||||
}
|
||||
|
||||
public void setValues(ValuesBean values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
public static class ValuesBean {
|
||||
/**
|
||||
* lon : 116.8
|
||||
* lat : 39.4
|
||||
* alt : 22.3
|
||||
* heading : 87.5
|
||||
* acceleration : 0.5
|
||||
* yaw_rate : 0.3
|
||||
*/
|
||||
|
||||
private double lon;
|
||||
private double lat;
|
||||
private double alt;
|
||||
private double heading;
|
||||
private double acceleration;
|
||||
private double yaw_rate;
|
||||
|
||||
public double getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public void setLon(double lon) {
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
public double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(double lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public double getAlt() {
|
||||
return alt;
|
||||
}
|
||||
|
||||
public void setAlt(double alt) {
|
||||
this.alt = alt;
|
||||
}
|
||||
|
||||
public double getHeading() {
|
||||
return heading;
|
||||
}
|
||||
|
||||
public void setHeading(double heading) {
|
||||
this.heading = heading;
|
||||
}
|
||||
|
||||
public double getAcceleration() {
|
||||
return acceleration;
|
||||
}
|
||||
|
||||
public void setAcceleration(double acceleration) {
|
||||
this.acceleration = acceleration;
|
||||
}
|
||||
|
||||
public double getYaw_rate() {
|
||||
return yaw_rate;
|
||||
}
|
||||
|
||||
public void setYaw_rate(double yaw_rate) {
|
||||
this.yaw_rate = yaw_rate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ValuesBean{" +
|
||||
"lon=" + lon +
|
||||
", lat=" + lat +
|
||||
", alt=" + alt +
|
||||
", heading=" + heading +
|
||||
", acceleration=" + acceleration +
|
||||
", yaw_rate=" + yaw_rate +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CarStateInfo{" +
|
||||
"action='" + action + '\'' +
|
||||
", values=" + values +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.mogo.module.service.datamanager;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.datamanager.IMogoDataChanged2Listener;
|
||||
import com.mogo.service.datamanager.IMogoDataChangedListener;
|
||||
import com.mogo.service.datamanager.IMogoDataManager;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
@@ -20,7 +20,7 @@ import java.util.Map;
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class MogoDataHandler {
|
||||
public class MogoDataHandler implements IMogoDataManager {
|
||||
|
||||
private static final String TAG = "MogoDataHandler";
|
||||
|
||||
@@ -43,7 +43,7 @@ public class MogoDataHandler {
|
||||
return;
|
||||
}
|
||||
if ( !mListeners.containsKey( tag ) || mListeners.get( tag ) == null ) {
|
||||
mListeners.put( tag, new ArrayList< IMogoDataChangedListener >() );
|
||||
mListeners.put( tag, new ArrayList<>() );
|
||||
}
|
||||
mListeners.get( tag ).add( listener );
|
||||
}
|
||||
@@ -57,6 +57,47 @@ public class MogoDataHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeDataFrom( String module, Object object ) {
|
||||
if ( module == null || mListeners.get( module ) == null ) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Iterator< IMogoDataChangedListener > iterator = mListeners.get( module ).iterator();
|
||||
while ( iterator.hasNext() ) {
|
||||
IMogoDataChangedListener listener = iterator.next();
|
||||
if ( listener instanceof IMogoDataChanged2Listener ) {
|
||||
( ( IMogoDataChanged2Listener ) listener ).onDataRemoved( module, object );
|
||||
}
|
||||
}
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addData2( String module, Object object ) {
|
||||
if ( module == null || mListeners.get( module ) == null ) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Iterator< IMogoDataChangedListener > iterator = mListeners.get( module ).iterator();
|
||||
while ( iterator.hasNext() ) {
|
||||
IMogoDataChangedListener listener = iterator.next();
|
||||
if ( listener instanceof IMogoDataChanged2Listener ) {
|
||||
( ( IMogoDataChanged2Listener ) listener ).onDataAdded( module, object );
|
||||
}
|
||||
}
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
|
||||
}
|
||||
|
||||
public void invoke( String tag, Object data ) {
|
||||
if ( tag == null || mListeners.get( tag ) == null ) {
|
||||
return;
|
||||
@@ -69,8 +110,8 @@ public class MogoDataHandler {
|
||||
listener.onDataSetChanged( data );
|
||||
}
|
||||
}
|
||||
} catch( Exception e ){
|
||||
Logger.e(TAG, e, "error.");
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,17 @@ public class MogoDataManager implements IMogoDataManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
public void addData2( String module, Object object ) {
|
||||
MogoDataHandler.getInstance().addData2( module, object );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeDataFrom( String module, Object object ) {
|
||||
MogoDataHandler.getInstance().removeDataFrom( module, object );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
MogoDataHandler.getInstance().init( context );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,11 @@ public class MogoReceiver extends BroadcastReceiver {
|
||||
public static final String VALUE_DISMISS = "dismiss";
|
||||
public static final String VALUE_SHOW = "show";
|
||||
|
||||
/**
|
||||
* 从 adas 同步过来的信息
|
||||
*/
|
||||
public static final String ACTION_ADAS_STATUS = "com.zhidao.autopilot.adas.msg";
|
||||
|
||||
private IMogoIntentManager mMogoIntentManager;
|
||||
|
||||
public MogoReceiver( Context context ) {
|
||||
|
||||
Reference in New Issue
Block a user