Merge branch 'dev_MogoAP_eagle-930_210926_8.0.12' into dev/dev_eagle_architecture_upgrade
This commit is contained in:
@@ -34,9 +34,12 @@ ext {
|
||||
androidxjunit : "androidx.test.ext:junit:1.1.2",
|
||||
androidxespressocore : "androidx.test.espresso:espresso-core:3.3.0",
|
||||
// 地图
|
||||
amapnavi3dmap : "com.amap.api:navi-3dmap:8.0.1_3dmap8.0.1",
|
||||
amapsearch : "com.amap.api:search:7.9.0",
|
||||
amaplocation : "com.amap.api:location:5.5.0",
|
||||
// amapnavi3dmap : "com.amap.api:navi-3dmap:8.0.1_3dmap8.0.1",
|
||||
// amapsearch : "com.amap.api:search:7.9.0",
|
||||
// amaplocation : "com.amap.api:location:5.5.0",
|
||||
amapnavi3dmap : "com.amap.api:navi-3dmap:7.2.0_3dmap7.2.0",
|
||||
amapsearch : "com.amap.api:search:7.1.0",
|
||||
amaplocation : "com.amap.api:location:5.3.1",
|
||||
// json 转换
|
||||
gson : "com.google.code.gson:gson:2.8.4",
|
||||
// 内存泄漏检测
|
||||
|
||||
@@ -1,19 +1,40 @@
|
||||
package com.mogo.eagle.core.function.check;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.elegant.network.ParamsBuilder;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.commons.network.SubscribeImpl;
|
||||
import com.mogo.eagle.core.function.call.check.CallerCheckManager;
|
||||
import com.mogo.eagle.core.function.check.api.ICheckResultCallBack;
|
||||
import com.mogo.eagle.core.function.check.net.CheckApiServiceFactory;
|
||||
import com.mogo.eagle.core.function.check.net.CheckResultData;
|
||||
import com.mogo.eagle.core.function.check.view.CheckDialog;
|
||||
import com.mogo.eagle.core.utilcode.util.ActivityUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.AppUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.LogUtils;
|
||||
import com.mogo.eagle.core.function.api.check.IMogoCheckListener;
|
||||
import com.mogo.eagle.core.function.check.view.CheckActivity;
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
|
||||
import com.mogo.module.service.receiver.MogoReceiver;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.eagle.core.function.api.check.ICheckProvider;
|
||||
import com.mogo.utils.ActivityLifecycleManager;
|
||||
import com.mogo.utils.network.RequestOptions;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
|
||||
/**
|
||||
* 鹰眼系统、自动驾驶系统 检测模块
|
||||
@@ -27,6 +48,7 @@ public class VehicleMonitoringManager implements ICheckProvider {
|
||||
private static final String TAG = "VehicleMonitoringManager";
|
||||
private Context mContext;
|
||||
private final Map<String, CopyOnWriteArrayList> mListeners = new ConcurrentHashMap<>();
|
||||
private boolean hasTipShow = false;//是否已经弹框提示
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
@@ -56,33 +78,81 @@ public class VehicleMonitoringManager implements ICheckProvider {
|
||||
|
||||
@Override
|
||||
public void startCheckActivity(Context context) {
|
||||
if (context != null) {
|
||||
CheckActivity.start(context);
|
||||
}
|
||||
Intent starter = new Intent(context, CheckActivity.class);
|
||||
starter.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(starter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showCheckDialog(Context context) {
|
||||
if (context != null) {
|
||||
CheckActivity.showDialog(context);
|
||||
}
|
||||
showDialog(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkMonitor(Context context) {
|
||||
public void checkMonitor(Context context) {
|
||||
if (context != null) {
|
||||
return CheckActivity.checkMonitor(context);
|
||||
CheckActivity.checkMonitor(context, new ICheckResultCallBack() {
|
||||
@Override
|
||||
public void callBackWithErrorState(Integer state) {
|
||||
updateMonitoringStatus(MogoReceiver.ACTION_CHECK_VEHICLE_MONITORING, state);
|
||||
if (state == 1) {
|
||||
hasTipShow = false;
|
||||
} else {
|
||||
if (hasTipShow == false) {
|
||||
showDialog(context);
|
||||
hasTipShow = true;//已弹框
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static CheckDialog dialog;
|
||||
|
||||
/**
|
||||
* 指标异常弹框
|
||||
*/
|
||||
public void showDialog(Context context) {
|
||||
try {
|
||||
if (ActivityLifecycleManager.getInstance().isAppActive() == true &&
|
||||
AppUtils.isAppRunning(getPackageName(context)) &&
|
||||
ActivityUtils.getTopActivity() instanceof CheckActivity == false) {
|
||||
if (dialog != null) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
dialog = new CheckDialog(context, true);
|
||||
dialog.show();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context
|
||||
* @return 当前应用的版本名称
|
||||
*/
|
||||
public static synchronized String getPackageName(Context context) {
|
||||
try {
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
PackageInfo packageInfo = packageManager.getPackageInfo(
|
||||
context.getPackageName(), 0);
|
||||
return packageInfo.packageName;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "com.mogo.launcher.f";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMonitoringStatus(String module, boolean hasError) {
|
||||
public void updateMonitoringStatus(String module, Integer state) {
|
||||
List<IMogoCheckListener> listeners = mListeners.get(module);
|
||||
if (listeners != null && !listeners.isEmpty()) {
|
||||
for (IMogoCheckListener listener : listeners) {
|
||||
if (listener != null) {
|
||||
listener.updateMonitoringStatus(hasError);
|
||||
listener.updateMonitoringStatus(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.mogo.eagle.core.function.check.api;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 描述
|
||||
* @since: 8/6/21
|
||||
*/
|
||||
public interface ICheckListener {
|
||||
|
||||
/**
|
||||
* 工控机->鹰眼定位数据延时
|
||||
*/
|
||||
void getAutoLocationTimeCallbackDelayed(long time);
|
||||
|
||||
/**
|
||||
* 工控机->鹰眼识别数据延时
|
||||
*/
|
||||
void getAutoDataCallbackDelayed(long time);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.mogo.eagle.core.function.check.api;
|
||||
|
||||
import com.mogo.service.adas.IMogoAdasDataCallback;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 自车检测结果回调
|
||||
* @since: 9/28/21
|
||||
*/
|
||||
public interface ICheckResultCallBack {
|
||||
void callBackWithErrorState(Integer state);
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.mogo.eagle.core.function.check.api;
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/7/5 2:54 下午
|
||||
* <p>
|
||||
* 软件环境检测
|
||||
* -----> 自动驾驶版本
|
||||
* -----> 鹰眼版本
|
||||
*/
|
||||
public interface SoftCheckApi {
|
||||
|
||||
/**
|
||||
* 检测「自动驾驶」版本
|
||||
*/
|
||||
void checkAutoPilotSoftVersion();
|
||||
|
||||
/**
|
||||
* 检测「鹰眼」版本
|
||||
*/
|
||||
void checkEagleEyeSoftVersion();
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.mogo.eagle.core.function.check.net;
|
||||
|
||||
import com.mogo.commons.data.BaseData;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -38,7 +39,7 @@ public class CheckResultData extends BaseData {
|
||||
'}';
|
||||
}
|
||||
|
||||
public static class Data {
|
||||
public static class Data implements Serializable{
|
||||
private Vehicle vehicle;
|
||||
private List<CheckListItem> soft;
|
||||
private List<CheckListItem> devices;
|
||||
@@ -97,7 +98,7 @@ public class CheckResultData extends BaseData {
|
||||
}
|
||||
}
|
||||
|
||||
public static class Vehicle {
|
||||
public static class Vehicle implements Serializable {
|
||||
private String id;
|
||||
private String sn;
|
||||
private String vin;
|
||||
@@ -236,7 +237,7 @@ public class CheckResultData extends BaseData {
|
||||
}
|
||||
}
|
||||
|
||||
public static class CheckListItem {
|
||||
public static class CheckListItem implements Serializable{
|
||||
private String name;
|
||||
private String stateValue;
|
||||
private List<CheckResultData.CheckListItem> items;
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.commons.network.SubscribeImpl;
|
||||
import com.mogo.eagle.core.function.call.check.CallerCheckManager;
|
||||
import com.mogo.eagle.core.function.check.R;
|
||||
import com.mogo.eagle.core.function.check.api.ICheckResultCallBack;
|
||||
import com.mogo.eagle.core.function.check.net.CheckApiServiceFactory;
|
||||
import com.mogo.eagle.core.function.check.net.CheckResultData;
|
||||
import com.mogo.eagle.core.utilcode.util.ActivityUtils;
|
||||
@@ -55,7 +56,6 @@ public class CheckActivity extends AppCompatActivity {
|
||||
private static Context context;
|
||||
private static NetworkStatusUtil.NetWorkStatus sNetWorkStatus;
|
||||
private ImageView mImageView;
|
||||
private static String packageName = "com.mogo.launcher.f";
|
||||
//车模
|
||||
private ImageView scanBottomCarImage;
|
||||
//扫描束
|
||||
@@ -73,7 +73,6 @@ public class CheckActivity extends AppCompatActivity {
|
||||
private final static long DURATION_TIME = 1000;
|
||||
private static CheckAdapter mCheckAdapter;
|
||||
private static boolean isFront = false;
|
||||
private static CheckDialog dialog;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
@@ -82,6 +81,12 @@ public class CheckActivity extends AppCompatActivity {
|
||||
initView();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
animation();
|
||||
loadDetail(context, null);
|
||||
}
|
||||
/**
|
||||
* 列表View初始化
|
||||
*/
|
||||
@@ -95,12 +100,10 @@ public class CheckActivity extends AppCompatActivity {
|
||||
tipsImageView = findViewById(R.id.scan_car_tips);
|
||||
mProgressBar = findViewById(R.id.check_progress);
|
||||
context = mImageView.getContext();
|
||||
packageName = getPackageName(context);
|
||||
mImageView.setOnClickListener(v -> {
|
||||
finish();
|
||||
});
|
||||
animation();
|
||||
loadDetail(context);
|
||||
|
||||
mRecyclerView = findViewById(R.id.check_list);
|
||||
CheckLinearLayout linearLayoutManager =
|
||||
new CheckLinearLayout(this, CheckLinearLayout.VERTICAL, false);
|
||||
@@ -113,14 +116,13 @@ public class CheckActivity extends AppCompatActivity {
|
||||
/**
|
||||
* 自动驾驶状态下指标监测
|
||||
*/
|
||||
public static boolean checkMonitor(Context context) {
|
||||
public static void checkMonitor(Context context, ICheckResultCallBack checkResultCallBack) {
|
||||
Log.d(TAG, "checkMonitor");
|
||||
loadDetail(context);
|
||||
return true;
|
||||
loadDetail(context, checkResultCallBack);
|
||||
}
|
||||
|
||||
//网络请求,获取自车检测结果(工控机上报云端)
|
||||
public static void loadDetail(Context context) {
|
||||
public static void loadDetail(Context context, ICheckResultCallBack checkResultCallBack) {
|
||||
final Map<String, Object> params = ParamsBuilder.of(false)
|
||||
.append("sn", MoGoAiCloudClientConfig.getInstance().getSn())
|
||||
.build();
|
||||
@@ -139,12 +141,8 @@ public class CheckActivity extends AppCompatActivity {
|
||||
mCheckAdapter.mCheckResultData = o;
|
||||
mCheckAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
if (((CheckResultData) o).getData().getVehicle().getState() == 1) {
|
||||
CallerCheckManager.updateMonitoringStatus(MogoReceiver.ACTION_CHECK_VEHICLE_MONITORING, false);
|
||||
} else {
|
||||
CallerCheckManager.updateMonitoringStatus(MogoReceiver.ACTION_CHECK_VEHICLE_MONITORING, true);
|
||||
showDialog(context);
|
||||
if (checkResultCallBack != null) {
|
||||
checkResultCallBack.callBackWithErrorState(o.getData().getVehicle().getState());
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -153,29 +151,11 @@ public class CheckActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
Log.d(TAG, "车辆自检失败,请稍后重试" + "==" + message + String.valueOf(code));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context
|
||||
* @return 当前应用的版本名称
|
||||
*/
|
||||
public static synchronized String getPackageName(Context context) {
|
||||
try {
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
PackageInfo packageInfo = packageManager.getPackageInfo(
|
||||
context.getPackageName(), 0);
|
||||
Log.d(TAG, "包名:" + packageInfo.packageName);
|
||||
return packageInfo.packageName;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "com.mogo.launcher.f";
|
||||
}
|
||||
|
||||
/**
|
||||
* **************************************************************************************检测动画
|
||||
*/
|
||||
@@ -264,28 +244,19 @@ public class CheckActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
public static void start(Context context) {
|
||||
Intent starter = new Intent(context, CheckActivity.class);
|
||||
starter.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(starter);
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
/**
|
||||
* 指标异常弹框
|
||||
*/
|
||||
public static void showDialog(Context context) {
|
||||
try {
|
||||
if (AppUtils.isAppRunning(getPackageName(context)) &&
|
||||
(ActivityUtils.getTopActivity() instanceof CheckActivity == false)) {
|
||||
if (dialog != null) {
|
||||
dialog.cancel();
|
||||
}
|
||||
dialog = new CheckDialog(context, true);
|
||||
dialog.show();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestart() {
|
||||
super.onRestart();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -294,9 +265,4 @@ public class CheckActivity extends AppCompatActivity {
|
||||
isFront = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,11 +40,11 @@ public class CheckDialog extends BaseFloatDialog {
|
||||
setContentView(R.layout.check_dialog);
|
||||
cancel = findViewById(R.id.cancel_button);
|
||||
cancel.setOnClickListener(v -> {
|
||||
cancel();
|
||||
dismiss();
|
||||
});
|
||||
checkDetail = findViewById(R.id.check_detail);
|
||||
checkDetail.setOnClickListener(v -> {
|
||||
cancel();
|
||||
dismiss();
|
||||
if (mContext != null) {
|
||||
CallerCheckManager.startCheckActivity(mContext);
|
||||
}
|
||||
@@ -63,11 +63,11 @@ public class CheckDialog extends BaseFloatDialog {
|
||||
|
||||
|
||||
public void cancel() {
|
||||
super.dismiss();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismiss() {
|
||||
|
||||
super.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class CheckInfoListDialog extends BaseFloatDialog {
|
||||
mRecyclerView.setAdapter(new CheckInfoAdapter(mContext, mStyle, resultData));
|
||||
//关闭按钮
|
||||
findViewById(R.id.cancel_info_list_button).setOnClickListener(v -> {
|
||||
cancel();
|
||||
dismiss();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -106,11 +106,11 @@ public class CheckInfoListDialog extends BaseFloatDialog {
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
super.dismiss();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismiss() {
|
||||
|
||||
super.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.mogo.eagle.core.function.smp;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -87,8 +88,8 @@ public class SmallMapDirectionView
|
||||
View smpView = LayoutInflater.from(context).inflate(R.layout.module_small_map_view, this);
|
||||
|
||||
mAMapNaviView = (TextureMapView)smpView.findViewById(R.id.aMapNaviView);
|
||||
rlSmallMapBorder = findViewById(R.id.rlSmallMapBorder);
|
||||
rlSmallMapBorder.addView(mAMapNaviView);
|
||||
// rlSmallMapBorder = findViewById(R.id.rlSmallMapBorder);
|
||||
// rlSmallMapBorder.addView(mAMapNaviView);
|
||||
|
||||
initAMapView();
|
||||
|
||||
@@ -280,4 +281,27 @@ public class SmallMapDirectionView
|
||||
}
|
||||
}
|
||||
|
||||
public void onCreateView(Bundle savedInstanceState) {
|
||||
if(mAMapNaviView != null){
|
||||
mAMapNaviView.onCreate(savedInstanceState);
|
||||
}
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
if(mAMapNaviView != null){
|
||||
mAMapNaviView.onResume();
|
||||
}
|
||||
}
|
||||
|
||||
public void onPause() {
|
||||
if(mAMapNaviView != null){
|
||||
mAMapNaviView.onPause();
|
||||
}
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
if(mAMapNaviView != null){
|
||||
mAMapNaviView.onDestroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.function.smp.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -34,6 +33,7 @@ public class SmallMapFragment extends Fragment {
|
||||
if (mRootView == null) {
|
||||
mRootView = inflater.inflate(R.layout.module_small_map_fragment, container, false);
|
||||
mSmallMapDirectionView = mRootView.findViewById(R.id.smallMapDirectionView);
|
||||
mSmallMapDirectionView.onCreateView(savedInstanceState);
|
||||
} else {
|
||||
ViewGroup viewGroup = (ViewGroup) mRootView.getParent();
|
||||
if (viewGroup != null) {
|
||||
@@ -55,4 +55,23 @@ public class SmallMapFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mSmallMapDirectionView.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
mSmallMapDirectionView.onPause();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
mSmallMapDirectionView.onDestroy();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,11 +36,11 @@ public interface ICheckProvider extends IProvider {
|
||||
/**
|
||||
* 指标监测
|
||||
*/
|
||||
boolean checkMonitor(Context context);
|
||||
void checkMonitor(Context context);
|
||||
|
||||
/**
|
||||
* 根据监测指标修改主页检测按钮
|
||||
*/
|
||||
void updateMonitoringStatus(String module, boolean hasError);
|
||||
void updateMonitoringStatus(String module, Integer state);
|
||||
|
||||
}
|
||||
|
||||
@@ -6,5 +6,5 @@ package com.mogo.eagle.core.function.api.check;
|
||||
* @since: 8/26/21
|
||||
*/
|
||||
public interface IMogoCheckListener {
|
||||
void updateMonitoringStatus(boolean hasError);
|
||||
void updateMonitoringStatus(Integer state);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.mogo.eagle.core.function.call.base.CallerBase;
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/9/17 8:26 下午
|
||||
*
|
||||
* <p>
|
||||
* HMI 调用者管理,这里对外及其他模块提供功能的调用,用啥写啥,不要过度设计,不允许直接将Provider暴露出去
|
||||
*/
|
||||
public class CallerCheckManager extends CallerBase {
|
||||
@@ -49,14 +49,14 @@ public class CallerCheckManager extends CallerBase {
|
||||
/**
|
||||
* 根据监测指标修改主页检测按钮
|
||||
*/
|
||||
public static void updateMonitoringStatus(String module, boolean hasError) {
|
||||
getCheckProvider().updateMonitoringStatus(module, hasError);
|
||||
public static void updateMonitoringStatus(String module, Integer state) {
|
||||
getCheckProvider().updateMonitoringStatus(module, state);
|
||||
}
|
||||
|
||||
/**
|
||||
* 指标监测
|
||||
*/
|
||||
public static boolean checkMonitor(Context context) {
|
||||
return getCheckProvider().checkMonitor(context);
|
||||
public static void checkMonitor(Context context) {
|
||||
getCheckProvider().checkMonitor(context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,14 +17,14 @@ public class ActivityLifecycleManager {
|
||||
/**
|
||||
* 当前出于 Start 状态的 Activity
|
||||
*/
|
||||
private ArrayList< Activity > mStartedActivities = new ArrayList<>();
|
||||
private ArrayList<Activity> mStartedActivities = new ArrayList<>();
|
||||
|
||||
private ArrayList<AppStateListener> mAppStateListeners = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 当前存活的 Activity
|
||||
*/
|
||||
private HashMap< Activity, ActivityTrace> mAliveActivities = new HashMap<>();
|
||||
private HashMap<Activity, ActivityTrace> mAliveActivities = new HashMap<>();
|
||||
|
||||
/**
|
||||
* App 是否出于前台
|
||||
@@ -44,10 +44,10 @@ public class ActivityLifecycleManager {
|
||||
|
||||
private DefActivityLifecycleCallbacks mInnerActivityListener = new DefActivityLifecycleCallbacks() {
|
||||
@Override
|
||||
public void onActivityStarted( Activity activity) {
|
||||
public void onActivityStarted(Activity activity) {
|
||||
if (mStartedActivities.isEmpty()) {
|
||||
mIsAppActive = true;
|
||||
notifyAppStateChanged( AppStateListener.ACTIVE);
|
||||
notifyAppStateChanged(AppStateListener.ACTIVE);
|
||||
}
|
||||
mStartedActivities.add(activity);
|
||||
|
||||
@@ -58,11 +58,11 @@ public class ActivityLifecycleManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityStopped( Activity activity) {
|
||||
public void onActivityStopped(Activity activity) {
|
||||
mStartedActivities.remove(activity);
|
||||
if (mStartedActivities.isEmpty()) {
|
||||
mIsAppActive = false;
|
||||
notifyAppStateChanged( AppStateListener.INACTIVE);
|
||||
notifyAppStateChanged(AppStateListener.INACTIVE);
|
||||
}
|
||||
|
||||
ActivityTrace trace = mAliveActivities.get(activity);
|
||||
@@ -72,7 +72,7 @@ public class ActivityLifecycleManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResumed( Activity activity) {
|
||||
public void onActivityResumed(Activity activity) {
|
||||
mCurrentResumedActivity = activity;
|
||||
ActivityTrace trace = mAliveActivities.get(activity);
|
||||
if (trace != null) {
|
||||
@@ -81,7 +81,7 @@ public class ActivityLifecycleManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityPaused( Activity activity) {
|
||||
public void onActivityPaused(Activity activity) {
|
||||
ActivityTrace trace = mAliveActivities.get(activity);
|
||||
if (trace != null) {
|
||||
trace.pauseCnt++;
|
||||
@@ -89,33 +89,34 @@ public class ActivityLifecycleManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated( Activity activity, Bundle savedInstanceState) {
|
||||
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
|
||||
mAliveActivities.put(activity, new ActivityTrace(activity));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityDestroyed( Activity activity) {
|
||||
public void onActivityDestroyed(Activity activity) {
|
||||
mAliveActivities.remove(activity);
|
||||
}
|
||||
};
|
||||
|
||||
private ActivityLifecycleManager() {}
|
||||
private ActivityLifecycleManager() {
|
||||
}
|
||||
|
||||
public static ActivityLifecycleManager getInstance() {
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder{
|
||||
private static class SingletonHolder {
|
||||
private static final ActivityLifecycleManager INSTANCE = new ActivityLifecycleManager();
|
||||
}
|
||||
|
||||
public void start( Application application) {
|
||||
public void start(Application application) {
|
||||
this.mApplication = application;
|
||||
registerInnerActivityListener();
|
||||
registerHomeKeyEventReceiver();
|
||||
}
|
||||
|
||||
public void stop(){
|
||||
public void stop() {
|
||||
unregisterActivityLifecycleCallbacks(mInnerActivityListener);
|
||||
unregisterHomeKeyEventReceiver();
|
||||
}
|
||||
@@ -125,12 +126,12 @@ public class ActivityLifecycleManager {
|
||||
*
|
||||
* @param callbacks Activity 生命周期的回调
|
||||
*/
|
||||
public void registerActivityLifecycleCallbacks( Application.ActivityLifecycleCallbacks callbacks) {
|
||||
public void registerActivityLifecycleCallbacks(Application.ActivityLifecycleCallbacks callbacks) {
|
||||
if (mApplication == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -142,12 +143,12 @@ public class ActivityLifecycleManager {
|
||||
*
|
||||
* @param callbacks Activity 生命周期的回调
|
||||
*/
|
||||
public void unregisterActivityLifecycleCallbacks( Application.ActivityLifecycleCallbacks callbacks) {
|
||||
public void unregisterActivityLifecycleCallbacks(Application.ActivityLifecycleCallbacks callbacks) {
|
||||
if (mApplication == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -161,7 +162,11 @@ public class ActivityLifecycleManager {
|
||||
return mIsAppActive;
|
||||
}
|
||||
|
||||
public Activity getCurrentActivity(){
|
||||
public void setAppActive(boolean appActive) {
|
||||
mIsAppActive = appActive;
|
||||
}
|
||||
|
||||
public Activity getCurrentActivity() {
|
||||
return mCurrentResumedActivity;
|
||||
}
|
||||
|
||||
@@ -248,7 +253,7 @@ public class ActivityLifecycleManager {
|
||||
|
||||
private void registerHomeKeyEventReceiver() {
|
||||
android.content.IntentFilter filter = new android.content.IntentFilter();
|
||||
filter.addAction( Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
|
||||
filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
|
||||
|
||||
mHomeKeyEventReceiver = new HomeKeyEventReceiver();
|
||||
mApplication.registerReceiver(mHomeKeyEventReceiver, filter);
|
||||
@@ -267,31 +272,45 @@ public class ActivityLifecycleManager {
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi( Build.VERSION_CODES.ICE_CREAM_SANDWICH)
|
||||
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
|
||||
public static abstract class DefActivityLifecycleCallbacks implements Application.ActivityLifecycleCallbacks {
|
||||
@Override
|
||||
public void onActivityCreated( Activity activity, Bundle savedInstanceState) {}
|
||||
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityStarted( Activity activity) {}
|
||||
public void onActivityStarted(Activity activity) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResumed( Activity activity) {}
|
||||
public void onActivityResumed(Activity activity) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityPaused( Activity activity) {}
|
||||
public void onActivityPaused(Activity activity) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityStopped( Activity activity) {}
|
||||
public void onActivityStopped(Activity activity) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivitySaveInstanceState( Activity activity, Bundle outState) {}
|
||||
public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityDestroyed( Activity activity) {}
|
||||
public void onActivityDestroyed(Activity activity) {
|
||||
}
|
||||
}
|
||||
|
||||
public interface AppStateListener {
|
||||
int INACTIVE = 0;
|
||||
int ACTIVE = 1;
|
||||
|
||||
/**
|
||||
* App 状态的回调
|
||||
*/
|
||||
void onStateChanged( int state );
|
||||
void onStateChanged(int state);
|
||||
|
||||
}
|
||||
|
||||
@@ -312,7 +331,7 @@ public class ActivityLifecycleManager {
|
||||
int startCnt;
|
||||
int stopCnt;
|
||||
|
||||
ActivityTrace( Activity activity) {
|
||||
ActivityTrace(Activity activity) {
|
||||
this.activity = activity;
|
||||
}
|
||||
}
|
||||
@@ -322,9 +341,9 @@ public class ActivityLifecycleManager {
|
||||
private final String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey";
|
||||
|
||||
@Override
|
||||
public void onReceive( Context context, Intent intent) {
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if ( Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) {
|
||||
if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) {
|
||||
String reason = intent.getStringExtra(SYSTEM_DIALOG_REASON_KEY);
|
||||
if (reason != null && reason.equals(SYSTEM_DIALOG_REASON_HOME_KEY)) {
|
||||
onHomeKeyPressed();
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.eagle.core.function.api.map.smp.IMogoSmallMapProvider;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
import com.mogo.service.v2x.IV2XWarningListener;
|
||||
import com.mogo.utils.ActivityLifecycleManager;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
/**
|
||||
@@ -90,6 +91,7 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
getApis().getIntentManagerApi().registerIntentListener(Intent.ACTION_CLOSE_SYSTEM_DIALOGS, this);
|
||||
ActivityLifecycleManager.getInstance().setAppActive(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -102,6 +104,7 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
getApis().getIntentManagerApi().unregisterIntentListener(Intent.ACTION_CLOSE_SYSTEM_DIALOGS, this);
|
||||
ActivityLifecycleManager.getInstance().setAppActive(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1402,12 +1402,12 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMonitoringStatus(boolean hasError) {
|
||||
public void updateMonitoringStatus(Integer state) {
|
||||
Log.d(TAG, "updateCheckStatus");
|
||||
if (hasError == true) {
|
||||
tipImageView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
if (state == 1) {
|
||||
tipImageView.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
tipImageView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,9 +60,9 @@ public class VehicleMonitoring implements Handler.Callback {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean vehicleMonitor() {
|
||||
public void vehicleMonitor() {
|
||||
Log.d(TAG, "vehicleMonitor");
|
||||
return CallerCheckManager.checkMonitor(mContext);
|
||||
CallerCheckManager.checkMonitor(mContext);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user