[6.4.0][全量日志] 上传入口添加时间段选择
This commit is contained in:
@@ -211,8 +211,8 @@ internal class MoGoLogRecordProviderImpl: IMoGoLogRecordProvider,
|
||||
return LogcatManager.export()
|
||||
}
|
||||
|
||||
override fun upload(): Unit = runBlocking {
|
||||
val state = LogcatManager.upload(0, System.currentTimeMillis())
|
||||
override fun upload(startTime: Long, endTime: Long): Unit = runBlocking {
|
||||
val state = LogcatManager.upload(startTime, endTime)
|
||||
if (state is UploadError) {
|
||||
throw AssertionError(state.toString())
|
||||
}
|
||||
|
||||
@@ -1582,26 +1582,48 @@ internal class DebugSettingView @JvmOverloads constructor(
|
||||
|
||||
//上传全量日志
|
||||
exportAllLogs?.onClick { v ->
|
||||
v.visibility = View.INVISIBLE
|
||||
logLoadingView?.visibility = View.VISIBLE
|
||||
v.scope.launch(Dispatchers.IO) {
|
||||
var isUploadSuccess = false
|
||||
try {
|
||||
CallerDevaToolsManager.logcat()?.upload()
|
||||
isUploadSuccess = true
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
withContext(Dispatchers.Main) {
|
||||
if (isUploadSuccess) {
|
||||
ToastUtils.showShort("上传成功")
|
||||
} else {
|
||||
ToastUtils.showShort("上传失败")
|
||||
ListPopupWindow(v.context).also { p ->
|
||||
val items = LogcatUploadDuration.values()
|
||||
p.setAdapter(LogcatUploadAdapter(v.context, items))
|
||||
p.anchorView = v
|
||||
p.isModal = true
|
||||
p.setBackgroundDrawable(ColorDrawable(Color.WHITE))
|
||||
p.setOnItemClickListener { _, _, position, _ ->
|
||||
val item = items[position]
|
||||
v.visibility = View.INVISIBLE
|
||||
logLoadingView?.visibility = View.VISIBLE
|
||||
p.dismiss()
|
||||
v.scope.launch(Dispatchers.IO) {
|
||||
val endTime = System.currentTimeMillis()
|
||||
val startTime = when(item) {
|
||||
LogcatUploadDuration.IN_15M -> endTime - TimeUnit.MINUTES.toMillis(15)
|
||||
LogcatUploadDuration.IN_45M -> endTime - TimeUnit.MINUTES.toMillis(45)
|
||||
LogcatUploadDuration.IN_1H -> endTime - TimeUnit.HOURS.toMillis(1)
|
||||
LogcatUploadDuration.IN_2H -> endTime - TimeUnit.HOURS.toMillis(2)
|
||||
LogcatUploadDuration.IN_3H -> endTime - TimeUnit.HOURS.toMillis(3)
|
||||
LogcatUploadDuration.IN_6H -> endTime - TimeUnit.HOURS.toMillis(6)
|
||||
LogcatUploadDuration.IN_1D -> endTime - TimeUnit.DAYS.toMillis(1)
|
||||
LogcatUploadDuration.ALL -> 0
|
||||
}
|
||||
var isUploadSuccess = false
|
||||
try {
|
||||
CallerDevaToolsManager.logcat()?.upload(startTime, endTime)
|
||||
isUploadSuccess = true
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
withContext(Dispatchers.Main) {
|
||||
if (isUploadSuccess) {
|
||||
ToastUtils.showShort("上传成功")
|
||||
} else {
|
||||
ToastUtils.showShort("上传失败")
|
||||
}
|
||||
logLoadingView?.visibility = View.INVISIBLE
|
||||
exportAllLogs?.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
logLoadingView?.visibility = View.INVISIBLE
|
||||
exportAllLogs?.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
}.show()
|
||||
}
|
||||
|
||||
if (JunkConfig.isSupportJunkDetect) {
|
||||
@@ -1737,6 +1759,54 @@ internal class DebugSettingView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private enum class LogcatUploadDuration(val text: String) {
|
||||
IN_15M("15分钟内"),
|
||||
IN_45M("45分钟内"),
|
||||
IN_1H("1小时内"),
|
||||
IN_2H("2小时内"),
|
||||
IN_3H("3小时内"),
|
||||
IN_6H("6小时内"),
|
||||
IN_1D("一天内"),
|
||||
ALL("上传所有")
|
||||
}
|
||||
|
||||
private class LogcatUploadAdapter(private val ctx: Context, private val items: Array<LogcatUploadDuration>): BaseAdapter() {
|
||||
override fun getCount(): Int {
|
||||
return items.size
|
||||
}
|
||||
|
||||
override fun getItem(position: Int): Any {
|
||||
return items[position]
|
||||
}
|
||||
|
||||
override fun getItemId(position: Int): Long {
|
||||
return items[position].ordinal.toLong()
|
||||
}
|
||||
|
||||
override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
|
||||
var result = convertView
|
||||
val duration = items[position]
|
||||
if (result == null) {
|
||||
val temp = View.inflate(ctx, android.R.layout.simple_list_item_1, null)
|
||||
temp.tag = Holder(temp.findViewById(android.R.id.text1))
|
||||
result = temp
|
||||
}
|
||||
val holder = result?.tag as? Holder
|
||||
if (holder != null) {
|
||||
holder.text?.setTextColor(Color.BLACK)
|
||||
holder.text?.text = duration.text
|
||||
} else {
|
||||
val text = result?.findViewById<TextView>(android.R.id.text1)
|
||||
text?.setTextColor(Color.BLACK)
|
||||
text?.text = duration.text
|
||||
result?.tag = Holder(text)
|
||||
}
|
||||
return result!!
|
||||
}
|
||||
|
||||
private inner class Holder(val text: TextView? = null)
|
||||
}
|
||||
|
||||
private enum class ApmVLogUploadDuration(val text: String) {
|
||||
IN_15M("15分钟内"),
|
||||
IN_45M("45分钟内"),
|
||||
|
||||
@@ -13,7 +13,7 @@ interface IMoGoLogRecordProvider {
|
||||
|
||||
fun export(): File?
|
||||
|
||||
fun upload()
|
||||
fun upload(startTime: Long, endTime: Long)
|
||||
|
||||
fun testJavaCrash(runOnNewThread: Boolean)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user