帮酷LOGO
  • 显示原文与译文双语对照的内容
A ui-block detection library for Android.

  • 源代码名称:AndroidPerformanceMonitor
  • 源代码网址:http://www.github.com/markzhai/AndroidPerformanceMonitor
  • AndroidPerformanceMonitor源代码文档
  • AndroidPerformanceMonitor源代码下载
  • Git URL:
    git://www.github.com/markzhai/AndroidPerformanceMonitor.git
  • Git Clone代码到本地:
    git clone http://www.github.com/markzhai/AndroidPerformanceMonitor
  • Subversion代码到本地:
    $ svn co --depth empty http://www.github.com/markzhai/AndroidPerformanceMonitor
    Checked out revision 1.
    $ cd repo
    $ svn up trunk
  • 中文自述文件

    Android性能监视器 Maven Central

    Android的透明ui块检测库,应用程序只需要one-line-code设置。

    命名是为了支付伟大库的 LeakCanary,ui相关代码是从部分的用户界面修改的。

    • 1.5.0 添加可以在调试模式停止监视器的上下文。
    • 1.4.1 Bug 修复。
    • 1.4.0 Bug 修复,在上下文中添加onBlock拦截器。
    • 1.3.1 启用标签和 icon的配置。
    • 1.3.0 添加白名单和相关软件包功能。
    正在启动

    你可以选择如何根据需要组合它们。

    dependencies {
     // most often used way, enable notification to notify block event compile 'com.github.markzhai:blockcanary-android:1.5.0'// this way you only enable BlockCanary in debug package// debugCompile 'com.github.markzhai:blockcanary-android:1.5.0'// releaseCompile 'com.github.markzhai:blockcanary-no-op:1.5.0'}

    因为这个库使用 getMainLooper().setMessageLogging() 如果你在应用程序中设置了它( 相关问题 https://github.com/moduth/blockcanary/issues/27 ),

    用法

    最大日志数设置为 500,你可以在应用程序 int.xml 中重写它。

    <integername="block_canary_max_stored_count">1000</integer>

    可以通过在 xhdpi drawable目录和 strings.xml 中放置 block_canary_icon 来配置应用程序和 icon的监视器标签:

    <stringname="block_canary_display_activity_label">Blocks</string>
    publicclassDemoApplicationextendsApplication {
     @OverridepublicvoidonCreate() {
     //.. .// Do it on main processBlockCanary.install(this, newAppBlockCanaryContext()).start();
     }
    }

    publicclassAppBlockCanaryContextextendsBlockCanaryContext {
     /** * Implement in your project. * * @return Qualifier which can specify this installation, like version + flavor.*/publicStringprovideQualifier() {
     return"unknown";
     }
     /** * Implement in your project. * * @return user id*/publicStringprovideUid() {
     return"uid";
     }
     /** * Network type * * @return {@link String} like 2G, 3G, 4G, wifi, etc.*/publicStringprovideNetworkType() {
     return"unknown";
     }
     /** * Config monitor duration, after this time BlockCanary will stop, use * with {@code BlockCanary}'s isMonitorDurationEnd * * @return monitor last duration (in hour)*/publicintprovideMonitorDuration() {
     return-1;
     }
     /** * Config block threshold (in millis), dispatch over this duration is regarded as a BLOCK. You may set it * from performance of device. * * @return threshold in mills*/publicintprovideBlockThreshold() {
     return1000;
     }
     /** * Thread stack dump interval, use when block happens, BlockCanary will dump on main thread * stack according to current sample cycle. * <p> * Because the implementation mechanism of Looper, real dump interval would be longer than * the period specified here (especially when cpu is busier). * </p> * * @return dump interval (in millis)*/publicintprovideDumpInterval() {
     return provideBlockThreshold();
     }
     /** * Path to save log, like"/blockcanary/", will save to sdcard if can. * * @return path of log files*/publicStringprovidePath() {
     return"/blockcanary/";
     }
     /** * If need notification to notice block. * * @return true if need, else if not need.*/publicbooleandisplayNotification() {
     returntrue;
     }
     /** * Implement in your project, bundle files into a zip file. * * @param src files before compress * @param dest files compressed * @return true if compression is successful*/publicbooleanzip(File[] src, Filedest) {
     returnfalse;
     }
     /** * Implement in your project, bundled log files. * * @param zippedFile zipped file*/publicvoidupload(FilezippedFile) {
     thrownewUnsupportedOperationException();
     }
     /** * Packages that developer concern, by default it uses process name, * put high priority one in pre-order. * * @return null if simply concern only package with process name.*/publicList<String>concernPackages() {
     returnnull;
     }
     /** * Filter stack without any in concern package, used with @{code concernPackages}. * * @return true if filter, false it not.*/publicbooleanfilterNonConcernStack() {
     returnfalse;
     }
     /** * Provide white list, entry in white list will not be shown in ui list. * * @return return null if you don't need white-list filter.*/publicList<String>provideWhiteList() {
     LinkedList<String> whiteList =newLinkedList<>();
     whiteList.add("org.chromium");
     return whiteList;
     }
     /** * Whether to delete files whose stack is in white list, used with white-list. * * @return true if delete, false it not.*/publicbooleandeleteFilesInWhiteList() {
     returntrue;
     }
     /** * Block interceptor, developer may provide their own actions.*/publicvoidonBlock(Contextcontext, BlockInfoblockInfo) {
     }
    }
    :它是如何工作的

    中文博客:BlockCanary

    原理流图:

    flow

    屏幕截图

    Block detailBlock list

    捐赠

    如果你发现这个知识库有用,你可以通过支付宝或者微信捐赠给我。 alipaywechat

    贡献者

    这个库最初由 创建,并在组织 moduth和zzz40500和下保持。

    特别感谢 android-cjj插件,Mr.Bao 插件,chiahaolu,以帮助你。

    更改日志

    检查变更日志

    如果你想为BlockCanary提供代码,你可以以通过GitHub分叉存储库并发送请求请求。

    许可证
    Copyright (C) 2016 MarkZhai (http://zhaiyifan.cn).
    Licensed under the Apache License, Version 2.0 (the"License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
     http://www.apache.org/licenses/LICENSE-2.0
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an"AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.



    Copyright © 2011 HelpLib All rights reserved.    知识分享协议 京ICP备05059198号-3  |  如果智培  |  酷兔英语