opt
This commit is contained in:
@@ -32,6 +32,7 @@ import com.mogo.module.common.MogoModule;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.common.map.MapCenterPointStrategy;
|
||||
import com.mogo.module.common.map.Scene;
|
||||
import com.mogo.module.service.intent.AutoNaviIntentHandler;
|
||||
import com.mogo.module.service.intent.IntentHandlerFactory;
|
||||
import com.mogo.module.service.marker.MapMarkerManager;
|
||||
import com.mogo.module.service.network.RefreshCallback;
|
||||
@@ -274,7 +275,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
|
||||
private boolean mIsFirstAccOn = true;
|
||||
|
||||
private IMogoStatusChangedListener statusChangedListener = new StatusChangedAdapter(){
|
||||
private IMogoStatusChangedListener statusChangedListener = new StatusChangedAdapter() {
|
||||
@Override
|
||||
public void onUserInteracted( boolean userInteracted ) {
|
||||
if ( userInteracted ) {
|
||||
@@ -303,9 +304,11 @@ public class MogoServices implements IMogoMapListener,
|
||||
restartAutoRefreshAtTime( 2_000L );
|
||||
}
|
||||
mIsMainPageFirstResume = false;
|
||||
AutoNaviIntentHandler.getInstance().closeEntrance();
|
||||
} else {
|
||||
unregisterInternalUnWakeupWords();
|
||||
stopAutoRefreshStrategy();
|
||||
AutoNaviIntentHandler.getInstance().syncAutoNaviForgroundStatus( mContext );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,6 +385,8 @@ public class MogoServices implements IMogoMapListener,
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_ZHIDAO_NEARBY_USER_ONLINE, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_ZHIDAO_NEARBY_FRIEND_BYLOCATION, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_BACK, this );
|
||||
mIntentManager.registerIntentListener( MogoReceiver.ACTION_AUTO_NAVI_RECEIVER, this );
|
||||
mIntentManager.registerIntentListener( MogoReceiver.ACTION_AUTO_NAVI_SEND, this );
|
||||
|
||||
mADASController = MarkerServiceHandler.getADASController();
|
||||
mLauncher = MarkerServiceHandler.getLauncher();
|
||||
@@ -395,6 +400,9 @@ public class MogoServices implements IMogoMapListener,
|
||||
if ( DebugConfig.isLaunchLocationService() ) {
|
||||
initLocationServiceProcess( context );
|
||||
}
|
||||
|
||||
AutoNaviIntentHandler.getInstance().syncAutoNaviForgroundStatus( mContext );
|
||||
|
||||
}
|
||||
|
||||
private void initLocationServiceProcess( Context context ) {
|
||||
@@ -473,6 +481,8 @@ public class MogoServices implements IMogoMapListener,
|
||||
filter.addAction( MogoReceiver.ACTION_VOICE_READY );
|
||||
filter.addAction( MogoReceiver.ACTION_MOCK );
|
||||
filter.addAction( Intent.ACTION_CLOSE_SYSTEM_DIALOGS );
|
||||
filter.addAction( MogoReceiver.ACTION_AUTO_NAVI_RECEIVER );
|
||||
filter.addAction( MogoReceiver.ACTION_AUTO_NAVI_SEND );
|
||||
try {
|
||||
context.getApplicationContext().registerReceiver( mAIAssistReceiver, filter );
|
||||
Logger.i( TAG, "register voice receiver." );
|
||||
@@ -914,4 +924,14 @@ public class MogoServices implements IMogoMapListener,
|
||||
AIAssist.getInstance( mContext ).registerUnWakeupCommand( ServiceConst.CMD_BACK, ServiceConst.CMD_BACK_WORDS, this );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartNavi() {
|
||||
AutoNaviIntentHandler.getInstance().preShowEntrance( mContext );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopNavi() {
|
||||
AutoNaviIntentHandler.getInstance().closeEntrance();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
package com.mogo.module.service.intent;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.module.common.wm.WindowManagerView;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.R;
|
||||
import com.mogo.module.service.receiver.MogoReceiver;
|
||||
import com.mogo.utils.AppUtils;
|
||||
import com.mogo.utils.LaunchUtils;
|
||||
import com.mogo.utils.ResourcesHelper;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/6/5
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
class AutoNaviIntentHandler implements IntentHandler {
|
||||
|
||||
private static final String TAG = "AutoNaviIntentHandler";
|
||||
|
||||
private static volatile AutoNaviIntentHandler sInstance;
|
||||
|
||||
private AutoNaviIntentHandler() {
|
||||
}
|
||||
|
||||
public static AutoNaviIntentHandler getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( AutoNaviIntentHandler.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new AutoNaviIntentHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
private WindowManagerView mWindowManagerView;
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle( Context context, Intent intent ) {
|
||||
int keyType = intent.getIntExtra( "KEY_TYPE", 0 );
|
||||
switch ( keyType ) {
|
||||
case 10021:
|
||||
closeEntrance();
|
||||
MarkerServiceHandler.getADASController().showADAS();
|
||||
break;
|
||||
case 20009:
|
||||
MarkerServiceHandler.getADASController().closeADAS();
|
||||
break;
|
||||
case 10019:
|
||||
int extraState = intent.getIntExtra( "EXTRA_STATE", -1 );
|
||||
switch ( extraState ) {
|
||||
case 3:
|
||||
syncAutoNaviNavingStatus( context );
|
||||
break;
|
||||
case 4:
|
||||
closeEntrance();
|
||||
break;
|
||||
case 8:
|
||||
showEntrance( context );
|
||||
break;
|
||||
case 9:
|
||||
closeEntrance();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过查询高德地图状态后再显示
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
public void preShowEntrance( Context context ) {
|
||||
syncAutoNaviForgroundStatus( context );
|
||||
}
|
||||
|
||||
private void showEntrance( Context context ) {
|
||||
if ( mWindowManagerView == null ) {
|
||||
mWindowManagerView = new WindowManagerView.Builder( AbsMogoApplication.getApp() )
|
||||
.contentView( R.layout.module_service_app_entrance )
|
||||
.size( WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT )
|
||||
.position( ResourcesHelper.getDimensionPixelSize( context, R.dimen.module_services_app_entrance_x ), ResourcesHelper.getDimensionPixelSize( AbsMogoApplication.getApp(), R.dimen.module_services_app_entrance_y ) )
|
||||
.gravity( Gravity.LEFT|Gravity.TOP )
|
||||
.showInWindowManager();
|
||||
View root = mWindowManagerView.findViewById( R.id.module_service_app_entrance_root );
|
||||
root.setOnClickListener( view -> {
|
||||
try {
|
||||
if ( DebugConfig.isLauncher() ) {
|
||||
MarkerServiceHandler.getLauncher().backToLauncher( context );
|
||||
} else {
|
||||
LaunchUtils.launchByPkg( context, "com.mogo.launcher.app" );
|
||||
}
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
}
|
||||
} );
|
||||
}
|
||||
try {
|
||||
mWindowManagerView.show();
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
}
|
||||
}
|
||||
|
||||
public void closeEntrance() {
|
||||
if ( mWindowManagerView == null ) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
mWindowManagerView.dismiss();
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
}
|
||||
}
|
||||
|
||||
public void syncAutoNaviForgroundStatus( Context context ) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction( "AUTONAVI_STANDARD_BROADCAST_RECV" );
|
||||
intent.putExtra( "KEY_TYPE", 12404 );
|
||||
intent.putExtra( "EXTRA_REQUEST_AUTO_STATE", 0 );
|
||||
context.sendBroadcast( intent );
|
||||
}
|
||||
|
||||
public void syncAutoNaviNavingStatus( Context context ) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction( "AUTONAVI_STANDARD_BROADCAST_RECV" );
|
||||
intent.putExtra( "KEY_TYPE", 12404 );
|
||||
intent.putExtra( "EXTRA_REQUEST_AUTO_STATE", 1 );
|
||||
context.sendBroadcast( intent );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,8 @@ public class IntentHandlerFactory {
|
||||
mHandlers.put( MogoReceiver.ACTIION_ADAS, ADASStatusIntentHandler.getInstance() );
|
||||
mHandlers.put( MogoReceiver.ACTION_VOICE_READY, new AIAssistIntentHandler() );
|
||||
mHandlers.put( ServiceConst.COMMAND_BACK, WholeVoiceCommandIntentHandler.getInstance() );
|
||||
mHandlers.put( MogoReceiver.ACTION_AUTO_NAVI_RECEIVER, AutoNaviIntentHandler.getInstance() );
|
||||
mHandlers.put( MogoReceiver.ACTION_AUTO_NAVI_SEND, AutoNaviIntentHandler.getInstance() );
|
||||
}
|
||||
|
||||
private static final class InstanceHolder {
|
||||
|
||||
@@ -53,6 +53,11 @@ public class MogoReceiver extends BroadcastReceiver {
|
||||
|
||||
public static final String ACTION_MOCK = "com.mogo.mock";
|
||||
|
||||
// 接受其他app发给高德的广播
|
||||
public static final String ACTION_AUTO_NAVI_RECEIVER = "AUTONAVI_STANDARD_BROADCAST_RECV";
|
||||
// 接受高德发过来的广播
|
||||
public static final String ACTION_AUTO_NAVI_SEND = "AUTONAVI_STANDARD_BROADCAST_SEND";
|
||||
|
||||
private IMogoIntentManager mMogoIntentManager;
|
||||
|
||||
public MogoReceiver(Context context) {
|
||||
|
||||
Reference in New Issue
Block a user