|
|
|
|
@@ -8,6 +8,7 @@ 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;
|
|
|
|
|
@@ -25,12 +26,12 @@ 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.hmi.CallerHmiManager;
|
|
|
|
|
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
|
|
|
|
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.BarUtils;
|
|
|
|
|
import com.mogo.eagle.core.utilcode.util.ToastUtils;
|
|
|
|
|
import com.mogo.map.MogoMapUIController;
|
|
|
|
|
@@ -42,10 +43,7 @@ import com.zhjt.service.chain.TracingConstants;
|
|
|
|
|
import org.greenrobot.eventbus.EventBus;
|
|
|
|
|
import org.greenrobot.eventbus.Subscribe;
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.InvocationTargetException;
|
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
import java.util.Timer;
|
|
|
|
|
import java.util.TimerTask;
|
|
|
|
|
|
|
|
|
|
@@ -64,8 +62,7 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
|
|
|
|
|
private Timer timerHorn;
|
|
|
|
|
private Timer timerAcc;
|
|
|
|
|
|
|
|
|
|
private BluetoothAdapter mBluetoothAdapter;
|
|
|
|
|
private boolean isConnected;
|
|
|
|
|
private BluetoothMonitorReceiver mBluetoothReceiver = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@@ -75,14 +72,13 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
|
|
|
|
|
EventBus.getDefault().register(this);
|
|
|
|
|
CallerLogger.INSTANCE.i(M_HMI + TAG, "onCreate");
|
|
|
|
|
|
|
|
|
|
SharedPrefsMgr.getInstance(getContext()).putBoolean("BLUETOOTH", false);
|
|
|
|
|
|
|
|
|
|
initBluetooth();
|
|
|
|
|
|
|
|
|
|
// mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onBackPressed() {
|
|
|
|
|
super.onBackPressed();
|
|
|
|
|
Log.d("liyz", "onBackPressed --------> ");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void initViews() {
|
|
|
|
|
@@ -189,37 +185,36 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
|
|
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { //向上长按
|
|
|
|
|
ToastUtils.showShort("长按 ↑↑↑");
|
|
|
|
|
// ToastUtils.showShort("长按 ↑↑↑");
|
|
|
|
|
// CallerHmiManager.INSTANCE.showMaskView(); //长按出现蒙层,
|
|
|
|
|
// CallerHmiManager.INSTANCE.showBindingcarDialog(); //长按出现dialog蒙层
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
} else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { //下和中间键盘长按,减速为-2
|
|
|
|
|
ToastUtils.showShort("长按 ↓↓↓");
|
|
|
|
|
// ToastUtils.showShort("长按 ↓↓↓");
|
|
|
|
|
sendAcc(true, -2);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
// return false;
|
|
|
|
|
return super.onKeyDown(keyCode, event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean dispatchTouchEvent(MotionEvent event) {
|
|
|
|
|
Log.d("liyz", "dispatchTouchEvent event.getX() = " + event.getX() + "--event.getY() = " + event.getY() + "--action = " + event.getAction());
|
|
|
|
|
// Log.d("liyz", "dispatchTouchEvent event.getX() = " + event.getX() + "--event.getY() = " + event.getY() + "--action = " + event.getAction());
|
|
|
|
|
if (event.getX() == -1469.6875 && event.getY() == 530.0) { //向左变道
|
|
|
|
|
ToastUtils.showShort("← 向左变道");
|
|
|
|
|
// ToastUtils.showShort("← 向左变道");
|
|
|
|
|
// MogoMapUIController.getInstance().setLockMode( true );
|
|
|
|
|
CallerAutoPilotManager.INSTANCE.sendOperatorChangeLaneLeft();
|
|
|
|
|
MogoMapUIController.getInstance().setLockMode( true );
|
|
|
|
|
|
|
|
|
|
// showBondedDevice(mBluetoothAdapter);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
} else if (event.getX() == -1096.25 && event.getY() == 132.5) { //鸣笛
|
|
|
|
|
ToastUtils.showShort("↑ 鸣笛 ");
|
|
|
|
|
// ToastUtils.showShort("↑ 鸣笛 ");
|
|
|
|
|
CallerAutoPilotManager.INSTANCE.sendOperatorSetHorn(1);
|
|
|
|
|
MogoMapUIController.getInstance().setLockMode( true );
|
|
|
|
|
|
|
|
|
|
CallerAutoPilotManager.INSTANCE.sendOperatorSetHorn(1);
|
|
|
|
|
timerHorn = new Timer();
|
|
|
|
|
if (timerHorn == null) {
|
|
|
|
|
timerHorn = new Timer();
|
|
|
|
|
}
|
|
|
|
|
timerHorn.schedule(new TimerTask() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
@@ -231,30 +226,28 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
|
|
|
|
|
return true;
|
|
|
|
|
} else if (event.getX() == -863.4375 && event.getY() == 690.0) { //向右变道
|
|
|
|
|
CallerAutoPilotManager.INSTANCE.sendOperatorChangeLaneRight();
|
|
|
|
|
MogoMapUIController.getInstance().setLockMode( true );
|
|
|
|
|
// showBondedDevice(mBluetoothAdapter);
|
|
|
|
|
ToastUtils.showShort("→ 向右变道");
|
|
|
|
|
// MogoMapUIController.getInstance().setLockMode( true );
|
|
|
|
|
// ToastUtils.showShort("→ 向右变道");
|
|
|
|
|
return true;
|
|
|
|
|
} else if (event.getX() == -1096.25 && event.getY() == 1099.0) { // -1减速
|
|
|
|
|
sendAcc(true, -1); //TODO 需要可以配置,向下直接退出鹰眼了,这个必须处理
|
|
|
|
|
ToastUtils.showShort("↓");
|
|
|
|
|
MogoMapUIController.getInstance().setLockMode( true );
|
|
|
|
|
// MogoMapUIController.getInstance().setLockMode( true );
|
|
|
|
|
sendAcc(true, -1); //TODO 需要可以配置
|
|
|
|
|
// ToastUtils.showShort("↓ 减速");
|
|
|
|
|
return true;
|
|
|
|
|
} else if (event.getX() == -1096.25 && event.getY() == 690.0) { //复原
|
|
|
|
|
ToastUtils.showShort("O 复原 ");
|
|
|
|
|
MogoMapUIController.getInstance().setLockMode( true );
|
|
|
|
|
// ToastUtils.showShort("O 复原 ");
|
|
|
|
|
sendAcc(false, 0.0);
|
|
|
|
|
// MogoMapUIController.getInstance().setLockMode( true );
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return super.dispatchTouchEvent(event);
|
|
|
|
|
|
|
|
|
|
// if (isConnected) { //如果连接了蓝牙
|
|
|
|
|
// return false;
|
|
|
|
|
// } else {
|
|
|
|
|
// return super.dispatchTouchEvent(event);
|
|
|
|
|
// }
|
|
|
|
|
// Log.d("liyz", "--- " + SharedPrefsMgr.getInstance(getContext()).getBoolean("BLUETOOTH", false));
|
|
|
|
|
if (SharedPrefsMgr.getInstance(getContext()).getBoolean("BLUETOOTH", false)) {
|
|
|
|
|
return false;
|
|
|
|
|
} else {
|
|
|
|
|
return super.dispatchTouchEvent(event);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@@ -268,19 +261,19 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
|
|
|
|
|
Log.d("liyz", "onTouchEvent event.getX() = " + event.getX() + "--event.getY() = " + event.getY());
|
|
|
|
|
|
|
|
|
|
if (event.getX() == -1469.6875 && event.getY() == 530.0) {
|
|
|
|
|
ToastUtils.showShort("←");
|
|
|
|
|
// ToastUtils.showShort("←");
|
|
|
|
|
return true;
|
|
|
|
|
} else if (event.getX() == -1096.25 && event.getY() == 132.5) {
|
|
|
|
|
ToastUtils.showShort("↑");
|
|
|
|
|
// ToastUtils.showShort("↑");
|
|
|
|
|
return true;
|
|
|
|
|
} else if (event.getX() == -863.4375 && event.getY() == 690.0) {
|
|
|
|
|
ToastUtils.showShort("→");
|
|
|
|
|
// ToastUtils.showShort("→");
|
|
|
|
|
return true;
|
|
|
|
|
} else if (event.getX() == -1096.25 && event.getY() == 1099.0) {
|
|
|
|
|
ToastUtils.showShort("↓");
|
|
|
|
|
// ToastUtils.showShort("↓");
|
|
|
|
|
return true;
|
|
|
|
|
} else if (event.getX() == -1096.25 && event.getY() == 690.0) {
|
|
|
|
|
ToastUtils.showShort("O");
|
|
|
|
|
// ToastUtils.showShort("O");
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return super.onTouchEvent(event);
|
|
|
|
|
@@ -306,7 +299,7 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
|
|
|
|
|
public void run() {
|
|
|
|
|
CallerAutoPilotManager.INSTANCE.sendOperatorSetAcceleratedSpeed(accelerated);
|
|
|
|
|
}
|
|
|
|
|
}, 0, 500); //TODO
|
|
|
|
|
}, 0, 500);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (timerAcc != null) {
|
|
|
|
|
@@ -317,23 +310,22 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
isConnected = (boolean) isConnectedMethod.invoke(device, (Object[]) null);
|
|
|
|
|
Log.e("liyz", "showBondedDevice Name:" + device.getName() + " Mac:" + device.getAddress() + "---isConnected = " + isConnected);
|
|
|
|
|
} catch (NoSuchMethodException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} catch (IllegalAccessException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} catch (InvocationTargetException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 初始化蓝牙广播
|
|
|
|
|
*/
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|