后台任务添加:根据后期需求修改指标监测轮询时间,缺少对自动驾驶状态变化的监听
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.mogo.module.check;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.module.check.view.CheckActivity;
|
||||
@@ -41,4 +42,11 @@ public class CheckProvider implements ICheckProvider {
|
||||
CheckActivity.showDialog(context);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkMonitor(Context context) {
|
||||
if (context != null){
|
||||
CheckActivity.checkMonitor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +82,13 @@ public class CheckActivity extends AppCompatActivity {
|
||||
mRecyclerView.setLayoutManager(linearLayoutManager);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动驾驶状态下指标监测
|
||||
*/
|
||||
public static void checkMonitor(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,6 +4,10 @@ package com.mogo.module.main.monitoring;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.service.adas.IMogoAdasOCHCallback;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
@@ -12,33 +16,54 @@ import android.os.Message;
|
||||
*/
|
||||
public class VehicleMonitoring implements Handler.Callback {
|
||||
|
||||
private static final String TAG = "VehicleMonitoring";
|
||||
private final Context mContext;
|
||||
private final Handler mHandler = new Handler();
|
||||
private final Handler mHandler = new Handler(this);
|
||||
//自动驾驶状态下10分钟弹框提示一次
|
||||
private static final long AUTO_CHECK_STATUS_DELAY = 10 * 60 * 1000;
|
||||
private static final long AUTO_CHECK_STATUS_DELAY = 10 * 60 * 1000;//自动驾驶状态下10分钟弹框提示一次
|
||||
//非自动驾驶测试数据 后期根据需求做修改
|
||||
private static final long MANUAL_CHECK_STATUS_DELAY = 1 * 60 * 1000;
|
||||
//自动驾驶状态
|
||||
private static final int AUTO_CHECK_STATUS = 10001;
|
||||
//费自动驾驶状态
|
||||
private static final int MANUAL_CHECK_STATUS = 10002;
|
||||
|
||||
public VehicleMonitoring(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public void vehicleCheckForAuto() {
|
||||
mHandler.sendEmptyMessageDelayed(AUTO_CHECK_STATUS, AUTO_CHECK_STATUS_DELAY);
|
||||
public void vehicleCheck() {
|
||||
Log.d(TAG, "vehicleCheck");
|
||||
if (MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus() == IMogoAdasOCHCallback.STATUS_AUTOPILOT_RUNNING) {
|
||||
Log.d(TAG, "自动驾驶中...");
|
||||
mHandler.sendEmptyMessageDelayed(AUTO_CHECK_STATUS, AUTO_CHECK_STATUS_DELAY);
|
||||
} else {
|
||||
Log.d(TAG, "非自动驾驶状态");
|
||||
//非自动驾驶状态只展示一次
|
||||
mHandler.sendEmptyMessageDelayed(MANUAL_CHECK_STATUS, MANUAL_CHECK_STATUS_DELAY);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case AUTO_CHECK_STATUS:
|
||||
|
||||
vehicleMonitor();
|
||||
mHandler.sendEmptyMessageDelayed(AUTO_CHECK_STATUS, AUTO_CHECK_STATUS_DELAY);
|
||||
return true;
|
||||
case MANUAL_CHECK_STATUS:
|
||||
vehicleMonitor();
|
||||
return true;
|
||||
default:
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void vehicleMonitor() {
|
||||
Log.d(TAG, "vehicleMonitor");
|
||||
MogoApisHandler.getInstance().getApis().getCheckProvider().checkMonitor(mContext);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -53,9 +53,9 @@ class MogoMainService extends Service implements IMogoLocationListener {
|
||||
// 开启延时检测
|
||||
DelayCheckUtil delayCheckUtil = new DelayCheckUtil(this);
|
||||
delayCheckUtil.waitingForCheck();
|
||||
//车辆检测
|
||||
// 车辆检测
|
||||
VehicleMonitoring monitoring = new VehicleMonitoring(this);
|
||||
monitoring.vehicleCheckForAuto();
|
||||
monitoring.vehicleCheck();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -18,5 +18,10 @@ public interface ICheckProvider extends IProvider {
|
||||
*/
|
||||
void showCheckDialog(Context context);
|
||||
|
||||
/**
|
||||
* 指标监测
|
||||
*/
|
||||
void checkMonitor(Context context);
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user