新建provider承载抽离免唤醒的逻辑

This commit is contained in:
tongchenfei
2020-10-20 14:57:48 +08:00
parent 2946aa1774
commit d0b0cc1236
3 changed files with 101 additions and 13 deletions

View File

@@ -0,0 +1,44 @@
package com.mogo.module.service.unwake;
/**
* 全局免唤醒常量类
*
* @author tongchenfei
*/
public class GlobalUnwakeConst {
public static final String MODULE_NAME = "GlobalUnwakeManager";
public static final String PATH_NAME = "/global/unwake";
// command
public static final String VOICE_CMD_GO_TO_SHARE = "com.zhidao.share";
/**
* 这个是实时路况不是拥堵拥堵放在了extention模块里面处理
*/
public static final String VOICE_CMD_PUB_ROAD_CONDITION = "com.zhidao.pathfinder.report.roadCondition";
/**
* 故障求助
*/
public static final String VOICE_CMD_PUB_TROUBLE_HELP = "com.zhidao.auxiliaryDriving" +
".pubTroubleHelp";
/**
* 关闭分享框 唤醒
*/
public static final String VOICE_CMD_SHARE_DIALOG_CLOSE = "com.zhidao.share.close";
/**
* 两次未回复关闭分享对话框
*/
public static final String VOICE_CMD_NO_REPLY_SHARE_DIALOG_CLOSE = "com.zhidao.share.dialog" +
".close";
/**
* 免唤醒词上报拥堵,但是现在当唤醒词使用
*/
public static final String UNWAKE_UPLOAD_ROAD_CONDITION = "command_upload_roadcondition";
/**
* 免唤醒词上报实时路况
*/
public static final String UNWAKE_UPLOAD_REAL_TIME_TRAFFIC = "command_upload_real_time_traffic";
// 词
public static final String[] UPLOAD_REAL_TIME_TRAFFIC = {"上报实时路况", "上报路况"};
}

View File

@@ -0,0 +1,57 @@
package com.mogo.module.service.unwake;
import android.content.Context;
import android.content.Intent;
import com.alibaba.android.arouter.facade.template.IProvider;
import com.mogo.commons.voice.AIAssist;
import com.mogo.commons.voice.IMogoVoiceCmdCallBack;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.service.intent.IMogoIntentListener;
import com.mogo.service.intent.IMogoIntentManager;
import com.mogo.utils.logger.Logger;
import static com.mogo.module.service.unwake.GlobalUnwakeConst.UNWAKE_UPLOAD_REAL_TIME_TRAFFIC;
import static com.mogo.module.service.unwake.GlobalUnwakeConst.UNWAKE_UPLOAD_ROAD_CONDITION;
import static com.mogo.module.service.unwake.GlobalUnwakeConst.UPLOAD_REAL_TIME_TRAFFIC;
import static com.mogo.module.service.unwake.GlobalUnwakeConst.VOICE_CMD_GO_TO_SHARE;
import static com.mogo.module.service.unwake.GlobalUnwakeConst.VOICE_CMD_NO_REPLY_SHARE_DIALOG_CLOSE;
import static com.mogo.module.service.unwake.GlobalUnwakeConst.VOICE_CMD_PUB_ROAD_CONDITION;
import static com.mogo.module.service.unwake.GlobalUnwakeConst.VOICE_CMD_PUB_TROUBLE_HELP;
import static com.mogo.module.service.unwake.GlobalUnwakeConst.VOICE_CMD_SHARE_DIALOG_CLOSE;
/**
* 全局免唤醒管理
* 有几个Module仅仅是因为要注册全局免唤醒词加到了BaseModule中为了将这部分Module从BaseModule中去掉特抽离全局免唤醒词注册监听逻辑
*
* @author tongchenfei
*/
public class GlobalUnwakeManager implements IProvider, IMogoIntentListener, IMogoVoiceCmdCallBack {
private IMogoIntentManager intentManager;
private static final String TAG = "GlobalUnwakeManager";
@Override
public void init(Context context) {
intentManager = MogoApisHandler.getInstance().getApis().getIntentManagerApi();
intentManager.registerIntentListener(VOICE_CMD_GO_TO_SHARE, this);
intentManager.registerIntentListener(VOICE_CMD_PUB_TROUBLE_HELP, this);
intentManager.registerIntentListener(VOICE_CMD_PUB_ROAD_CONDITION, this);
intentManager.registerIntentListener(VOICE_CMD_SHARE_DIALOG_CLOSE, this);
intentManager.registerIntentListener(VOICE_CMD_NO_REPLY_SHARE_DIALOG_CLOSE, this);
intentManager.registerIntentListener(UNWAKE_UPLOAD_ROAD_CONDITION, this);
// 免唤醒词注册,全局免唤醒
AIAssist.getInstance(context).registerUnWakeupCommand(UNWAKE_UPLOAD_REAL_TIME_TRAFFIC,
UPLOAD_REAL_TIME_TRAFFIC, this);
}
@Override
public void onIntentReceived(String intentStr, Intent intent) {
// 此处只接受处理语音相关广播
Logger.d(TAG, "收到唤醒词指令: " + intentStr);
switch (intentStr) {
default:
break;
}
}
}

View File

@@ -107,7 +107,6 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener,
private BaseFloatDialog mShareDialog;
private IMogoAuthorizeModuleManager authorizeModuleManager;
private IMogoIntentManager intentManager;
@Override
public void showShareDialog() {
@@ -197,18 +196,6 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener,
TipToast.tip("未授权,无法分享");
}
});
intentManager = ServiceApisManager.serviceApis.getIntentManagerApi();
intentManager.registerIntentListener(VOICE_CMD_GO_TO_SHARE, this);
intentManager.registerIntentListener(VOICE_CMD_PUB_TROUBLE_HELP, this);
intentManager.registerIntentListener(VOICE_CMD_PUB_ROAD_CONDITION, this);
intentManager.registerIntentListener(VOICE_CMD_SHARE_DIALOG_CLOSE, this);
intentManager.registerIntentListener(VOICE_CMD_NO_REPLY_SHARE_DIALOG_CLOSE, this);
intentManager.registerIntentListener(UNWAKE_UPLOAD_ROAD_CONDITION, 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() {