The reason for the slowness is that android uses reflection to query the window elements to get the properties. Since reflection by itself is very performance intensive, it slows down the whole process.
Android uses annotation to mark specific properties to be exported. So every field and method that is marked with the exportedproperty annotation is processed. You have to look into what happens after the the windowmanagerservice issues a binder call. The viewrootimpl which implements the Iwindowimpl interface gets invoked. This invokes the ViewDebug class which does the final processing. If you look into viewdebug class you might get a good idea of how everything works. ~David On Saturday, September 22, 2012 1:34:46 AM UTC-5, Binhua Liu wrote: > > Hi All, > > I am try write a open source tool which need get UI element tree out of > the application, just like hierarchyviewer. but the problem is the way like > hierarchyviewer is too slow, need about 3-5 seconds. > > I have read the code of ViewServer.java and WindowManagerService.java. > In viewServerWindowCommand method of WindowManagerService.java, I see the > request of dumping element tree at last is sent to IWindow object through > binder <http://androidxref.com/4.0.4/s?defs=binder&project=frameworks>. > transact <http://androidxref.com/4.0.4/s?defs=transact&project=frameworks> > method. > But I still have no idea why this way is slow and how can be more faster? > why the test framework -- Robotium can get UI elements so fast? I need get > element tree in black box way. > > this is our opensource projects: github.com/vowei > > Thanks > -- unsubscribe: android-kernel+unsubscr...@googlegroups.com website: http://groups.google.com/group/android-kernel