Saturday, September 24, 2011

Failed to successfully run an emulated Android device on Ubuntu 11.04

 I was trying to play with Android platform on Ubuntu 11.04 but I hit a roadblock trying to run an emulated Android device using a non-root account. Did an strace but nothing stands out, not that I am an expert. Searching the web does not provide me with something really useful.

Here few things interesting. Running an android virtual device as root works as expected. But running an android virtual device as a regular user halt/stops at a blank window for the emulated device.

Running it verbose shows the following:

//---- some of the strings removed ----
.
QEMU options list:
emulator: argv[00] = "./emulator-arm"
emulator: argv[01] = "-android-hw"
emulator: argv[02] = "/home/timus/.android/avd/e.avd/hardware-qemu.ini"
Concatenated QEMU options:
 ./emulator-arm -android-hw /home/timus/.android/avd/e.avd/hardware-qemu.ini
emulator: registered 'boot-properties' qemud service
emulator: nand_add_dev: system,size=0x4e00000,initfile=/home/timus/android/platforms/android-8/images//system.img
emulator: mapping 'system' NAND image to /tmp/android-timus/emulator-kTuuh9
emulator: rounding devsize up to a full eraseunit, now 4e1e000

emulator: nand_add_dev: userdata,size=0x4200000,file=/home/timus/.android/avd/e.avd/userdata-qemu.img
emulator: registered 'boot-properties' qemud service
emulator: Adding boot property: 'dalvik.vm.heapsize' = '24m'
emulator: Adding boot property: 'qemu.sf.lcd_density' = '120'
emulator: nand_add_dev: cache,size=0x4200000,file=/home/timus/.android/avd/e.avd/cache.img
emulator: Kernel parameters: qemu=1 console=ttyS0 android.qemud=ttyS1 android.checkjni=1 ndns=1
emulator: Trace file name is not set

emulator: autoconfig: -scale 1
emulator: control console listening on port 5554, ADB on port 5555
emulator: sent '0012host:emulator:5555' to ADB server
emulator: ping program: /home/timus/android/tools/ddms
emulator: ping command: /home/timus/android/tools/ddms ping emulator 13.0


strace shows the following, with the top messages cut off:

//---- a lot of messages before this... left out as I am not sure if it helps ----

