GraphViz dot
工具
在线编译工具:http://viz-js.com
VSCode安装插件:Graphviz (dot) language support for Visual Studio Code
命令行:dot,比如,dot -Tpng -ofile.png file.dot
可以导出图片。在Ubuntu系统中,通过sudo apt install graphviz
安装即可使用。
添加系统环境变量:
GRAPHVIZ_DOT = D:\Program Files\Graphviz\bin\dot.exe
学习资料
Node Shapes
Graphviz (dot) examples
Node, Edge and Graph Attributes
常用属性介绍
节点(node)属性
节点的形状主要有三种:Polygon-based Nodes, Record-based Nodes, User-defined Nodes。点击链接可看到详细介绍。
属性名称 | 介绍 |
---|---|
shape | 节点形状,box长方形、circle圆形等,参考Node Shapes |
color | 边框颜色 |
style | 节点样式,filled, invisible, diagonals等,参考Styles for Nodes |
fillcolor | 填充颜色, 只有在style=filled时才生效 |
fontcolor | 文字颜色 |
Hexo User Manual
VSCode + Hexo
安装Paste Image插件
安装完插件后,通过 Ctrl + Shift + P
快捷键打开setting.json
然后,在setting.json文件中添加两行配置
1 | "pasteImage.path": "${currentFileNameWithoutExt}/", |
然后就可以使用Ctrl + Alt + V
快捷键就可以粘贴图片到markdown文档中了。但是这个快捷键不一定好使。也可以通过Ctrl + Shift + P
然后输入past image
来粘贴。
插入的图片采用asset_img
语法,关于asset_img详细信息可参考:https://hexo.io/docs/asset-folders。插入的图片将会放到markdown文件同名的文件夹中。
安装Markdown Preview Enhanced插件
Markdown Preview Enhanced插件无法展示使用asset_img
插入的图片,需要修改插件的parser.js
。通过快捷键Ctrl+Shift+P
打开parser.js
:
然后修改onWillParseMarkdown函数:
1 | onWillParseMarkdown: function(markdown) { |
参考文章:
Android binder剖析之addService
本文基于Android 8.0源码分析。以mediaserver为例剖析binder addService的流程。
Android Java虚拟机创建过程
本文基于Android8.0源码
Android8.0使用的java虚拟机为ART,在大名鼎鼎的zygote进程中启动java虚拟机。
首先看一下zygote的main函数:
1 | //app_main.cpp |
runtime.start会调用父类的AndroidRuntime::start,看一下实现
1 | //AndroidRuntime.cpp |
- 加载虚拟机动态库,并加载库函数符号
1 | //JniInvocation.cpp |
- 启动虚拟机
1 | /* |
软件设计原则
SOLID
Single responsibility principle 单一职责
The single responsibility principle is a computer programming principle that states that every module, class, or function should have responsibility over a single part of the functionality provided by the software, and that responsibility should be entirely encapsulated by the class, module or function. All its services should be narrowly aligned with that responsibility. Robert C. Martin expresses the principle as, “A class should have only one reason to change,” although, because of confusion around the word “reason” he more recently stated “This principle is about people.(Actor)”
Martin defines a responsibility as a reason to change, and concludes that a class or module should have one, and only one, reason to be changed (i.e. rewritten). As an example, consider a module that compiles and prints a report. Imagine such a module can be changed for two reasons. First, the content of the report could change. Second, the format of the report could change. These two things change for very different causes; one substantive, and one cosmetic. The single responsibility principle says that these two aspects of the problem are really two separate responsibilities, and should therefore be in separate classes or modules. It would be a bad design to couple two things that change for different reasons at different times.
The reason it is important to keep a class focused on a single concern is that it makes the class more robust. Continuing with the foregoing example, if there is a change to the report compilation process, there is greater danger that the printing code will break if it is part of the same class.
Open–closed principle 开闭原则
Open/closed principle states “software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification”; that is, such an entity can allow its behaviour to be extended without modifying its source code.
The name open/closed principle has been used in two ways. Both ways use generalizations (for instance, inheritance or delegate functions) to resolve the apparent dilemma, but the goals, techniques, and results are different.
Liskov substitution principle 里式替换
APK 反编译
使用的工具
dex转换为jar
1 | d2j-dex2jar.sh -f ~/path/to/apk_to_decompile.apk |
生成jar包后,需要使用JD-GUI打开查看
在macos上打开JD-GUI可能会报下面错误:
1 | No suitable Java version found on your system! |
解决方案:在JD-GUI应用程序右击,然后选择“显示包内容”,然后打开Contents/MacOS/universalJavaApplicationStub.sh
文件,找到这个报错的打印位置,把JAVA_HOME赋值为jdk home路径即可。
反编译为Smali
1 | java -jar apktool_2.8.1.jar decode -o apk_smali app.apk |