Bharathi Subramanian

The Social Animal 

ADB Over Network

By default, ADB is connected over the USB. To make ADB connection over network, user need to do few setting on target device:

  1. stop adbd
  2. setprop service.adb.tcp.port 6665
  3. start adbd

Now the ADB will start listen on network interface. Next using the following commands, user can connect to the remote target from PC:

  1. adb connect <Target-IP>:6665
  2. adb shell

 

Filed under  //   android  

Comments [0]

Android Reunite with Linux Kernel

Nearly after 2 yrs, the core Android related Kernel codes are again going into the Linux Kernel Source. Here is the statement from Linux developer Greg Kroah-Hartman to Wired Magazine. Link: http://www.wired.com/wiredenterprise/2012/03/android-linux/

Filed under  //   android   kernel  

Comments [0]

Resistive Touch Screen Interface

I did few touchscreen integrations and like to share some of basic understanding:

Resistive Touch Screen (RTS) is a low cost and easy to integrate solution of touch panels. RTS is available in with 4/5/8 wires interface. From the operation perspective, there is no major difference between different wire interfaces. But more wires will help to increase the accuracy and reduce the impact of the behavior change, due to the temperature.

Block Diagram:

Rts-block
Operation Logic:

RTS is having two conductive layers X-Plane (Top, X+, X-) & Y-Plane (Bottom, Y+, Y-) and both planes are isolated with thin layer of DOTS. In the normal state, X-plane will be powered and Y-plane will be grounded. Whenever user touches the top layer, due to the pressure, a contact will be formed between the layers and there will be a voltage surge. This surge will be detected by the Touch Detection Logic and generates the PEN IRQ interrupt towards the processor. For interrupt, Processor GPIO pin may be used and for the data communication any of the interface (like I2C, SPI, USB, ..) will be used, it depends on the Touch Screen Controller (TSC).

Driver registered for PEN IRQ interrupt will respond and send a command/request to TSC. TSC will start the measurement logic. 1st Y co-ordinate detected, by powering the X-plane and measuring the voltage drop across the resistor network on the Y-plane (Y+,Y-). Next X co-ordinate detected, by powering the Y-plane and measuring the voltage drop across the resistor network on the X-plane (X+, X-). The measured analog voltages will be converted to digital using a ADC. At the end of this measurement cycle, values will be passed back to the processor.

The time difference between the interrupt received and sending the command to get the co-ordinate values, is called debuncing time. If the driver sends this command too early or too late, then end-up with a wrong co-ordinate value. Sometime RTS spec won't give the exact value. So trail and error method may be needed to find the exact value. After receiving this values, if driver continue to detect a PRESS/PEN DOWN, then again start reading the co-ordinate values from TSC, till it detect a PEN UP.

Calibration:
The RTS X/Y co-ordinates, which are read from the TSC, cannot be directly mapped to LCD co-ordinates. So there is a need for co-ordinate calibration/remap arise. There are few formulas are available for this purpose.

Sometime, you may end-up in a situation, where you cannot identify, whether an issue is with the touch screen or controller. During this time, you can use 4 potentiometers/trimmers mimic the touch screen and it connect to TSC. This setup will help to isolate the issues.

For more info:

Filed under  //   android   embedded   kernel   linux  

Comments [0]

Android Socket Communication thru ADB

I hope, most of the Android Developer know about ADB (Android Debugging Bridge) Tool. It is very handy to make a quick connection to target (Emulator or Device) for debugging and has no of useful options (shell, install, push, pull, forward, etc ..). The ADB Forward option is a less used option. It is very useful for making a socket communication between the target and host with-out getting into  complex programming.

Format: adb forward Protocol:HostPort Protocol:TargetPort

Here is a netcat based example, which I tried on the Emulator and HTC Desire (Rooted & Running Cynogen Mod 7).

From Host (GNU/Linux PC):
$ adb forward tcp:12345 tcp:12346
$ nc 127.0.0.1 12345

From Target (after adb shell):
# nc -l -p 12346

whatever string typed on target will appear on host and vice versa. This can be used to forward some command from target to host, etc ..

Filed under  //   android  

Comments [0]