open("/home/timus/.android/modem-nv-ram-5554", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0755) = 21
write(21, "modem_technology gsm\noper_name_i"..., 171) = 171
close(21)                               = 0
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 21
connect(21, {sa_family=AF_INET, sin_port=htons(5037), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
send(21, "0012host:emulator:5555", 22, 0) = 22
write(1, "emulator: sent '0012host:emulato"..., 54emulator: sent '0012host:emulator:5555' to ADB server
) = 54
shutdown(21, 2 /* send and receive */)  = 0
close(21)                               = 0
readlink("/proc/self/exe", "/home/timus/android/tools/emulator-arm"..., 1024) = 38
write(1, "emulator: ping program: /home/ti"..., 55emulator: ping program: /home/timus/android/tools/ddms
) = 55
access("/home/timus/android/tools/ddms", F_OK) = 0
rt_sigprocmask(SIG_BLOCK, [ALRM], [ALRM], 8) = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb7809948) = 6537
rt_sigprocmask(SIG_SETMASK, [ALRM], NULL, 8) = 0
write(1, "emulator: ping command: /home/ti"..., 74emulator: ping command: /home/timus/android/tools/ddms ping emulator 13.0
) = 74
brk(0xa643000)                          = 0xa643000
poll([{fd=3, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=3, revents=POLLOUT}])
writev(3, [{"\22\0\10\0\3\0\340\4'\0\0\0\37\0\0\0\10\0\0\0\6\0\0\0005554:e\7\0"..., 132}, {NULL, 0}, {"", 0}], 3) = 132
poll([{fd=3, events=POLLIN}], 1, -1)    = 1 ([{fd=3, revents=POLLIN}])
read(3, "\34\0~\0\3\0\340\4'\0\0\0\302\20\357\2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096) = 160
read(3, 0xa2a84a0, 4096)                = -1 EAGAIN (Resource temporarily unavailable)
clock_gettime(CLOCK_MONOTONIC, {49221, 836305909}) = 0
select(21, [8 11 19 20], [], [], {0, 0}) = 1 (in [19], left {0, 0})
gettimeofday({1316917045, 343804}, NULL) = 0
accept(19, {sa_family=AF_INET, sin_port=htons(52886), sin_addr=inet_addr("127.0.0.1")}, [16]) = 21
fcntl64(21, F_GETFL)                    = 0x2 (flags O_RDWR)
fcntl64(21, F_SETFL, O_RDWR|O_NONBLOCK) = 0
setsockopt(21, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
setsockopt(21, SOL_SOCKET, SO_OOBINLINE, [1], 4) = 0
setsockopt(21, SOL_TCP, TCP_NODELAY, [1], 4) = 0
clock_gettime(CLOCK_MONOTONIC, {49221, 837887026}) = 0
clock_gettime(CLOCK_MONOTONIC, {49221, 837911639}) = 0
read(3, "\34\0\202\0\3\0\340\4\16\1\0\0\307\20\357\2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 4096) = 32
read(3, 0xa2a84a0, 4096)                = -1 EAGAIN (Resource temporarily unavailable)
read(3, 0xa2a84a0, 4096)                = -1 EAGAIN (Resource temporarily unavailable)
read(3, 0xa2a84a0, 4096)                = -1 EAGAIN (Resource temporarily unavailable)
read(3, 0xa2a84a0, 4096)                = -1 EAGAIN (Resource temporarily unavailable)
read(3, 0xa2a84a0, 4096)                = -1 EAGAIN (Resource temporarily unavailable)
read(3, 0xa2a84a0, 4096)                = -1 EAGAIN (Resource temporarily unavailable)
read(3, "\226\0\202\0\3\0\340\4\3\0\340\4&\0`\4\270\1k\0\307\2\263\1\0\0\0\0\0\0\0\0"..., 4096) = 128
read(3, 0xa2a84a0, 4096)                = -1 EAGAIN (Resource temporarily unavailable)
read(3, 0xa2a84a0, 4096)                = -1 EAGAIN (Resource temporarily unavailable)
read(3, 0xa2a84a0, 4096)                = -1 EAGAIN (Resource temporarily unavailable)
read(3, 0xa2a84a0, 4096)                = -1 EAGAIN (Resource temporarily unavailable)
read(3, 0xa2a84a0, 4096)                = -1 EAGAIN (Resource temporarily unavailable)
read(3, 0xa2a84a0, 4096)                = -1 EAGAIN (Resource temporarily unavailable)
read(3, 0xa2a84a0, 4096)                = -1 EAGAIN (Resource temporarily unavailable)
read(3, 0xa2a84a0, 4096)                = -1 EAGAIN (Resource temporarily unavailable)
read(3, 0xa2a84a0, 4096)                = -1 EAGAIN (Resource temporarily unavailable)
read(3, 0xa2a84a0, 4096)                = -1 EAGAIN (Resource temporarily unavailable)
select(4, [3], NULL, NULL, {0, 0})      = 0 (Timeout)
read(3, 0xa2a84a0, 4096)                = -1 EAGAIN (Resource temporarily unavailable)
select(4, [3], NULL, NULL, {0, 0})      = 0 (Timeout)
clock_gettime(CLOCK_MONOTONIC, {49221, 894015842}) = 0
gettimeofday({1316917045, 400822}, NULL) = 0
--- SIGCHLD (Child exited) @ 0 (0) ---
waitpid(-1, NULL, WNOHANG)              = 6537
sigreturn()                             = ? (mask now [ALRM])
clock_gettime(CLOCK_MONOTONIC, {49223, 124717374}) = 0
clock_gettime(CLOCK_MONOTONIC, {49223, 124752199}) = 0


As a workaround, I have to run the application using sudo (essentially as a root user). Anyway, my command looks like:
./emulator @my_avd -verbose

I will keep on investigating what it takes to run emulated Android device in Ubuntu 11.04 as non-root.

~ts

Error deleting :Zone.Identifier access is denied running stream.exe from Technet

Part of Windows NTFS is to support multiple stream for a single file. Most applications only access the main stream and this is what's normally readable information.

Multiple streams in a file is also being used by Internet Explorer to tag files download from the internet. The additional information, among other things, saves the zone information about the file. This is mainly used for security purposes like warn a user that certain files was coming from an untrusted sources. Unfortunately this also introduces complication to handling files from the internet specially if the source is trusted.

There is a tool from Technet  which can remove the streams added by Internet Explorer. The first time I used the application I am seeing "Error deleting :Zone.Identifier access is denied" when operating on files that was extracted from a zip file. I was expecting that it should be able to handle those files as well. It seems like this might a bug of the streams.exe application.

Anyway, as a workaround, instead of extracting the files and removing the streams aside from the main I run the program on the zip file itself. Lesson learned, run the application against the file that was downloaded from the net instead of files as by product of the downloaded information.

~ts

Friday, September 23, 2011

View current Windows user privileges

To display currently logged on Windows user account privileges, do:

c:\>whoami /priv

~y

Monday, September 19, 2011

Android emulator-arm.exe crashing in Windows XP

I have tried to install Android SDK (r12) to start playing with developing applications for the platform. For no reason, I picked Windows XP Sp3 as my development OS.

Customary to getting started with new programming language or platform is to create the equivalent "Hello World". The sample program was small and easy to digest but running it for the first time was not a good experience.

The default Android Virtual Device configuation as per the tutorial keeps crashing on Windows XP. This is the message that I am seeing:
emulator-arm.exe has encountered a problem and needs to close.
We are sorry for the inconvenience
Searching the blogosphere shows the following sites that standout:
The information from Stackoverflow did give a good hint as to what might be the issue. It seems like the Android SDK, specially the emulator, does not like spaces in the directories. With VirtualBox virtualization at my disposal, I started poking around with the installer.

To make the long trial and error short, below are the key changes to make Android development a little smoother.

Before installing the Android SDK (installer_r12-windows.exe), set the following system environment variable:
ANDROID_SDK_HOME = d:\home
Of course you have to change d:\home to your desired folder. Ensure that the folder exists, this is important before starting with the installation. By the way, this is the folder where the Android virtual device(s) will be created.

Now, install Android SDK. I would suggest to use c:\android\sdk for the destination folder.  If not, ensure that the path location does not include any spaces and that the individual folder length is less than or equal to eight characters.

With all this set, continue with the installation of Android software development environment and enjoy!!!

~ts

Saturday, September 10, 2011

Linux rdesktop looped to remote desktop another Windows how to send secure attention sequence

Connecting from Windows Server 2008 R2 from Linux is made easy using rdesktop. But if you want to connect from your W2k8 box to another Windows box, as part of Windows security you are requested to send CTRL+ALT+END. Doing so does not work. So what's the key sequence to send secure attention sequence? It is Control+Alt+End

:(