wait to finish
This commit is contained in:
@@ -3,7 +3,6 @@ package com.mogo.service;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.service.module.IMogoRegisterCenter;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.service.windowview.IMogoWindowManager;
|
||||
|
||||
/**
|
||||
@@ -15,7 +14,6 @@ import com.mogo.service.windowview.IMogoWindowManager;
|
||||
|
||||
public interface IMogoServiceApis extends IProvider {
|
||||
|
||||
|
||||
/**
|
||||
* 各业务回调接口注册接口
|
||||
*
|
||||
@@ -23,13 +21,6 @@ public interface IMogoServiceApis extends IProvider {
|
||||
*/
|
||||
IMogoRegisterCenter getRegisterCenterApi();
|
||||
|
||||
/**
|
||||
* 状态管理接口
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IMogoStatusManager getStatusManagerApi();
|
||||
|
||||
/**
|
||||
* 桌面浮窗控制接口
|
||||
*
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
package com.mogo.service.module;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-24
|
||||
* <p>
|
||||
* 模块 UI 接口
|
||||
*/
|
||||
public interface IMogoModuleProvider extends IProvider {
|
||||
|
||||
/**
|
||||
* 创建卡片
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
Fragment createFragment( Context context, Bundle data );
|
||||
|
||||
/**
|
||||
* 创建view
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
default View createView( Context context ){
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 模块唯一标识
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@NonNull
|
||||
String getModuleName();
|
||||
|
||||
/**
|
||||
* 是哪种类型的提供者
|
||||
* <p>
|
||||
* @return
|
||||
*/
|
||||
int getType();
|
||||
|
||||
/**
|
||||
* 获取模块对应 app 的包名
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
default String getAppPackage() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对应模块 app 名称
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
default String getAppName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
default void onDestroy(){
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.mogo.service.statusmanager;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-04
|
||||
* <p>
|
||||
* 状态控制器监听
|
||||
*/
|
||||
public interface IMogoStatusChangedListener {
|
||||
|
||||
/**
|
||||
* @param descriptor 状态类型
|
||||
* @param isTrue true - accOn、adas ui show、voice ui show、push ui show、v2x ui show
|
||||
*/
|
||||
void onStatusChanged( StatusDescriptor descriptor, boolean isTrue );
|
||||
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
package com.mogo.service.statusmanager;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-02
|
||||
* <p>
|
||||
* 车机状态
|
||||
*/
|
||||
public interface IMogoStatusManager extends IProvider {
|
||||
|
||||
/**
|
||||
* 是否在vr模式
|
||||
* @return true - 在vr模式 false - 不在vr模式
|
||||
*/
|
||||
boolean isVrMode();
|
||||
|
||||
/**
|
||||
* 小智语音 UI 是否在展示
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isVoiceShow();
|
||||
|
||||
/**
|
||||
* v2x UI 是否在展示
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isV2XShow();
|
||||
|
||||
/**
|
||||
* 是否开机
|
||||
*
|
||||
* @return true - 开机 false - 关机
|
||||
*/
|
||||
boolean isAccOn();
|
||||
|
||||
/**
|
||||
* 主页是否显示
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isMainPageOnResume();
|
||||
|
||||
/**
|
||||
* 主页是否在后台运行
|
||||
*
|
||||
* @return true-在后台,false-不在后台
|
||||
*/
|
||||
boolean isMainPageIsBackground();
|
||||
|
||||
/**
|
||||
* 主页是否已启动
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isMainPageLaunched();
|
||||
|
||||
/**
|
||||
* 设置vrMode状态
|
||||
* @param tag 业务类型
|
||||
* @param vrMode true - 在vr模式 false 不在vr模式
|
||||
*/
|
||||
void setVrMode(String tag, boolean vrMode);
|
||||
|
||||
/**
|
||||
* 设置小智语音UI状态
|
||||
*
|
||||
* @param tag 业务类型
|
||||
* @param show true - 显示 false - 隐藏
|
||||
*/
|
||||
void setVoiceUIShow( String tag, boolean show );
|
||||
|
||||
/**
|
||||
* 设置 V2X UI 状态
|
||||
* <p>
|
||||
*
|
||||
* @param tag 业务类型
|
||||
* @param show true - 显示 false - 隐藏
|
||||
*/
|
||||
void setV2XUIShow( String tag, boolean show );
|
||||
|
||||
/**
|
||||
* 设置 acc 状态
|
||||
*
|
||||
* @param tag 业务类型
|
||||
* @param isOn true - on, false - off
|
||||
*/
|
||||
void setAccStatus( String tag, boolean isOn );
|
||||
|
||||
/**
|
||||
* 主页 resume 状态
|
||||
*
|
||||
* @param tag
|
||||
* @param resume
|
||||
*/
|
||||
void setMainPageResumeStatus( String tag, boolean resume );
|
||||
|
||||
/**
|
||||
* 主页 后台运行 状态
|
||||
*
|
||||
* @param tag 控制来源
|
||||
* @param isBackground true-在后台运行,false-不在后台运行(也可能是挂了)
|
||||
*/
|
||||
void setMainPageIsBackgroundStatus( String tag, boolean isBackground );
|
||||
|
||||
/**
|
||||
* 设置小智语音状态
|
||||
*
|
||||
* @param tag
|
||||
* @param ready
|
||||
*/
|
||||
void setAIAssistReady( String tag, boolean ready );
|
||||
|
||||
/**
|
||||
* 设置求助状态
|
||||
*
|
||||
* @param tag
|
||||
* @param seekHelping
|
||||
*/
|
||||
void setSeekHelping( String tag, boolean seekHelping );
|
||||
|
||||
/**
|
||||
* 设置主页是否启动
|
||||
*
|
||||
* @param tag
|
||||
* @param launched
|
||||
*/
|
||||
void setMainPageLaunchedStatus( String tag, boolean launched );
|
||||
|
||||
/**
|
||||
* 注册监听
|
||||
*
|
||||
* @param tag 业务类型
|
||||
* @param descriptor 监听类型
|
||||
* @param listener 监听回调
|
||||
*/
|
||||
void registerStatusChangedListener( String tag, StatusDescriptor descriptor, IMogoStatusChangedListener listener );
|
||||
|
||||
/**
|
||||
* 注销
|
||||
*
|
||||
* @param tag 业务类型
|
||||
* @param descriptor 注销类型
|
||||
* @param listener 注销回调
|
||||
*/
|
||||
void unregisterStatusChangedListener( String tag, StatusDescriptor descriptor, IMogoStatusChangedListener listener );
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.mogo.service.statusmanager;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-04
|
||||
* <p>
|
||||
* 状态控制器监听
|
||||
*/
|
||||
public interface IMogoStickyStatusChangedListener extends IMogoStatusChangedListener {
|
||||
|
||||
/**
|
||||
* 是否需要黏性状态: 先改变状态,后注册监听
|
||||
*
|
||||
* @param descriptor 状态
|
||||
* @return 默认不需要
|
||||
*/
|
||||
boolean requestStickyStatus( StatusDescriptor descriptor );
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package com.mogo.service.statusmanager;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-04
|
||||
* <p>
|
||||
* 状态描述
|
||||
*/
|
||||
public enum StatusDescriptor {
|
||||
|
||||
/**
|
||||
* v2x UI
|
||||
*/
|
||||
V2X_UI,
|
||||
|
||||
/**
|
||||
* 小智语音交互 UI
|
||||
*/
|
||||
VOICE_UI,
|
||||
|
||||
/**
|
||||
* 开机状态
|
||||
*/
|
||||
ACC_STATUS,
|
||||
|
||||
/**
|
||||
* 主页 resume 状态
|
||||
*/
|
||||
MAIN_PAGE_RESUME,
|
||||
|
||||
/**
|
||||
* 主页 isBackground 状态
|
||||
*/
|
||||
MAIN_PAGE_IS_BACKGROUND,
|
||||
|
||||
/**
|
||||
* 小智语音状态
|
||||
*/
|
||||
AI_ASSIST_READY,
|
||||
|
||||
/**
|
||||
* 求助状态
|
||||
*/
|
||||
SEEK_HELPING,
|
||||
|
||||
/**
|
||||
* 是否已经进入过主页
|
||||
*/
|
||||
MAIN_PAGE_CREATED,
|
||||
|
||||
/**
|
||||
* 是否已经进入vr模式
|
||||
*/
|
||||
VR_MODE,
|
||||
|
||||
|
||||
}
|
||||
@@ -8,9 +8,7 @@ import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.impl.singleton.SingletonsHolder;
|
||||
import com.mogo.service.module.IMogoRegisterCenter;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.service.windowview.IMogoWindowManager;
|
||||
|
||||
/**
|
||||
@@ -27,11 +25,6 @@ public class MogoServiceApis implements IMogoServiceApis {
|
||||
|
||||
private static final Object sLock = new Object();
|
||||
|
||||
@Override
|
||||
public IMogoStatusManager getStatusManagerApi() {
|
||||
return SingletonsHolder.get(IMogoStatusManager.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
|
||||
@@ -50,23 +43,14 @@ public class MogoServiceApis implements IMogoServiceApis {
|
||||
}
|
||||
|
||||
private static <T extends IProvider> T getApiInstance(Class<T> clazz, String path) {
|
||||
T inst = SingletonsHolder.get(clazz);
|
||||
if (inst == null) {
|
||||
synchronized (sLock) {
|
||||
inst = SingletonsHolder.get(clazz);
|
||||
if (inst != null) {
|
||||
return inst;
|
||||
}
|
||||
T newInst = (T) ARouter.getInstance().build(path).navigation();
|
||||
try {
|
||||
SingletonsHolder.registerApi(clazz, newInst);
|
||||
CallerLogger.INSTANCE.d(TAG, "keep IProvider instance to SingletonHolder: path = " + path);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return newInst;
|
||||
synchronized (sLock) {
|
||||
T newInst = (T) ARouter.getInstance().build(path).navigation();
|
||||
try {
|
||||
CallerLogger.INSTANCE.d(TAG, "keep IProvider instance to SingletonHolder: path = " + path);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return newInst;
|
||||
}
|
||||
return inst;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package com.mogo.service.impl.singleton;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.service.impl.statusmanager.MogoStatusManager;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-06
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class SingletonsHolder {
|
||||
|
||||
private static final Map<Class, Object> sSingletons = new ConcurrentHashMap<>();
|
||||
|
||||
static {
|
||||
sSingletons.put(IMogoStatusManager.class, new MogoStatusManager());
|
||||
}
|
||||
|
||||
public static <T> T get(Class<T> clazz) {
|
||||
return (T) sSingletons.get(clazz);
|
||||
}
|
||||
|
||||
public static <T extends IProvider> void registerApi(Class<? extends IProvider> api, T impl) throws Exception {
|
||||
if (api == null || impl == null) {
|
||||
return;
|
||||
}
|
||||
sSingletons.put(api, impl);
|
||||
}
|
||||
}
|
||||
@@ -1,179 +0,0 @@
|
||||
package com.mogo.service.impl.statusmanager;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.service.statusmanager.IMogoStickyStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-02
|
||||
* <p>
|
||||
* 状态控制器
|
||||
*/
|
||||
public class MogoStatusManager implements IMogoStatusManager {
|
||||
|
||||
private static final String TAG = "MogoStatusManager";
|
||||
|
||||
/**
|
||||
* 状态记录
|
||||
*/
|
||||
private static final Map< StatusDescriptor, Boolean > mStatus = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 回调集合
|
||||
*/
|
||||
private static final Map< StatusDescriptor, List< IMogoStatusChangedListener > > mListeners = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 状态类型修改记录
|
||||
*/
|
||||
private static final Map< StatusDescriptor, String > mModifier = new ConcurrentHashMap<>();
|
||||
|
||||
@Override
|
||||
public boolean isVoiceShow() {
|
||||
return get_bool_val( StatusDescriptor.VOICE_UI );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVrMode() {
|
||||
return get_bool_val(StatusDescriptor.VR_MODE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isV2XShow() {
|
||||
return get_bool_val( StatusDescriptor.V2X_UI );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAccOn() {
|
||||
return get_bool_val( StatusDescriptor.ACC_STATUS );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMainPageOnResume() {
|
||||
return get_bool_val( StatusDescriptor.MAIN_PAGE_RESUME );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMainPageIsBackground() {
|
||||
return get_bool_val( StatusDescriptor.MAIN_PAGE_IS_BACKGROUND );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMainPageLaunched() {
|
||||
return get_bool_val( StatusDescriptor.MAIN_PAGE_CREATED );
|
||||
}
|
||||
|
||||
private boolean get_bool_val(StatusDescriptor descriptor ) {
|
||||
Boolean val = mStatus.get( descriptor );
|
||||
return val != null && val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVrMode(String tag, boolean vrMode) {
|
||||
doSetStatus(tag, StatusDescriptor.VR_MODE, vrMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVoiceUIShow( String tag, boolean show ) {
|
||||
doSetStatus( tag, StatusDescriptor.VOICE_UI, show );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setV2XUIShow( String tag, boolean show ) {
|
||||
doSetStatus( tag, StatusDescriptor.V2X_UI, show );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAccStatus( String tag, boolean isOn ) {
|
||||
doSetStatus( tag, StatusDescriptor.ACC_STATUS, isOn );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMainPageResumeStatus( String tag, boolean resume ) {
|
||||
doSetStatus( tag, StatusDescriptor.MAIN_PAGE_RESUME, resume );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMainPageIsBackgroundStatus(String tag, boolean isBackground) {
|
||||
doSetStatus( tag, StatusDescriptor.MAIN_PAGE_IS_BACKGROUND, isBackground );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAIAssistReady( String tag, boolean ready ) {
|
||||
doSetStatus( tag, StatusDescriptor.AI_ASSIST_READY, ready );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSeekHelping( String tag, boolean seekHelping ) {
|
||||
doSetStatus( tag, StatusDescriptor.SEEK_HELPING, seekHelping );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMainPageLaunchedStatus( String tag, boolean launched ) {
|
||||
doSetStatus( tag, StatusDescriptor.MAIN_PAGE_CREATED, launched );
|
||||
}
|
||||
|
||||
private void doSetStatus( String tag, StatusDescriptor target, boolean value ) {
|
||||
mStatus.put( target, value );
|
||||
invokeStatusChangedListener( target, value );
|
||||
recordStatusModifier( tag, target );
|
||||
}
|
||||
|
||||
private void invokeStatusChangedListener( StatusDescriptor descriptor, boolean status ) {
|
||||
List< IMogoStatusChangedListener > listenerList = mListeners.get( descriptor );
|
||||
if ( listenerList != null && listenerList.size() > 0 ) {
|
||||
IMogoStatusChangedListener[] listeners = new IMogoStatusChangedListener[listenerList.size()];
|
||||
listenerList.toArray( listeners );
|
||||
for ( IMogoStatusChangedListener listener : listeners ) {
|
||||
if ( listener != null ) {
|
||||
listener.onStatusChanged( descriptor, status );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void recordStatusModifier( String tag, StatusDescriptor descriptor ) {
|
||||
mModifier.put( descriptor, tag );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerStatusChangedListener( String tag, StatusDescriptor descriptor, IMogoStatusChangedListener listener ) {
|
||||
if ( listener == null || descriptor == null ) {
|
||||
return;
|
||||
}
|
||||
if ( !mListeners.containsKey( descriptor ) ) {
|
||||
mListeners.put( descriptor, new ArrayList<>() );
|
||||
}
|
||||
mListeners.get( descriptor ).add( listener );
|
||||
|
||||
if ( listener instanceof IMogoStickyStatusChangedListener && ((IMogoStickyStatusChangedListener)listener).requestStickyStatus( descriptor ) ) {
|
||||
Boolean val = mStatus.get( descriptor );
|
||||
if ( val != null ) {
|
||||
listener.onStatusChanged( descriptor, get_bool_val( descriptor ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterStatusChangedListener( String tag, StatusDescriptor descriptor, IMogoStatusChangedListener listener ) {
|
||||
if ( mListeners.get( descriptor ) != null ) {
|
||||
mListeners.get( descriptor ).remove( listener );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user