[2.13.0]
[Change] [合并司机端、乘客端为一个应用,适用于异屏、异显、异交互] Signed-off-by: donghongyu <donghongyu@zhidaoauto.com>
This commit is contained in:
@@ -65,6 +65,38 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.mogo.eagle.core.function.main.PassengerLauncherActivity"
|
||||
android:clearTaskOnLaunch="${ACTIVITY_ROOT}"
|
||||
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize"
|
||||
android:enabled="true"
|
||||
android:resizeableActivity="false"
|
||||
android:resumeWhilePausing="true"
|
||||
android:screenOrientation="landscape"
|
||||
android:stateNotNeeded="true"
|
||||
android:theme="@style/Main"
|
||||
android:exported="true"
|
||||
android:process=":sub"
|
||||
android:windowSoftInputMode="adjustPan|stateHidden">
|
||||
<!--<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<!–调试用,暂时开启LAUNCHER这个属性–>
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
<category android:name="android.intent.category.LAUNCHER_APP" />
|
||||
<category android:name="android.intent.category.HOME" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>-->
|
||||
<intent-filter>
|
||||
<data
|
||||
android:host="launcher"
|
||||
android:path="/main/switch2"
|
||||
android:scheme="mogo" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<meta-data
|
||||
android:name="MAP_SDK_VERSION111111"
|
||||
android:value="${MAP_SDK_VERSION}" />
|
||||
|
||||
@@ -15,7 +15,6 @@ import android.os.Process;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -32,7 +31,7 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListener
|
||||
import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager;
|
||||
import com.mogo.eagle.core.function.hmi.R;
|
||||
import com.mogo.eagle.core.function.main.moujie.BluetoothMonitorReceiver;
|
||||
import com.mogo.eagle.core.function.main.moujie.ConnectBluetoothEvent;
|
||||
import com.mogo.eagle.core.function.main.utils.MultiDisplayUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
|
||||
@@ -43,9 +42,7 @@ import com.zhjt.service.chain.TracingConstants;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -148,11 +145,19 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
|
||||
*/
|
||||
private void loadOCHModule() {
|
||||
IMoGoFunctionProvider ochProvider = (IMoGoFunctionProvider) ARouter.getInstance()
|
||||
.build("/och/api")
|
||||
.build("/driver/api")
|
||||
.navigation(getContext());
|
||||
if (ochProvider != null) {
|
||||
ochProvider.createCoverage(this, R.id.module_main_id_och_fragment);
|
||||
}
|
||||
// TODO:这里只针对目前有的 Bus、Taxi业务进行异屏幕启动,这里需要考虑现有方案如何兼容
|
||||
if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode) ||
|
||||
AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) {
|
||||
MultiDisplayUtils.INSTANCE.startActWithProcess(
|
||||
this,
|
||||
2,
|
||||
PassengerLauncherActivity.class);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(sticky = true)
|
||||
@@ -253,7 +258,7 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
|
||||
} else if (event.getAction() == KeyEvent.ACTION_UP) {
|
||||
pressAUpTime = System.currentTimeMillis();
|
||||
Log.e(TAG, "dispatchKeyEvent A up pressAUpTime = " + pressAUpTime + "---" + (pressAUpTime - startPressTime) + "--pressBDownTime = " + pressBDownTime);
|
||||
if ((pressAUpTime - startPressTime) < 300 && !isCombinationKey) {
|
||||
if ((pressAUpTime - startPressTime) < 300 && !isCombinationKey) {
|
||||
ToastUtils.showShort("方块 单击A -1 ");
|
||||
sendAcc(true, -1);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import android.os.Process;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.bytedance.boost_multidex.BoostMultiDex;
|
||||
import com.elegant.utils.UiThreadHandler;
|
||||
import com.mogo.cloud.socket.SocketBuildConfig;
|
||||
@@ -21,6 +22,7 @@ import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
import com.mogo.eagle.core.data.constants.MoGoConfig;
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths;
|
||||
import com.mogo.eagle.core.function.api.base.IMoGoFunctionProvider;
|
||||
import com.mogo.eagle.core.function.api.chat.biz.ChatConsts;
|
||||
import com.mogo.eagle.core.function.api.devatools.IMogoDevaToolsUpgradeListener;
|
||||
import com.mogo.eagle.core.function.call.bindingcar.CallerBindingcarManager;
|
||||
@@ -82,7 +84,7 @@ public abstract class MainMoGoApplication extends AbsMogoApplication {
|
||||
@Override
|
||||
protected boolean shouldInit() {
|
||||
CallerLogger.INSTANCE.w(M_HMI + TAG, "evaluate shouldInit() with: " + ProcessUtils.getProcessName(Process.myPid()));
|
||||
return ProcessUtils.isMainProcess(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void queryAppUpgrade() {
|
||||
@@ -209,7 +211,8 @@ public abstract class MainMoGoApplication extends AbsMogoApplication {
|
||||
private void initModules() {
|
||||
CallerLogger.INSTANCE.d(M_HMI + TAG, "initModules");
|
||||
//och模块
|
||||
MogoModulePaths.addModuleFunction(new MogoModule("/och/api", "IMoGoFunctionProvider"));
|
||||
// MogoModulePaths.addModuleFunction(new MogoModule("/driver/api", "IMoGoFunctionProvider"));
|
||||
// MogoModulePaths.addModuleFunction(new MogoModule("/passenger/api", "IMoGoFunctionProvider"));
|
||||
|
||||
MogoModulePaths.addBaseModule(new MogoModule(MapApiPath.PATH, "CustomMapApiBuilder"));
|
||||
// MogoModulePaths.addBaseModule(new MogoModule(V2XConst.PATH_V2X_UI, V2XConst.MODULE_NAME));
|
||||
@@ -244,9 +247,9 @@ public abstract class MainMoGoApplication extends AbsMogoApplication {
|
||||
protected void attachBaseContext(Context base) {
|
||||
super.attachBaseContext(base);
|
||||
/*如果是主进程**/
|
||||
if (ProcessUtils.isMainProcess(this)) {
|
||||
// if (ProcessUtils.isMainProcess(this)) {
|
||||
AppLaunchTimeUtils.beginTimeCalculate(AppLaunchTimeUtils.COLD_START);
|
||||
}
|
||||
// }
|
||||
BoostMultiDex.install(base);
|
||||
AbsMogoApplication.sApp = this;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,427 @@
|
||||
package com.mogo.eagle.core.function.main;
|
||||
|
||||
import static com.mogo.eagle.core.data.deva.chain.ChainConstant.CHAIN_ALIAS_CODE_START_UP;
|
||||
import static com.mogo.eagle.core.data.deva.chain.ChainConstant.CHAIN_LINK_INIT;
|
||||
import static com.mogo.eagle.core.data.deva.chain.ChainConstant.CHAIN_LINK_LOG_CONNECT_STATUS;
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_HMI;
|
||||
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Process;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.module.intent.IMogoIntentListener;
|
||||
import com.mogo.commons.module.intent.IntentManager;
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
import com.mogo.eagle.core.function.api.base.IMoGoFunctionProvider;
|
||||
import com.mogo.eagle.core.function.api.setting.IMoGoSkinModeChangeListener;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
|
||||
import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager;
|
||||
import com.mogo.eagle.core.function.hmi.R;
|
||||
import com.mogo.eagle.core.function.main.moujie.BluetoothMonitorReceiver;
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils;
|
||||
import com.rousetime.android_startup.model.CostTimesModel;
|
||||
import com.zhjt.service.chain.ChainLog;
|
||||
import com.zhjt.service.chain.TracingConstants;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import me.jessyan.autosize.utils.AutoSizeUtils;
|
||||
|
||||
/**
|
||||
* 针对作为Launcher的情况,做个性化操作
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class PassengerLauncherActivity extends MainActivity implements IMogoIntentListener, IMoGoSkinModeChangeListener {
|
||||
private static final String TAG = "PassengerLauncherActivity";
|
||||
protected boolean mIsHomeKeyDown = false;
|
||||
private final static Handler handlerV2XEvent = new Handler();
|
||||
private static Runnable runnableV2XEvent;
|
||||
|
||||
private volatile double accelerated;//加速度
|
||||
private Timer timerHorn;
|
||||
private Timer timerAcc;
|
||||
|
||||
private BluetoothMonitorReceiver mBluetoothReceiver = null;
|
||||
private BluetoothAdapter mBluetoothAdapter;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
DebugConfig.setNeedRequestUserInfo(true);
|
||||
EventBus.getDefault().register(this);
|
||||
CallerLogger.INSTANCE.i(M_HMI + TAG, "onCreate");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
initBluetooth();
|
||||
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
if (!mBluetoothAdapter.isEnabled()) {
|
||||
mBluetoothAdapter.enable();
|
||||
}
|
||||
mBluetoothAdapter.startDiscovery();
|
||||
showBondedDevice(mBluetoothAdapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
super.initViews();
|
||||
// 这里在初始化完GUI后,做一些个性化的定制
|
||||
// 小巴车的乘客屏幕
|
||||
if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode) &&
|
||||
AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) {
|
||||
FrameLayout frameLayout = findViewById(R.id.module_main_id_map_fragment_container);
|
||||
frameLayout.setPadding(0, 0, AutoSizeUtils.dp2px(getContext(),700), 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
IntentManager.getInstance().registerIntentListener(Intent.ACTION_CLOSE_SYSTEM_DIALOGS, this);
|
||||
// 添加换肤监听
|
||||
CallerSkinModeListenerManager.INSTANCE.addListener(TAG, this);
|
||||
//ActivityLifecycleManager.getInstance().setAppActive(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mIsHomeKeyDown = false;
|
||||
unregisterReceiver(this.mBluetoothReceiver);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
IntentManager.getInstance().unregisterIntentListener(Intent.ACTION_CLOSE_SYSTEM_DIALOGS, this);
|
||||
//ActivityLifecycleManager.getInstance().setAppActive(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIntentReceived(String intentStr, Intent intent) {
|
||||
if (TextUtils.equals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS, intentStr)) {
|
||||
mIsHomeKeyDown = intent.getBooleanExtra("isHomeKeyDown", true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadOthersModules() {
|
||||
super.loadOthersModules();
|
||||
CallerLogger.INSTANCE.d(M_HMI + TAG, "loadOthersModules");
|
||||
loadOCHModule();
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载网约车模块
|
||||
*/
|
||||
private void loadOCHModule() {
|
||||
IMoGoFunctionProvider ochProvider = (IMoGoFunctionProvider) ARouter.getInstance()
|
||||
.build("/passenger/api")
|
||||
.navigation(getContext());
|
||||
if (ochProvider != null) {
|
||||
ochProvider.createCoverage(this, R.id.module_main_id_och_fragment);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(sticky = true)
|
||||
public void handleStartUp(List<CostTimesModel> costTimesModels) {
|
||||
for (CostTimesModel costModel : costTimesModels) {
|
||||
traceStartUp(costModel.toString());
|
||||
}
|
||||
EventBus.getDefault().removeStickyEvent(costTimesModels);
|
||||
}
|
||||
|
||||
@ChainLog(
|
||||
linkChainLog = CHAIN_LINK_LOG_CONNECT_STATUS,
|
||||
linkCode = CHAIN_LINK_INIT,
|
||||
endpoint = TracingConstants.Endpoint.PAD,
|
||||
nodeAliasCode = CHAIN_ALIAS_CODE_START_UP,
|
||||
paramIndexes = {0},
|
||||
clientPkFileName = "sn"
|
||||
)
|
||||
private void traceStartUp(String content) {
|
||||
CallerLogger.INSTANCE.d(M_HMI + TAG, content);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
stopCountDown();
|
||||
try {
|
||||
// acc off 之后会出现进程还在,但是页面被杀的情况,这个直接杀掉进程,然后让整个进程重启
|
||||
Process.killProcess(Process.myPid());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 移除换肤监听
|
||||
CallerSkinModeListenerManager.INSTANCE.removeListener(TAG);
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
private void stopCountDown() {
|
||||
if (runnableV2XEvent != null) {
|
||||
handlerV2XEvent.removeCallbacks(runnableV2XEvent);
|
||||
runnableV2XEvent = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
private long startPressTime = 0; //开始按减时间
|
||||
private boolean isPressEnd = false; //按键是否结束
|
||||
private boolean isCombinationKey = false; //是否是组合按键
|
||||
|
||||
private long pressADownTime = 0;
|
||||
private long pressAUpTime = 0;
|
||||
private long pressBDownTime = 0;
|
||||
private long pressBUpTime = 0;
|
||||
private long pressCDownTime = 0;
|
||||
private long pressCUpTime = 0;
|
||||
private long pressDDownTime = 0;
|
||||
private long pressDUpTime = 0;
|
||||
private long pressEDownTime = 0;
|
||||
private long pressEUpTime = 0;
|
||||
|
||||
|
||||
/**
|
||||
* 魔方按键分发 提测前注释 ToastUtils TODO
|
||||
* @param event
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||
// Log.d(TAG, "dispatchKeyEvent code = " + event.getKeyCode() + "--action = " + event.getAction() + "----" + event);
|
||||
String bluetoothName = SharedPrefsMgr.getInstance(getContext()).getString("BLUETOOTH");
|
||||
if (!isPressEnd) {
|
||||
Log.e(TAG, "dispatchKeyEvent bluetoothName = " + bluetoothName);
|
||||
}
|
||||
if (bluetoothName.equals("MINI_KEYBOARD")) {
|
||||
if (!isPressEnd) {
|
||||
isPressEnd = true;
|
||||
startPressTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
if (event.getKeyCode() == KeyEvent.KEYCODE_A) { //单击 -1,长按无操作,AB组合-2
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
pressADownTime = System.currentTimeMillis();
|
||||
Log.d(TAG, "dispatchKeyEvent A down pressADownTime = " + pressADownTime + "---" + (pressADownTime - startPressTime) + "----isCombinationKey = " + isCombinationKey + "--pressBDownTime = " + pressBDownTime);
|
||||
if ((pressADownTime - startPressTime) > 350 && (pressADownTime - startPressTime) < 1800 && pressBDownTime > 0) {
|
||||
ToastUtils.showShort("方块 A 按AB组合 -2 ");
|
||||
sendAcc(true, -2);
|
||||
isCombinationKey = true;
|
||||
}
|
||||
if (!isCombinationKey) {
|
||||
if ((pressADownTime - startPressTime) > 1900) {
|
||||
ToastUtils.showShort("方块 长按A 无 操作 ");
|
||||
}
|
||||
}
|
||||
} else if (event.getAction() == KeyEvent.ACTION_UP) {
|
||||
pressAUpTime = System.currentTimeMillis();
|
||||
isPressEnd = false;
|
||||
isCombinationKey = false;
|
||||
Log.e(TAG, "dispatchKeyEvent A up pressAUpTime = " + pressAUpTime + "---" + (pressAUpTime - startPressTime) + "--pressBDownTime = " + pressBDownTime);
|
||||
if ((pressAUpTime - startPressTime) < 300) {
|
||||
ToastUtils.showShort("方块 单击A -1 ");
|
||||
sendAcc(true, -1);
|
||||
}
|
||||
pressAUpTime = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
} else if (event.getKeyCode() == KeyEvent.KEYCODE_B) {//单击复原,长按+1,AB组合-2
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
pressBDownTime = System.currentTimeMillis();
|
||||
Log.d(TAG, "dispatchKeyEvent B down pressBDownTime = " + pressBDownTime + "--差-" + (pressBDownTime - startPressTime) + "---isCombinationKey = " + isCombinationKey + "--pressADownTime = " + pressADownTime);
|
||||
if ((pressBDownTime - startPressTime) > 350 && (pressBDownTime - startPressTime) < 1800 && pressADownTime > 0) {
|
||||
ToastUtils.showShort("方块 B 按AB组合 ");
|
||||
sendAcc(true, -2);
|
||||
isCombinationKey = true;
|
||||
}
|
||||
if (!isCombinationKey) {
|
||||
if ((pressBDownTime - startPressTime) > 1900) {
|
||||
ToastUtils.showShort("方块 长按B =1 ");
|
||||
sendAcc(true, +1);
|
||||
}
|
||||
}
|
||||
} else if (event.getAction() == KeyEvent.ACTION_UP) {
|
||||
pressBUpTime = System.currentTimeMillis();
|
||||
isPressEnd = false;
|
||||
isCombinationKey = false;
|
||||
Log.e(TAG, "dispatchKeyEvent B up pressBUpTime = " + pressBUpTime + "--差-" + (pressBUpTime - startPressTime) + "--pressADownTime = " + pressADownTime);
|
||||
if ((pressBUpTime - startPressTime) < 300) {
|
||||
ToastUtils.showShort("方块 单击B 0 ");
|
||||
sendAcc(false, 0.0);
|
||||
}
|
||||
pressBDownTime = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
} else if (event.getKeyCode() == KeyEvent.KEYCODE_C) { //单击左变道,长按无操作
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
pressCDownTime = System.currentTimeMillis();
|
||||
if (!isCombinationKey) {
|
||||
if ((pressCDownTime - startPressTime) > 1900) {
|
||||
ToastUtils.showShort("方块 长按C 无操作 ");
|
||||
}
|
||||
}
|
||||
} else if (event.getAction() == KeyEvent.ACTION_UP) {
|
||||
pressCUpTime = System.currentTimeMillis();
|
||||
isPressEnd = false;
|
||||
isCombinationKey = false;
|
||||
if ((pressCUpTime - startPressTime) < 300) {
|
||||
ToastUtils.showShort("方块 单击C ← 向左变道 ");
|
||||
CallerAutoPilotManager.INSTANCE.sendOperatorChangeLaneLeft();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else if (event.getKeyCode() == KeyEvent.KEYCODE_D) { //单击向右变道,双击无操作
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
pressDDownTime = System.currentTimeMillis();
|
||||
if (!isCombinationKey) {
|
||||
if ((pressDDownTime - startPressTime) > 1900) {
|
||||
ToastUtils.showShort("方块 长按D 无操作 ");
|
||||
}
|
||||
}
|
||||
} else if (event.getAction() == KeyEvent.ACTION_UP) {
|
||||
pressDUpTime = System.currentTimeMillis();
|
||||
isPressEnd = false;
|
||||
isCombinationKey = false;
|
||||
if ((pressDUpTime - startPressTime) < 300) {
|
||||
ToastUtils.showShort("方块 单击D → 向右变道 ");
|
||||
CallerAutoPilotManager.INSTANCE.sendOperatorChangeLaneRight();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} else if (event.getKeyCode() == KeyEvent.KEYCODE_E) { //单击启动自驾,长按鸣笛
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
pressEDownTime = System.currentTimeMillis();
|
||||
if (!isCombinationKey) {
|
||||
if ((pressEDownTime - startPressTime) > 1900) {
|
||||
ToastUtils.showShort("方块 长按E 鸣笛 ");
|
||||
CallerAutoPilotManager.INSTANCE.sendOperatorSetHorn(1);
|
||||
if (timerHorn == null) {
|
||||
timerHorn = new Timer();
|
||||
}
|
||||
timerHorn.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
CallerAutoPilotManager.INSTANCE.sendOperatorSetHorn(2);
|
||||
timerHorn = null;
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
} else if (event.getAction() == KeyEvent.ACTION_UP) {
|
||||
pressEUpTime = System.currentTimeMillis();
|
||||
isPressEnd = false;
|
||||
isCombinationKey = false;
|
||||
if ((pressEUpTime - startPressTime) < 300) {
|
||||
ToastUtils.showShort("方块 单击E 开启自动驾驶 ");
|
||||
CallerAutoPilotManager.INSTANCE.startAutoPilot(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getAutopilotControlParameters());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return super.dispatchKeyEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSkinModeChange(int skinMode) {
|
||||
|
||||
}
|
||||
|
||||
private synchronized void sendAcc(boolean isSend, double acc) {
|
||||
if (isSend) {
|
||||
accelerated = acc;
|
||||
if (timerAcc == null) {
|
||||
timerAcc = new Timer();
|
||||
timerAcc.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
CallerAutoPilotManager.INSTANCE.sendOperatorSetAcceleratedSpeed(accelerated);
|
||||
}
|
||||
}, 0, 500);
|
||||
}
|
||||
} else {
|
||||
if (timerAcc != null) {
|
||||
timerAcc.cancel();
|
||||
timerAcc = null;
|
||||
}
|
||||
CallerAutoPilotManager.INSTANCE.sendOperatorSetAcceleratedSpeed(acc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化蓝牙广播
|
||||
*/
|
||||
private void initBluetooth() {
|
||||
this.mBluetoothReceiver = new BluetoothMonitorReceiver();
|
||||
IntentFilter intentFilter = new IntentFilter();
|
||||
// 监视蓝牙关闭和打开的状态
|
||||
intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
|
||||
|
||||
// 监视蓝牙设备与APP连接的状态
|
||||
intentFilter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED);
|
||||
intentFilter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED);
|
||||
|
||||
// 注册广播
|
||||
registerReceiver(this.mBluetoothReceiver, intentFilter);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找蓝牙连接过的蓝牙设备
|
||||
*/
|
||||
private void showBondedDevice(BluetoothAdapter bluetoothAdapter) {
|
||||
Set<BluetoothDevice> deviceList = bluetoothAdapter.getBondedDevices();
|
||||
for (BluetoothDevice device : deviceList) {
|
||||
try {
|
||||
//使用反射调用获取设备连接状态方法
|
||||
Method isConnectedMethod = BluetoothDevice.class.getDeclaredMethod("isConnected", (Class[]) null);
|
||||
isConnectedMethod.setAccessible(true);
|
||||
// boolean isConnected = (boolean) isConnectedMethod.invoke(device, (Object[]) null);
|
||||
Log.d(TAG, "-- device.getName() = " + device.getName()); //device.getAddress()
|
||||
if (device.getName().equals("MINI_KEYBOARD")) {
|
||||
SharedPrefsMgr.getInstance(getContext()).putString("BLUETOOTH", device.getName());
|
||||
}
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.mogo.eagle.core.function.main.utils
|
||||
|
||||
import android.app.ActivityOptions
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.hardware.display.DisplayManager
|
||||
import android.view.Display
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
|
||||
/**
|
||||
* 多屏幕操作工具类
|
||||
*/
|
||||
object MultiDisplayUtils {
|
||||
private val TAG: String = "MultiDisplayUtils"
|
||||
|
||||
// 获取 是否支持扩展屏幕打开应用
|
||||
fun isSupportMultiDisplay(context: Context): Boolean {
|
||||
// 先检查一下是不是支持在第二屏上显示activity这个特性,
|
||||
// 在ActivityOptions.java setLaunchDisplayId 上面有相关的说明
|
||||
val packageManager = context.packageManager
|
||||
return packageManager.hasSystemFeature(PackageManager.FEATURE_ACTIVITIES_ON_SECONDARY_DISPLAYS)
|
||||
}
|
||||
|
||||
// 获取 当前接入的屏幕集合(含主屏幕)
|
||||
fun getMultiDisplay(context: Context): Array<out Display> {
|
||||
// 多次创建副屏 则副屏的id都是增加的,所以不一定是1,这里还是获取一下
|
||||
val displayManager =
|
||||
context.getSystemService(AppCompatActivity.DISPLAY_SERVICE) as DisplayManager
|
||||
return displayManager.displays
|
||||
}
|
||||
|
||||
/**
|
||||
* 在指定ID的屏幕打开Activity,当前应用的,当前进程
|
||||
* @param context
|
||||
* @param launchDisplayId 指定屏幕ID
|
||||
*/
|
||||
fun startActWithProcess(context: Context, launchDisplayId: Int, activity: Class<*>) {
|
||||
// 要加上Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
val options = ActivityOptions.makeBasic()
|
||||
options.launchDisplayId = launchDisplayId
|
||||
val intent = Intent(context, activity)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
context.startActivity(intent, options.toBundle())
|
||||
}
|
||||
|
||||
/**
|
||||
* 在指定ID的屏幕打开Activity,当前应用的,新开进程启动
|
||||
* @param context
|
||||
* @param launchDisplayId 指定屏幕ID
|
||||
*/
|
||||
fun startActWithOtherProcess(context: Context, launchDisplayId: Int, activity: Class<*>) {
|
||||
// 要加上Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
val options = ActivityOptions.makeBasic()
|
||||
options.launchDisplayId = launchDisplayId
|
||||
val intent = Intent(context, activity)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
context.startActivity(intent, options.toBundle())
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user