Merge branch 'dev_robotaxi-d-app-module_2100_220816_2.10.0' of gitlab.zhidaoauto.com:zhjt/AndroidApp/MoGoEagleEye into dev_robotaxi-d-app-module_2100_220816_2.10.0
@@ -171,11 +171,7 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
|
||||
@Override
|
||||
public void onClickImpl(View v) {
|
||||
if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE){
|
||||
restartAutopilot();
|
||||
}else {
|
||||
ToastUtils.showShort(getResources().getString(R.string.bus_auto_disable_tip));
|
||||
}
|
||||
restartAutopilot();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.mogo.och.common.module.utils;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils;
|
||||
|
||||
public class ToastUtilsOch {
|
||||
public static void showWithCodeMessage(int code,String message){
|
||||
if(message==null){
|
||||
return;
|
||||
}
|
||||
if (DebugConfig.isDebug()) {
|
||||
ToastUtils.showShort(code+","+message);
|
||||
}else {
|
||||
ToastUtils.showShort(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -143,13 +143,6 @@ public class TaxiPassengerBaseFragment extends MvpFragment<TaxiPassengerBaseFrag
|
||||
//OverlayLeftViewUtils.INSTANCE.dismissOverlayView();
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.iv_temp).setOnClickListener(view -> {
|
||||
OverlayLeftViewUtils.INSTANCE.showOverlayView(getActivity(),0,true,-1,true);
|
||||
//showOrHideArrivedEndLayout(true, "北京北京北京", "1527481606997577728");
|
||||
//showOrHidePressengerCheckPager(true, "开始站点开", "开始站点开始站点开始", "2", "京A888888", "18811539480");
|
||||
//OCHFloatWindowManager.getInstance().ShowFloatWindow(getContext());
|
||||
});
|
||||
}
|
||||
|
||||
private void initArrivedView(){
|
||||
|
||||
|
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 5.3 KiB |
BIN
OCH/mogo-och-taxi-passenger/src/main/res/drawable-xhdpi-2560x1440/taxi_p_mogo_movies_title_icon.png
Executable file → Normal file
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 5.3 KiB |
BIN
OCH/mogo-och-taxi-passenger/src/main/res/drawable-xhdpi/taxi_p_mogo_movies_title_icon.png
Executable file → Normal file
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
@@ -5,14 +5,14 @@ import com.mogo.eagle.core.data.BaseData;
|
||||
/**
|
||||
* Created by pangfan on 2021/8/19
|
||||
*
|
||||
* 收车/出车状态查询返回数据结构
|
||||
* 状态查询返回数据结构
|
||||
*/
|
||||
public class DriverStatusQueryRespBean extends BaseData {
|
||||
public Result data;
|
||||
|
||||
public static class Result {
|
||||
public int servingStatus; //0收车,1出车
|
||||
public int driverStatus; //0收车,1出车
|
||||
public int servingStatus; //1接单,1暂停接单
|
||||
public int driverStatus; //1登录,0登出
|
||||
public String orderNo;
|
||||
public int purpose; // 1 运营, 2 测试, 3演示
|
||||
}
|
||||
|
||||
@@ -3,14 +3,12 @@ package com.mogo.och.taxi.bean;
|
||||
/**
|
||||
* Created by pangfan on 2021/8/19
|
||||
*
|
||||
* 收车/出车状态更新请求数据结构
|
||||
* 状态更新请求数据结构
|
||||
*/
|
||||
public class DriverStatusUpdateReqBean {
|
||||
public String sn;
|
||||
public int status; //0收车,1出车
|
||||
|
||||
public DriverStatusUpdateReqBean(String sn, int status) {
|
||||
public DriverStatusUpdateReqBean(String sn) {
|
||||
this.sn = sn;
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.mogo.och.taxi.callback;
|
||||
/**
|
||||
* Created on 2021/9/8
|
||||
*
|
||||
* Model->Presenter回调:出车/收车状态变更
|
||||
* Model->Presenter回调:接单车状态变更 登录状态变更
|
||||
*/
|
||||
public interface ITaxiCarStatusCallback {
|
||||
void onCarStatusChanged(boolean inOperation,String role);
|
||||
|
||||
@@ -80,5 +80,7 @@ class TaxiConst {
|
||||
const val TYPE_MARKER_TAXI_ORDER = "TYPE_MARKER_TAXI_ORDER"
|
||||
|
||||
const val TIMER_START_AUTOPILOT_INTERVAL = 20 * 1000L
|
||||
|
||||
const val WAIT_TAKEN = 100046
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,7 @@ import com.mogo.map.navi.IMogoCarLocationChangedListener2;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil;
|
||||
import com.mogo.och.common.module.utils.PinYinUtil;
|
||||
import com.mogo.och.common.module.utils.ToastUtilsOch;
|
||||
import com.mogo.och.taxi.R;
|
||||
import com.mogo.och.taxi.bean.DriverServiceDataRespBean;
|
||||
import com.mogo.och.taxi.bean.DriverStatusQueryRespBean;
|
||||
@@ -115,7 +116,7 @@ public class TaxiModel {
|
||||
private volatile List<OrderQueryRespBean.Result> mWaitServiceList = Collections.emptyList(); //待服务订单
|
||||
|
||||
private ITaxiADASStatusCallback mADASStatusCallback; //Model->Presenter:自动驾驶状态相关
|
||||
private ITaxiCarStatusCallback mCarStatusCallback; //Model->Presenter:出车/收车状态
|
||||
private ITaxiCarStatusCallback mCarStatusCallback; //Model->Presenter:接单状态、登录状态和司机今日接单状态
|
||||
private ITaxiControllerStatusCallback mControllerStatusCallback; //Model->Presenter:VR mode等
|
||||
private ITaxiOrderStatusCallback mOrderStatusCallback; //Model->Presenter:订单变更
|
||||
private Disposable subscribe;
|
||||
@@ -261,7 +262,7 @@ public class TaxiModel {
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询出车/收车状态
|
||||
* 接单状态和登录状态查询
|
||||
* 1、初始化查下状态
|
||||
* 2、点击更新接单状态 如果是初始化状态就查下状态
|
||||
* 3、点击更新接单状态后 查询状态
|
||||
@@ -278,7 +279,7 @@ public class TaxiModel {
|
||||
StatusManager.setOpenOrderStatus(data.data.servingStatus);
|
||||
//更新view
|
||||
CallerLogger.INSTANCE.d(M_TAXI + TAG, "changeCarStatus:" + StatusManager.getLoginStatus());
|
||||
startOrStopOrderLoop(StatusManager.isLogin());
|
||||
startOrStopOrderLoop(StatusManager.isLogin()&&StatusManager.isOpeningOrderStatus());
|
||||
if(mCarStatusCallback!=null) {
|
||||
mCarStatusCallback.onCarLoginStatusChange(StatusManager.isLogin());
|
||||
}
|
||||
@@ -305,23 +306,25 @@ public class TaxiModel {
|
||||
subscribe = Observable.timer(5, TimeUnit.SECONDS).subscribe(aLong -> {
|
||||
queryCarStatus();
|
||||
});
|
||||
|
||||
if(mCarStatusCallback!=null) {
|
||||
mCarStatusCallback.onCarLoginStatusChange(StatusManager.isLogin());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(int code, String msg) {
|
||||
ToastUtils.showShort(code + "," + msg);
|
||||
if(mCarStatusCallback!=null) {
|
||||
mCarStatusCallback.onCarLoginStatusChange(StatusManager.isLogin());
|
||||
ToastUtilsOch.showWithCodeMessage(code,msg);
|
||||
if(code==TaxiConst.WAIT_TAKEN){
|
||||
subscribe = Observable.timer(3, TimeUnit.SECONDS).subscribe(aLong -> {
|
||||
queryCarStatus();
|
||||
});
|
||||
}else {
|
||||
if (mCarStatusCallback != null) {
|
||||
mCarStatusCallback.onCarLoginStatusChange(StatusManager.isLogin());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//更新出车收车状态
|
||||
//更新接单状态
|
||||
public void updateCarStatus() {
|
||||
if(!StatusManager.isLogin()){
|
||||
queryCarStatus();
|
||||
@@ -348,7 +351,7 @@ public class TaxiModel {
|
||||
|
||||
@Override
|
||||
public void onFail(int code, String msg) {
|
||||
ToastUtils.showShort(code + "," + msg);
|
||||
ToastUtilsOch.showWithCodeMessage(code, msg);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -494,7 +497,7 @@ public class TaxiModel {
|
||||
|
||||
@Override
|
||||
public void onFail(int code, String msg) {
|
||||
ToastUtils.showShort(code + "," + msg);
|
||||
ToastUtilsOch.showWithCodeMessage(code,msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -523,7 +526,7 @@ public class TaxiModel {
|
||||
|
||||
@Override
|
||||
public void onFail(int code, String msg) {
|
||||
ToastUtils.showShort(code + "," + msg);
|
||||
ToastUtilsOch.showWithCodeMessage(code,msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -577,7 +580,7 @@ public class TaxiModel {
|
||||
|
||||
@Override
|
||||
public void onFail(int code, String msg) {
|
||||
ToastUtils.showShort(code + "," + msg);
|
||||
ToastUtilsOch.showWithCodeMessage(code,msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -671,7 +674,7 @@ public class TaxiModel {
|
||||
|
||||
@Override
|
||||
public void onFail(int code, String msg) {
|
||||
ToastUtils.showShort(code + "," + msg);
|
||||
ToastUtilsOch.showWithCodeMessage(code,msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -765,7 +768,7 @@ public class TaxiModel {
|
||||
|
||||
@Override
|
||||
public void onFail(int code, String msg) {
|
||||
ToastUtils.showShort(code + "," + msg);
|
||||
ToastUtilsOch.showWithCodeMessage(code,msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -996,7 +999,7 @@ public class TaxiModel {
|
||||
CallerLogger.INSTANCE.d(M_TAXI + TAG, "onIntentReceived = %s", intentStr);
|
||||
if (ConnectivityManager.CONNECTIVITY_ACTION.equals(intentStr)) {
|
||||
if (NetworkUtils.isConnected(mContext)) {
|
||||
startOrStopOrderLoop(StatusManager.isLogin());
|
||||
startOrStopOrderLoop(StatusManager.isLogin()&&StatusManager.isOpeningOrderStatus());
|
||||
queryCarStatus();
|
||||
}
|
||||
}
|
||||
@@ -1582,7 +1585,6 @@ public class TaxiModel {
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
mCarStatusCallback.onCarLoginStatusChange(false);
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort(mContext.getString(R.string.network_error_tip));
|
||||
} else {
|
||||
@@ -1592,7 +1594,7 @@ public class TaxiModel {
|
||||
|
||||
@Override
|
||||
public void onFail(int code, String msg) {
|
||||
ToastUtils.showShort(code + "," + msg);
|
||||
ToastUtilsOch.showWithCodeMessage(code,msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -154,28 +154,6 @@ interface TaxiServiceApiNew {
|
||||
Observable<BaseData> updateOrderStatus(@Header ("appId") String appId,@Header("ticket") String ticket
|
||||
,@Body OrderStatusUpdateReqBean data);
|
||||
|
||||
/**
|
||||
* 收车/出车状态更新
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@Headers( {"Content-type:application/json;charset=UTF-8"} )
|
||||
// @POST( "/autopilot-car-hailing/api/v1/driver/serviceStatus/update" )
|
||||
@POST( "/autopilot-car-hailing/car/v2/driver/taxi/serviceStatus/update" )
|
||||
Observable<BaseData> updateDriverServiceStatus(@Header ("appId") String appId,@Header("ticket") String ticket
|
||||
,@Body DriverStatusUpdateReqBean data);
|
||||
|
||||
/**
|
||||
* 收车/出车状态查询
|
||||
* @param sn
|
||||
* @return
|
||||
*/
|
||||
@Headers( {"Content-type:application/json;charset=UTF-8"} )
|
||||
// @GET( "/autopilot-car-hailing/api/v1/driver/serviceStatus/query" )
|
||||
@GET( "/autopilot-car-hailing/car/v2/driver/taxi/serviceStatus/query" )
|
||||
Observable<DriverStatusQueryRespBean> queryDriverServiceStatus(@Header ("appId") String appId
|
||||
,@Header("ticket") String ticket,@Query("sn") String sn);
|
||||
|
||||
/**
|
||||
* 车机端上传心跳数据(只在出车状态时上传):包含高德坐标系经纬度
|
||||
* @param data
|
||||
@@ -362,7 +340,7 @@ interface TaxiServiceApiNew {
|
||||
Observable<BaseData> resetOrderServing(@Header ("appId") String appId,@Header("ticket") String ticket
|
||||
,@Body DriverStatusUpdateReqBean data);
|
||||
/**
|
||||
* 收车/出车状态和登录状态查询
|
||||
* 接单状态和登录状态查询
|
||||
* @param sn
|
||||
* @return
|
||||
*/
|
||||
|
||||
@@ -4,6 +4,7 @@ import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAX
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory;
|
||||
@@ -237,22 +238,6 @@ public class TaxiServiceManager {
|
||||
.subscribe(getSubscribeImpl(context, callback, "updateOrderStatus"));
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 收车/出车状态更新
|
||||
// * @param context
|
||||
// * @param status
|
||||
// * @param callback
|
||||
// */
|
||||
// public void updateDriverServiceStatus(Context context, int status,
|
||||
// TaxiServiceCallback<BaseData> callback) {
|
||||
// mOCHTaxiServiceApi.updateDriverServiceStatus(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
// ,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
// ,new DriverStatusUpdateReqBean(
|
||||
// MoGoAiCloudClientConfig.getInstance().getSn(), status))
|
||||
// .subscribeOn(Schedulers.io())
|
||||
// .observeOn(AndroidSchedulers.mainThread())
|
||||
// .subscribe(getSubscribeImpl(context, callback, "updateDriverServiceStatus"));
|
||||
// }
|
||||
|
||||
/**
|
||||
* 暂停接单
|
||||
@@ -266,12 +251,12 @@ public class TaxiServiceManager {
|
||||
baseDataObservable = mOCHTaxiServiceApi.stopOrderServing(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
, MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
, new DriverStatusUpdateReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().getSn(), 0));
|
||||
MoGoAiCloudClientConfig.getInstance().getSn()));
|
||||
}else {// 没有接单去接单
|
||||
baseDataObservable = mOCHTaxiServiceApi.resetOrderServing(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
, MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
, new DriverStatusUpdateReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().getSn(), 0));
|
||||
MoGoAiCloudClientConfig.getInstance().getSn()));
|
||||
}
|
||||
baseDataObservable.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@@ -279,12 +264,17 @@ public class TaxiServiceManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* 收车/出车状态查询
|
||||
* 接单状态和登录状态查询
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
public void queryDriverServiceStatus(Context context,
|
||||
TaxiServiceCallback<DriverStatusQueryRespBean> callback) {
|
||||
if(MoGoAiCloudClientConfig.getInstance().getToken().isEmpty()){
|
||||
callback.onFail(TaxiConst.WAIT_TAKEN,"等待令牌中请稍等");
|
||||
MoGoAiCloudClient.getInstance().refreshToken();
|
||||
return;
|
||||
}
|
||||
mOCHTaxiServiceApi.queryDriverServiceStatusAndLoginStatus(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,MoGoAiCloudClientConfig.getInstance().getSn())
|
||||
@@ -466,7 +456,7 @@ public class TaxiServiceManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* 收车/出车状态查询
|
||||
* 获取手机验证码
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
@@ -480,7 +470,7 @@ public class TaxiServiceManager {
|
||||
.subscribe(getSubscribeImpl(context, callback, "getPhoneCode"));
|
||||
}
|
||||
/**
|
||||
* 收车/出车状态查询
|
||||
* 通过验证码登录
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
|
||||
@@ -96,6 +96,10 @@ class TaxiLoginPresenter(view: TaxiLoginDialogFragment?) :
|
||||
mView?.inputPhoneError()
|
||||
return
|
||||
}
|
||||
if(code.isBlank()||code.length<4){
|
||||
ToastUtils.showShort(R.string.module_och_taxi_login_code_error)
|
||||
return
|
||||
}
|
||||
mView?.closeSoftInput()
|
||||
TaxiLoginModel.gotoLogin(phone,code)
|
||||
}
|
||||
|
||||
@@ -112,6 +112,13 @@ public class TaxiPresenter extends Presenter<TaxiFragment> implements ITaxiADASS
|
||||
TaxiModel.getInstance().jumpPassengerCheckDone();
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录成功后查询登录状态
|
||||
*/
|
||||
public void queryLoginStatus() {
|
||||
TaxiModel.getInstance().queryCarStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
* 司机确认车辆环境可开启自动驾驶
|
||||
*/
|
||||
@@ -119,7 +126,7 @@ public class TaxiPresenter extends Presenter<TaxiFragment> implements ITaxiADASS
|
||||
TaxiModel.getInstance().confirmAutopilotConditionByDriver();
|
||||
}
|
||||
|
||||
// 更新出车/收车状态
|
||||
// 更新接单状态
|
||||
public void updateCarStatus() {
|
||||
TaxiModel.getInstance().updateCarStatus();
|
||||
}
|
||||
|
||||
@@ -65,7 +65,6 @@ public abstract class BaseTaxiTabFragment<V extends IView, P extends Presenter<V
|
||||
private ImageView mAnimFlowIv;
|
||||
protected TextView tvOperationStatus;
|
||||
protected TextView mDriverRole;
|
||||
public boolean isOperationStatus;//false-收车,true-出车
|
||||
protected FrameLayout flStationPanelContainer;
|
||||
private FrameLayout flNaviPanelContainer;
|
||||
private Group groupTestPanel;
|
||||
@@ -232,9 +231,6 @@ public abstract class BaseTaxiTabFragment<V extends IView, P extends Presenter<V
|
||||
if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() ==
|
||||
IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING){
|
||||
return; //远程代驾状态下不可开启自动驾驶,只能等远程代驾主动退出
|
||||
}else if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() ==
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE){
|
||||
ToastUtils.showShort(getResources().getString(R.string.module_och_taxi_auto_disable_tip));
|
||||
}else if (!(boolean)ctvAutopilotStatusRL.getTag()){
|
||||
ToastUtils.showShort(getResources().getString(R.string.module_och_taxi_auto_disable_tip1));
|
||||
}else {
|
||||
|
||||
@@ -175,7 +175,6 @@ public class TaxiFragment extends BaseTaxiTabFragment<TaxiFragment, TaxiPresente
|
||||
*/
|
||||
public void updateOperationStatus(boolean inOperation,String role) {
|
||||
CallerLogger.INSTANCE.e(M_TAXI + TAG, "onOperationChanged:" + inOperation);
|
||||
isOperationStatus = inOperation;
|
||||
if (inOperation) {
|
||||
if (!TextUtils.isEmpty(role)){
|
||||
mDriverRole.setVisibility(View.VISIBLE);
|
||||
@@ -189,7 +188,7 @@ public class TaxiFragment extends BaseTaxiTabFragment<TaxiFragment, TaxiPresente
|
||||
showPanel();
|
||||
} else {
|
||||
mDriverRole.setVisibility(View.GONE);
|
||||
// AIAssist.getInstance(getContext()).speakTTSVoice("已收车");
|
||||
// AIAssist.getInstance(getContext()).speakTTSVoice("已接单");
|
||||
tvOperationStatus.setText("接单");
|
||||
tvOperationStatus.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.taxi_out_btn), null, null, null);
|
||||
mPersonalBtn.setVisibility(View.GONE);
|
||||
@@ -203,23 +202,6 @@ public class TaxiFragment extends BaseTaxiTabFragment<TaxiFragment, TaxiPresente
|
||||
personalDialogFragment.get().show(getActivity().getSupportFragmentManager(), "service_data");
|
||||
}
|
||||
|
||||
// public void routeResult(List<AutopilotRouteInfo.RouteModels> routeList) {
|
||||
// if (routeList == null ) return;
|
||||
// double distance = calculateTravelDistance(mogoLocation,routeList);
|
||||
// if ( MogoOCHTaxiModel.getInstance().checkCurrentOCHOrder() ) {
|
||||
// MogoOCHTaxiModel.getInstance().getCurrentOCHOrder().decreaseTravelDistance( distance );
|
||||
// updateOrderBaseStatusInfo();
|
||||
// }
|
||||
// CallerLogger.INSTANCE.d(M_TAXI + "lianglihui","routeResult 剩余导航距离:"+distance);
|
||||
// if (routeList != null && routeList.size() >0){
|
||||
// CallerLogger.INSTANCE.d(M_TAXI + "lianglihui","routeResult:"+routeList.size());
|
||||
// //adas回调导航路径 绘制引导线
|
||||
// if ( ochTaxiOverlayManager == null){
|
||||
// ochTaxiOverlayManager = new TaxiOverlayManager(this.getContext());
|
||||
// }
|
||||
// ochTaxiOverlayManager.draw(mogoLocation,routeList);
|
||||
// }
|
||||
// }
|
||||
@Override
|
||||
public void onMapLoaded() {
|
||||
}
|
||||
@@ -410,9 +392,13 @@ public class TaxiFragment extends BaseTaxiTabFragment<TaxiFragment, TaxiPresente
|
||||
return;
|
||||
}
|
||||
if (taxiLoginDialog.isAdded()) {//解决方法就是添加这行代码,如果已经添加了,就移除掉然后再show,就不会出现Fragment already added的错误了。
|
||||
getParentFragmentManager().beginTransaction().remove(taxiLoginDialog).commit();
|
||||
getParentFragmentManager().beginTransaction().remove(taxiLoginDialog).commitAllowingStateLoss();
|
||||
}
|
||||
taxiLoginDialog.show(getParentFragmentManager(), taxiLoginDialog.getTag());
|
||||
taxiLoginDialog.setOnDismissListener(dialog -> {
|
||||
mPresenter.queryLoginStatus();
|
||||
taxiLoginDialogFragment.clear();
|
||||
});
|
||||
}
|
||||
}
|
||||
public void hideLoginDialogFragment(){
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.mogo.och.taxi.ui
|
||||
import android.content.DialogInterface
|
||||
import android.graphics.Rect
|
||||
import android.os.Bundle
|
||||
import android.os.SystemClock
|
||||
import android.util.Log
|
||||
import android.view.*
|
||||
import androidx.appcompat.widget.AppCompatButton
|
||||
import androidx.appcompat.widget.AppCompatEditText
|
||||
@@ -10,6 +12,9 @@ import androidx.appcompat.widget.AppCompatTextView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.widget.addTextChangedListener
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.fragment.app.FragmentTransaction
|
||||
import com.mogo.commons.mvp.MvpDialogFragment
|
||||
import com.mogo.eagle.core.utilcode.kotlin.onClick
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
@@ -18,12 +23,6 @@ import com.mogo.eagle.core.utilcode.util.BarUtils
|
||||
import com.mogo.eagle.core.utilcode.util.KeyboardUtils
|
||||
import com.mogo.och.taxi.R
|
||||
import com.mogo.och.taxi.presenter.TaxiLoginPresenter
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.Observer
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
|
||||
/**
|
||||
@@ -38,6 +37,9 @@ class TaxiLoginDialogFragment : MvpDialogFragment<TaxiLoginDialogFragment?, Taxi
|
||||
lateinit var actvLoginGetCode: AppCompatTextView
|
||||
lateinit var aceLoginPhoneValue: AppCompatEditText
|
||||
lateinit var acetPhoneCodeValue: AppCompatEditText
|
||||
lateinit var actvWelcomeLoginTitle: AppCompatTextView
|
||||
private var mOnClickListener: DialogInterface.OnDismissListener? = null
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@@ -58,12 +60,12 @@ class TaxiLoginDialogFragment : MvpDialogFragment<TaxiLoginDialogFragment?, Taxi
|
||||
}
|
||||
|
||||
override fun initViews() {
|
||||
findViewById<View>(R.id.module_och_taxi_order_list_close_iv)!!.setOnClickListener { v: View? -> dismissAllowingStateLoss() }
|
||||
clMain = mRootView.findViewById(R.id.cl_main)
|
||||
acbtnLogin = mRootView.findViewById(R.id.acbtn_login)
|
||||
actvLoginGetCode = mRootView.findViewById(R.id.actv_login_get_code)
|
||||
aceLoginPhoneValue = mRootView.findViewById(R.id.ace_login_phone_value)
|
||||
acetPhoneCodeValue = mRootView.findViewById(R.id.acet_phone_code_value)
|
||||
actvWelcomeLoginTitle = mRootView.findViewById(R.id.actv_welcome_login_title)
|
||||
inputPhoneNormal()
|
||||
initListener()
|
||||
dialog?.window?.let {
|
||||
@@ -94,6 +96,9 @@ class TaxiLoginDialogFragment : MvpDialogFragment<TaxiLoginDialogFragment?, Taxi
|
||||
val code = acetPhoneCodeValue.text.toString()
|
||||
mPresenter?.gotoLogin(phone,code)
|
||||
}
|
||||
actvWelcomeLoginTitle.setOnClickListener {
|
||||
continuousClick()
|
||||
}
|
||||
clMain.viewTreeObserver.addOnGlobalLayoutListener {
|
||||
val rect = Rect()
|
||||
clMain.getWindowVisibleDisplayFrame(rect)
|
||||
@@ -162,20 +167,18 @@ class TaxiLoginDialogFragment : MvpDialogFragment<TaxiLoginDialogFragment?, Taxi
|
||||
return TaxiLoginPresenter(this)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
}
|
||||
|
||||
override fun onHiddenChanged(hidden: Boolean) {
|
||||
super.onHiddenChanged(hidden)
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
val COUNTS = 4 // 点击次数
|
||||
val DURATION: Long = 1000 // 规定有效时间
|
||||
var mHits = LongArray(COUNTS)
|
||||
private fun continuousClick() {
|
||||
//每次点击时,数组向前移动一位
|
||||
System.arraycopy(mHits, 1, mHits, 0, mHits.size - 1)
|
||||
//为数组最后一位赋值
|
||||
mHits[mHits.size-1] = SystemClock.uptimeMillis()
|
||||
if (mHits[0] >= (SystemClock.uptimeMillis() - DURATION)) {
|
||||
mHits = LongArray(COUNTS) //重新初始化数组
|
||||
mPresenter?.gotoLogin("13288888888","8888")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onKey(dialog: DialogInterface, keyCode: Int, event: KeyEvent): Boolean {
|
||||
@@ -186,6 +189,46 @@ class TaxiLoginDialogFragment : MvpDialogFragment<TaxiLoginDialogFragment?, Taxi
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
fun setOnDismissListener(listener: DialogInterface.OnDismissListener?) {
|
||||
mOnClickListener = listener
|
||||
}
|
||||
|
||||
override fun onDismiss(dialog: DialogInterface) {
|
||||
super.onDismiss(dialog)
|
||||
mOnClickListener?.onDismiss(dialog)
|
||||
}
|
||||
|
||||
/**
|
||||
* 重写父类show()方法
|
||||
* 避免出现java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
|
||||
*/
|
||||
override fun show(manager: FragmentManager, tag: String?) {
|
||||
try {
|
||||
var cls = this.javaClass.superclass ?: return
|
||||
while (cls != null) {
|
||||
if (cls.name == "java.lang.Object") {
|
||||
break
|
||||
}
|
||||
cls = cls.superclass!!
|
||||
if (cls == DialogFragment::class.java) {
|
||||
break
|
||||
}
|
||||
}
|
||||
val mDismissed = cls.getDeclaredField("mDismissed")
|
||||
val mShownByMe = cls.getDeclaredField("mShownByMe")
|
||||
mDismissed.isAccessible = true
|
||||
mShownByMe.isAccessible = true
|
||||
mDismissed.setBoolean(this, false)
|
||||
mShownByMe.setBoolean(this, true)
|
||||
} catch (e: Exception) {
|
||||
Log.e("DialogFragment", "show", e.fillInStackTrace())
|
||||
}
|
||||
val ft: FragmentTransaction = manager.beginTransaction()
|
||||
ft.add(this, tag)
|
||||
ft.commitAllowingStateLoss()
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
private val TAG = TaxiLoginDialogFragment::class.java.simpleName
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil;
|
||||
import com.mogo.och.taxi.R;
|
||||
import com.mogo.och.taxi.model.TaxiModel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -53,6 +54,11 @@ public class TaxiOperationDatasFragment extends BaseTaxiUIFragment {
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext));
|
||||
mAdapter = new OperationDataAdapter(mContext, mData);
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
initDatas();
|
||||
}
|
||||
|
||||
private void initDatas() {
|
||||
TaxiModel.getInstance().queryDriverServiceData();
|
||||
}
|
||||
|
||||
public void setmType(int type) {
|
||||
@@ -73,7 +79,7 @@ public class TaxiOperationDatasFragment extends BaseTaxiUIFragment {
|
||||
mDurationData.add(dailyTimeDuration);
|
||||
mOrderNumData.add(dailyOrderNum);
|
||||
mData.addAll(mDurationData);
|
||||
mAdapter.notifyDataSetChanged();
|
||||
if (mAdapter != null) mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
class OperationDataAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.mogo.och.taxi.ui;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Point;
|
||||
@@ -36,6 +37,7 @@ import com.mogo.och.taxi.constant.TaxiOrderStatusEnum;
|
||||
import com.mogo.och.taxi.R;
|
||||
import com.mogo.och.taxi.bean.OrderQueryRespBean;
|
||||
import com.mogo.och.taxi.constant.TaxiOrderTypeEnum;
|
||||
import com.mogo.och.taxi.ui.base.AvoidLeakDialog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
@@ -74,6 +76,15 @@ public class TaxiPersonalDialogFragment extends DialogFragment implements View.O
|
||||
public TaxiPersonalDialogFragment(TaxiFragment taxiFragment){
|
||||
mTaxiFragment = taxiFragment;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
AvoidLeakDialog dialog = new AvoidLeakDialog(getContext());
|
||||
dialog.setHostFragmentReference(this);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
@@ -82,6 +93,11 @@ public class TaxiPersonalDialogFragment extends DialogFragment implements View.O
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismissAllowingStateLoss() {
|
||||
super.dismissAllowingStateLoss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
@@ -182,14 +198,15 @@ public class TaxiPersonalDialogFragment extends DialogFragment implements View.O
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
}
|
||||
});
|
||||
mOperationViewPager.setAdapter(new OrdersOperationFragmentAdapter(getChildFragmentManager(), FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT));
|
||||
mOperationViewPager.setAdapter(new OrdersOperationFragmentAdapter(
|
||||
getChildFragmentManager(), FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT));
|
||||
fragments.get(0).setmType(0);
|
||||
|
||||
if (mTaxiFragment == null){
|
||||
dismiss();
|
||||
}else {
|
||||
mTaxiFragment.queryDriverServiceData();
|
||||
}
|
||||
// if (mTaxiFragment == null){
|
||||
// dismiss();
|
||||
// }else {
|
||||
// mTaxiFragment.queryDriverServiceData();
|
||||
// }
|
||||
}
|
||||
|
||||
public void onServiceDataUpdate(long dailyTimeDuration, long dailyOrderNum){
|
||||
@@ -430,14 +447,6 @@ public class TaxiPersonalDialogFragment extends DialogFragment implements View.O
|
||||
orderTypeBt = itemView.findViewById(R.id.order_type_bt);
|
||||
dividerLine = itemView.findViewById(R.id.module_och_taxi_order_divider);
|
||||
mBootNoDataView = itemView.findViewById(R.id.boot_refresh_no_data_view);
|
||||
|
||||
//orderId已经换成orderNo,所以显示
|
||||
// if (DebugConfig.isDebug()){
|
||||
//
|
||||
// orderNumTv.setVisibility(View.GONE);
|
||||
// }else {
|
||||
// orderNumTv.setVisibility(View.GONE);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.mogo.och.taxi.ui.base;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2022/9/1
|
||||
*/
|
||||
public class AvoidLeakDialog extends Dialog {
|
||||
|
||||
private WeakReference<DialogFragment> hostFragmentReference;
|
||||
|
||||
public void setHostFragmentReference(DialogFragment hostFragment) {
|
||||
this.hostFragmentReference = new WeakReference<>(hostFragment);
|
||||
}
|
||||
|
||||
public AvoidLeakDialog(@NonNull Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public AvoidLeakDialog(@NonNull Context context, int themeResId) {
|
||||
super(context, themeResId);
|
||||
}
|
||||
|
||||
protected AvoidLeakDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
|
||||
super(context, cancelable, cancelListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnCancelListener(@Nullable OnCancelListener listener) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnDismissListener(@Nullable OnDismissListener listener) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnShowListener(@Nullable OnShowListener listener) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismiss() {
|
||||
super.dismiss();
|
||||
if (null != hostFragmentReference && null != hostFragmentReference.get()) {
|
||||
hostFragmentReference.get().dismissAllowingStateLoss();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 44 KiB |
@@ -103,7 +103,7 @@
|
||||
android:gravity="center"
|
||||
android:paddingLeft="46px"
|
||||
android:paddingRight="50px"
|
||||
android:text="出车"
|
||||
android:text="--"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/taxi_autopilot_text_color_selector"
|
||||
android:textSize="20sp"
|
||||
|
||||
@@ -115,13 +115,5 @@
|
||||
android:layout_width="760px"
|
||||
android:layout_height="136px"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/module_och_taxi_order_list_close_iv"
|
||||
android:layout_width="150px"
|
||||
android:layout_height="150px"
|
||||
android:layout_gravity="right"
|
||||
android:padding="30px"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
<string name="module_och_taxi_login_get_code_success">获取验证码成功</string>
|
||||
<string name="module_och_taxi_login_login_success">登录成功</string>
|
||||
<string name="module_och_taxi_login_phone_error">请输入正确的手机号</string>
|
||||
<string name="module_och_taxi_login_code_error">请输入正确的验证码</string>
|
||||
<string name="module_och_taxi_login_phone_hint_text">请输入手机号</string>
|
||||
<string name="module_och_taxi_login_get_phone_title">请输入手机号</string>
|
||||
|
||||
|
||||
@@ -243,6 +243,9 @@ dependencies {
|
||||
debugImplementation rootProject.ext.dependencies.debugleakcanary
|
||||
releaseImplementation rootProject.ext.dependencies.releaseleakcanary
|
||||
implementation rootProject.ext.dependencies.android_start_up
|
||||
|
||||
// // 暂不使用Shizuku-API
|
||||
// implementation rootProject.ext.dependencies.shizuku_provider
|
||||
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
|
||||
implementation rootProject.ext.dependencies.ttspad
|
||||
implementation rootProject.ext.dependencies.mogo_core_function_hmi
|
||||
|
||||
@@ -31,6 +31,15 @@
|
||||
android:value="android.startup.provider.config" />
|
||||
</provider>
|
||||
|
||||
<!-- <!– 暂不使用Shizuku-API –>-->
|
||||
<!-- <provider-->
|
||||
<!-- android:name="rikka.shizuku.ShizukuProvider"-->
|
||||
<!-- android:authorities="${applicationId}.shizuku"-->
|
||||
<!-- android:enabled="true"-->
|
||||
<!-- android:exported="true"-->
|
||||
<!-- android:multiprocess="false"-->
|
||||
<!-- android:permission="android.permission.INTERACT_ACROSS_USERS_FULL" />-->
|
||||
|
||||
<!-- 配置APP ID -->
|
||||
<meta-data
|
||||
android:name="BUGLY_APPID"
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.mogo.launcher;
|
||||
|
||||
import com.mogo.eagle.core.function.main.MainMoGoApplication;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.LogLevel;
|
||||
@@ -11,11 +10,7 @@ import com.mogo.launcher.crash.CrashSystem;
|
||||
import com.mogo.thread.ext.core.ThreadManager;
|
||||
import com.mogo.thread.ext.core.config.ThreadConfig;
|
||||
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.RejectedExecutionHandler;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
|
||||
@@ -61,6 +61,8 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
|
||||
|
||||
private var context: Context? = null
|
||||
|
||||
private var gotToken = false
|
||||
|
||||
override fun callCreateOnMainThread() = true
|
||||
|
||||
override fun waitOnMainThread() = false
|
||||
@@ -198,15 +200,19 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
|
||||
MoGoAiCloudClient.getInstance().init(context, clientConfig).addTokenCallbacks(
|
||||
object : IMoGoTokenCallback {
|
||||
override fun onTokenGot(token: String, sn: String) {
|
||||
CallerLogger.d(SceneConstant.M_HMI + TAG, "onTokenGot ")
|
||||
clientConfig.token = token
|
||||
CallerCloudListenerManager.invokeCloudTokenGot(token)
|
||||
// 异步初始化NetConfig
|
||||
asyncInit()
|
||||
// HttpDns ttl回调 --- socketTTL
|
||||
registerSocketHttpDnsTTL(HostConst.SOCKET_CENTER_DOMAIN)
|
||||
// 开启每5s/次定位上报
|
||||
uploadLocPerFiveSecond()
|
||||
// 由于存在token过期问题,在更新后会回调至此处,增加二次判定
|
||||
if(!gotToken){
|
||||
CallerLogger.d(SceneConstant.M_MAP + TAG, "onTokenGot ")
|
||||
CallerCloudListenerManager.invokeCloudTokenGot(token)
|
||||
// 异步初始化NetConfig
|
||||
asyncInit()
|
||||
// HttpDns ttl回调 --- socketTTL
|
||||
registerSocketHttpDnsTTL(HostConst.SOCKET_CENTER_DOMAIN)
|
||||
// 开启每5s/次定位上报
|
||||
uploadLocPerFiveSecond()
|
||||
gotToken = true
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError(code: Int, msg: String) {
|
||||
|
||||
@@ -32,7 +32,7 @@ buildscript {
|
||||
classpath "com.bytedance.android.byteX:base-plugin:0.3.0"
|
||||
classpath "com.mogo.cloud:hook:${HOOK_LOG_VERSION}"
|
||||
classpath 'com.volcengine:apm_insight_plugin:1.4.1'
|
||||
classpath 'com.mogo.thread.opt:plg:2.1.0'
|
||||
classpath 'com.mogo.thread.opt:plg:2.1.2'
|
||||
classpath 'com.mogo.cloud:systrace:1.0.1'
|
||||
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.18'
|
||||
|
||||
|
||||
@@ -240,7 +240,11 @@ ext {
|
||||
//========================= DataStore ======================
|
||||
androidx_datastore_preferences : "androidx.datastore:datastore-preferences:1.0.0",
|
||||
androidx_datastore : "androidx.datastore:datastore:1.0.0",
|
||||
android_start_up : "com.mogo:android-startup:1.0.1"
|
||||
android_start_up : "com.mogo:android-startup:1.0.1",
|
||||
|
||||
//========================= Shizuku ======================
|
||||
shizuku_api : "dev.rikka.shizuku:api:12.1.0",
|
||||
shizuku_provider : "dev.rikka.shizuku:provider:12.1.0"
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -433,15 +433,15 @@ class MoGoAutopilotProvider :
|
||||
*/
|
||||
override fun sendOperatorChangeLaneLeft() {
|
||||
// Log.d("liyz", "MoGoAutopilotProvider sendOperatorChangeLaneLeft -------> ")
|
||||
// AdasManager.getInstance().sendOperatorCmdChangeLaneLeft()
|
||||
AdasManager.getInstance().sendOperatorCmdChangeLaneLeft()
|
||||
}
|
||||
|
||||
/**
|
||||
* 向右变道
|
||||
*/
|
||||
override fun sendOperatorChangeLaneRight() {
|
||||
Log.d("liyz", "MoGoAutopilotProvider sendOperatorChangeLaneRight -------> ")
|
||||
// AdasManager.getInstance().sendOperatorCmdChangeLaneRight()
|
||||
// Log.d("liyz", "MoGoAutopilotProvider sendOperatorChangeLaneRight -------> ")
|
||||
AdasManager.getInstance().sendOperatorCmdChangeLaneRight()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -449,7 +449,7 @@ class MoGoAutopilotProvider :
|
||||
*/
|
||||
override fun sendOperatorSetAcceleratedSpeed(cc: Double) {
|
||||
// Log.d("liyz", "MoGoAutopilotProvider sendOperatorSetAcceleratedSpeed cc $cc ")
|
||||
// AdasManager.getInstance().sendOperatorCmdSetAcceleratedSpeed(cc)
|
||||
AdasManager.getInstance().sendOperatorCmdSetAcceleratedSpeed(cc)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -457,7 +457,7 @@ class MoGoAutopilotProvider :
|
||||
*/
|
||||
override fun sendOperatorSetHorn(value: Double) {
|
||||
// Log.d("liyz", "MoGoAutopilotProvider sendOperatorSetHorn value $value ")
|
||||
// AdasManager.getInstance().sendOperatorCmdSetHorn(value)
|
||||
AdasManager.getInstance().sendOperatorCmdSetHorn(value)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -82,7 +82,6 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.androidxconstraintlayout
|
||||
implementation rootProject.ext.dependencies.androidxrecyclerview
|
||||
implementation rootProject.ext.dependencies.flexbox
|
||||
|
||||
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
|
||||
implementation rootProject.ext.dependencies.mogoserviceapi
|
||||
implementation rootProject.ext.dependencies.modulecommon
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.mogo.eagle.core.data.deva.scene.SceneTAG
|
||||
import com.mogo.eagle.core.function.api.devatools.IDevaToolsProvider
|
||||
import com.zhjt.mogo_core_function_devatools.badcase.BadCaseManager
|
||||
import com.zhjt.mogo_core_function_devatools.logcatch.MogoLogCatchManager
|
||||
import com.zhjt.mogo_core_function_devatools.monitor.MonitorManager
|
||||
import com.zhjt.mogo_core_function_devatools.scene.SceneManager.Companion.sceneManager
|
||||
import com.zhjt.mogo_core_function_devatools.status.*
|
||||
import com.zhjt.mogo_core_function_devatools.trace.TraceManager.Companion.traceManager
|
||||
@@ -110,4 +111,12 @@ class DevaToolsProvider : IDevaToolsProvider {
|
||||
override fun hideStatusBar() {
|
||||
StatusManager.hide()
|
||||
}
|
||||
|
||||
override fun startMonitor() {
|
||||
mContext?.let { MonitorManager.getInstance(it)?.startMonitor() }
|
||||
}
|
||||
|
||||
override fun stopMonitor() {
|
||||
mContext?.let { MonitorManager.getInstance(it)?.stopMonitor() }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package com.zhjt.mogo_core_function_devatools.monitor
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Process
|
||||
import android.util.Log
|
||||
import com.zhjt.mogo_core_function_devatools.monitor.db.CpuInfo
|
||||
import com.zhjt.mogo_core_function_devatools.monitor.db.MonitorDb
|
||||
import com.zhjt.mogo_core_function_devatools.monitor.utils.CpuUtils
|
||||
import java.text.SimpleDateFormat
|
||||
|
||||
class CpuMonitor private constructor(var context: Context) {
|
||||
|
||||
var isRunning = false
|
||||
|
||||
private val pid by lazy {
|
||||
Process.myPid()
|
||||
}
|
||||
|
||||
private val cpuInfoList by lazy {
|
||||
ArrayList<CpuInfo>()
|
||||
}
|
||||
|
||||
private val dateFormat by lazy {
|
||||
SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val TAG = "CpuMonitor"
|
||||
const val INTERVAL_PERF = 1000L
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
@Volatile
|
||||
private var sInstance: CpuMonitor? = null
|
||||
fun getInstance(context: Context): CpuMonitor? {
|
||||
if (sInstance == null) {
|
||||
synchronized(CpuMonitor::class.java) {
|
||||
if (sInstance == null) {
|
||||
sInstance = CpuMonitor(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 请先运行Shizuku的服务
|
||||
*/
|
||||
@Synchronized
|
||||
fun startRun() {
|
||||
if (!isRunning) {
|
||||
Thread(CpuRunnable()).start()
|
||||
isRunning = true
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun isStarted() = isRunning
|
||||
|
||||
@Synchronized
|
||||
fun stop() {
|
||||
isRunning = false
|
||||
}
|
||||
|
||||
fun saveCpuInfos() {
|
||||
synchronized(this) {
|
||||
MonitorDb.getDb(context).monitorDao().saveAllCpuInfos(*cpuInfoList.toTypedArray())
|
||||
cpuInfoList.clear()
|
||||
}
|
||||
}
|
||||
|
||||
private fun getCpuValue(): Double {
|
||||
var value = 0.0
|
||||
try {
|
||||
// 应用获取当前进程CPU使用时间,Binder服务端获取系统CPU时间,中间用耗时,不如使用top命令
|
||||
// value = UserServiceManager.getCpuUsage(Process.myPid())
|
||||
value = CpuUtils.getCpuUsageForO()
|
||||
return value
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, e.message ?: "未知异常!")
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
inner class CpuRunnable : Runnable {
|
||||
override fun run() {
|
||||
while (isRunning) {
|
||||
val cpu = getCpuValue()
|
||||
if (cpu > 0) {
|
||||
synchronized(this@CpuMonitor) {
|
||||
cpuInfoList.add(
|
||||
CpuInfo(
|
||||
saveTime = dateFormat.format(System.currentTimeMillis()),
|
||||
cpuPercent = cpu
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(INTERVAL_PERF)
|
||||
} catch (e: InterruptedException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.zhjt.mogo_core_function_devatools.monitor
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Process.myPid
|
||||
import android.util.Log
|
||||
import com.zhjt.mogo_core_function_devatools.monitor.db.MemInfo
|
||||
import com.zhjt.mogo_core_function_devatools.monitor.db.MonitorDb
|
||||
import com.zhjt.mogo_core_function_devatools.monitor.utils.HookUtils
|
||||
import com.zhjt.mogo_core_function_devatools.monitor.utils.MemUtils
|
||||
import java.text.SimpleDateFormat
|
||||
|
||||
class MemMonitor private constructor(var context: Context) {
|
||||
|
||||
var isRunning = false
|
||||
|
||||
private val memInfoList by lazy {
|
||||
ArrayList<MemInfo>()
|
||||
}
|
||||
|
||||
private val dateFormat by lazy {
|
||||
SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val TAG = "MemMonitor"
|
||||
const val INTERVAL_PERF = 1000L
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
@Volatile
|
||||
private var sInstance: MemMonitor? = null
|
||||
fun getInstance(context: Context): MemMonitor? {
|
||||
if (sInstance == null) {
|
||||
synchronized(MemMonitor::class.java) {
|
||||
if (sInstance == null) {
|
||||
sInstance = MemMonitor(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun startRun() {
|
||||
if (!isRunning) {
|
||||
Thread(MemoryRunnable()).start()
|
||||
isRunning = true
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun isStarted() = isRunning
|
||||
|
||||
@Synchronized
|
||||
fun stop() {
|
||||
isRunning = false
|
||||
}
|
||||
|
||||
fun saveMemInfos() {
|
||||
synchronized(this) {
|
||||
MonitorDb.getDb(context).monitorDao().saveAllMemInfos(*memInfoList.toTypedArray())
|
||||
memInfoList.clear()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 单位MB
|
||||
*/
|
||||
private fun getMemoryValue(): Double {
|
||||
var value = 0.0
|
||||
try {
|
||||
value = MemUtils.getPssMemValue(context, intArrayOf(myPid()))
|
||||
return value
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, e.message ?: "未知异常!")
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
/**
|
||||
* 单位MB
|
||||
*/
|
||||
private fun getMemoryArray(): DoubleArray {
|
||||
var value = doubleArrayOf()
|
||||
try {
|
||||
value = MemUtils.getPssArray(context, intArrayOf(myPid()))
|
||||
return value
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, e.message ?: "未知异常!")
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
inner class MemoryRunnable : Runnable {
|
||||
override fun run() {
|
||||
while (isRunning) {
|
||||
// 0: 总PSS,1: dalvik总Pss, 2: native总Pss, 3: other总Pss
|
||||
val pssArray = getMemoryArray()
|
||||
if (pssArray[0] > 0) {
|
||||
synchronized(this@MemMonitor) {
|
||||
memInfoList.add(
|
||||
MemInfo(
|
||||
saveTime = dateFormat.format(System.currentTimeMillis()),
|
||||
totalPss = pssArray[0],
|
||||
dalvikPss = pssArray[1],
|
||||
nativePss = pssArray[2],
|
||||
otherPss = pssArray[3]
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(INTERVAL_PERF)
|
||||
} catch (e: InterruptedException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.zhjt.mogo_core_function_devatools.monitor
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Looper
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import java.util.*
|
||||
|
||||
class MonitorManager private constructor(var context: Context) {
|
||||
|
||||
private var timer: Timer? = null
|
||||
|
||||
private var isStarted = false
|
||||
|
||||
companion object {
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
@Volatile
|
||||
private var sInstance: MonitorManager? = null
|
||||
fun getInstance(context: Context): MonitorManager? {
|
||||
if (sInstance == null) {
|
||||
synchronized(MonitorManager::class.java) {
|
||||
if (sInstance == null) {
|
||||
sInstance = MonitorManager(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 主线程中执行
|
||||
*/
|
||||
fun startMonitor() {
|
||||
if (Thread.currentThread() == Looper.getMainLooper().thread) {
|
||||
if (!isStarted) {
|
||||
CpuMonitor.getInstance(context)?.startRun()
|
||||
MemMonitor.getInstance(context)?.startRun()
|
||||
if (timer == null) {
|
||||
timer = Timer()
|
||||
}
|
||||
timer!!.schedule(object : TimerTask() {
|
||||
override fun run() {
|
||||
CpuMonitor.getInstance(context)?.saveCpuInfos()
|
||||
MemMonitor.getInstance(context)?.saveMemInfos()
|
||||
}
|
||||
}, 1000, 60000)
|
||||
isStarted = true
|
||||
ToastUtils.showShort("性能监控启动成功!")
|
||||
} else {
|
||||
ToastUtils.showShort("性能监控已启动,请勿重复启动!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun stopMonitor() {
|
||||
CpuMonitor.getInstance(context)?.stop()
|
||||
MemMonitor.getInstance(context)?.stop()
|
||||
timer?.cancel()
|
||||
timer = null
|
||||
isStarted = false
|
||||
ToastUtils.showShort("性能监控停止成功!")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.zhjt.mogo_core_function_devatools.monitor.db
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
@Entity(tableName = "t_cpu")
|
||||
data class CpuInfo(
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
@ColumnInfo(name = "id")
|
||||
val uuid: Long = 0,
|
||||
|
||||
@ColumnInfo(name = "save_time")
|
||||
val saveTime: String?,
|
||||
|
||||
@ColumnInfo(name = "cpu_percent")
|
||||
val cpuPercent: Double
|
||||
)
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.zhjt.mogo_core_function_devatools.monitor.db
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
@Entity(tableName = "t_memory")
|
||||
data class MemInfo(
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
@ColumnInfo(name = "id")
|
||||
val uuid: Long = 0,
|
||||
|
||||
@ColumnInfo(name = "save_time")
|
||||
val saveTime: String,
|
||||
|
||||
@ColumnInfo(name = "total_pss")
|
||||
val totalPss: Double,
|
||||
|
||||
@ColumnInfo(name = "dalvik_pss")
|
||||
val dalvikPss: Double,
|
||||
|
||||
@ColumnInfo(name = "native_pss")
|
||||
val nativePss: Double,
|
||||
|
||||
@ColumnInfo(name = "other_pss")
|
||||
val otherPss: Double
|
||||
)
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.zhjt.mogo_core_function_devatools.monitor.db
|
||||
|
||||
import androidx.room.*
|
||||
|
||||
@Dao
|
||||
interface MonitorDao {
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun saveCpu(info: CpuInfo)
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun saveAllCpuInfos(vararg cpuInfo: CpuInfo)
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun saveMemory(info: MemInfo)
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun saveAllMemInfos(vararg memInfo: MemInfo)
|
||||
|
||||
@Query("SELECT * FROM t_cpu WHERE id =:id")
|
||||
fun getAllCPUById(id: Long): List<CpuInfo>
|
||||
|
||||
@Query("SELECT * FROM t_memory WHERE id =:id")
|
||||
fun getAllMemById(id: Long): List<MemInfo>
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.zhjt.mogo_core_function_devatools.monitor.db
|
||||
|
||||
import android.content.Context
|
||||
import androidx.room.Database
|
||||
import androidx.room.Room
|
||||
import androidx.room.RoomDatabase
|
||||
|
||||
@Database(entities = [CpuInfo::class, MemInfo::class], version = 1, exportSchema = false)
|
||||
abstract class MonitorDb: RoomDatabase() {
|
||||
abstract fun monitorDao(): MonitorDao
|
||||
|
||||
companion object {
|
||||
const val INTERNAL_DB_NAME = "mogo_monitor.db"
|
||||
|
||||
private var db: MonitorDb? = null
|
||||
|
||||
@JvmStatic
|
||||
fun getDb(context: Context): MonitorDb {
|
||||
if (db == null) {
|
||||
db = Room.databaseBuilder(context.applicationContext, MonitorDb::class.java, INTERNAL_DB_NAME)
|
||||
.fallbackToDestructiveMigration()
|
||||
.build()
|
||||
}
|
||||
return db!!
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.zhjt.mogo_core_function_devatools.monitor.remote;
|
||||
|
||||
import android.os.IBinder;
|
||||
import android.os.IInterface;
|
||||
import android.os.RemoteException;
|
||||
|
||||
public interface IUserInterface extends IInterface {
|
||||
|
||||
String DESCRIPTOR = "rikka.shizuku.demo.IUserInterface";
|
||||
|
||||
int TRANSACTION_exec = IBinder.FIRST_CALL_TRANSACTION;
|
||||
int TRANSACTION_getCpuUsage = IBinder.FIRST_CALL_TRANSACTION + 1;
|
||||
|
||||
String exec(String cmd) throws RemoteException;
|
||||
|
||||
double getCpuUsage(int pid) throws RemoteException;
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
package com.zhjt.mogo_core_function_devatools.monitor.remote;
|
||||
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import android.os.IInterface;
|
||||
import android.os.Parcel;
|
||||
import android.os.RemoteException;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.zhjt.mogo_core_function_devatools.monitor.utils.CpuUtils;
|
||||
|
||||
/**
|
||||
* Server端Binder类
|
||||
*/
|
||||
public class RemoteUserServiceImp extends Binder implements IUserInterface {
|
||||
|
||||
public RemoteUserServiceImp() {
|
||||
attachInterface(this, DESCRIPTOR);
|
||||
}
|
||||
|
||||
public static IUserInterface asInterface(IBinder obj) {
|
||||
if ((obj == null)) {
|
||||
return null;
|
||||
}
|
||||
IInterface iin = obj.queryLocalInterface(DESCRIPTOR);
|
||||
if (iin instanceof IUserInterface) {
|
||||
return ((IUserInterface) iin);
|
||||
}
|
||||
return new Proxy(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String exec(String cmd) throws RemoteException {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCpuUsage(int pid) throws RemoteException {
|
||||
return CpuUtils.getCpuUsagePercentWithPid(pid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理Client端请求
|
||||
*
|
||||
* @param code
|
||||
* @param data
|
||||
* @param reply
|
||||
* @param flags
|
||||
* @return
|
||||
* @throws RemoteException
|
||||
*/
|
||||
@Override
|
||||
protected boolean onTransact(int code, @NonNull Parcel data, @Nullable Parcel reply, int flags) throws RemoteException {
|
||||
final String descriptor = DESCRIPTOR;
|
||||
switch (code) {
|
||||
case TRANSACTION_exec:
|
||||
data.enforceInterface(descriptor);
|
||||
String _arg0;
|
||||
_arg0 = data.readString();
|
||||
String _result = this.exec(_arg0);
|
||||
reply.writeNoException();
|
||||
reply.writeString(_result);
|
||||
return true;
|
||||
default:
|
||||
return super.onTransact(code, data, reply, flags);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getInterfaceDescriptor() {
|
||||
return super.getInterfaceDescriptor();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回给Client端并被封装成BinderProxy
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public IBinder asBinder() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public static class Proxy implements IUserInterface {
|
||||
private IBinder mRemote;
|
||||
|
||||
public Proxy(IBinder remote) {
|
||||
mRemote = remote;
|
||||
}
|
||||
|
||||
public String getInterfaceDescriptor() {
|
||||
return DESCRIPTOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder asBinder() {
|
||||
// 返回Server端Binder对象
|
||||
return mRemote;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String exec(String cmd) throws RemoteException {
|
||||
// 参数传递给Server端并挂起当前线程,等待Server端执行完返回结果
|
||||
Parcel _data = Parcel.obtain();
|
||||
Parcel _reply = Parcel.obtain();
|
||||
String _result;
|
||||
try {
|
||||
_data.writeInterfaceToken(DESCRIPTOR);
|
||||
_data.writeString(cmd);
|
||||
mRemote.transact(TRANSACTION_exec, _data, _reply, 0);
|
||||
_reply.readException();
|
||||
_result = _reply.readString();
|
||||
} finally {
|
||||
_reply.recycle();
|
||||
_data.recycle();
|
||||
}
|
||||
return _result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCpuUsage(int pid) throws RemoteException {
|
||||
Parcel _data = Parcel.obtain();
|
||||
Parcel _reply = Parcel.obtain();
|
||||
double _result;
|
||||
try {
|
||||
_data.writeInterfaceToken(DESCRIPTOR);
|
||||
_data.writeInt(pid);
|
||||
mRemote.transact(TRANSACTION_getCpuUsage, _data, _reply, 0);
|
||||
_reply.readException();
|
||||
_result = _reply.readDouble();
|
||||
} finally {
|
||||
_reply.recycle();
|
||||
_data.recycle();
|
||||
}
|
||||
return _result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
package com.zhjt.mogo_core_function_devatools.monitor.remote
|
||||
|
||||
//import rikka.shizuku.Shizuku
|
||||
//import android.content.ServiceConnection
|
||||
//import android.content.ComponentName
|
||||
//import android.os.IBinder
|
||||
//import rikka.shizuku.Shizuku.UserServiceArgs
|
||||
//import android.content.pm.PackageManager
|
||||
//import android.util.Log
|
||||
//import com.mogo.eagle.core.utilcode.util.AppUtils
|
||||
//import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
//import rikka.shizuku.Shizuku.OnBinderReceivedListener
|
||||
//import rikka.shizuku.Shizuku.OnBinderDeadListener
|
||||
//import rikka.shizuku.Shizuku.OnRequestPermissionResultListener
|
||||
//import java.lang.StringBuilder
|
||||
|
||||
object UserServiceManager {
|
||||
|
||||
// private const val TAG = "UserServiceManager"
|
||||
// private const val REQUEST_CODE_BIND = 1
|
||||
// private const val REQUEST_CODE_UNBIND = 2
|
||||
//
|
||||
// private var userServiceProxy: IUserInterface? = null
|
||||
// private var isFirst = true
|
||||
//
|
||||
// fun init() {
|
||||
// if (isFirst) {
|
||||
// addListener()
|
||||
// isFirst = false
|
||||
// }
|
||||
// bindUserService()
|
||||
// }
|
||||
//
|
||||
// fun stopService() {
|
||||
// removeListener()
|
||||
// unbindUserService()
|
||||
// }
|
||||
//
|
||||
// fun isServiceActive(): Boolean {
|
||||
// var isActive = false
|
||||
// val service = userServiceProxy
|
||||
// if (service != null && service is IBinder && service.isBinderAlive) {
|
||||
// isActive = true
|
||||
// }
|
||||
// return isActive
|
||||
// }
|
||||
//
|
||||
// private fun addListener() {
|
||||
// Shizuku.addBinderReceivedListenerSticky(BINDER_RECEIVED_LISTENER)
|
||||
// Shizuku.addBinderDeadListener(BINDER_DEAD_LISTENER)
|
||||
// Shizuku.addRequestPermissionResultListener(REQUEST_PERMISSION_RESULT_LISTENER)
|
||||
// }
|
||||
//
|
||||
// private fun removeListener() {
|
||||
// Shizuku.removeBinderReceivedListener(BINDER_RECEIVED_LISTENER)
|
||||
// Shizuku.removeBinderDeadListener(BINDER_DEAD_LISTENER)
|
||||
// Shizuku.removeRequestPermissionResultListener(REQUEST_PERMISSION_RESULT_LISTENER)
|
||||
// }
|
||||
//
|
||||
// private fun bindUserService() {
|
||||
// if (checkPermission(REQUEST_CODE_BIND)) {
|
||||
// val res = StringBuilder()
|
||||
// try {
|
||||
// if (Shizuku.getVersion() < 10) {
|
||||
// res.append("requires Shizuku API 10")
|
||||
// } else {
|
||||
// Shizuku.bindUserService(userServiceArgs, userServiceConnection)
|
||||
// }
|
||||
// } catch (tr: Throwable) {
|
||||
// tr.printStackTrace()
|
||||
// res.append(tr.toString())
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private fun unbindUserService() {
|
||||
// if (checkPermission(REQUEST_CODE_UNBIND)) {
|
||||
// val res = StringBuilder()
|
||||
// try {
|
||||
// if (Shizuku.getVersion() < 10) {
|
||||
// res.append("requires Shizuku API 10")
|
||||
// } else {
|
||||
// Shizuku.unbindUserService(userServiceArgs, userServiceConnection, true)
|
||||
// }
|
||||
// } catch (tr: Throwable) {
|
||||
// tr.printStackTrace()
|
||||
// res.append(tr.toString())
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// fun exec(cmd: String): String {
|
||||
// return userServiceProxy?.exec(cmd) ?: ""
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 单位:%,保留1位小数
|
||||
// */
|
||||
// fun getCpuUsage(pid: Int): Double {
|
||||
// return userServiceProxy?.getCpuUsage(pid) ?: -1.0
|
||||
// }
|
||||
//
|
||||
// private val userServiceConnection: ServiceConnection = object : ServiceConnection {
|
||||
// override fun onServiceConnected(componentName: ComponentName, binder: IBinder?) {
|
||||
// if (binder != null && binder.pingBinder()) {
|
||||
// val service = RemoteUserServiceImp.asInterface(binder)
|
||||
// userServiceProxy = service
|
||||
// ToastUtils.showShort("监控权限获取成功!")
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun onServiceDisconnected(componentName: ComponentName) {}
|
||||
// }
|
||||
//
|
||||
// private val userServiceArgs by lazy {
|
||||
// val appInfo = AppUtils.getAppInfo()
|
||||
// UserServiceArgs(
|
||||
// ComponentName(
|
||||
// appInfo?.packageName ?: "com.mogo.launcher.f",
|
||||
// RemoteUserServiceImp::class.java.name
|
||||
// )
|
||||
// )
|
||||
// .daemon(false)
|
||||
// .processNameSuffix("service")
|
||||
// .debuggable(true)
|
||||
// .version(appInfo?.versionCode ?: 1)
|
||||
// }
|
||||
//
|
||||
// private fun checkPermission(code: Int): Boolean {
|
||||
// if (Shizuku.isPreV11()) {
|
||||
// Log.w(TAG, "Version is preV11!")
|
||||
// return false
|
||||
// }
|
||||
// try {
|
||||
// return if (Shizuku.checkSelfPermission() == PackageManager.PERMISSION_GRANTED) {
|
||||
// true
|
||||
// } else if (Shizuku.shouldShowRequestPermissionRationale()) {
|
||||
// Log.e(TAG, "User denied permission (shouldShowRequestPermissionRationale=true)")
|
||||
// false
|
||||
// } else {
|
||||
// Shizuku.requestPermission(code)
|
||||
// false
|
||||
// }
|
||||
// } catch (e: Throwable) {
|
||||
// Log.e(TAG, Log.getStackTraceString(e))
|
||||
// ToastUtils.showLong("请先打开Shizuku并启动它!")
|
||||
// }
|
||||
// return false
|
||||
// }
|
||||
//
|
||||
// private fun onRequestPermissionsResult(requestCode: Int, grantResult: Int) {
|
||||
// if (grantResult == PackageManager.PERMISSION_GRANTED) {
|
||||
// when (requestCode) {
|
||||
// REQUEST_CODE_BIND -> {
|
||||
// bindUserService()
|
||||
// }
|
||||
// REQUEST_CODE_UNBIND -> {
|
||||
// unbindUserService()
|
||||
// }
|
||||
// else -> {}
|
||||
// }
|
||||
// } else {
|
||||
// Log.e(TAG, "User denied permission")
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private val BINDER_RECEIVED_LISTENER = OnBinderReceivedListener {
|
||||
// if (Shizuku.isPreV11()) {
|
||||
// Log.w(TAG, "Shizuku pre-v11 is not supported")
|
||||
// } else {
|
||||
// Log.d(TAG, "Binder received")
|
||||
// }
|
||||
// }
|
||||
// private val BINDER_DEAD_LISTENER = OnBinderDeadListener { Log.w(TAG, "Binder dead") }
|
||||
// private val REQUEST_PERMISSION_RESULT_LISTENER =
|
||||
// OnRequestPermissionResultListener { requestCode: Int, grantResult: Int ->
|
||||
// onRequestPermissionsResult(
|
||||
// requestCode,
|
||||
// grantResult
|
||||
// )
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,298 @@
|
||||
package com.zhjt.mogo_core_function_devatools.monitor.utils;
|
||||
|
||||
import android.os.Process;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.RandomAccessFile;
|
||||
|
||||
/**
|
||||
* CPU相关工具类。
|
||||
*/
|
||||
public class CpuUtils {
|
||||
private static boolean initCpu = true;
|
||||
private static double oCpu = 0.0;
|
||||
private static double oIdle = 0.0;
|
||||
|
||||
private static double pJif = 0.0;
|
||||
private static double pCpu = 0.0;
|
||||
private static double aCpu = 0.0;
|
||||
private static double opCpu = 0.0;
|
||||
private static double oaCpu = 0.0;
|
||||
|
||||
/**
|
||||
* 8.0以上获取cpu的方式
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static double getCpuUsageForO() {
|
||||
java.lang.Process process = null;
|
||||
try {
|
||||
process = Runtime.getRuntime().exec("top -n 1");
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
String line;
|
||||
int cpuIndex = -1;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
line = line.trim();
|
||||
if (TextUtils.isEmpty(line)) {
|
||||
continue;
|
||||
}
|
||||
int tempIndex = getCPUIndex(line);
|
||||
if (tempIndex != -1) {
|
||||
cpuIndex = tempIndex;
|
||||
continue;
|
||||
}
|
||||
if (line.startsWith(String.valueOf(Process.myPid()))) {
|
||||
if (cpuIndex == -1) {
|
||||
continue;
|
||||
}
|
||||
String[] param = line.split("\\s+");
|
||||
if (param.length <= cpuIndex) {
|
||||
continue;
|
||||
}
|
||||
String cpu = param[cpuIndex];
|
||||
if (cpu.endsWith("%")) {
|
||||
cpu = cpu.substring(0, cpu.lastIndexOf("%"));
|
||||
}
|
||||
return Double.parseDouble(cpu) / Runtime.getRuntime().availableProcessors();
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (process != null) {
|
||||
process.destroy();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static int getCPUIndex(String line) {
|
||||
if (line.contains("CPU")) {
|
||||
String[] titles = line.split("\\s+");
|
||||
for (int i = 0; i < titles.length; i++) {
|
||||
if (titles[i].contains("CPU")) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取应用的CPU占用率,单位:%,保留1位小数
|
||||
* @param pid
|
||||
* @return
|
||||
*/
|
||||
public static double getCpuUsagePercentWithPid(int pid) {
|
||||
double usage = 0.0;
|
||||
String[] result1;
|
||||
String[] result2;
|
||||
if (pid >= 0) {
|
||||
result1 = getCpuWithPid(pid);
|
||||
if (null != result1) {
|
||||
pCpu = Double.parseDouble(result1[1])
|
||||
+ Double.parseDouble(result1[2]);
|
||||
}
|
||||
result2 = getSystemCpu();
|
||||
if (null != result2) {
|
||||
aCpu = 0.0;
|
||||
for (int i = 2; i < result2.length; i++) {
|
||||
if (result2[i] != null) {
|
||||
aCpu += Double.parseDouble(result2[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((aCpu - oaCpu) != 0) {
|
||||
usage = DoubleUtils.div(((pCpu - opCpu) * 100.00),
|
||||
(aCpu - oaCpu), 1);
|
||||
if (usage < 0) {
|
||||
usage = 0;
|
||||
}
|
||||
else if (usage > 100)
|
||||
{
|
||||
usage = 100;
|
||||
}
|
||||
|
||||
}
|
||||
opCpu = pCpu;
|
||||
oaCpu = aCpu;
|
||||
}
|
||||
pJif = pCpu;
|
||||
return usage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取CPU使用率
|
||||
*
|
||||
* @return CPU使用率,单位:%
|
||||
*/
|
||||
public static double getSysCpuUsagePercent() {
|
||||
double usage = 0.0;
|
||||
if (initCpu) {
|
||||
initCpu = false;
|
||||
RandomAccessFile reader = null;
|
||||
try {
|
||||
reader = new RandomAccessFile("/proc/stat",
|
||||
"r");
|
||||
String load;
|
||||
load = reader.readLine();
|
||||
String[] toks = load.split(" ");
|
||||
oIdle = Double.parseDouble(toks[5]);
|
||||
oCpu = Double.parseDouble(toks[2])
|
||||
+ Double.parseDouble(toks[3])
|
||||
+ Double.parseDouble(toks[4])
|
||||
+ Double.parseDouble(toks[6])
|
||||
+ Double.parseDouble(toks[8])
|
||||
+ Double.parseDouble(toks[7]);
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
FileUtil.closeRandomAccessFile(reader);
|
||||
}
|
||||
} else {
|
||||
RandomAccessFile reader = null;
|
||||
try {
|
||||
reader = new RandomAccessFile("/proc/stat", "r");
|
||||
String load;
|
||||
load = reader.readLine();
|
||||
String[] toks = load.split(" ");
|
||||
double cIdle = Double.parseDouble(toks[5]);
|
||||
double cCpu = Double.parseDouble(toks[2])
|
||||
+ Double.parseDouble(toks[3])
|
||||
+ Double.parseDouble(toks[4])
|
||||
+ Double.parseDouble(toks[6])
|
||||
+ Double.parseDouble(toks[8])
|
||||
+ Double.parseDouble(toks[7]);
|
||||
if (0 != ((cCpu + cIdle) - (oCpu + oIdle))) {
|
||||
usage = DoubleUtils.div((100.00 * ((cCpu - oCpu))),
|
||||
((cCpu + cIdle) - (oCpu + oIdle)), 1);
|
||||
if (usage < 0) {
|
||||
usage = 0;
|
||||
}
|
||||
else if (usage > 100)
|
||||
{
|
||||
usage = 100;
|
||||
}
|
||||
}
|
||||
oCpu = cCpu;
|
||||
oIdle = cIdle;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
FileUtil.closeRandomAccessFile(reader);
|
||||
}
|
||||
}
|
||||
return usage;
|
||||
}
|
||||
|
||||
private static String[] getCpuWithPid(int pid) {
|
||||
String cpuPath = "/proc/" + pid + "/stat";
|
||||
String cpu = "";
|
||||
String[] result = new String[3];
|
||||
|
||||
File f = new File(cpuPath);
|
||||
// 部分进程信息无法读取
|
||||
if (!f.exists() || !f.canRead())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
FileReader fr = null;
|
||||
BufferedReader localBufferedReader = null;
|
||||
|
||||
try {
|
||||
fr = new FileReader(f);
|
||||
localBufferedReader = new BufferedReader(fr, 8192);
|
||||
cpu = localBufferedReader.readLine();
|
||||
if (null != cpu) {
|
||||
String[] cpuSplit = cpu.split(" ");
|
||||
result[0] = cpuSplit[1];
|
||||
result[1] = cpuSplit[13];
|
||||
result[2] = cpuSplit[14];
|
||||
}
|
||||
}catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
FileUtil.closeReader(localBufferedReader);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static String[] getSystemCpu() {
|
||||
String cpuPath = "/proc/stat";
|
||||
String cpu = "";
|
||||
String[] result = new String[7];
|
||||
|
||||
File f = new File(cpuPath);
|
||||
if (!f.exists() || !f.canRead())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
FileReader fr = null;
|
||||
BufferedReader localBufferedReader = null;
|
||||
|
||||
try {
|
||||
fr = new FileReader(f);
|
||||
localBufferedReader = new BufferedReader(fr, 8192);
|
||||
cpu = localBufferedReader.readLine();
|
||||
if (null != cpu) {
|
||||
result = cpu.split(" ");
|
||||
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
FileUtil.closeReader(localBufferedReader);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String getCpuUsageByCmd() {
|
||||
java.lang.Process process;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String line;
|
||||
String cmd = "dumpsys cpuinfo";
|
||||
try {
|
||||
process = Runtime.getRuntime().exec(
|
||||
new String[] { "sh", "-c", cmd });
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(
|
||||
process.getInputStream()));
|
||||
while (((line = br.readLine()) != null)) {
|
||||
// 去掉空白行数据
|
||||
line = line.trim();
|
||||
if (line.equals("")) {
|
||||
continue;
|
||||
}
|
||||
sb.append(line);
|
||||
sb.append("\r\n");
|
||||
}
|
||||
try {
|
||||
process.waitFor();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取进程的CPU使用时间片
|
||||
*
|
||||
* @return 进程的CPU使用时间片
|
||||
*/
|
||||
public long getJif() {
|
||||
return (long)pJif;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.zhjt.mogo_core_function_devatools.monitor.utils
|
||||
|
||||
import java.lang.Exception
|
||||
import java.math.BigDecimal
|
||||
|
||||
|
||||
object DoubleUtils {
|
||||
|
||||
fun mul(d1: Double, d2: Double): Double {
|
||||
val bd1 = BigDecimal(d1.toString())
|
||||
val bd2 = BigDecimal(d2.toString())
|
||||
return try {
|
||||
bd1.multiply(bd2).toDouble()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
0.0
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun div(d1: Double, d2: Double, scale: Int): Double {
|
||||
val bd1 = BigDecimal(d1.toString())
|
||||
val bd2 = BigDecimal(d2.toString())
|
||||
return try {
|
||||
// 直接向下取整
|
||||
bd1.divide(bd2, scale, BigDecimal.ROUND_DOWN).toDouble()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
0.0
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 四舍五入
|
||||
* scale:保留多少个小数位
|
||||
*/
|
||||
@JvmStatic
|
||||
fun keepDecimal(v: Double, scale: Int = 1): Double {
|
||||
if (scale < 0) {
|
||||
throw IllegalArgumentException("The scale must be a positive integer or zero")
|
||||
}
|
||||
return BigDecimal(v).setScale(scale, BigDecimal.ROUND_HALF_UP).toDouble()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,304 @@
|
||||
package com.zhjt.mogo_core_function_devatools.monitor.utils
|
||||
|
||||
import android.net.LocalSocket
|
||||
import android.util.Log
|
||||
import java.io.*
|
||||
import java.lang.Exception
|
||||
import java.net.Socket
|
||||
import java.nio.channels.FileChannel
|
||||
|
||||
object FileUtil {
|
||||
private const val TAG = "FileUtil"
|
||||
const val separator = "/"
|
||||
fun isPathStringValid(path: String?): Boolean {
|
||||
if (null == path || path.isEmpty()) {
|
||||
return false
|
||||
}
|
||||
if (path.contains(":") || path.contains("*") || path.contains("?")
|
||||
|| path.contains("\"") || path.contains("<")
|
||||
|| path.contains(">") || path.contains("|")
|
||||
) {
|
||||
Log.w(TAG, "filename can not contains:*:?\"<>|")
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
fun isPath(path: String): Boolean {
|
||||
return path.contains(separator) || path.contains("\\")
|
||||
}
|
||||
|
||||
fun getPath(path: String): String {
|
||||
val la = path.lastIndexOf(separator)
|
||||
return path.substring(0, la)
|
||||
}
|
||||
|
||||
fun convertValidFilePath(path: String, defPosfix: String): String {
|
||||
var filePath = path
|
||||
if (path.contains(separator) || path.contains("\\")) {
|
||||
val la = filePath.lastIndexOf(".")
|
||||
if (la < 0) {
|
||||
filePath = path + defPosfix
|
||||
} else {
|
||||
val temp = filePath.substring(la)
|
||||
if (temp.contains(separator) || temp.contains("\\")) {
|
||||
// "."是目录名的一部分而不是后缀名的情况
|
||||
filePath = path + defPosfix
|
||||
}
|
||||
// else fileName = fileName
|
||||
}
|
||||
} else {
|
||||
if (!path.contains(".")) // 没有有后缀
|
||||
{
|
||||
filePath = filePath + defPosfix
|
||||
}
|
||||
}
|
||||
return filePath
|
||||
}
|
||||
|
||||
fun isFileExists(file: String?): Boolean {
|
||||
try {
|
||||
val f = File(file)
|
||||
if (!f.exists()) {
|
||||
return false
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
fun isFileValid(f: File): Boolean {
|
||||
if (!f.exists()) {
|
||||
try {
|
||||
f.createNewFile()
|
||||
} catch (e: IOException) {
|
||||
return false
|
||||
}
|
||||
f.delete()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
fun isFileValid(parent: File?, name: String?): Boolean {
|
||||
val f = File(parent, name)
|
||||
return isFileValid(f)
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除存在的文件
|
||||
*
|
||||
* @param filePath
|
||||
*/
|
||||
fun delExistFile(filePath: String?) {
|
||||
val f = File(filePath)
|
||||
if (f.exists()) f.delete()
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭bufferReader
|
||||
*
|
||||
* @param br
|
||||
*/
|
||||
@JvmStatic
|
||||
fun closeReader(br: Reader?) {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭Writer
|
||||
*
|
||||
* @param wr
|
||||
*/
|
||||
fun closeWriter(wr: Writer?) {
|
||||
if (wr != null) {
|
||||
try {
|
||||
wr.close()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* flush Writer
|
||||
*
|
||||
* @param wr
|
||||
*/
|
||||
fun flushWriter(wr: Writer?) {
|
||||
if (wr != null) {
|
||||
try {
|
||||
wr.flush()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 输入流的关闭
|
||||
*
|
||||
* @param in
|
||||
*/
|
||||
fun closeInputStream(`in`: InputStream?) {
|
||||
if (`in` != null) {
|
||||
try {
|
||||
`in`.close()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出流的关闭
|
||||
*
|
||||
* @param out
|
||||
*/
|
||||
fun closeOutputStream(out: OutputStream?) {
|
||||
if (out != null) {
|
||||
try {
|
||||
out.close()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件管道的关闭
|
||||
*
|
||||
* @param chl
|
||||
*/
|
||||
fun closeFileChannel(chl: FileChannel?) {
|
||||
if (chl != null) {
|
||||
try {
|
||||
chl.close()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* RandomAccessFile的关闭
|
||||
*
|
||||
* @param f RandomAccessFile对象
|
||||
*/
|
||||
@JvmStatic
|
||||
fun closeRandomAccessFile(f: RandomAccessFile?) {
|
||||
if (f != null) {
|
||||
try {
|
||||
f.close()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Socket的关闭
|
||||
*
|
||||
* @param s Socket对象
|
||||
*/
|
||||
fun colseSocket(s: Socket?) {
|
||||
if (s != null) {
|
||||
try {
|
||||
s.close()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* LocalSocket的关闭
|
||||
*
|
||||
* @param s Socket对象
|
||||
*/
|
||||
fun colseLocalSocket(s: LocalSocket?) {
|
||||
if (s != null) {
|
||||
try {
|
||||
s.close()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun deleteFile(file: File) {
|
||||
if (file.exists()) { // 判断文件是否存在
|
||||
if (file.isFile) { // 判断是否是文件
|
||||
file.delete() // delete()方法 你应该知道 是删除的意思;
|
||||
} else if (file.isDirectory) { // 否则如果它是一个目录
|
||||
val files = file.listFiles() // 声明目录下所有的文件 files[];
|
||||
for (i in files.indices) { // 遍历目录下所有的文件
|
||||
deleteFile(files[i]) // 把每个文件 用这个方法进行迭代
|
||||
}
|
||||
}
|
||||
file.delete()
|
||||
} else {
|
||||
Log.e(TAG, "文件不存在!" + "n")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 拷贝文件
|
||||
*
|
||||
* @param s 源文件
|
||||
* @param t 目标文件
|
||||
*/
|
||||
fun copyFile(s: File?, t: File) {
|
||||
var fi: FileInputStream? = null
|
||||
var fo: FileOutputStream? = null
|
||||
var `in`: FileChannel? = null
|
||||
var out: FileChannel? = null
|
||||
try {
|
||||
if (!t.exists()) {
|
||||
t.createNewFile()
|
||||
}
|
||||
fi = FileInputStream(s)
|
||||
fo = FileOutputStream(t)
|
||||
`in` = fi.channel
|
||||
out = fo.channel
|
||||
// 连接两个通道,并且从in通道读取,然后写入out通道
|
||||
`in`.transferTo(0, `in`.size(), out)
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
} finally {
|
||||
closeOutputStream(fo)
|
||||
closeInputStream(fi)
|
||||
closeFileChannel(`in`)
|
||||
closeFileChannel(out)
|
||||
}
|
||||
}
|
||||
|
||||
fun copyInputToFile(`in`: InputStream?, path: String?) {
|
||||
var bis: BufferedInputStream? = null
|
||||
var fos: FileOutputStream? = null
|
||||
try {
|
||||
val buffer = ByteArray(10 * 1024)
|
||||
bis = BufferedInputStream(`in`)
|
||||
fos = FileOutputStream(path)
|
||||
var a = bis.read(buffer, 0, buffer.size)
|
||||
while (a != -1) {
|
||||
fos.write(buffer, 0, a)
|
||||
fos.flush()
|
||||
a = bis.read(buffer, 0, buffer.size)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
} finally {
|
||||
closeOutputStream(fos)
|
||||
closeInputStream(bis)
|
||||
closeInputStream(`in`)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.zhjt.mogo_core_function_devatools.monitor.utils;
|
||||
|
||||
import android.os.Debug;
|
||||
import android.util.Log;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class HookUtils {
|
||||
private static final String TAG = "HookUtils";
|
||||
|
||||
/**
|
||||
* 单位为MB
|
||||
* 0: 总PSS,1: dalvik总Pss, 2: native总Pss, 3: other总Pss
|
||||
* @param memoryInfo
|
||||
* @return
|
||||
*/
|
||||
public static double[] getPssArray(Debug.MemoryInfo memoryInfo) {
|
||||
double[] pssArray = new double[4];
|
||||
if (memoryInfo != null) {
|
||||
double totalPss = DoubleUtils.keepDecimal(memoryInfo.getTotalPss() / 1024.0, 3);
|
||||
// Log.d(TAG, "===========Hook PSS 开始:===========\n");
|
||||
// Log.d(TAG, "总PSS内存为:" + totalPss);
|
||||
pssArray[0] = totalPss;
|
||||
try {
|
||||
Field dalvikField = memoryInfo.getClass().getField("dalvikSwappedOutPss");
|
||||
double dalvikPss = DoubleUtils.keepDecimal(memoryInfo.dalvikPss / 1024.0, 3);
|
||||
double dalvikSwappedOutPss = DoubleUtils.keepDecimal((int) dalvikField.get(memoryInfo) / 1024.0, 3);
|
||||
pssArray[1] = dalvikPss + dalvikSwappedOutPss;
|
||||
// Log.d(TAG, "dalvikPss is:" + dalvikSwappedOutPss);
|
||||
// Log.d(TAG, "dalvikSwappedOutPss is:" + dalvikPss + "\n\n");
|
||||
|
||||
Field nativeField = memoryInfo.getClass().getField("nativeSwappedOutPss");
|
||||
double nativePss = DoubleUtils.keepDecimal(memoryInfo.nativePss / 1024.0, 3);
|
||||
double nativeSwappedOutPss = DoubleUtils.keepDecimal((int) nativeField.get(memoryInfo) / 1024.0, 3);
|
||||
pssArray[2] = nativePss + nativeSwappedOutPss;
|
||||
// Log.d(TAG, "nativePss is:" + nativePss);
|
||||
// Log.d(TAG, "nativeSwappedOutPss is:" + nativeSwappedOutPss + "\n\n");
|
||||
|
||||
Field otherField = memoryInfo.getClass().getField("otherSwappedOutPss");
|
||||
double otherPss = DoubleUtils.keepDecimal(memoryInfo.otherPss / 1024.0, 3);
|
||||
double otherSwappedOutPss = DoubleUtils.keepDecimal((int) otherField.get(memoryInfo) / 1024.0, 3);
|
||||
pssArray[3] = otherPss + otherSwappedOutPss;
|
||||
// Log.d(TAG, "otherPss is:" + otherPss);
|
||||
// Log.d(TAG, "otherSwappedOutPss is:" + otherSwappedOutPss + "\n\n");
|
||||
//
|
||||
// Log.d(TAG, "===========Hook PSS 结束!===========\n");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, e.getMessage());
|
||||
}
|
||||
}
|
||||
return pssArray;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
package com.zhjt.mogo_core_function_devatools.monitor.utils;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.os.Debug;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* 内存信息工具类。
|
||||
*/
|
||||
public class MemUtils {
|
||||
|
||||
public static double[] getPssArray(Context context, int[] pids) {
|
||||
Debug.MemoryInfo[] memoryArray = getMemoryInfo(context, pids);
|
||||
if (memoryArray.length > 0) {
|
||||
return HookUtils.getPssArray(memoryArray[0]);
|
||||
} else {
|
||||
return new double[4];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 单位MB
|
||||
*/
|
||||
public static double getPssMemValue(Context context, int[] pids) {
|
||||
double value = 0.0;
|
||||
Debug.MemoryInfo[] memoryArray = getMemoryInfo(context, pids);
|
||||
if (memoryArray.length > 0) {
|
||||
value = DoubleUtils.keepDecimal(memoryArray[0].getTotalPss() / 1024.0, 1);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 只能获取本应用的PSS内存占系统百分比:单位%,保留1位小数
|
||||
* @return
|
||||
*/
|
||||
public static double getPidMemPercent() {
|
||||
double percent = 0.0;
|
||||
Debug.MemoryInfo memInfo = new Debug.MemoryInfo();
|
||||
Debug.getMemoryInfo(memInfo);
|
||||
int pidTotalPss = memInfo.getTotalPss();
|
||||
long systemTotalMem = getTotalMem();
|
||||
percent = DoubleUtils.keepDecimal(pidTotalPss * 100.0 / systemTotalMem, 1);
|
||||
return percent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取本应用进程总pss内存,单位MB
|
||||
*/
|
||||
public static double getPssMem() {
|
||||
Debug.MemoryInfo memInfo = new Debug.MemoryInfo();
|
||||
Debug.getMemoryInfo(memInfo);
|
||||
return DoubleUtils.keepDecimal(memInfo.getTotalPss() / 1024.0, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统空闲内存占用百分比: 单位%
|
||||
* @return
|
||||
*/
|
||||
public static double getSystemMemPercent() {
|
||||
double percent = 0.0;
|
||||
long[] memInfo = getMemInfo();
|
||||
long free = memInfo[1] + memInfo[2] + memInfo[3];
|
||||
long total = memInfo[0];
|
||||
percent = DoubleUtils.keepDecimal(free * 100.0 / total, 1);
|
||||
return percent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取空闲内存
|
||||
*
|
||||
* @return 空闲内存,单位KB
|
||||
*/
|
||||
public static long getFreeMem() {
|
||||
long[] memInfo = getMemInfo();
|
||||
return memInfo[1] + memInfo[2] + memInfo[3];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取总内存
|
||||
*
|
||||
* @return 总内存,单位KB
|
||||
*/
|
||||
public static long getTotalMem() {
|
||||
long[] memInfo = getMemInfo();
|
||||
return memInfo[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取内存信息:total、free、buffers、cached,单位KB
|
||||
*
|
||||
* @return 内存信息
|
||||
*/
|
||||
public static long[] getMemInfo() {
|
||||
long memInfo[] = new long[4];
|
||||
try {
|
||||
Class<?> procClazz = Class.forName("android.os.Process");
|
||||
Class<?> paramTypes[] = new Class[] { String.class, String[].class,
|
||||
long[].class };
|
||||
Method readProclines = procClazz.getMethod("readProcLines",
|
||||
paramTypes);
|
||||
Object args[] = new Object[3];
|
||||
final String[] memInfoFields = new String[] { "MemTotal:",
|
||||
"MemFree:", "Buffers:", "Cached:" };
|
||||
long[] memInfoSizes = new long[memInfoFields.length];
|
||||
memInfoSizes[0] = 30;
|
||||
memInfoSizes[1] = -30;
|
||||
args[0] = "/proc/meminfo";
|
||||
args[1] = memInfoFields;
|
||||
args[2] = memInfoSizes;
|
||||
if (null != readProclines) {
|
||||
readProclines.invoke(null, args);
|
||||
for (int i = 0; i < memInfoSizes.length; i++) {
|
||||
memInfo[i] = memInfoSizes[i];
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return memInfo;
|
||||
}
|
||||
|
||||
public static long[] getHeapNative() {
|
||||
int Native_HeapSize = 0;
|
||||
int Native_HeapAlloc = 1;
|
||||
long[] value = new long[2];
|
||||
value[Native_HeapSize] = Debug.getNativeHeapSize() >> 10;
|
||||
value[Native_HeapAlloc] = Debug.getNativeHeapAllocatedSize() >> 10;
|
||||
return value;
|
||||
}
|
||||
|
||||
public static long[] getHeapDalvik() {
|
||||
int Total_HeapSize = 0;
|
||||
int Total_HeapAlloc = 1;
|
||||
|
||||
long[] value_total = new long[2];
|
||||
value_total[Total_HeapSize] = Runtime.getRuntime().totalMemory() >> 10;
|
||||
value_total[Total_HeapAlloc] = (Runtime.getRuntime().totalMemory() - Runtime
|
||||
.getRuntime().freeMemory()) >> 10;
|
||||
|
||||
long[] value_native = getHeapNative();
|
||||
|
||||
int Dalvik_HeapSize = 0;
|
||||
int Dalvik_HeapAlloc = 1;
|
||||
long[] value_dalvik = new long[2];
|
||||
value_dalvik[Dalvik_HeapSize] = value_total[Total_HeapSize]
|
||||
- value_native[0];
|
||||
value_dalvik[Dalvik_HeapAlloc] = value_total[Total_HeapAlloc]
|
||||
- value_native[1];
|
||||
|
||||
return value_dalvik;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取堆内存数据,精确到KB Get VM Heap Size by calling:
|
||||
* Runtime.getRuntime().totalMemory(); Get Allocated VM Memory by calling:
|
||||
* Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
|
||||
* Get VM Heap Size Limit by calling: Runtime.getRuntime().maxMemory() Get
|
||||
* Native Allocated Memory by calling: Debug.getNativeHeapAllocatedSize();
|
||||
*/
|
||||
public static long[] getVM() {
|
||||
long[] value = new long[5];
|
||||
value[0] = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime()
|
||||
.freeMemory()) >> 10;
|
||||
value[1] = Runtime.getRuntime().totalMemory() >> 10;
|
||||
|
||||
value[2] = Debug.getNativeHeapAllocatedSize() >> 10;
|
||||
value[3] = Debug.getNativeHeapSize() >> 10;
|
||||
value[4] = Debug.getGlobalAllocSize() >> 10;
|
||||
return value;
|
||||
}
|
||||
|
||||
private static Debug.MemoryInfo[] getMemoryInfo(Context context, int[] pids) {
|
||||
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
return am.getProcessMemoryInfo(pids);
|
||||
}
|
||||
}
|
||||
@@ -182,7 +182,7 @@ import java.util.*
|
||||
}
|
||||
}
|
||||
|
||||
/*ivCameraIcon?.setOnLongClickListener {
|
||||
/**ivCameraIcon?.setOnLongClickListener {
|
||||
activity?.let { it1 -> CarcorderPreviewView.show(it1) }
|
||||
true
|
||||
}*/
|
||||
|
||||
@@ -152,6 +152,8 @@ class DebugSettingView @JvmOverloads constructor(
|
||||
SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS")
|
||||
}
|
||||
|
||||
private var isStarted = false
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_debug_setting, this, true)
|
||||
initView()
|
||||
@@ -571,6 +573,11 @@ class DebugSettingView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
//只在司机端设置美化模式开关功能
|
||||
if(AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)){
|
||||
tbIsDemoMode.visibility = View.GONE
|
||||
}
|
||||
|
||||
// 雨天模式,上一次勾选的数据
|
||||
tbIsRainMode.isChecked = FunctionBuildConfig.isRainMode
|
||||
//雨天模式
|
||||
@@ -853,6 +860,17 @@ class DebugSettingView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
btnBrakeThreshold.setOnLongClickListener {
|
||||
if (!isStarted) {
|
||||
CallerDevaToolsManager.startMonitor()
|
||||
isStarted = true
|
||||
} else {
|
||||
CallerDevaToolsManager.stopMonitor()
|
||||
isStarted = false
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
//设置连接司机屏IP
|
||||
btnConnectServerIp.setOnClickListener {
|
||||
val ip = etConnectServerIp.text.toString()
|
||||
|
||||
@@ -31,9 +31,9 @@ class BusOperationView @JvmOverloads constructor(
|
||||
|
||||
override fun changerOperationStatus(isOut: Boolean) {
|
||||
if (isOut){
|
||||
ochBusOperationStatusCTV.setText("收车")
|
||||
ochBusOperationStatusCTV.text = "收车"
|
||||
}else{
|
||||
ochBusOperationStatusCTV.setText("出车")
|
||||
ochBusOperationStatusCTV.text = "出车"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import static com.mogo.eagle.core.data.deva.chain.ChainConstant.CHAIN_ALIAS_CODE
|
||||
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 static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_MAP;
|
||||
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
@@ -24,10 +23,8 @@ import androidx.annotation.Nullable;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
import com.mogo.eagle.core.data.config.HdMapBuildConfig;
|
||||
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.analytics.AnalyticsManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager;
|
||||
import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager;
|
||||
import com.mogo.eagle.core.function.hmi.R;
|
||||
@@ -39,7 +36,6 @@ 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.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.map.MogoMapUIController;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.rousetime.android_startup.model.CostTimesModel;
|
||||
import com.zhjt.service.chain.ChainLog;
|
||||
@@ -75,6 +71,16 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
|
||||
private BluetoothMonitorReceiver mBluetoothReceiver = null;
|
||||
private BluetoothAdapter mBluetoothAdapter;
|
||||
private List<BluetoothDevice> mAreadlyConnectedList = new ArrayList<>();//已连接设备集合
|
||||
private int numberA = 0;
|
||||
private boolean isLongPressA = false;
|
||||
private int numberB = 0;
|
||||
private boolean isLongPressB = false;
|
||||
private int numberC = 0;
|
||||
private boolean isLongPressC = false;
|
||||
private int numberD = 0;
|
||||
private boolean isLongPressD = false;
|
||||
private int numberE = 0;
|
||||
private boolean isLongPressE = false;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -226,15 +232,127 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Log.e("liyz", "onKeyDown keyCode = " + keyCode + "--action = " + event.getAction() + "---" + event);
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||
// Log.d("liyz", "dispatchKeyEvent code = " + event.getKeyCode() + "--action = " + event.getAction() + "----" + event);
|
||||
if (event.getKeyCode() == KeyEvent.KEYCODE_A) { //单击向左变道,长按-1
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
numberA++;
|
||||
if (numberA > 2) {
|
||||
if (!isLongPressA) {
|
||||
// ToastUtils.showShort("方块 长按A -2 ");
|
||||
sendAcc(true, -2);
|
||||
isLongPressA = true;
|
||||
}
|
||||
}
|
||||
} else if (event.getAction() == KeyEvent.ACTION_UP) {
|
||||
if (numberA == 1) {
|
||||
// ToastUtils.showShort("方块 点击A -1 ");
|
||||
sendAcc(true, -1);
|
||||
}
|
||||
numberA = 0;
|
||||
isLongPressA = false;
|
||||
}
|
||||
return true;
|
||||
} else if (event.getKeyCode() == KeyEvent.KEYCODE_B) { //单击向右变道,长按-2
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
numberB++;
|
||||
if (numberB > 2) {
|
||||
if (!isLongPressB) {
|
||||
// ToastUtils.showShort("方块 长按B 无操作 ");
|
||||
isLongPressB = true;
|
||||
}
|
||||
}
|
||||
} else if (event.getAction() == KeyEvent.ACTION_UP) {
|
||||
if (numberB == 1) {
|
||||
// ToastUtils.showShort("方块 单击B 复原 ");
|
||||
sendAcc(false, 0.0);
|
||||
}
|
||||
numberB = 0;
|
||||
isLongPressB = false;
|
||||
}
|
||||
return true;
|
||||
} else if (event.getKeyCode() == KeyEvent.KEYCODE_C) { //单击鸣笛,
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
numberC++;
|
||||
if (numberC > 2) {
|
||||
if (!isLongPressC) {
|
||||
// ToastUtils.showShort("方块 长按C 无操作");
|
||||
isLongPressC = true;
|
||||
}
|
||||
}
|
||||
} else if (event.getAction() == KeyEvent.ACTION_UP) {
|
||||
if (numberC == 1) {
|
||||
// ToastUtils.showShort("方块 单击C ← 向左变道 ");
|
||||
CallerAutoPilotManager.INSTANCE.sendOperatorChangeLaneLeft();
|
||||
}
|
||||
numberC = 0;
|
||||
isLongPressC = false;
|
||||
}
|
||||
return true;
|
||||
} else if (event.getKeyCode() == KeyEvent.KEYCODE_D) { //单击开启自动驾驶,
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
numberD++;
|
||||
if (numberD > 2) {
|
||||
if (!isLongPressD) {
|
||||
// ToastUtils.showShort("方块 长按D 无操作");
|
||||
isLongPressD = true;
|
||||
}
|
||||
}
|
||||
} else if (event.getAction() == KeyEvent.ACTION_UP) {
|
||||
if (numberD == 1) {
|
||||
// ToastUtils.showShort("方块 单击D → 向右变道 ");
|
||||
CallerAutoPilotManager.INSTANCE.sendOperatorChangeLaneRight();
|
||||
}
|
||||
numberD = 0;
|
||||
isLongPressD = false;
|
||||
}
|
||||
return true;
|
||||
} else if (event.getKeyCode() == KeyEvent.KEYCODE_E) { //单击复原,
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
numberE++;
|
||||
if (numberE > 2) {
|
||||
if (!isLongPressE) {
|
||||
// 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);
|
||||
isLongPressE = true;
|
||||
}
|
||||
}
|
||||
} else if (event.getAction() == KeyEvent.ACTION_UP) {
|
||||
if (numberE == 1) {
|
||||
// ToastUtils.showShort("方块 单击E 开启自动驾驶 ");
|
||||
CallerAutoPilotManager.INSTANCE.setControlAutopilotCarAuto(true);
|
||||
}
|
||||
numberE = 0;
|
||||
isLongPressE = false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.dispatchKeyEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchTouchEvent(MotionEvent event) {
|
||||
// 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("← 向左变道");
|
||||
// MogoMapUIController.getInstance().setLockMode( true );
|
||||
CallerAutoPilotManager.INSTANCE.sendOperatorChangeLaneLeft();
|
||||
|
||||
return true;
|
||||
@@ -271,44 +389,8 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
|
||||
}
|
||||
|
||||
return super.dispatchTouchEvent(event);
|
||||
|
||||
// if (SharedPrefsMgr.getInstance(getContext()).getBoolean("BLUETOOTH", false)) {
|
||||
// return false;
|
||||
// } else {
|
||||
// return super.dispatchTouchEvent(event);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
|
||||
//← x:-1469.6875 y:530.0
|
||||
//↑ x:-1096.25 y:132.5
|
||||
//→ x:-863.4375 y: 690.0
|
||||
//↓ x:-1096.25 y:1099.0
|
||||
//O x:-1096.25 y:690.0
|
||||
// Log.d("liyz", "onTouchEvent event.getX() = " + event.getX() + "--event.getY() = " + event.getY());
|
||||
|
||||
if (event.getX() == -1469.6875 && event.getY() == 530.0) {
|
||||
// ToastUtils.showShort("←");
|
||||
return true;
|
||||
} else if (event.getX() == -1096.25 && event.getY() == 132.5) {
|
||||
// ToastUtils.showShort("↑");
|
||||
return true;
|
||||
} else if (event.getX() == -863.4375 && event.getY() == 690.0) {
|
||||
// ToastUtils.showShort("→");
|
||||
return true;
|
||||
} else if (event.getX() == -1096.25 && event.getY() == 1099.0) {
|
||||
// ToastUtils.showShort("↓");
|
||||
return true;
|
||||
} else if (event.getX() == -1096.25 && event.getY() == 690.0) {
|
||||
// ToastUtils.showShort("O");
|
||||
return true;
|
||||
}
|
||||
return super.onTouchEvent(event);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onSkinModeChange(int skinMode) {
|
||||
if (skinMode == 0) {
|
||||
@@ -372,7 +454,7 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
|
||||
boolean isConnected = (boolean) isConnectedMethod.invoke(device, (Object[]) null);
|
||||
// Log.e("liyz", "showBondedDevice Name:" + device.getName() + " Mac:" + device.getAddress() + "---isConnected = " + isConnected);
|
||||
mAreadlyConnectedList.add(device);
|
||||
if (device.getName().equals("JX-05")) {
|
||||
if (device.getName().equals("JX-05")) { //后面魔戒可能不使用了
|
||||
SharedPrefsMgr.getInstance(getContext()).putString("BT_MAC", device.getAddress());
|
||||
}
|
||||
if (!isConnected) {
|
||||
@@ -380,7 +462,6 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
|
||||
connectBluetooth(); //主动连接一次
|
||||
}, 4000L);
|
||||
}
|
||||
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
@@ -394,7 +475,7 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onAutoConnection(ConnectBluetoothEvent event) {
|
||||
connectBluetooth();
|
||||
// connectBluetooth();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -412,6 +493,7 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
|
||||
pos = i;
|
||||
}
|
||||
}
|
||||
|
||||
// Log.d("liyz", "connectBluetooth macAddress = " + macAddress + "---pos = " + pos);
|
||||
if (mAreadlyConnectedList.size() > pos && (pos >= 0)) {
|
||||
method.invoke(mAreadlyConnectedList.get(pos));
|
||||
|
||||
@@ -28,8 +28,12 @@ import com.mogo.module.common.MogoModule;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
import com.zhidao.support.obu.ami.AmiClientManager;
|
||||
import com.zhjt.mogo_core_function_devatools.monitor.db.CpuInfo;
|
||||
import com.zhjt.mogo_core_function_devatools.monitor.db.MemInfo;
|
||||
import com.zhjt.mogo_core_function_devatools.monitor.db.MonitorDb;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 默认初始化一些基础服务配置
|
||||
@@ -58,6 +62,7 @@ public abstract class MainMoGoApplication extends AbsMogoApplication {
|
||||
|
||||
//查询是否有版本的更新
|
||||
queryAppUpgrade();
|
||||
checkMonitorDb();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,6 +80,18 @@ public abstract class MainMoGoApplication extends AbsMogoApplication {
|
||||
},5000);
|
||||
}
|
||||
|
||||
private void checkMonitorDb() {
|
||||
new Thread(() -> {
|
||||
long limitId = 50001;
|
||||
List<CpuInfo> cpuList = MonitorDb.getDb(this).monitorDao().getAllCPUById(limitId);
|
||||
List<MemInfo> memList = MonitorDb.getDb(this).monitorDao().getAllMemById(limitId);
|
||||
// 大于5w条清除
|
||||
if (cpuList.size() > 0 || memList.size() > 0) {
|
||||
this.deleteDatabase(MonitorDb.INTERNAL_DB_NAME);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化异常采集配置
|
||||
*/
|
||||
|
||||
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 20 KiB |
@@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval">
|
||||
<gradient
|
||||
android:startColor="#6D7BAF"
|
||||
android:endColor="#3B4577"
|
||||
android:angle="315"
|
||||
/>
|
||||
<size
|
||||
android:width="150px"
|
||||
android:height="150px"
|
||||
/>
|
||||
</shape>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/icon_bus_operation_status" android:state_focused="true" android:state_pressed="true" />
|
||||
<item android:drawable="@drawable/icon_bus_operation_status" android:state_focused="false" android:state_pressed="true" />
|
||||
<item android:drawable="@drawable/icon_bus_operation_status" android:state_selected="true" />
|
||||
<item android:drawable="@drawable/icon_bus_operation_status" android:state_focused="true" />
|
||||
<item android:drawable="@drawable/icon_bus_operation_status_un" />
|
||||
</selector>
|
||||
@@ -7,6 +7,7 @@
|
||||
android:layout_marginTop="40px"
|
||||
android:paddingBottom="40px"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"
|
||||
tools:ignore="DuplicateIds">
|
||||
|
||||
<View
|
||||
@@ -22,6 +23,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="113px"
|
||||
android:gravity="center"
|
||||
android:paddingBottom="4px"
|
||||
android:text="@string/bus_operation_title"
|
||||
android:textColor="@color/color_FFFFFF"
|
||||
android:textSize="42px" />
|
||||
@@ -33,12 +35,11 @@
|
||||
android:layout_below="@+id/tv_bus_operation_title"
|
||||
android:layout_marginStart="113px"
|
||||
android:layout_marginTop="40px"
|
||||
android:background="@drawable/bus_operation_status_bg"
|
||||
android:elevation="@dimen/dp_10"
|
||||
android:background="@drawable/bus_operation_status_bg_selector1"
|
||||
android:gravity="center"
|
||||
android:text="出车"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@drawable/bus_autopilot_text_color_selector"
|
||||
android:textColor="@color/bus_autopilot_text_color_normal"
|
||||
android:textSize="@dimen/module_mogo_och_autopilot_status_text_size"
|
||||
android:textStyle="bold" />
|
||||
</RelativeLayout>
|
||||
@@ -12,18 +12,20 @@ class RoadArrow {
|
||||
private const val TURN_LEFT_OR_U_TURN = 206 //左转或转向
|
||||
private const val TURN_RIGHT = 208 //右转
|
||||
private const val TURN_LEFT_OR_RIGHT = 210 //左右转向
|
||||
const val U_TURN = 211 //转向
|
||||
private const val U_TURN = 211 //转向
|
||||
private const val STRAIGHT_OR_LEFT_OR_RIGHT = 215 //直行或左转或右转
|
||||
private const val TURN_RIGHT_OR_U_TURN = 217 //右转或转向
|
||||
|
||||
fun isLeft(arrowId: Int): Boolean {
|
||||
return arrowId == STRAIGHT_OR_LEFT || arrowId == TURN_LEFT || arrowId == TURN_LEFT_OR_U_TURN || arrowId == TURN_LEFT_OR_RIGHT
|
||||
}
|
||||
|
||||
fun isStraight(arrowId: Int): Boolean {
|
||||
return arrowId == STRAIGHT_AHEAD || arrowId == STRAIGHT_OR_RIGHT || arrowId == STRAIGHT_OR_U_TURN
|
||||
return arrowId == STRAIGHT_AHEAD || arrowId == STRAIGHT_OR_RIGHT || arrowId == STRAIGHT_OR_U_TURN || arrowId == STRAIGHT_OR_LEFT_OR_RIGHT
|
||||
}
|
||||
|
||||
fun isRight(arrowId: Int): Boolean {
|
||||
return arrowId == TURN_RIGHT || arrowId == STRAIGHT_OR_RIGHT || arrowId == TURN_LEFT_OR_RIGHT
|
||||
return arrowId == STRAIGHT_OR_RIGHT || arrowId == TURN_RIGHT || arrowId == TURN_RIGHT_OR_U_TURN || arrowId == TURN_LEFT_OR_RIGHT
|
||||
}
|
||||
|
||||
fun isOnlyRight(arrowId: Int): Boolean {
|
||||
|
||||
@@ -113,4 +113,8 @@ interface IDevaToolsProvider : IProvider {
|
||||
* 隐藏状态栏
|
||||
*/
|
||||
fun hideStatusBar()
|
||||
|
||||
fun startMonitor()
|
||||
|
||||
fun stopMonitor()
|
||||
}
|
||||
@@ -164,4 +164,12 @@ object CallerDevaToolsManager {
|
||||
devaToolsProviderApi?.hideStatusBar()
|
||||
}
|
||||
}
|
||||
|
||||
fun startMonitor() {
|
||||
devaToolsProviderApi?.startMonitor()
|
||||
}
|
||||
|
||||
fun stopMonitor() {
|
||||
devaToolsProviderApi?.stopMonitor()
|
||||
}
|
||||
}
|
||||
@@ -171,7 +171,7 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
//设置手势是否可以缩放 isCanZoom true 可缩放 false 不可缩放
|
||||
options.setZoomGesturesEnabled(true);
|
||||
options.setScaleVRMode(true);
|
||||
options.setAllGesturesEnabled(false); //禁止全部手势
|
||||
// options.setAllGesturesEnabled(false); //禁止全部手势
|
||||
if (options.getMyLocationStyle() != null) {
|
||||
options.getMyLocationStyle().setDisplayAnimEnable(true);
|
||||
}
|
||||
|
||||