Merge remote-tracking branch 'origin/qa_1.1.2' into qa_1.1.2

This commit is contained in:
董宏宇
2020-08-19 19:29:09 +08:00
9 changed files with 109 additions and 27 deletions

View File

@@ -17,9 +17,5 @@ class MogoMonitorConst {
*/
public static final int LOCAL_CONFIG_CLOSE_LOG = 4;
public static final String BROADCAST_START_CATCH_LOG = "com.mogo.controller.action" +
".START_CATCH_LOG";
public static final String BROADCAST_STOP_CATCH_LOG = "com.mogo.controller.action" +
".STOP_CATCH_LOG";
public static final String BROADCAST_LOG_CTRL = "com.mogo.control.action.LOG_CTRL";
}

View File

@@ -1,8 +1,11 @@
package com.zhidao.mogo.module.monitor;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.util.ArrayMap;
import android.os.Handler;
import android.os.Message;
import android.widget.Toast;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
@@ -14,11 +17,13 @@ import com.mogo.service.monitor.IMogoMonitorProvider;
import com.mogo.utils.logger.LogLevel;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.NetConfig;
import com.mogo.utils.network.utils.GsonUtil;
import com.zhidao.mogo.module.monitor.bean.RemoteLogPushContent;
import com.zhidao.mogo.module.monitor.dialog.ILogDialogListener;
import com.zhidao.mogo.module.monitor.dialog.LogDebugDialog;
import java.util.Map;
import java.util.ArrayList;
import java.util.List;
/**
* 应用监控模块provider
@@ -27,10 +32,15 @@ import java.util.Map;
*/
@Route(path = MogoMonitorConst.MODULE_PATH)
public class MogoMonitorProvider implements IMogoMonitorProvider,
IMogoOnMessageListener<RemoteLogPushContent>, ILogDialogListener {
IMogoOnMessageListener<RemoteLogPushContent>, ILogDialogListener, Handler.Callback {
private static final String TAG = MogoMonitorConst.MODULE_NAME;
private static final int MSG_TRY_CLOSE_LOG = 1001;
private static final String MANUAL_CATCH_PKG_NAME = "manual-catch-log";
private Context context;
private LogDebugDialog logDebugDialog;
private RemoteLogPushContent manualContent = new RemoteLogPushContent(60,
MANUAL_CATCH_PKG_NAME);
private Handler handler = new Handler(this);
@Override
public void showLogDebugDialog() {
logDebugDialog.show();
@@ -43,11 +53,22 @@ public class MogoMonitorProvider implements IMogoMonitorProvider,
apis.getSocketManagerApi(context).registerOnMessageListener(MogoMonitorConst.LOG_PUSH_TYPE, this);
}
private void startRemoteCtrl(){
Intent intent = new Intent("com.mogo.remotecontrol.action");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ComponentName comp = new ComponentName("com.mogo.remotecontrol",
"com.mogo.remotecontrol.RemoteCtrlService");
intent.setComponent(comp);
context.startService(intent);
Logger.d(TAG, "startRemoteCtrl");
}
@Override
public void resetActivityContext(Context context) {
this.context = context;
logDebugDialog = new LogDebugDialog(context);
logDebugDialog.setDialogListener(this);
startRemoteCtrl();
}
@Override
@@ -60,10 +81,12 @@ public class MogoMonitorProvider implements IMogoMonitorProvider,
Logger.d(TAG, "收到push消息: " + obj);
switch (obj.getType()) {
case MogoMonitorConst.START_CATCH_LOG:
onLogStart();
if(!catchingList.contains(obj.getPkgName())){
startCatchLog(obj);
}
break;
case MogoMonitorConst.STOP_CATCH_LOG:
onLogStop();
stopCatchLog(obj);
break;
case MogoMonitorConst.LOCAL_CONFIG_OPEN_LOG:
openLoggerLevel();
@@ -76,20 +99,37 @@ public class MogoMonitorProvider implements IMogoMonitorProvider,
}
}
private List<String> catchingList = new ArrayList<>();
@Override
public void onLogStart() {
// 这个是通过对话框点击开始的回调
Logger.d(TAG,"开始抓取日志====");
context.sendBroadcast(new Intent(MogoMonitorConst.BROADCAST_START_CATCH_LOG));
openLoggerLevel();
if(catchingList.contains(MANUAL_CATCH_PKG_NAME)){
Toast.makeText(context, "已经在抓日志了", Toast.LENGTH_LONG).show();
}else {
Logger.d(TAG, "开始抓取日志====");
manualContent.setType(MogoMonitorConst.START_CATCH_LOG);
startCatchLog(manualContent);
}
}
@Override
public void onLogStop() {
// 这个是通过对话框点击结束的回调
Logger.d(TAG,"结束抓取日志====");
context.sendBroadcast(new Intent(MogoMonitorConst.BROADCAST_STOP_CATCH_LOG));
closeLoggerLevel();
manualContent.setType(MogoMonitorConst.STOP_CATCH_LOG);
stopCatchLog(manualContent);
}
public void sendCtrlBroadcast(RemoteLogPushContent content) {
startRemoteCtrl();
Intent intent = new Intent(MogoMonitorConst.BROADCAST_LOG_CTRL);
intent.putExtra("content", GsonUtil.jsonFromObject(content));
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Logger.d(TAG, "sendCtrlBroadcast: " + content);
context.sendBroadcast(intent);
}
/**
@@ -103,7 +143,41 @@ public class MogoMonitorProvider implements IMogoMonitorProvider,
* 根据状态收紧Logger的限制
*/
private void closeLoggerLevel() {
Logger.init(DebugConfig.isDebug() ? LogLevel.DEBUG : LogLevel.OFF);
NetConfig.instance().setLoggable(DebugConfig.isDebug());
if(!catchingList.isEmpty()) {
Logger.init(DebugConfig.isDebug() ? LogLevel.DEBUG : LogLevel.OFF);
NetConfig.instance().setLoggable(DebugConfig.isDebug());
}
}
private void startCatchLog(RemoteLogPushContent content){
catchingList.add(content.getPkgName());
long delay = content.getDuration() * 60 * 1000;
handler.removeMessages(MSG_TRY_CLOSE_LOG);
if (delay <= 0) {
// 如果push 下来的delay小于等于0那就给个默认最大值一小时
delay = 60 * 60 * 1000;
}
handler.sendEmptyMessageDelayed(MSG_TRY_CLOSE_LOG, delay);
openLoggerLevel();
sendCtrlBroadcast(content);
}
private void stopCatchLog(RemoteLogPushContent content) {
catchingList.remove(content.getPkgName());
if (catchingList.isEmpty()) {
handler.removeMessages(MSG_TRY_CLOSE_LOG);
}
sendCtrlBroadcast(content);
closeLoggerLevel();
}
@Override
public boolean handleMessage(Message msg) {
if (msg.what == MSG_TRY_CLOSE_LOG) {
closeLoggerLevel();
return true;
}
return false;
}
}

