adb shell dumpsys SurfaceFlinger
1. dump window
adb shell dumpsys window
2. dump window with details
adb shell dumpsys window all
3. dump visible window
adb shell dumpsys window visible
Dump activity information
adb shell dumpsys activity
//dump all visible layers
adb shell service call SurfaceFlinger 4000 i32 0
//dump all visible layers with corresponding buffers
adb shell service call SurfaceFlinger 4000 i32 1
//Output folder path:
adb pull /data/layerdump/
import android.graphics.Bitmap;
import java.io.FileOutputStream;
void captureView(View view, String filename) {
Bitmap bitmap = view.createSnapshot(Bitmap.Config.ARGB_8888, 0, false);
if (bitmap != null) {
try {
FileOutputStream out = new FileOutputStream(filename);
Log.d(TAG, "capture++ " + mWindowAttributes.getTitle());
bitmap.compress(Bitmap.CompressFormat.PNG, 90, out);
Log.d(TAG, "capture-- " + mWindowAttributes.getTitle());
} catch (Exception e) {
Log.d(TAG, "Exception " + mWindowAttributes.getTitle(), new RuntimeException().fillInStackTrace());
}
} else {
Log.d(TAG, "bitmap=null " + mWindowAttributes.getTitle());
}
}
1. adb shell "echo profiler.debug.disable_hw_accel=1 > /data/local.prop"
2. adb shell chmod 644 /data/local.prop
3. adb reboot
1. code
boolean bValue = SystemProperties.getBoolean("view.debug.stopped_false", false);
2. get
adb shell getprop view.debug.stopped_false
3. set
adb shell setprop view.debug.stopped_false 1
// debug gestureDetector
adb shell setprop debug.gesture.verbose 1
// logs like these
03-07 11:07:59.840 7016 7016 D InputEventReceiver dispatchInputEvent - MotionEvent { action=ACTION_DOWN, id0=0, x0=322.65366, y0=156.15866, toolType0=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=4595278, downTime=4595278, deviceId=5, source=0x1002 }
03-07 11:07:59.840 7016 7016 D GestureDetector MotionEvent { action=ACTION_DOWN, id0=0, x0=322.65366, y0=50.15866, toolType0=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=4595278, downTime=4595278, deviceId=5, source=0x1002 }
03-07 11:07:59.840 7016 7016 D GestureDetector et(4595278) MotionEvent.ACTION_DOWN: mDownFocusX=322.65366, mLastFocusX=322.65366, focusX=322.65366
03-07 11:07:59.840 7016 7016 D GestureDetector et(4595278) MotionEvent.ACTION_DOWN: onDown()
03-07 11:07:59.840 7016 7016 D InputEventReceiver finishInputEvent - MotionEvent { action=ACTION_DOWN, id0=0, x0=322.65366, y0=156.15866, toolType0=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=4595278, downTime=4595278, deviceId=5, source=0x1002 }
adb shell am broadcast -a android.intent.action.DOCK_EVENT --ei android.intent.extra.DOCK_STATE 2
recovery
adb shell am broadcast -a android.intent.action.DOCK_EVENT --ei android.intent.extra.DOCK_STATE 1
ViewServer
[Turn On] adb shell service call window 1 i32 4939
[Turn Off] adb shell service call window 2 i32 4939
Debug view focus mechanism
I think the original way to build framework.jar is not efficient. It needs 19G storage and about 3 hours to build the out folder.
Here is the way to build the necessary files and it only needs about 700MB and about 4 minutes.
It can save our time and storage if you only need framework.jar.
Share the tips for you. You may use the similar way for the modules you need.
[original]
. build/envsetup.sh ; partner_setup evitareul EvitareUL_Generic_WWE_DEBUG ; make -j8 PRODUCT-evitareul-userdebug;
<framework.jar only>
cd framework/base
mm –j8 PRODUCT-evitareul-userdebug
[Efficient way]
. build/envsetup.sh ; partner_setup evitareul EvitareUL_Generic_WWE_DEBUG; add_lunch_combo evitareul-userdebug; lunch evitareul-userdebug; time make -j8 framework
<framework.jar only>
time mmm -j8 frameworks/base
[tips]
1. I use “make framework” to build the dependency for framework.jar. However, I can’t use something like “make framework PRODUCT-evitareul-userdebug”. That’s why I need “lunch” to setup TARGET_BUILD_VARIANT=userdebug instead of eng.
2. time is optional. I use it to check the build time.
[make modules commands]
make framework
mmm frameworks/base
make services
make HTCCommonctrl
mmm packages/modules/HTCCommonControl/java/
make com.htc.resources
make android.policy
- list all modules
make modules
get latest code
$ repo sync
# upload your patch START
# [format] repo start <name> <path>
$ repo start kenzyun customize/base/
$ cd customize/base
$ git add –i
$ git commit
# if you want to edit again, type "git commit --amend"
$ repo upload
# upload your patch END
# abandon this commit and get latest code after your patch merged
$ repo abandon kenzyun
$ repo sync
# example1 : whole new patch
$ repo start kenzyun customize/base/
$ cd customize/base
$ git add –i
$ git commit
$ repo upload
# example2 : modify your patch on Gerrit after repo upload
$ git add –i
$ git commit --amend
$ repo upload
# repo abandon <name>
$ repo abandon mark
# sync error because some files check out
$ go to the patch for your module
$ git checkout HEAD .
# example
$ cd customize/base
$ git checkout HEAD .
$ cd..
$ cd ..
$ repo sync
build jar file
U1_Tech._Presentation
Item No. Title(Link) Owner Date
1 Smali mechanism to build framework, Smali Tool Riddle Hsu 22 May 2013
Tips :
You need ViewDebug.java when you want to replace View.java or ViewGroup.java.
Add this line to /data/local.prop or /system/build.prop
dalvik.vm.dexopt-flags = v=n
Tips : make sure chmod 644 for local.prop / build.prop
Reference : http://www.netmite.com/android/mydroid/dalvik/docs/dexopt.html
By testing on my M7, it takes 3 minutes to do dalvik optimization and verification.
After disabling verification, it only takes 1 minute to do optimization.
Add this line to /data/local.prop or /system/build.prop
dalvik.vm.dex2oat-flags = --compiler-filter=verify-none
Tips : make sure chmod 644 for local.prop / build.prop
Reference : https://github.com/anestisb/oatdump_plus/blob/master/Android.mk
Smali Tool extended by Kenzyun Chen
./odex_build_framework_lite.sh <folderName> <jarFileName>
Ex: ./odex_build_framework_lite.sh M7 services
Reference : http://forum.xda-developers.com/galaxy-s2/themes-apps/how-to-manually-deodex-odex-t1208320
DEBUG_INPUT_RESIZE : help to clarify mScrollY value for EditText is covered by IME case.
Java
1. set break point by eclipse
2. use traceview, and open the trace log by htc LogAnalyzer
3. print callstack
Log.v(TAG, "dirty.isEmpty()", new RuntimeException().fillInStackTrace());
C++
#include <utils/CallStack.h>
android::CallStack stack("Tag Name");
ACC http://masd:43000/
http://10.116.65.253:10101/images/e/e5/New_Customization_API_Guides.pdf
/system/customize/ACC/default.xml
<app name="Android_App_Framework">
<item type="boolean" name="support_pen_event">true</item>
</app>
adb pull /system/customize/ACC/default.xml
1. pull ACC setting xml from device
adb pull /system/customize/ACC/default.xml
2. modify or add the key value
example: modify app name="Android_App_Framework", and key name="support_pen_event" to true
<app name="Android_App_Framework">
<item type="boolean" name="support_pen_event">true</item>
</app>
example : modify system, and key name="device_type"
<system>
<item type="integer" name="device_type">1</item>
</system>
3. push ACC setting xml to device
adb remount
adb push default.xml /system/customize/ACC/
adb reboot
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
Printer p = new PrintWriterPrinter(pw);
mHandler.getLooper().dump(p, "");
Slog.i(TAG, sw.toString());