[3.3.0][日志] 在调试面板添加导出全量日志入口
This commit is contained in:
@@ -5,7 +5,9 @@ import android.app.Activity
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.net.*
|
||||
import android.os.Build
|
||||
import android.os.Process
|
||||
import android.text.Html
|
||||
@@ -16,6 +18,7 @@ import androidx.annotation.RequiresApi
|
||||
import androidx.appcompat.widget.PopupMenu
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.FileProvider
|
||||
import androidx.core.view.*
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import chassis.Chassis
|
||||
@@ -1363,6 +1366,38 @@ internal class DebugSettingView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
//导出全量日志
|
||||
exportAllLogs?.onClick { v ->
|
||||
v.visibility = View.INVISIBLE
|
||||
logLoadingView?.visibility = View.VISIBLE
|
||||
v.scope.launch(Dispatchers.IO) {
|
||||
val file = CallerDevaToolsManager.logcat()?.export()
|
||||
if (file != null && file.exists()) {
|
||||
withContext(Dispatchers.Main) {
|
||||
var activity = AppStateManager.currentActivity()
|
||||
while (activity == null) {
|
||||
delay(2000)
|
||||
activity = AppStateManager.currentActivity()
|
||||
if (activity != null) {
|
||||
break
|
||||
}
|
||||
}
|
||||
activity?.startActivity(Intent.createChooser(Intent().also {
|
||||
it.action = Intent.ACTION_SEND
|
||||
it.type = "application/zip"
|
||||
it.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(activity, "${activity.packageName}.fileProvider", file))
|
||||
}, "分享全量日志压缩包到"))
|
||||
}
|
||||
} else {
|
||||
ToastUtils.showShort("全量日志压缩文件生成失败")
|
||||
}
|
||||
withContext(Dispatchers.Main) {
|
||||
logLoadingView?.visibility = View.INVISIBLE
|
||||
exportAllLogs?.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示、关闭日志过滤面板
|
||||
*/
|
||||
|
||||
@@ -2217,6 +2217,50 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/bg_mf_sop_operator"
|
||||
android:paddingBottom="10dip"
|
||||
android:layout_marginStart="10dip"
|
||||
android:layout_marginEnd="10dip"
|
||||
android:paddingTop="10dip">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/logLoadingView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center"
|
||||
android:visibility="invisible"
|
||||
android:layout_gravity="center">
|
||||
|
||||
<TextView
|
||||
android:text="正在压缩全量日志,请稍候"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="20dip"/>
|
||||
|
||||
<ProgressBar
|
||||
style="?android:attr/progressBarStyleSmall"
|
||||
android:layout_width="30dip"
|
||||
android:layout_height="30dip"
|
||||
android:layout_marginStart="10dip"/>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/exportAllLogs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="20dip"
|
||||
android:text="导出全量日志"
|
||||
android:gravity="center"
|
||||
android:layout_marginTop="10dip"
|
||||
android:layout_marginBottom="10dip" />
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
Reference in New Issue
Block a user