Linux Local Privilege Escalation Bug

Here is the nice write-up about the "Linux (2.6.39) Local Privilege Escalation via SUID /proc/pid/mem Write" with an example. Link: http://blog.zx2c4.com/749

Filed under  //   kernel   linux  

Comments [0]

Only Ture Interview Questions

Yesterday I read this in LinkedIn News.

The 3 interview questions by employer:

  1. Can you do the job? (Strength)
  2. Will you love the job? (Motivation)
  3. Can we tolerate working with you? (Fit)

The 3 interview questions from employee:

  1. Will you allow me to do my job? (Trust in letting someone do their job once hired)
  2. Will you love that I love doing my job? (Respect that there is more to a job than a pay check)
  3. Can I tolerate working for you? (Corporate culture affects both parties)

In my carrier, I never undergone a formal interview process like several round of discussions, etc, and in most of the time, I faced similar type of questions :-)

Filed under  //   life  

Comments [0]

Android KeyEvent Sequence

Just in case, if your device touch screen failed, here few key sequences:

input keyevent 82 -- Menu (also help to unlock the screen)

input keyevent 4 -- Back

input keyevent 19/20/21/22 -- Movement (Left/Right/Up/Down)

input keyevent 66 -- Select/Enter

Filed under  //   android  

Comments [0]

Myth and Reality: Android Scheduling

One more nice write-up from Dianne Hackborn about the Scheduling of task in Android System.

Filed under  //   android  

Comments [0]

Myth and Reality: Android Graphics System

Recently Android Core Developer Dianne Hackborn explained about some of myth and reality of the GPU usage in Android Graphics System. I also in the assumption that, GPU is the only way to increase the rendering speed. But this explanation shows, that is not 100% correct :-)

• Android has always used some hardware accelerated drawing. Since before 1.0 all window compositing to the display has been done with hardware.

• This means that many of the animations you see have always been hardware accelerated: menus being shown, sliding the notification shade, transitions between activities, pop-ups and dialogs showing and hiding, etc.

• Android did historically use software to render the contents of each window. For example in a UI like

Media_httpwwwsimplemo_ehgob
there are four windows: the status bar, the wallpaper, the launcher on top of the wallpaper, and the menu. If one of the windows updates its contents, such as highlighting a menu item, then (prior to 3.0) software is used to draw the new contents of that window; however none of the other windows are redrawn at all, and the re-composition of the windows is done in hardware. Likewise, any movement of the windows such as the menu going up and down is all hardware rendering.

• Looking at drawing inside of a window, you don’t necessarily need to do this in hardware to achieve full 60fps rendering. This depends very much on the number of pixels in your display and the speed of your CPU. For example, Nexus S has no trouble doing 60fps rendering of all the normal stuff you see in the Android UI like scrolling lists on its 800x480 screen. The original Droid however struggled with a similar screen resolution.

• "Full" hardware accelerated drawing within a window was added in Android 3.0. The implementation in Android 4.0 is not any more full than in 3.0. Starting with 3.0, if you set the flag in your app saying that hardware accelerated drawing is allowed, then all drawing to the application’s windows will be done with the GPU. The main change in this regard in Android 4.0 is that now apps that are explicitly targeting 4.0 or higher will have acceleration enabled by default rather than having to put android:handwareAccelerated="true" in their manifest. (And the reason this isn’t just turned on for all existing applications is that some types of drawing operations can’t be supported well in hardware and it also impacts the behavior when an application asks to have a part of its UI updated. Forcing hardware accelerated drawing upon existing apps will break a significant number of them, from subtly to significantly.)

• Hardware accelerated drawing is not all full of win. For example on the PVR drivers of devices like the Nexus S and Galaxy Nexus, simply starting to use OpenGL in a process eats about 8MB of RAM. Given that our process overhead is about 2MB, this is pretty huge. That RAM takes away from other things, such as the number of background processes that can be kept running, potentially slowing down things like app switching.

• Because of the overhead of OpenGL, one may very well not want to use it for drawing. For example some of the work we are doing to make Android 4.0 run well on the Nexus S has involved turning off hardware accelerated drawing in parts of the UI so we don’t lose 8MB of RAM in the system process, another 8MB in the phone process, another 8MB in the system UI process, etc. Trust me, you won’t notice -- there is just no benefit on that device in using OpenGL to draw something like the status bar, even with fancy animations going on in there.

