中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

常州企業(yè)網(wǎng)站建設(shè)價(jià)格網(wǎng)站優(yōu)化關(guān)鍵詞排名

常州企業(yè)網(wǎng)站建設(shè)價(jià)格,網(wǎng)站優(yōu)化關(guān)鍵詞排名,模板制作視頻免費(fèi)軟件,wordpress調(diào)用實(shí)際那背景: 看SystemUI的鎖屏相關(guān)代碼時(shí)候發(fā)現(xiàn)SystemUI有一個(gè)日志打印相關(guān)的方法調(diào)用,相比于常規(guī)的Log.i直接可以logcat查看方式還是比較新穎。 具體日志打印代碼如下: 下面就來介紹一下這個(gè)ShadeLogger到底是如何打印的。 分析源碼&#xff1…

背景:

看SystemUI的鎖屏相關(guān)代碼時(shí)候發(fā)現(xiàn)SystemUI有一個(gè)日志打印相關(guān)的方法調(diào)用,相比于常規(guī)的Log.i直接可以logcat查看方式還是比較新穎。

具體日志打印代碼如下:
在這里插入圖片描述
下面就來介紹一下這個(gè)ShadeLogger到底是如何打印的。

分析源碼:

源碼位置:
frameworks/base/packages/SystemUI/src/com/android/systemui/shade/ShadeLogger.kt

明顯是一個(gè)kt類,這里就只拿一個(gè)logEndMotionEvent方法來進(jìn)行源碼分析

fun logEndMotionEvent(msg: String,forceCancel: Boolean,expand: Boolean,
)
{buffer.log(TAG,LogLevel.VERBOSE,{str1 = msgbool1 = forceCancelbool2 = expand},{ "$str1; force=$bool1; expand=$bool2" })
}

可以看到這里看到實(shí)際是調(diào)用的buffer.log方法,也有對(duì)應(yīng)TAG和LogLevel等級(jí)。
那么下面來看看這個(gè)buffer.log中的buffer哪里來的,但是因?yàn)檫@構(gòu)造都是采用了很多注解drag2方式,所以不方便找,這里找到了一個(gè)NotificationPanelViewControllerBaseTest一個(gè)測(cè)試類有手動(dòng)進(jìn)行構(gòu)造,這里也可以看出相關(guān)過程

frameworks/base/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java

具體過程如下:
在這里插入圖片描述
再看看mShadeLog構(gòu)造
在這里插入圖片描述再看看logcatLogBuffer方法
在這里插入圖片描述這里調(diào)用到了LogBuffer類,注意這里test類給的是50,實(shí)際的Shader類給的是500
frameworks/base/packages/SystemUI/log/src/com/android/systemui/log/LogBuffer.kt
看看log方法:

inline fun log(tag: String,level: LogLevel,messageInitializer: MessageInitializer,noinline messagePrinter: MessagePrinter,exception: Throwable? = null,
) {val message = obtain(tag, level, messagePrinter, exception)messageInitializer(message)commit(message)
}

看看obtain方法:

@Synchronizedoverride fun obtain(tag: String,level: LogLevel,messagePrinter: MessagePrinter,exception: Throwable?,): LogMessage {if (!mutable) {return FROZEN_MESSAGE}val message = buffer.advance()//可以看到這里是buffer中獲取,message.reset(tag, level, System.currentTimeMillis(), messagePrinter, exception)return message}

這里其實(shí)只是看出來了buffer中搞出了一個(gè)message,根據(jù)傳遞來的tag和msg
接下來重點(diǎn)看看commit方法

override fun commit(message: LogMessage) {if (echoMessageQueue != null && echoMessageQueue.remainingCapacity() > 0) {try {echoMessageQueue.put(message)//主要就是放入隊(duì)列} catch (e: InterruptedException) {// the background thread has been shut down, so just log on this oneechoToDesiredEndpoints(message)}} else {echoToDesiredEndpoints(message)}
}

commit主要就是實(shí)現(xiàn)對(duì)message放入到echoMessageQueue,那么什么時(shí)候取這個(gè)隊(duì)列呢?

這里要看最開始的init方法中有啟動(dòng)一個(gè)線程

init {if (logcatEchoTracker.logInBackgroundThread && echoMessageQueue != null) {thread(start = true, name = "LogBuffer-$name", priority = Thread.NORM_PRIORITY) {try {while (true) {//死循環(huán)的取出隊(duì)列echoToDesiredEndpoints(echoMessageQueue.take())//調(diào)用echoToDesiredEndpoints來處理消息}} catch (e: InterruptedException) {Thread.currentThread().interrupt()}}}
}

具體echoToDesiredEndpoints方法如下:

 private fun echoToDesiredEndpoints(message: LogMessage) {//獲取log打印level,即其實(shí)可以通過命令來控制打印level,這里的level本質(zhì)是來自settings,具體啥settings值下面操作時(shí)候會(huì)講解val includeInLogcat =logcatEchoTracker.isBufferLoggable(name, message.level) ||logcatEchoTracker.isTagLoggable(message.tag, message.level)echo(message, toLogcat = includeInLogcat, toSystrace = systrace)//有了上面level后,echo開始處理}private fun echo(message: LogMessage, toLogcat: Boolean, toSystrace: Boolean) {if (toLogcat || toSystrace) {val strMessage = message.messagePrinter(message)if (toSystrace) {echoToSystrace(message, strMessage)//可以看這個(gè)日志還支持systrace相關(guān)}if (toLogcat) {echoToLogcat(message, strMessage)//這里就是最普通的logcat打印出來}}}
//具體的echoToLogcat其實(shí)就是根據(jù)傳遞進(jìn)來的等級(jí)進(jìn)行普通log打印private fun echoToLogcat(message: LogMessage, strMessage: String) {when (message.level) {LogLevel.VERBOSE -> Log.v(message.tag, strMessage, message.exception)LogLevel.DEBUG -> Log.d(message.tag, strMessage, message.exception)LogLevel.INFO -> Log.i(message.tag, strMessage, message.exception)LogLevel.WARNING -> Log.w(message.tag, strMessage, message.exception)LogLevel.ERROR -> Log.e(message.tag, strMessage, message.exception)LogLevel.WTF -> Log.wtf(message.tag, strMessage, message.exception)}}

到此LogBuffer源碼也就大概分析完成,可以得出以下幾個(gè)結(jié)論:

1、所有的埋點(diǎn)日志會(huì)保存到buffer中,這個(gè)buffer只是在內(nèi)存中的一個(gè)環(huán)形buffer,有固定大小

2、buffer中的日志是可以 實(shí)現(xiàn)輸出到logcat和systrace的功能

那么具體如何控制輸出到logcat,還有如何看buffer中的日志呢?接下來看看使用方法

使用方式:

在類的最開始部分有如下的使用注釋:

/*** A simple ring buffer of recyclable log messages** The goal of this class is to enable logging that is both extremely chatty and extremely* lightweight. If done properly, logging a message will not result in any heap allocations or* string generation. Messages are only converted to strings if the log is actually dumped (usually* as the result of taking a bug report).** You can dump the entire buffer at any time by running:* ```* $ adb shell dumpsys activity service com.android.systemui/.SystemUIService <bufferName>* ```** ...where `bufferName` is the (case-sensitive) [name] passed to the constructor.** By default, only messages of WARN level or higher are echoed to logcat, but this can be adjusted* locally (usually for debugging purposes).** To enable logcat echoing for an entire buffer:* ```* $ adb shell settings put global systemui/buffer/<bufferName> <level>* ```** To enable logcat echoing for a specific tag:* ```* $ adb shell settings put global systemui/tag/<tag> <level>* ```** In either case, `level` can be any of `verbose`, `debug`, `info`, `warn`, `error`, `assert`, or* the first letter of any of the previous.** In SystemUI, buffers are provided by LogModule. Instances should be created using a SysUI* LogBufferFactory.** @param name The name of this buffer, printed when the buffer is dumped and in some other*   situations.* @param maxSize The maximum number of messages to keep in memory at any one time. Buffers start*   out empty and grow up to [maxSize] as new messages are logged. Once the buffer's size reaches*   the maximum, it behaves like a ring buffer.*/

其實(shí)上面已經(jīng)寫的很詳細(xì)了,主要就是2個(gè)核心點(diǎn),一個(gè)可以通過dumpsys看所有日志,一個(gè)是可以控制logcat輸出

控制dumpsys查看方法

adb shell dumpsys activity service com.android.systemui/.SystemUIService <bufferName>

比如這里的對(duì)ShadeLog

adb shell dumpsys activity service com.android.systemui/.SystemUIService ShadeLog

dumpsys后可以查看到相關(guān)的Log:
在這里插入圖片描述
看到這個(gè)dump日志就感覺非常詳細(xì)的記錄了Shade鎖屏相關(guān)的操作,相關(guān)的tag等也是在ShadeLogger.kt定義的
在這里插入圖片描述

如果想要普通logcat輸出呢?

 adb shell settings put global systemui/tag/ShadeLog v

這里其實(shí)就是配置一個(gè)settings,然后上面的提到的echoToDesiredEndpoints的 logcatEchoTracker.isBufferLoggable就會(huì)去查詢這個(gè)settings值。
在這里插入圖片描述

總結(jié)圖

在這里插入圖片描述

更多framework詳細(xì)代碼和資料參考如下鏈接
投屏專題部分:
https://mp.weixin.qq.com/s/IGm6VHMiAOPejC_H3N_SNg
hal+perfetto+surfaceflinger

https://mp.weixin.qq.com/s/LbVLnu1udqExHVKxd74ILg
其他課程七件套專題:在這里插入圖片描述
點(diǎn)擊這里
https://mp.weixin.qq.com/s/Qv8zjgQ0CkalKmvi8tMGaw

視頻試看:
https://www.bilibili.com/video/BV1wc41117L4/

參考相關(guān)鏈接:
https://blog.csdn.net/zhimokf/article/details/137958615

更多framework假威風(fēng)耗:androidframework007

http://m.risenshineclean.com/news/58620.html

相關(guān)文章:

  • 政府網(wǎng)站建設(shè)被問責(zé)怎么讓網(wǎng)站快速收錄
  • 福州做網(wǎng)站的公seo分析工具有哪些
  • 中山哪里做網(wǎng)站seo職業(yè)培訓(xùn)班
  • 邯鄲網(wǎng)站設(shè)計(jì)招聘最新域名查詢
  • 公眾號(hào)視頻網(wǎng)站開發(fā)微博營(yíng)銷成功案例8個(gè)
  • 怎么讓網(wǎng)站欄目頁收錄廣州公司關(guān)鍵詞網(wǎng)絡(luò)推廣
  • 企業(yè)商務(wù)網(wǎng)站建設(shè)策劃書優(yōu)化網(wǎng)站首頁
  • 播視頻網(wǎng)站開發(fā)網(wǎng)站外鏈查詢
  • 做網(wǎng)站找哪家好熊掌號(hào)英文關(guān)鍵詞seo
  • 做視頻網(wǎng)站需要什么空間視頻號(hào)直播推廣二維碼
  • 微信如何做積分商城網(wǎng)站網(wǎng)站seo關(guān)鍵詞優(yōu)化排名
  • 番禺seo培訓(xùn)如何優(yōu)化關(guān)鍵詞的排名
  • wordpress交互主題揭陽seo快速排名
  • 設(shè)計(jì)門戶網(wǎng)百度seo競(jìng)價(jià)推廣是什么
  • 做b2b比較好的網(wǎng)站seo零基礎(chǔ)入門教程
  • axure做網(wǎng)站教學(xué)視頻寧海關(guān)鍵詞優(yōu)化怎么優(yōu)化
  • 杭州做企業(yè)網(wǎng)站公司seo前線
  • 織夢(mèng)網(wǎng)站需要付費(fèi)嗎百度搜首頁
  • 許昌那有做網(wǎng)站網(wǎng)頁點(diǎn)擊量統(tǒng)計(jì)
  • 廣州做網(wǎng)站最好的公司深圳seo公司排名
  • php 建設(shè)網(wǎng)站網(wǎng)站老域名跳轉(zhuǎn)到新域名
  • 哪有做企業(yè)網(wǎng)站seo關(guān)鍵詞排名優(yōu)化品牌
  • 南岸網(wǎng)站建設(shè)百度搜索引擎怎么做
  • 企業(yè)h5網(wǎng)站建設(shè)百度推廣平臺(tái)收費(fèi)標(biāo)準(zhǔn)
  • vuejs做視頻網(wǎng)站免費(fèi)加精準(zhǔn)客源
  • 濟(jì)南做網(wǎng)站優(yōu)化網(wǎng)站制作方案
  • 馬鞍山網(wǎng)站建設(shè)咨詢電艾滋病多長(zhǎng)時(shí)間能查出來
  • 網(wǎng)站的層次怎么優(yōu)化自己網(wǎng)站
  • 一簾幽夢(mèng)紫菱做的網(wǎng)站網(wǎng)站策劃方案案例
  • 做網(wǎng)站賺錢廣州seo團(tuán)隊(duì)