qqApk反编译:
android,开一个QQ,后台显示运行3个QQ程序:QQ的运行组件;配置文件780行;12个service;15个receiver;309个activity;
<manifest **>
<permission android:name="com.tencent.msf.service.permission" android:protectionLevel="signature" />
<permission android:name="com.tencent.msf.permission.account.sync" android:protectionLevel="normal" android:permissionGroup="android.permission-group.SYSTEM_TOOLS" />
<permission android:name="com.tencent.mobileqq.activity.starterreceiver.permission.OWNER" android:protectionLevel="signature" />
<service android:name="com.tencent.mobileqq.msf.service.MsfService" android:exported="true" android:process=":MSF">
<intent-filter><action android:name="com.tencent.qphone.base.subservice" /></intent-filter>
</service>
<service android:name="com.tencent.mobileqq.msf.core.wtlogin.WtLoginService" android:process=":MSF" />
<service android:name=".app.CoreService" />
<receiver android:name="com.tencent.mobileqq.msf.core.NetConnInfoCenter" android:process=":MSF"> ***** </receiver>
<service android:name="com.tencent.mobileqq.emosm.web.MessengerService" android:exported="false" />
<service android:name="com.tencent.av.service.QQServiceForAV" />
<service android:name="com.tencent.av.service.AVServiceForQQ" android:process=":video" />
<service android:name="com.tencent.securemodule.impl.SecureService" android:process=":remote" />
<service android:name="com.tencent.imageservice.ImageProcessService" android:process=":imageservice" />
<service android:name="cooperation.qzone.QzonePluginProxyService" android:process=":qzone" />
<service android:name="cooperation.qzone.QzonePictureViewerProxyService" android:exported="true" android:process=":picture" />
<service android:name="com.tencent.tmassistantsdk.downloadservice.TMAssistantDownloadSDKService" android:exported="false" android:process=":TMAssistantDownloadSDKService" />
<service android:name="com.tencent.mobileqq.service.QQPlayerService" />
</manifest>
android开发小工具:
HierarchyView,弄处正在现实view的结构;
MemoryAnalyzer,内存分析;
AllocationTracker,内存分配跟踪;
Heap,堆内存信息;
DdmsTrace:分析方法调用的次数,调用时间等;
SystemInformation:(CpuLoad,MemoryUsage,FrameRenderTime);
eclipse截屏:Ddms中ScreenCapture; eclipse手机UI信息:Ddms中DumpViewHierarchyForUiAutomator;
测试分析:monkey,monekyrunner,uiautomator,Robotium(同一签名权限),单元测试,启动性能;
启动过程:Init进程->Zygote进程->SystemServer进程->SurfaceFlinger服务; Init是linux启动的第一个进程,Zygote就是由Init进程fork出来的;
SurfaceFlinger直译就是surface的投递者;每个应用在它自己的surface完成各种图形操作后,请求SurfaceFlinger显示到屏幕,surfaceflinger就会将所有的surface叠加起来,并且反映到framebuffer;
SurfaceFlinger服务运行在Android系统的System进程中,它负责管理Android系统的帧缓冲区(FrameBuffer);
SurfaceFlinger.cpp继承了BinderService<SurfaceFlinger>/BnSufaceComposer/IBinder::DeadthRecipient/Thread/HWComposer::EventHandler;
ListView优化:convertView的重复利用(item量大),利用WeakRefference(item量小); scrap,废料;
convertView是在AbsListView类中的obtainView方法中取出来的,mRecycleBin.getScrapView(position);同一个View对象不能同时被展示多次;
调试工具traceView的使用:
内部通过android.os包下,public final class Debug{ *** }实现;//生成的文件存储在/sdcard/dmtrace.trace;
可视图说明,每行下面粗的线段标注了ProfilePanel中被选中函数调用所消耗的时间段,每个线段对应一次函数的运行; Calls+RecurCalls/Total:非递归调用和递归调用的次数; time/calls:表示平均的调用时间;
tcpdump和wireshark使用:
安装tcpdump,$adb root; $adb push tcpdump /data/local/tcpdump; $adb shell chmod 6755 /data/local/tcpdump;
启动tcpdump,$adb shell /data/local/tcpdump -n -s 0; $adb shell /data/local/tcpdump -i any -p -s 0 -w /sdcard/netCapture.pcap; $adb pull /sdcard/netCapture.pcap
wireshark,安装$sudo apt-get install wireshark; $wireshark netCapture.pcap;
DDMS截屏:
DDMS通过adb调用设备端的adbd(ADB daemon)提供的framebuffer service进行截屏(源码在system/core/adb/framebuffer_service.c),在较早版本的Android中,framebuffer service通过直接读framebuffer设备(/dev/graphics/fb0)来截屏,在较新版本的Android中,framebuffer service则调用截屏工具screencap来截屏;
screencap是Android原生自带的工具,是一个C写的可执行文件,在设备上的/system/bin/下面可以找到它,screencap截屏后可保存为PNG格式文件或RGB RAW文件.
screencap的源码在frameworks/base/cmds/screencap/,它调用SurfaceFlinger提供的截屏接口ScreenshotClient,其源码在frameworks/native/include/gui/SurfaceComposerClient.h; ScreenshotClient通过进程间通信调用SurfaceFlinger service的截屏功能,源码在frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp中的函数SurfaceFlinger::captureScreen(*);
在各种截屏方法中,读framebuffer设备(/dev/graphics/fb0)在某些使用硬件overlay显示时可能无法截取到某些画面(例如video playback和camera preview画面),但是SurfaceFlinger提供的上述截屏接口则可以完美截取任何屏幕画面;
截屏操作方法:同时按下电源键和"音量-"键1秒,源码在frameworks/base/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java,调用hide类SurfaceControl的screenshot方法;
SurfaceControl.screenshot(*);//android.view包下hide类; 内部调jni的nativeScreenshot(*); 内部调SurfaceComposerClient.h的,ScreenshotClient::capture(*);