• Hardware accelerated drawing is not a magical silver bullet to butter-smooth UI. There are many different efforts that have been going on towards this, such as improved scheduling of foreground vs. background threads in 1.6, rewriting the input system in 2.3, strict mode, concurrent garbage collection, loaders, etc. If you want to achieve 60fps, you have 20 milliseconds to handle each frame. This is not a lot of time. Just touching the flash storage system in the thread that is running the UI can in some cases introduce a delay that puts you out of that timing window, especially if you are writing to storage.

• A recent example of the kinds of interesting things that impact UI smoothness: we noticed that ICS on Nexus S was actually less smooth when scrolling through lists than it was on Gingerbread. It turned out that the reason for this was due to subtle changes in timing, so that sometimes in ICS as the app was retrieving touch events and drawing the screen, it would go to get the next event slightly before it was ready, causing it to visibly miss a frame while tracking the finger even though it was drawing the screen at a solid 60fps.

• When people have historically compared web browser scrolling between Android and iOS, most of the differences they are seeing are not due to hardware accelerated drawing. Originally Android went a different route for its web page rendering and made different compromises: the web page is turned in to a display list, which is continually rendered to the screen, instead of using tiles. This has the benefit that scrolling and zooming never have artifacts of tiles that haven’t yet been drawn. Its downside is that as the graphics on the web page get more complicated to draw the frame rate goes down. As of Android 3.0, the browser now uses tiles, so it can maintain a consistent frame rate as you scroll or zoom, with the negative of having artifacts when newly needed tiles can’t be rendered quickly enough. The tiles themselves are rendered in software, which I believe is the case for iOS as well. (And this tile-based approach could be used prior to 3.0 without hardware accelerated drawing; as mentioned previously, the Nexus S CPU can easily draw the tiles to the window at 60fps.)

• Hardware accleration does not magically make drawing performance problems disappear. There is still a limit to how much the GPU can do. A recent interesting example of this is tablets built with Tegra 2 -- that GPU can touch every pixel of a 1024x800 screen about 2.5 times at 60fps. Now consider the Android 3.0 tablet home screen where you are switching to the all apps list: you need to draw the background (1x all pixels), then the layer of shortcuts and widgets (let’s be nice and say this is .5x all pixels), then the black background of all apps (1x all pixels), and the icons and labels of all apps (.5x all pixels). We’ve already blown our per-pixel budget, and we haven’t even composited the separate windows to the final display yet. To get 60fps animation, Android 3.0 and later use a number of tricks. A big one is that it tries to put all windows into overlays instead of having to copy them to the framebuffer with the GPU. In the case here even with that we are still over-budget, but we have another trick: because the wallpaper on Android is in a separate window, we can make this window larger than the screen to hold the entire bitmap. Now, as you scroll, the movement of the background doesn’t require any drawing, just moving its window... and because this window is in an overlay, it doesn’t even need to be composited to the screen with the GPU.

• As device screen resolution goes up, achieving a 60fps UI is closely related to GPU speed and especially the GPU’s memory bus bandwidth. In fact, if you want to get an idea of the performance of a piece of hardware, always pay close attention to the memory bus bandwidth. There are plenty of times where the CPU (especially with those wonderful NEON instructions) can go a lot faster than the memory bus.

Related Links:

Skia (2D Graphics Library)

Filed under  //   android  

Comments [0]

iPhone: Network Speed Limit

Few days back, we are trying to emulate the slow speed network connection to test our iPhone Application behavior. Unlike Android Emulator, the iPhone Simulator does not have an in-build option to enforce the network speed. Many suggest to go for iPhone device. But I felt, this is not something, I am only under going and someone might be having some solution for it.

Media_httpmschraggith_beezi

After few search, I found SpeedLimit, the Leopard preference pane to regulate the network speed. It is very useful for iPhone testing and has few default connection profiles like Dial-Up, Edge, ..

Filed under  //   iPhone  

Comments [0]