View File

@@ -9,6 +9,15 @@ public class RemoteLogPushContent {
private String cmd;
private String pkgName;
public RemoteLogPushContent(){
}
public RemoteLogPushContent(int duration, String pkgName) {
this.duration = duration;
this.pkgName = pkgName;
}
public int getType() {
return type;
}

View File

@@ -48,7 +48,6 @@ public class V2XShareEventAdapter extends RecyclerView.Adapter<RecyclerView.View
if (viewType == V2XShareEventItemEnum.ITEM_TYPE_NUM_DES) {
View v = shareLayoutInflater.inflate(R.layout.module_v2x_event_share_description, parent,
false);
v.getBackground().setAlpha((int) 0.7);
shareDescriptionViewHolder holder = new shareDescriptionViewHolder(v);
return holder;
} else if (viewType == V2XShareEventItemEnum.ITEM_TYPE_SHARE_LIST) {

View File

@@ -108,7 +108,12 @@ public class V2XShareEventsFragment extends MvpFragment<V2XShareEventsFragment,
@Override
public void onFail(String msg) {
if (dataArrayList.size() > 0) {
dataArrayList.clear();
adapter.notifyDataSetChanged();
}
loadingView.stopWithError(msg, View.VISIBLE);
loadingView.refresButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

View File

@@ -181,8 +181,8 @@ public class V2XSurroundingFragment extends MvpFragment<SurroundingEventView, Su
String originStr = String.format(getContext().getResources().getString(R.string.v2x_surrounding_top_brief), exploreWayList.size());
SpannableString spannableString = new SpannableString(originStr);
spannableString.setSpan(new ForegroundColorSpan(Color.parseColor("#459DFF")), 7, originStr.length() - 5, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
//设置字体大小true表示前面的字体大小20单位为dip
spannableString.setSpan(new AbsoluteSizeSpan(38, true), 7, originStr.length() - 5, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
//设置字体大小true表示前面的字体大小 dip
spannableString.setSpan(new AbsoluteSizeSpan(46, true), 7, originStr.length() - 5, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
spannableString.setSpan(new StyleSpan(Typeface.NORMAL), 7, originStr.length() - 5, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
mTotalTv.setText(spannableString);
} else {

View File

@@ -20,7 +20,7 @@
android:id="@+id/tv_brief"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:gravity="top"
android:layout_marginLeft="@dimen/module_v2x_surrounding_margin_left"
android:text="周围5公里共15条交通信息"
android:textColor="@color/white"
@@ -48,12 +48,12 @@
android:layout_height="match_parent"
android:layout_below="@+id/layout_top"
android:layout_marginLeft="@dimen/module_v2x_surrounding_root_margin_left"
android:layout_marginTop="@dimen/module_v2x_surrounding_empty_tv_margin_top"
android:layout_marginRight="@dimen/module_v2x_surrounding_root_margin_left"
android:layout_marginBottom="@dimen/module_v2x_surrounding_margin_left">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/surrounding_recycleview"
android:layout_marginTop="@dimen/module_v2x_surrounding_empty_tv_margin_top"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible" />

View File

@@ -5,7 +5,7 @@
android:layout_height="wrap_content"
android:layout_marginLeft="20px"
android:layout_marginRight="20px"
android:layout_marginBottom="16px"
android:layout_marginBottom="14px"
android:background="@drawable/bg_v2x_event_description"
android:orientation="vertical">

View File

@@ -7,9 +7,8 @@
<style name="customRatingBarStyle" parent="@style/Widget.AppCompat.RatingBar">
<item name="android:minHeight">16px</item>
<item name="android:maxHeight">16px</item>
<item name="android:maxWidth">19px</item>
<item name="android:minWidth">19px</item>
<item name="android:spacing">4px</item>
<item name="android:maxWidth">20px</item>
<item name="android:minWidth">20px</item>
<item name="android:numStars">5</item>
<item name="android:rating">1</item>
<item name="android:stepSize">0.5</item>