Repository: D-clock/AndroidPerformanceTools
Branch: master
Commit: dd1c950c7013
Files: 43
Total size: 56.9 KB
Directory structure:
gitextract_mhsma7gf/
├── .gitignore
├── .idea/
│ ├── compiler.xml
│ ├── copyright/
│ │ └── profiles_settings.xml
│ ├── gradle.xml
│ ├── markdown-exported-files.xml
│ ├── markdown-navigator/
│ │ └── profiles_settings.xml
│ ├── markdown-navigator.xml
│ ├── misc.xml
│ ├── modules.xml
│ ├── runConfigurations.xml
│ └── vcs.xml
├── LICENSE
├── README.md
├── app/
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src/
│ └── main/
│ ├── AndroidManifest.xml
│ ├── java/
│ │ └── com/
│ │ └── clock/
│ │ └── performance/
│ │ └── tools/
│ │ ├── AndroidPerformanceToolsApplication.java
│ │ ├── MainActivity.java
│ │ └── block/
│ │ ├── BlockReceiver.java
│ │ └── BlockSamplesActivity.java
│ └── res/
│ ├── layout/
│ │ ├── activity_anr_samples.xml
│ │ └── activity_main.xml
│ └── values/
│ ├── colors.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── gradle/
│ └── wrapper/
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── library/
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src/
│ ├── androidTest/
│ │ └── java/
│ │ └── com/
│ │ └── performance/
│ │ └── tools/
│ │ └── ExampleInstrumentedTest.java
│ ├── main/
│ │ ├── AndroidManifest.xml
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── performance/
│ │ │ └── tools/
│ │ │ ├── block/
│ │ │ │ ├── BlockError.java
│ │ │ │ └── BlockLooper.java
│ │ │ └── utils/
│ │ │ └── StorageUtils.java
│ │ └── res/
│ │ └── values/
│ │ └── strings.xml
│ └── test/
│ └── java/
│ └── com/
│ └── performance/
│ └── tools/
│ └── ExampleUnitTest.java
└── settings.gradle
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
================================================
FILE: .idea/compiler.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>
================================================
FILE: .idea/copyright/profiles_settings.xml
================================================
<component name="CopyrightManager">
<settings default="" />
</component>
================================================
FILE: .idea/gradle.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
<option value="$PROJECT_DIR$/library" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>
================================================
FILE: .idea/markdown-exported-files.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MarkdownExportedFiles">
<htmlFiles />
<imageFiles />
<otherFiles />
</component>
</project>
================================================
FILE: .idea/markdown-navigator/profiles_settings.xml
================================================
<component name="MarkdownNavigator.ProfileManager">
<settings default="" pdf-export="" />
</component>
================================================
FILE: .idea/markdown-navigator.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MarkdownProjectSettings">
<PreviewSettings splitEditorLayout="FIRST" splitEditorPreview="PREVIEW" useGrayscaleRendering="false" zoomFactor="1.0" maxImageWidth="0" showGitHubPageIfSynced="false" allowBrowsingInPreview="false" synchronizePreviewPosition="true" highlightPreviewType="LINE" highlightFadeOut="5" highlightOnTyping="true" synchronizeSourcePosition="true" verticallyAlignSourceAndPreviewSyncPosition="true" showSearchHighlightsInPreview="true" showSelectionInPreview="true">
<PanelProvider>
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.panel" providerName="Default - Swing" />
</PanelProvider>
</PreviewSettings>
<ParserSettings gitHubSyntaxChange="false">
<PegdownExtensions>
<option name="ABBREVIATIONS" value="false" />
<option name="ANCHORLINKS" value="true" />
<option name="ASIDE" value="false" />
<option name="ATXHEADERSPACE" value="false" />
<option name="AUTOLINKS" value="true" />
<option name="DEFINITIONS" value="true" />
<option name="DEFINITION_BREAK_DOUBLE_BLANK_LINE" value="false" />
<option name="FENCED_CODE_BLOCKS" value="true" />
<option name="FOOTNOTES" value="false" />
<option name="HARDWRAPS" value="true" />
<option name="INSERTED" value="false" />
<option name="QUOTES" value="false" />
<option name="RELAXEDHRULES" value="true" />
<option name="SMARTS" value="false" />
<option name="STRIKETHROUGH" value="true" />
<option name="SUBSCRIPT" value="false" />
<option name="SUPERSCRIPT" value="false" />
<option name="SUPPRESS_HTML_BLOCKS" value="false" />
<option name="SUPPRESS_INLINE_HTML" value="false" />
<option name="TABLES" value="true" />
<option name="TASKLISTITEMS" value="true" />
<option name="TOC" value="false" />
<option name="WIKILINKS" value="true" />
</PegdownExtensions>
<ParserOptions>
<option name="COMMONMARK_LISTS" value="false" />
<option name="DUMMY" value="false" />
<option name="EMOJI_SHORTCUTS" value="false" />
<option name="FLEXMARK_FRONT_MATTER" value="false" />
<option name="GFM_LOOSE_BLANK_LINE_AFTER_ITEM_PARA" value="false" />
<option name="GFM_TABLE_RENDERING" value="true" />
<option name="GITBOOK_URL_ENCODING" value="false" />
<option name="GITHUB_EMOJI_URL" value="false" />
<option name="GITHUB_LISTS" value="false" />
<option name="GITHUB_WIKI_LINKS" value="true" />
<option name="JEKYLL_FRONT_MATTER" value="false" />
<option name="SIM_TOC_BLANK_LINE_SPACER" value="false" />
</ParserOptions>
</ParserSettings>
<HtmlSettings headerTopEnabled="false" headerBottomEnabled="false" bodyTopEnabled="false" bodyBottomEnabled="false" embedUrlContent="false" addPageHeader="true">
<GeneratorProvider>
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.generator" providerName="Default Swing HTML Generator" />
</GeneratorProvider>
<headerTop />
<headerBottom />
<bodyTop />
<bodyBottom />
</HtmlSettings>
<CssSettings previewScheme="UI_SCHEME" cssUri="" isCssUriEnabled="false" isCssTextEnabled="false" isDynamicPageWidth="true">
<StylesheetProvider>
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.css" providerName="Default Swing Stylesheet" />
</StylesheetProvider>
<ScriptProviders />
<cssText />
</CssSettings>
<HtmlExportSettings updateOnSave="false" parentDir="$ProjectFileDir$" targetDir="$ProjectFileDir$" cssDir="" scriptDir="" plainHtml="false" imageDir="" copyLinkedImages="false" imageUniquifyType="0" targetExt="" useTargetExt="false" noCssNoScripts="false" linkToExportedHtml="true" exportOnSettingsChange="true" regenerateOnProjectOpen="false" />
<LinkMapSettings>
<textMaps />
</LinkMapSettings>
</component>
</project>
================================================
FILE: .idea/misc.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
<component name="masterDetails">
<states>
<state key="ProjectJDKs.UI">
<settings>
<last-edited>1.8</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>
================================================
FILE: .idea/modules.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/AndroidPerformanceTools.iml" filepath="$PROJECT_DIR$/AndroidPerformanceTools.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
<module fileurl="file://$PROJECT_DIR$/library/library.iml" filepath="$PROJECT_DIR$/library/library.iml" />
</modules>
</component>
</project>
================================================
FILE: .idea/runConfigurations.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
================================================
FILE: .idea/vcs.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
================================================
FILE: LICENSE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
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.
================================================
FILE: README.md
================================================
# AndroidPerformanceTools
本项目用于整理安卓性能监测方案,如果你有不错的方案推荐,欢迎给我提个Issue!
## Features
- 检测卡顿,并dump出卡顿发生时所有的堆栈信息,定位到卡顿源头。实现原理:[Android卡顿检测方案](http://blog.coderclock.com/2017/06/04/android/AndroidPerformanceTools-BlockLooper/)
## Usage
本项目目前没有打包上传至JCenter上,只能通过引入lib的方式进行使用,功能代码全部在library工程中,使用Demo在app工程中。
## Reference
感谢以下提供思路的(开源/闭源)项目!
- https://github.com/SalomonBrys/ANR-WatchDog
================================================
FILE: app/.gitignore
================================================
/build
================================================
FILE: app/build.gradle
================================================
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.clock.performance.tools"
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.3.1'
compile project(':library')
}
================================================
FILE: app/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in D:\Android\sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
================================================
FILE: app/src/main/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.clock.performance.tools">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:name=".AndroidPerformanceToolsApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".block.BlockSamplesActivity"
android:label="@string/block_samples_activity_name" />
<receiver
android:name=".block.BlockReceiver"
android:enabled="true"
android:exported="false">
<intent-filter>
<action android:name="com.clock.performance.tools.block" />
</intent-filter>
</receiver>
</application>
</manifest>
================================================
FILE: app/src/main/java/com/clock/performance/tools/AndroidPerformanceToolsApplication.java
================================================
package com.clock.performance.tools;
import android.app.Application;
import com.performance.tools.block.BlockError;
import com.performance.tools.block.BlockLooper;
/**
* Created by Clock on 2017/5/16.
*/
public class AndroidPerformanceToolsApplication extends Application {
private final static String TAG = AndroidPerformanceToolsApplication.class.getSimpleName();
@Override
public void onCreate() {
super.onCreate();
BlockLooper.initialize(new BlockLooper.Builder(this)
.setFrequency(5000)//超过5s为卡顿
.setIgnoreDebugger(true)//是否忽略调试引起的卡顿
.setReportAllThreadInfo(true) //是否打印出卡顿发生时所有线程的堆栈信息
.setSaveLog(true)//是否保存到log信息到文件
.setOnBlockListener(new BlockLooper.OnBlockListener() {//当卡顿发生时的回调接口,回调过程发生在异步线程中
@Override
public void onBlock(BlockError blockError) {
blockError.printStackTrace();
}
})
.build());
}
}
================================================
FILE: app/src/main/java/com/clock/performance/tools/MainActivity.java
================================================
package com.clock.performance.tools;
import android.Manifest;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import com.clock.performance.tools.block.BlockSamplesActivity;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private final static int NEED_PERMISSION_REQUEST_CODE = 1000;
private final static String[] NEED_PERMISSIONS = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
requestRuntimePermission();
}
findViewById(R.id.btn_anr_samples).setOnClickListener(this);
}
private void requestRuntimePermission() {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) !=
PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
new AlertDialog.Builder(this)
.setTitle("权限申请")
.setMessage("为了应用能够正常使用,现在需要申请相应权限")
.setNeutralButton("一键申请", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
ActivityCompat.requestPermissions(MainActivity.this, NEED_PERMISSIONS, NEED_PERMISSION_REQUEST_CODE);
}
});
} else {
ActivityCompat.requestPermissions(MainActivity.this, NEED_PERMISSIONS, NEED_PERMISSION_REQUEST_CODE);
}
}
}
@Override
public void onClick(View view) {
int viewId = view.getId();
if (viewId == R.id.btn_anr_samples) {
Intent anrSamplesIntent = new Intent(this, BlockSamplesActivity.class);
startActivity(anrSamplesIntent);
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == NEED_PERMISSION_REQUEST_CODE) {
boolean isAllGranted = true;
for (int index = 0; index < permissions.length; index++) {
if (grantResults[index] != PackageManager.PERMISSION_GRANTED) {
isAllGranted = false;
}
}
if (!isAllGranted) {
Toast.makeText(this, "部分权限未授予,可能导致应用无法正常使用", Toast.LENGTH_SHORT).show();
}
}
}
}
================================================
FILE: app/src/main/java/com/clock/performance/tools/block/BlockReceiver.java
================================================
package com.clock.performance.tools.block;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
public class BlockReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
================================================
FILE: app/src/main/java/com/clock/performance/tools/block/BlockSamplesActivity.java
================================================
package com.clock.performance.tools.block;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Toast;
import com.clock.performance.tools.R;
import com.performance.tools.block.BlockLooper;
public class BlockSamplesActivity extends AppCompatActivity implements View.OnClickListener {
private Object lockObj = new Object();
private Handler uiHandler = new Handler();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_anr_samples);
findViewById(R.id.btn_start_looper).setOnClickListener(this);
findViewById(R.id.btn_stop_looper).setOnClickListener(this);
findViewById(R.id.btn_ui_thread_create_anr).setOnClickListener(this);
findViewById(R.id.btn_worker_thread_create_anr).setOnClickListener(this);
findViewById(R.id.btn_send_broadcast).setOnClickListener(this);
}
@Override
public void onClick(View view) {
int viewId = view.getId();
if (viewId == R.id.btn_start_looper) {
BlockLooper.getBlockLooper().start();
} else if (viewId == R.id.btn_stop_looper) {
BlockLooper.getBlockLooper().stop();
} else if (viewId == R.id.btn_ui_thread_create_anr) {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
} else if (viewId == R.id.btn_worker_thread_create_anr) {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... voids) {
synchronized (lockObj) {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
return null;
}
}.execute();
uiHandler.postDelayed(new Runnable() {
@Override
public void run() {
synchronized (lockObj) {
Toast.makeText(BlockSamplesActivity.this, "hello anr", Toast.LENGTH_SHORT).show();
}
}
}, 1000);
} else if (viewId == R.id.btn_send_broadcast){
Intent intent = new Intent();
intent.setAction("com.clock.performance.tools.block");
sendBroadcast(intent);
}
}
}
================================================
FILE: app/src/main/res/layout/activity_anr_samples.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp"
tools:context="com.clock.performance.tools.block.BlockSamplesActivity">
<ProgressBar
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center_horizontal" />
<Button
android:id="@+id/btn_start_looper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="start ANRLooper" />
<Button
android:id="@+id/btn_stop_looper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="stop ANRLooper" />
<Button
android:id="@+id/btn_ui_thread_create_anr"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="UI线程来个ANR" />
<Button
android:id="@+id/btn_worker_thread_create_anr"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Worker线程来个ANR" />
<Button
android:id="@+id/btn_send_broadcast"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="发送个造成卡顿的广播" />
</LinearLayout>
================================================
FILE: app/src/main/res/layout/activity_main.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp"
tools:context="com.clock.performance.tools.MainActivity">
<Button
android:id="@+id/btn_anr_samples"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ANR Samples" />
</LinearLayout>
================================================
FILE: app/src/main/res/values/colors.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>
================================================
FILE: app/src/main/res/values/strings.xml
================================================
<resources>
<string name="app_name">AndroidPerformanceTools</string>
<string name="block_samples_activity_name">BlockSamples</string>
</resources>
================================================
FILE: app/src/main/res/values/styles.xml
================================================
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
================================================
FILE: build.gradle
================================================
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
================================================
FILE: gradle/wrapper/gradle-wrapper.properties
================================================
#Tue May 16 16:00:22 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
================================================
FILE: gradle.properties
================================================
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
================================================
FILE: gradlew
================================================
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
================================================
FILE: gradlew.bat
================================================
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
================================================
FILE: library/.gitignore
================================================
/build
================================================
FILE: library/build.gradle
================================================
apply plugin: 'com.android.library'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
================================================
FILE: library/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in F:\android-sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
================================================
FILE: library/src/androidTest/java/com/performance/tools/ExampleInstrumentedTest.java
================================================
package com.performance.tools;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.performance.tools.test", appContext.getPackageName());
}
}
================================================
FILE: library/src/main/AndroidManifest.xml
================================================
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.performance.tools">
<application android:allowBackup="true" android:label="@string/app_name"
android:supportsRtl="true">
</application>
</manifest>
================================================
FILE: library/src/main/java/com/performance/tools/block/BlockError.java
================================================
package com.performance.tools.block;
import android.os.Looper;
import java.util.Comparator;
import java.util.Map;
import java.util.TreeMap;
/**
* Created by Clock on 2017/5/16.
*/
public class BlockError extends Error {
private BlockError(ThreadStackInfoWrapper.ThreadStackInfo threadStackInfo) {
super("BlockLooper Catch BlockError", threadStackInfo);
}
public static BlockError getUiThread() {
Thread uiThread = Looper.getMainLooper().getThread();
StackTraceElement[] stackTraceElements = uiThread.getStackTrace();
ThreadStackInfoWrapper.ThreadStackInfo threadStackInfo = new ThreadStackInfoWrapper(getThreadNameAndState(uiThread), stackTraceElements)
.new ThreadStackInfo(null);
return new BlockError(threadStackInfo);
}
public static BlockError getAllThread() {
final Thread uiThread = Looper.getMainLooper().getThread();
Map<Thread, StackTraceElement[]> stackTraceElementMap = new TreeMap<Thread, StackTraceElement[]>(new Comparator<Thread>() {
@Override
public int compare(Thread lhs, Thread rhs) {
if (lhs == rhs) {
return 0;
} else if (lhs == uiThread) {
return 1;
} else if (rhs == uiThread) {
return -1;
}
return rhs.getName().compareTo(lhs.getName());
}
});
for (Map.Entry<Thread, StackTraceElement[]> entry : Thread.getAllStackTraces().entrySet()) {
Thread key = entry.getKey();
StackTraceElement[] value = entry.getValue();
if (value.length > 0) {
stackTraceElementMap.put(key, value);
}
}
//Fix有时候Thread.getAllStackTraces()不包含UI线程的问题
if (!stackTraceElementMap.containsKey(uiThread)) {
stackTraceElementMap.put(uiThread, uiThread.getStackTrace());
}
ThreadStackInfoWrapper.ThreadStackInfo threadStackInfo = null;
for (Map.Entry<Thread, StackTraceElement[]> entry : stackTraceElementMap.entrySet()) {
Thread key = entry.getKey();
StackTraceElement[] value = entry.getValue();
threadStackInfo = new ThreadStackInfoWrapper(getThreadNameAndState(key), value).
new ThreadStackInfo(threadStackInfo);
}
return new BlockError(threadStackInfo);
}
public static String getThreadNameAndState(Thread thread) {
return thread.getName() + "-state-" + thread.getState();
}
private static class ThreadStackInfoWrapper {
private String nameAndState;
private StackTraceElement[] stackTraceElements;
private ThreadStackInfoWrapper(String nameAndState, StackTraceElement[] stackTraceElements) {
this.nameAndState = nameAndState;
this.stackTraceElements = stackTraceElements;
}
private class ThreadStackInfo extends Throwable {
private ThreadStackInfo(Throwable throwable) {
super(nameAndState, throwable);
}
@Override
public synchronized Throwable fillInStackTrace() {
setStackTrace(stackTraceElements);
return this;
}
}
}
}
================================================
FILE: library/src/main/java/com/performance/tools/block/BlockLooper.java
================================================
package com.performance.tools.block;
import android.content.Context;
import android.os.Debug;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import com.performance.tools.utils.StorageUtils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* BlockLooper
* <p>
* 使用线程轮询的方式监听App是否产生卡顿
* <p>
* Created by Clock 2017/5/16.
*/
public class BlockLooper implements Runnable {
private final static String TAG = BlockLooper.class.getSimpleName();
private final static String LOOPER_NAME = "block-looper-thread";
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyyMMdd-HH-mm-ss");
/**
* 最小的轮询频率(单位:ms)
*/
private final static long MIN_FREQUENCY = 500;
private static BlockLooper sLooper;
private Context appContext;
private Handler uiHandler = new Handler(Looper.getMainLooper());
private volatile int tickCounter = 0;
private Runnable ticker = new Runnable() {
@Override
public void run() {
tickCounter = (tickCounter + 1) % Integer.MAX_VALUE;
}
};
private long frequency;
private boolean ignoreDebugger;
private boolean reportAllThreadInfo;
private boolean saveLog;
private OnBlockListener onBlockListener;
private boolean isStop = true;
public static void initialize(Configuration configuration) {
if (sLooper == null) {
synchronized (BlockLooper.class) {
if (sLooper == null) {
sLooper = new BlockLooper();
}
}
sLooper.init(configuration);
}
}
public static BlockLooper getBlockLooper() {
if (sLooper == null) {
throw new IllegalStateException("未使用initialize方法初始化BlockLooper");
}
return sLooper;
}
private BlockLooper() {
}
private void init(Configuration configuration) {
this.appContext = configuration.appContext;
this.frequency = configuration.frequency < MIN_FREQUENCY ? MIN_FREQUENCY : configuration.frequency;
this.ignoreDebugger = configuration.ignoreDebugger;
this.reportAllThreadInfo = configuration.reportAllThreadInfo;
this.onBlockListener = configuration.onBlockListener;
this.saveLog = configuration.saveLog;
}
@Override
public void run() {
int lastTickNumber;
while (!isStop) {
lastTickNumber = tickCounter;
uiHandler.post(ticker);
try {
Thread.sleep(frequency);
} catch (InterruptedException e) {
e.printStackTrace();
break;
}
if (lastTickNumber == tickCounter) {
if (!ignoreDebugger && Debug.isDebuggerConnected()) {
Log.w(TAG, "当前由调试模式引起消息阻塞引起ANR,可以通过setIgnoreDebugger(true)来忽略调试模式造成的ANR");
continue;
}
BlockError blockError;
if (!reportAllThreadInfo) {
blockError = BlockError.getUiThread();
} else {
blockError = BlockError.getAllThread();
}
if (onBlockListener != null) {
onBlockListener.onBlock(blockError);
}
if (saveLog) {
if (StorageUtils.isMounted()) {
File logDir = getLogDirectory();
saveLogToSdcard(blockError, logDir);
} else {
Log.w(TAG, "sdcard is unmounted");
}
}
}
}
}
private void saveLogToSdcard(BlockError blockError, File dir) {
if (blockError == null) {
return;
}
if (dir != null && dir.exists() && dir.isDirectory()) {
String fileName = getLogFileName();
File logFile = new File(dir, fileName);
if (!logFile.exists()) {
try {
logFile.createNewFile();
PrintStream printStream = new PrintStream(new FileOutputStream(logFile, false), true);
blockError.printStackTrace(printStream);
printStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
private File getLogDirectory() {
File cacheDir = appContext.getExternalCacheDir();
if (cacheDir != null) {
File logDir = new File(cacheDir, "block");
if (!logDir.exists()) {
boolean successful = logDir.mkdirs();
if (successful) {
return logDir;
} else {
return null;
}
} else {
return logDir;
}
}
return null;
}
private String getLogFileName() {
String timeStampString = DATE_FORMAT.format(new Date());
String fileName = timeStampString + ".trace";
return fileName;
}
public synchronized void start() {
if (isStop) {
isStop = false;
Thread blockThread = new Thread(this);
blockThread.setName(LOOPER_NAME);
blockThread.start();
}
}
public synchronized void stop() {
if (!isStop) {
isStop = true;
}
}
public static class Builder {
private Context appContext;
private long frequency;
private boolean ignoreDebugger;
private boolean reportAllThreadInfo = false;
private boolean saveLog;
private OnBlockListener onBlockListener;
public Builder(Context appContext) {
this.appContext = appContext;
}
public Builder setFrequency(long frequency) {
this.frequency = frequency;
return this;
}
/**
* 设置是否忽略debugger模式引起的卡顿
*
* @param ignoreDebugger
* @return
*/
public Builder setIgnoreDebugger(boolean ignoreDebugger) {
this.ignoreDebugger = ignoreDebugger;
return this;
}
/**
* 设置发生卡顿时,是否上报所有的线程信息,默认是false
*
* @param reportAllThreadInfo
* @return
*/
public Builder setReportAllThreadInfo(boolean reportAllThreadInfo) {
this.reportAllThreadInfo = reportAllThreadInfo;
return this;
}
public Builder setSaveLog(boolean saveLog) {
this.saveLog = saveLog;
return this;
}
/**
* 设置发生卡顿时的回调
*
* @param onBlockListener
* @return
*/
public Builder setOnBlockListener(OnBlockListener onBlockListener) {
this.onBlockListener = onBlockListener;
return this;
}
public Configuration build() {
Configuration configuration = new Configuration();
configuration.appContext = appContext;
configuration.frequency = frequency;
configuration.ignoreDebugger = ignoreDebugger;
configuration.reportAllThreadInfo = reportAllThreadInfo;
configuration.saveLog = saveLog;
configuration.onBlockListener = onBlockListener;
return configuration;
}
}
private static class Configuration {
private Context appContext;
private long frequency;
private boolean ignoreDebugger;
private boolean reportAllThreadInfo;
private boolean saveLog;
private OnBlockListener onBlockListener;
}
public static interface OnBlockListener {
/**
* 发生ANR时产生回调(在非UI线程中回调)
*
* @param blockError
*/
public void onBlock(BlockError blockError);
}
}
================================================
FILE: library/src/main/java/com/performance/tools/utils/StorageUtils.java
================================================
package com.performance.tools.utils;
import android.os.Environment;
/**
* Created by Clock on 2017/5/21.
*/
public class StorageUtils {
private StorageUtils() {
}
/**
* SD卡是否挂载
*
* @return
*/
public static boolean isMounted() {
return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState());
}
}
================================================
FILE: library/src/main/res/values/strings.xml
================================================
<resources>
<string name="app_name">library</string>
</resources>
================================================
FILE: library/src/test/java/com/performance/tools/ExampleUnitTest.java
================================================
package com.performance.tools;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
================================================
FILE: settings.gradle
================================================
include ':app', ':library'
gitextract_mhsma7gf/ ├── .gitignore ├── .idea/ │ ├── compiler.xml │ ├── copyright/ │ │ └── profiles_settings.xml │ ├── gradle.xml │ ├── markdown-exported-files.xml │ ├── markdown-navigator/ │ │ └── profiles_settings.xml │ ├── markdown-navigator.xml │ ├── misc.xml │ ├── modules.xml │ ├── runConfigurations.xml │ └── vcs.xml ├── LICENSE ├── README.md ├── app/ │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ ├── java/ │ │ └── com/ │ │ └── clock/ │ │ └── performance/ │ │ └── tools/ │ │ ├── AndroidPerformanceToolsApplication.java │ │ ├── MainActivity.java │ │ └── block/ │ │ ├── BlockReceiver.java │ │ └── BlockSamplesActivity.java │ └── res/ │ ├── layout/ │ │ ├── activity_anr_samples.xml │ │ └── activity_main.xml │ └── values/ │ ├── colors.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── gradle/ │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew ├── gradlew.bat ├── library/ │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src/ │ ├── androidTest/ │ │ └── java/ │ │ └── com/ │ │ └── performance/ │ │ └── tools/ │ │ └── ExampleInstrumentedTest.java │ ├── main/ │ │ ├── AndroidManifest.xml │ │ ├── java/ │ │ │ └── com/ │ │ │ └── performance/ │ │ │ └── tools/ │ │ │ ├── block/ │ │ │ │ ├── BlockError.java │ │ │ │ └── BlockLooper.java │ │ │ └── utils/ │ │ │ └── StorageUtils.java │ │ └── res/ │ │ └── values/ │ │ └── strings.xml │ └── test/ │ └── java/ │ └── com/ │ └── performance/ │ └── tools/ │ └── ExampleUnitTest.java └── settings.gradle
SYMBOL INDEX (52 symbols across 9 files)
FILE: app/src/main/java/com/clock/performance/tools/AndroidPerformanceToolsApplication.java
class AndroidPerformanceToolsApplication (line 12) | public class AndroidPerformanceToolsApplication extends Application {
method onCreate (line 16) | @Override
FILE: app/src/main/java/com/clock/performance/tools/MainActivity.java
class MainActivity (line 18) | public class MainActivity extends AppCompatActivity implements View.OnCl...
method onCreate (line 24) | @Override
method requestRuntimePermission (line 35) | private void requestRuntimePermission() {
method onClick (line 54) | @Override
method onRequestPermissionsResult (line 63) | @Override
FILE: app/src/main/java/com/clock/performance/tools/block/BlockReceiver.java
class BlockReceiver (line 8) | public class BlockReceiver extends BroadcastReceiver {
method onReceive (line 10) | @Override
FILE: app/src/main/java/com/clock/performance/tools/block/BlockSamplesActivity.java
class BlockSamplesActivity (line 14) | public class BlockSamplesActivity extends AppCompatActivity implements V...
method onCreate (line 20) | @Override
method onClick (line 33) | @Override
FILE: library/src/androidTest/java/com/performance/tools/ExampleInstrumentedTest.java
class ExampleInstrumentedTest (line 17) | @RunWith(AndroidJUnit4.class)
method useAppContext (line 19) | @Test
FILE: library/src/main/java/com/performance/tools/block/BlockError.java
class BlockError (line 13) | public class BlockError extends Error {
method BlockError (line 15) | private BlockError(ThreadStackInfoWrapper.ThreadStackInfo threadStackI...
method getUiThread (line 20) | public static BlockError getUiThread() {
method getAllThread (line 29) | public static BlockError getAllThread() {
method getThreadNameAndState (line 70) | public static String getThreadNameAndState(Thread thread) {
class ThreadStackInfoWrapper (line 75) | private static class ThreadStackInfoWrapper {
method ThreadStackInfoWrapper (line 80) | private ThreadStackInfoWrapper(String nameAndState, StackTraceElemen...
class ThreadStackInfo (line 85) | private class ThreadStackInfo extends Throwable {
method ThreadStackInfo (line 87) | private ThreadStackInfo(Throwable throwable) {
method fillInStackTrace (line 91) | @Override
FILE: library/src/main/java/com/performance/tools/block/BlockLooper.java
class BlockLooper (line 27) | public class BlockLooper implements Runnable {
method run (line 42) | @Override
method initialize (line 55) | public static void initialize(Configuration configuration) {
method getBlockLooper (line 66) | public static BlockLooper getBlockLooper() {
method BlockLooper (line 73) | private BlockLooper() {
method init (line 76) | private void init(Configuration configuration) {
method run (line 85) | @Override
method saveLogToSdcard (line 129) | private void saveLogToSdcard(BlockError blockError, File dir) {
method getLogDirectory (line 149) | private File getLogDirectory() {
method getLogFileName (line 167) | private String getLogFileName() {
method start (line 173) | public synchronized void start() {
method stop (line 182) | public synchronized void stop() {
class Builder (line 188) | public static class Builder {
method Builder (line 196) | public Builder(Context appContext) {
method setFrequency (line 200) | public Builder setFrequency(long frequency) {
method setIgnoreDebugger (line 211) | public Builder setIgnoreDebugger(boolean ignoreDebugger) {
method setReportAllThreadInfo (line 222) | public Builder setReportAllThreadInfo(boolean reportAllThreadInfo) {
method setSaveLog (line 227) | public Builder setSaveLog(boolean saveLog) {
method setOnBlockListener (line 238) | public Builder setOnBlockListener(OnBlockListener onBlockListener) {
method build (line 243) | public Configuration build() {
class Configuration (line 255) | private static class Configuration {
type OnBlockListener (line 264) | public static interface OnBlockListener {
method onBlock (line 270) | public void onBlock(BlockError blockError);
FILE: library/src/main/java/com/performance/tools/utils/StorageUtils.java
class StorageUtils (line 9) | public class StorageUtils {
method StorageUtils (line 11) | private StorageUtils() {
method isMounted (line 20) | public static boolean isMounted() {
FILE: library/src/test/java/com/performance/tools/ExampleUnitTest.java
class ExampleUnitTest (line 12) | public class ExampleUnitTest {
method addition_isCorrect (line 13) | @Test
Condensed preview — 43 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (64K chars).
[
{
"path": ".gitignore",
"chars": 118,
"preview": "*.iml\n.gradle\n/local.properties\n/.idea/workspace.xml\n/.idea/libraries\n.DS_Store\n/build\n/captures\n.externalNativeBuild\n"
},
{
"path": ".idea/compiler.xml",
"chars": 686,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n <component name=\"CompilerConfiguration\">\n <resourceExt"
},
{
"path": ".idea/copyright/profiles_settings.xml",
"chars": 74,
"preview": "<component name=\"CopyrightManager\">\n <settings default=\"\" />\n</component>"
},
{
"path": ".idea/gradle.xml",
"chars": 679,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n <component name=\"GradleSettings\">\n <option name=\"linke"
},
{
"path": ".idea/markdown-exported-files.xml",
"chars": 185,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n <component name=\"MarkdownExportedFiles\">\n <htmlFiles /"
},
{
"path": ".idea/markdown-navigator/profiles_settings.xml",
"chars": 104,
"preview": "<component name=\"MarkdownNavigator.ProfileManager\">\n <settings default=\"\" pdf-export=\"\" />\n</component>"
},
{
"path": ".idea/markdown-navigator.xml",
"chars": 4111,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n <component name=\"MarkdownProjectSettings\">\n <PreviewSe"
},
{
"path": ".idea/misc.xml",
"chars": 2644,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n <component name=\"EntryPointsManager\">\n <entry_points v"
},
{
"path": ".idea/modules.xml",
"chars": 496,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n <component name=\"ProjectModuleManager\">\n <modules>\n "
},
{
"path": ".idea/runConfigurations.xml",
"chars": 564,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n <component name=\"RunConfigurationProducerService\">\n <o"
},
{
"path": ".idea/vcs.xml",
"chars": 180,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n <component name=\"VcsDirectoryMappings\">\n <mapping dire"
},
{
"path": "LICENSE",
"chars": 11357,
"preview": " Apache License\n Version 2.0, January 2004\n "
},
{
"path": "README.md",
"chars": 384,
"preview": "# AndroidPerformanceTools\n\n本项目用于整理安卓性能监测方案,如果你有不错的方案推荐,欢迎给我提个Issue!\n\n## Features\n\n- 检测卡顿,并dump出卡顿发生时所有的堆栈信息,定位到卡顿源头。实现原理"
},
{
"path": "app/.gitignore",
"chars": 7,
"preview": "/build\n"
},
{
"path": "app/build.gradle",
"chars": 707,
"preview": "apply plugin: 'com.android.application'\n\nandroid {\n compileSdkVersion 25\n buildToolsVersion \"25.0.2\"\n defaultCo"
},
{
"path": "app/proguard-rules.pro",
"chars": 916,
"preview": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in D:"
},
{
"path": "app/src/main/AndroidManifest.xml",
"chars": 1375,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n package="
},
{
"path": "app/src/main/java/com/clock/performance/tools/AndroidPerformanceToolsApplication.java",
"chars": 1048,
"preview": "package com.clock.performance.tools;\n\nimport android.app.Application;\n\nimport com.performance.tools.block.BlockError;\nim"
},
{
"path": "app/src/main/java/com/clock/performance/tools/MainActivity.java",
"chars": 3224,
"preview": "package com.clock.performance.tools;\n\nimport android.Manifest;\nimport android.content.DialogInterface;\nimport android.co"
},
{
"path": "app/src/main/java/com/clock/performance/tools/block/BlockReceiver.java",
"chars": 450,
"preview": "package com.clock.performance.tools.block;\n\nimport android.content.BroadcastReceiver;\nimport android.content.Context;\nim"
},
{
"path": "app/src/main/java/com/clock/performance/tools/block/BlockSamplesActivity.java",
"chars": 2699,
"preview": "package com.clock.performance.tools.block;\n\nimport android.content.Intent;\nimport android.os.AsyncTask;\nimport android.o"
},
{
"path": "app/src/main/res/layout/activity_anr_samples.xml",
"chars": 1487,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmln"
},
{
"path": "app/src/main/res/layout/activity_main.xml",
"chars": 567,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmln"
},
{
"path": "app/src/main/res/values/colors.xml",
"chars": 208,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n <color name=\"colorPrimary\">#3F51B5</color>\n <color name=\"color"
},
{
"path": "app/src/main/res/values/strings.xml",
"chars": 155,
"preview": "<resources>\n <string name=\"app_name\">AndroidPerformanceTools</string>\n <string name=\"block_samples_activity_name\">"
},
{
"path": "app/src/main/res/values/styles.xml",
"chars": 383,
"preview": "<resources>\n\n <!-- Base application theme. -->\n <style name=\"AppTheme\" parent=\"Theme.AppCompat.Light.DarkActionBar"
},
{
"path": "build.gradle",
"chars": 498,
"preview": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n r"
},
{
"path": "gradle/wrapper/gradle-wrapper.properties",
"chars": 230,
"preview": "#Tue May 16 16:00:22 CST 2017\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_"
},
{
"path": "gradle.properties",
"chars": 730,
"preview": "# Project-wide Gradle settings.\n\n# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will o"
},
{
"path": "gradlew",
"chars": 4971,
"preview": "#!/usr/bin/env bash\n\n##############################################################################\n##\n## Gradle start "
},
{
"path": "gradlew.bat",
"chars": 2314,
"preview": "@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem "
},
{
"path": "library/.gitignore",
"chars": 7,
"preview": "/build\n"
},
{
"path": "library/build.gradle",
"chars": 568,
"preview": "apply plugin: 'com.android.library'\n\nandroid {\n compileSdkVersion 25\n buildToolsVersion \"25.0.2\"\n\n defaultConfi"
},
{
"path": "library/proguard-rules.pro",
"chars": 916,
"preview": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in F:"
},
{
"path": "library/src/androidTest/java/com/performance/tools/ExampleInstrumentedTest.java",
"chars": 751,
"preview": "package com.performance.tools;\n\nimport android.content.Context;\nimport android.support.test.InstrumentationRegistry;\nimp"
},
{
"path": "library/src/main/AndroidManifest.xml",
"chars": 254,
"preview": "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n\n package=\"com.performance.tools\">\n\n <applica"
},
{
"path": "library/src/main/java/com/performance/tools/block/BlockError.java",
"chars": 3331,
"preview": "package com.performance.tools.block;\n\nimport android.os.Looper;\n\nimport java.util.Comparator;\nimport java.util.Map;\nimpo"
},
{
"path": "library/src/main/java/com/performance/tools/block/BlockLooper.java",
"chars": 8047,
"preview": "package com.performance.tools.block;\n\nimport android.content.Context;\nimport android.os.Debug;\nimport android.os.Handler"
},
{
"path": "library/src/main/java/com/performance/tools/utils/StorageUtils.java",
"chars": 369,
"preview": "package com.performance.tools.utils;\n\nimport android.os.Environment;\n\n/**\n * Created by Clock on 2017/5/21.\n */\n\npublic "
},
{
"path": "library/src/main/res/values/strings.xml",
"chars": 70,
"preview": "<resources>\n <string name=\"app_name\">library</string>\n</resources>\n"
},
{
"path": "library/src/test/java/com/performance/tools/ExampleUnitTest.java",
"chars": 399,
"preview": "package com.performance.tools;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.*;\n\n/**\n * Example local unit tes"
},
{
"path": "settings.gradle",
"chars": 27,
"preview": "include ':app', ':library'\n"
}
]
// ... and 1 more files (download for full content)
About this extraction
This page contains the full source code of the D-clock/AndroidPerformanceTools GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 43 files (56.9 KB), approximately 14.7k tokens, and a symbol index with 52 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.