Thursday, January 31, 2008

trying building shared library for google android

There is an article Shared library "Hello World!" for Android, describes how to create a simple shared library for google android, and shows how to link with the shared library to create a dynamic linked executable. The steps are correct, but it is not easy to create a shared library for google android with an existing linux distribution open source software.

Here is some findings when I tried to create a shared library for google android with a open source software:
1. pthread related functions are implemented in google android
2. no stderr, stdin, stdout definition are found in google android
3. some function mangling is different, such as strtod, strtol, isspace, and etc. Some can be fixed with some MACRO variable, such as __NO_INLINE__. Need to identify one by one, read the include head files in CROSS_COMPILE_FOLDER /arm-none-linux-gnueabi/libc/usr/include/
4. no mkstemp64, open64, and other xxx64 functions found

Following are the pthread found in google android /system/lib/
42: 0000a41c 32 FUNC GLOBAL DEFAULT 7 pthread_cond_signal
61: 0000a26c 56 FUNC GLOBAL DEFAULT 7 pthread_mutexattr_gettype
64: 0000a510 32 FUNC GLOBAL DEFAULT 7 pthread_attr_destroy
69: 0000a144 16 FUNC GLOBAL DEFAULT 7 pthread_attr_getstacksize
71: 0000afa0 620 FUNC GLOBAL DEFAULT 7 pthread_create
75: 0000a3a8 28 FUNC GLOBAL DEFAULT 7 pthread_getspecific
86: 0000a050 72 FUNC GLOBAL DEFAULT 7 pthread_attr_init
92: 0000ad60 304 FUNC GLOBAL DEFAULT 7 pthread_exit
119: 0000a1b0 24 FUNC GLOBAL DEFAULT 7 pthread_attr_getstack
165: 0000a15c 24 FUNC GLOBAL DEFAULT 7 pthread_attr_getstackaddr
177: 0000a8c8 228 FUNC GLOBAL DEFAULT 7 pthread_key_delete
202: 0000a254 24 FUNC GLOBAL DEFAULT 7 pthread_mutexattr_destroy
208: 0000a22c 16 FUNC GLOBAL DEFAULT 7 pthread_equal
265: 0000a1ec 16 FUNC GLOBAL DEFAULT 7 pthread_attr_getguardsize
299: 0000aad8 188 FUNC GLOBAL DEFAULT 7 pthread_cond_timedwait_mo
340: 0000ac58 176 FUNC GLOBAL DEFAULT 7 pthread_detach
352: 0000a0f0 16 FUNC GLOBAL DEFAULT 7 pthread_attr_getschedpoli
368: 0000a154 8 FUNC GLOBAL DEFAULT 7 pthread_attr_setstackaddr
387: 0000a4b0 96 FUNC GLOBAL DEFAULT 7 pthread_getschedparam
441: 0000a43c 32 FUNC GLOBAL DEFAULT 7 pthread_cond_broadcast
459: 0000a45c 84 FUNC GLOBAL DEFAULT 7 pthread_setschedparam
471: 0000a9ac 176 FUNC GLOBAL DEFAULT 7 pthread_key_create
499: 0000a3cc 80 FUNC GLOBAL DEFAULT 7 pthread_kill
505: 0000aa5c 124 FUNC GLOBAL DEFAULT 7 pthread_cond_timeout_np
512: 0000a1fc 44 FUNC GLOBAL DEFAULT 7 pthread_getattr_np
514: 0000a120 36 FUNC GLOBAL DEFAULT 7 pthread_attr_setstacksize
546: 0000a3c4 8 FUNC GLOBAL DEFAULT 7 pthread_sigmask
559: 0000a35c 16 FUNC GLOBAL DEFAULT 7 pthread_cond_init
643: 0000a174 60 FUNC GLOBAL DEFAULT 7 pthread_attr_setstack
647: 0000a2a4 64 FUNC GLOBAL DEFAULT 7 pthread_mutexattr_settype
681: 0000a0d0 20 FUNC GLOBAL DEFAULT 7 pthread_attr_getdetachsta
694: 0000a690 180 FUNC GLOBAL DEFAULT 7 pthread_mutex_unlock
772: 0000a228 4 FUNC GLOBAL DEFAULT 7 pthread_self
778: 0000a23c 24 FUNC GLOBAL DEFAULT 7 pthread_mutexattr_init
788: 00009630 0 FUNC GLOBAL DEFAULT 7 __pthread_clone
818: 0000a344 24 FUNC GLOBAL DEFAULT 7 pthread_mutex_destroy
826: 0000a744 388 FUNC GLOBAL DEFAULT 7 pthread_mutex_lock
831: 0000ac50 8 FUNC GLOBAL DEFAULT 7 pthread_cond_wait
845: 0000a1c8 36 FUNC GLOBAL DEFAULT 7 pthread_attr_setguardsize
858: 0000a55c 308 FUNC GLOBAL DEFAULT 7 pthread_mutex_trylock
869: 0000a36c 24 FUNC GLOBAL DEFAULT 7 pthread_cond_destroy
874: 0000a0e4 12 FUNC GLOBAL DEFAULT 7 pthread_attr_setschedpoli
886: 0000a2e4 96 FUNC GLOBAL DEFAULT 7 pthread_mutex_init
920: 0000a100 16 FUNC GLOBAL DEFAULT 7 pthread_attr_setschedpara
936: 0000a098 56 FUNC GLOBAL DEFAULT 7 pthread_attr_setdetachsta
942: 0000ad08 88 FUNC GLOBAL DEFAULT 7 pthread_join
952: 0000ab94 188 FUNC GLOBAL DEFAULT 7 pthread_cond_timedwait
963: 0000a110 16 FUNC GLOBAL DEFAULT 7 pthread_attr_getschedpara
967: 0000a384 36 FUNC GLOBAL DEFAULT 7 pthread_setspecific

Thursday, January 17, 2008

Set proxy for android web browser

There is no UI for proxy settings for android web browser. But the android web browser will read the proxy settings in its settings database.
Here is the instructions to enable the proxy in the android web browser.
  1. > adb shell
  2. # sqlite3 /data/data/
  3. sqlite> INSERT INTO system VALUES(99,’http_proxy', 'proxy:port');
  4. sqlite>.exit
You can talk to settings.db for more information.
  1. sqlite> SELECT * FROM system;
  2. sqlite> .tables
  3. sqlite> .databases
  4. sqlite> .schema table_name
  5. sqlite> more SQL expression to talk to the tables
Don't forget the ';' at the end of the SQL expression.

Wednesday, January 16, 2008

Create google android strace tool

Prerequisite, you already have the cross compiler downloaded from download GNU toolchain site, make sure you select ARM GNU/Linux, and IA32 GNU/Linux.

  1. Download the strace source distribution from SourceForge strace project
  2. Extract the strace package on your linux machine
  3. Set your cross compiler information with command: # export CC=your_cross_compiler_folder/bin/arm-none-linux-gnueabi-gcc
  4. Add your_cross_compiler_folder/bin into your $PATH for path searching
  5. Change your current folder to strace package extract folder, use command: # ./configure -host=arm-linux
  6. You have the Makefile generated, edit it, append -static after CFLAGS variable in Makefile
  7. Compile it with simple command: # make
  8. You have the strace now, verify it with command: # file strace, you shall see "strace: ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.6.14, statically linked, not stripped"
Done, you have another powerful tool for your android

Manually start android in the google android emulator

The google android kernel will invoke services listed in the file /etc/init.rc after the kernel is started up. The /etc/init.rc is included in the ramdisk.img. Find the ramdisk.img in $EMULATOR_SDK_FOLDER/tools/lib/images/. One can change the ramdisk.img to change the init.rc and so to change the google android startup sequence.

Follow the tips in Step by step to create/modify ramdisk.img to change ramdisk.img.

Following is the items to comment out in init.rc to stop the android to be loaded at the initial time:
  1. Find the service section in the init.rc (following the startup section)
  2. Comment out the zygote sub-section, and runtime sub-section
  3. Recreate the ramdisk.img and replace the original ramdisk.img (backup the original if you want)
  4. Restart the google android emulator, use -debug-kernel to see more information
Comment out lines are listed for your reference:
#zygote {
#exec /system/bin/app_process
#args {
#0 -Xzygote
#1 /system/bin
#2 --zygote
#autostart 1
#runtime {
#exec /system/bin/runtime
#autostart 1
After the google android emulator is started up, manually start up the google android services below:
  1. # adb shell to create a console
  2. # /system/bin/app_process -Xzygote /system/bin --zygote &
  3. # /system/bin/runtime &
Upload a strace tool to trace the above services:
  1. # strace -ff -F -tt -s 200 -o /tmp/log/zygote /system/bin/app_process -Xzygote /system/bin --zygote &
  2. # strace -ff -F -tt -s 200 -o /tmp/log/runtime /system/bin/runtime &

What can we expect for the google android next release

We have google android release m3-rc37a.
There are following files in the folder /system/app/:

While if we manually start the android, we can see some error informations:
Prepping: /system/app/AlarmProvider.apk:/system/app/Browser.apk:/system/app/Ca

File not found: /system/app/AlarmProvider.apk
File not found: /system/app/Calendar.apk
File not found: /system/app/Camera.apk
File not found: /system/app/GDataFeedsProvider.apk
File not found: /system/app/Gmail.apk
File not found: /system/app/GmailProvider.apk
File not found: /system/app/MediaPickerActivity.apk
File not found: /system/app/PimProvider.apk
File not found: /system/app/ApiDemos.apk
File not found: /system/app/Sms.apk
File not found: /system/app/SyncProvider.apk
File not found: /system/app/YouTube.apk
Prep complete
We are expecting the next release, what kind of applications will be provided next time?

Tuesday, January 15, 2008

Can't execute native command on google android emulator

I created hello.c, compiled successfully with the cross compiler.
But I failed to run it on the target google android emulator. The error is: xxx: not found.
I checked the compiled file, it looks just fine. It really puzzled me.

At last, I got hints that it is because of there is no base libraries necessary on the google android emulator. For example, there is no /usr/lib directory, which should contain many .so files.

Simply re-create your native command with '-static' parameter, and try again.
Check your compiled file with the following command to ensure:
# file a.out
possible output looks like:
a.out: ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.6.14, statically linked, not stripped

Customize google android system.img for emulator

The google android emulator included in the google android sdk is limited. Although you can use 'adb push' to upload more tools, but one has to do it again next time. Follow the steps to create a enhanced system.img:
  1. system.img is yaffs2 flash file system, so firstly you need the mkfs.yaffs2 tool, download it in the following link: Release Android Yaffs2 Tool (Both X86 And ARM). One has to be a registered user to download the tools.
  2. use the 'adb push' to upload tools to android emulator, executables in /system/bin/, libraries in /system/lib, one can also create folder. One need change the file mode necessary.
  3. upload the ARM mkfs.yaffs2 tool, use the following command to create system.img: # mkfs.yaffs2 /system /system.img
  4. download the system.img to local with command 'adb pull', replace the system.img in your emulator folder/tools/lib/images/

Monday, January 14, 2008

Step by step to create/modify ramdisk.img

Benno's blog has an article to change the ramdisk image, I tried it and give more details here.

ramdisk.img is included in the google android sdk, it exists in folder $SDK_ROOT/tools/lib/images/ramdisk.img. The ramdisk.img included in the google android sdk is a gzipped ramdisk.cpio file.

Here is the steps:
  1. Upload the ramdisk.img to your linux machine
  2. Change the ramdisk.img name to ramdisk.cpio.gz, and extract it by: # gzip -d ramdisk.cpio.gz
  3. Create a temporary folder, say tmp, copy ramdisk.cpio to tmp folder
  4. Extract the ramdisk.cpio in the tmp folder with command: # cpio -i -F ramdisk.cpio
  5. Remove the ramdisk.cpio in the tmp folder, and make any changes you want to the extracted ramdisk.cpio in tmp folder
  6. Recreate the ramdisk.cpio with command: # cpio -i -t -F ../ramdisk.cpio | cpio -o -H newc -O ../ramdisk_new.cpio
Some notes:
  1. I change ramdisk.img to ramdisk.cpio.gz, and unzip it. It is because I find the -z parameter is not supported with my cpio. I tried the latest cpio (2.9), it doesn't work too.
  2. Check cpio version by # cpio --version. I'm using cpio version 2.4.
  3. Find the latest cpio (v 2.9) on site: gnu cpio
  4. Notice that in step 6, the command includes two O's. First o is lower-case, second is up-case.
  5. Notice in step 6, please remain ramdisk.cpio in up folder of tmp folder. The command need it there.

YAFFS(YAFFS2) and JFFS2 comparison

Google android emulator extracts the system.img and userdata.img with YAFFS flash file system. I don't know much about YAFFS and its difference with JFFS2. I google it and share here.
  • YAFFS uses less run-time RAM to hold its state so YAFFS scales better than JFFS2. There are quite a few systems using large NAND arrays (the largest partitions I know of are around the 6Gbyte mark).
  • YAFFS garbage collection is simpler and faster typically making for better performance under hard writing.
  • YAFFS uses a whole page per file for headers, and does not provide compression. This means that JFFS2 is probably a better fit to small partitions. The flip side though is that a lot of data (eg. MP3) does not compress very well and enabling compression really hurts performance.
  • While YAFFS has been used on NOR, it does not fit that well (because YAFFS does not use erase suspend). Thus if you're using smaller NAND partitions and using jffs2 on NOR, then a jffs2-only solution is very appealing.
From the wikipedia, I can see YAFFS is Yet Another Flash File System, it is specifically designed for NAND flash. Here are some links for more information:
JFFS2 is a log-structured file system designed for use on flash devices in embedded systems. Rather than using a kind of translation layer on flash devices to emulate a normal hard drive, as is the case with older flash solutions, it places the filesystem directly on the flash chips. Here are some links for more information about JFFS2:
More information about Flash memory.
Flash memory is non-volatile computer memory that can be electrically erased and reprogrammed. There are NOR memories and NAND memories.
NOR memories:
Reading from NOR flash is similar to reading from random-access memory, provided the address and data bus are mapped correctly. Because of this, most microprocessors can use NOR flash memory as execute in place (XIP) memory, meaning that programs stored in NOR flash can be executed directly without the need to copy them into RAM. NOR flash chips lack intrinsic bad block management, so when a flash block is worn out, the software or device driver controlling the device must handle this, or the device will cease to work reliably.
When unlocking, erasing or writing NOR memories, special commands are written to the first page of the mapped memory. These commands are defined by the Common Flash memory Interface (CFI) and the flash chips can provide a list of available commands to the physical driver.
NAND memories:

NAND flash architecture was introduced by Toshiba in 1989. NAND flash memories cannot provide execute in place due to their different construction principles. These memories are accessed much like block devices such as hard disks or memory cards. The pages are typically 512 or 2,048 or 4,096 bytes in size. Associated with each page are a few bytes (typically 12–16 bytes) that should be used for storage of an error detection and correction checksum.

The pages are typically arranged in blocks. A typical block would be:
  • 32 pages of 512 bytes
  • 64 pages of 2,048 bytes.
  • 64 pages of 4,096 bytes.

Sunday, January 13, 2008

google android emulator console

Each running emulator instance includes a console facility that lets you dynamically query and control the simulated device environment. Connect to the console by the following command:
# telnet localhost 5554
If you have multiple emulator started, subsequent console port is 5556, 5558, etc.

In the current release, the console provides the following commands:
  • help|h|? ;print a list of commands
  • redir ;manage port redirections
  • network ;manage network settings
  • gsm ;GSM related commands
  • sms ;SMS related commands
  • kill ;kill the emulator instance
  • quit|exit ;quit control session
For more details of the console commands usage, refer to the Google Android Emulator documentation.

About Google Android Emulator

At the very beginning, google released google android SDK, it is running on the emulator. There is no hardware.

The Google android emulator is included in the google android sdk. So far google provides three platforms sdk, they are windows, Mac OS X (intel), Linux (i386). The emulator is in the tools folder: emulator.

The google android emulator is based on the qemu, which is a open source. Google makes some changes based on the qemu 0.8.2. The source code is also available. With the emulator source, you can make any changes you want, and replace the original one to look for information you want. One command to compile the emulator source code:

Available links:
  1. Google android sdk
  2. Google android emulator source package
  3. Qemu open source

Friday, January 11, 2008

Extract google android file system image

To run google android on the truely hardware, you may need the google android file system image.

Google android file system consists of two parts: system and data.
You can find the google android file system image on benno's website: Android filesystem images

You can also extract the google android file system by yourself from the android emulator by the following way:
1. download the google android sdk and extract onto your platform
2. start up the google android emulator
3. upload a busybox tool to the google android emulator, you can find a busybox binary on benno's website: busybox for android, you can also find the cross-compiler (select ARM GNU/Linux, and IA32 GNU/Linux) and create a busybox tool by yourself.
4. to upload files to the google android emulator, run the following command:
# adb push filename /target_folder/filename
the target_folder is the folder on the file system of google android emulator. e.g. /system/bin/
put the busybox to /system/bin, so you can see busybox tool in the extracted file system.
5. open a google android shell command window:
# adb shell
6. change the busybox mode to 555:
# chmod 555 /system/bin/busybox
7. create the tarball for /system and /data:
# busybox tar cvf /system.tar /system
# busybox tar cvf /data.tar /data
8. pull the tarball file from the google android emulator:
# adb pull system.tar /system.tar
# adb pull data.tar /data.tar

a note: when you want run google android on your truely hardware, the data.tar is not a must.

Get start playing with Google Android

The Android platform is a software stack for mobile devices including an operating system, middleware and key applications. Developers can create applications for the platform using the Android SDK. Applications are written using the Java programming language and run on Dalvik, a custom virtual machine designed for embedded use which runs on top of a Linux kernel.

Google provides Android SDK for three platforms: Windows, Mac OS X (intel), Linux (i386). There is Android emulator included in the SDK package. So first find a Android SDK for your platform: Download the Android SDK from Google.

Next, extract the Android SDK package into your system, let's say the root folder is $ANDROID_SDK.

Open a command window (shell window), change the working directory to $ANDROID_SDK/tools/. You will see tens of executable files, one is emulator. Simply start it with the following command:
# emulator
If you want to see the emulator kernel boot up detail information, start it with the following command:
# emulator -debug-kernel

When the Android started up, the following window is shown.
You can open a Android shell by the command:
# adb shell

It is a Linux kernel 2.6.23 (Android is linux kenel based) shell, play with it in the same way as linux.

Here is the Android kernel boot up log fyi:
Uncompressing Linux.............................................................
.................... done, booting the kernel.
Linux version 2.6.23-gcc3bc3b4 ( (gcc version 4.2.1
) #3 Tue Oct 30 16:28:18 PDT 2007
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00003137
Machine: Goldfish
Memory policy: ECC disabled, Data cache writeback
CPU0: D VIVT write-through cache
CPU0: I cache: 4096 bytes, associativity 4, 32 byte lines, 32 sets
CPU0: D cache: 65536 bytes, associativity 4, 32 byte lines, 512 sets
Built 1 zonelists in Zone order. Total pages: 24384
Kernel command line: qemu=1 console=ttyS0 android.checkjni=1 keycharmap=qwerty2
Unknown boot option `android.checkjni=1': ignoring
Unknown boot option `': ignoring
PID hash table entries: 512 (order: 9, 2048 bytes)
Console: colour dummy device 80x30
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 96MB = 96MB total
Memory: 94280KB available (2268K code, 458K data, 96K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
android_power_init done
NET: Registered protocol family 16
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 4096 (order: 3, 32768 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP reno registered
checking if image is initramfs... it is
Freeing initrd memory: 228K
goldfish_new_pdev goldfish_interrupt_controller at ff000000 irq -1
goldfish_new_pdev goldfish_device_bus at ff001000 irq 1
goldfish_new_pdev goldfish_timer at ff003000 irq 3
goldfish_new_pdev goldfish_rtc at ff010000 irq 10
goldfish_new_pdev goldfish_tty at ff002000 irq 4
goldfish_new_pdev goldfish_tty at ff011000 irq 11
goldfish_new_pdev smc91x at ff012000 irq 12
goldfish_new_pdev goldfish_fb at ff013000 irq 13
goldfish_new_pdev goldfish_audio at ff004000 irq 14
goldfish_new_pdev goldfish_events at ff014000 irq 15
goldfish_new_pdev goldfish_nand at ff015000 irq -1
goldfish_new_pdev goldfish-switch at ff016000 irq 16
goldfish_new_pdev goldfish-switch at ff017000 irq 17
goldfish_pdev_worker registered goldfish-switch
goldfish_pdev_worker registered goldfish-switch
goldfish_pdev_worker registered goldfish_nand
goldfish_pdev_worker registered goldfish_events
goldfish_pdev_worker registered goldfish_audio
goldfish_pdev_worker registered goldfish_fb
goldfish_pdev_worker registered smc91x
goldfish_pdev_worker registered goldfish_tty
goldfish_pdev_worker registered goldfish_tty
goldfish_pdev_worker registered goldfish_rtc
goldfish_pdev_worker registered goldfish_timer
goldfish_pdev_worker registered goldfish_device_bus
goldfish_pdev_worker registered goldfish_interrupt_controller
Installing knfsd (copyright (C) 1996
yaffs Oct 30 2007 16:24:34 Installing.
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
allocating frame buffer 320 * 480, got ffc10000
Console: switching to colour frame buffer device 40x30
console [ttyS0] enabled
RAMDISK driver initialized: 16 RAM disks of 8192K size 1024 blocksize
loop: module loaded
nbd: registered device at major 43
smc91x.c: v1.1, sep 22 2004 by Nicolas Pitre
No IRQF_TRIGGER set_type function for IRQ 12 (goldfish)
eth0: SMC91C11xFD (rev 1) at c6800000 IRQ 12 [nowait]
eth0: Ethernet addr: 52:54:00:12:34:56
goldfish nand dev0: size 4000000, page 2048, extra 64, erase 131072
goldfish nand dev1: size 4000000, page 2048, extra 64, erase 131072
mice: PS/2 mouse device common for all mice
*** events probe ***
events_probe() addr=0xc6804000 irq=15
input: goldfish-events-keyboard as /class/input/input0
goldfish_rtc goldfish_rtc: rtc core: registered goldfish_rtc as rtc0
logger: created 64K log 'log_main'
logger: created 64K log 'log_events'
logger: created 64K log 'log_radio'
IPv4 over IPv4 tunneling driver
GRE over IPv4 tunneling driver
TCP cubic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
802.1Q VLAN Support v1.8 Ben Greear
All bugs added by David S. Miller
VFP support v0.3: implementor 41 architecture 1 part 10 variant 9 rev 0
goldfish_rtc goldfish_rtc: setting the system clock to 2008-01-12 02:48:13 (1200
Freeing init memory: 96K
init: reading config file
init: device init
init: mtd partition -1,
init: mtd partition 0, "system"
yaffs: dev is 32505856 name is "mtdblock0"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.0, "mtdblock0"
init: mtd partition 1, "userdata"
yaffs: dev is 32505857 name is "mtdblock1"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.1, "mtdblock1"
eth0: link up
sh: can't access tty; job control turned off
# binder_open(c0833428 c0a0a4a0) (pid 468) got c5f13000
binder_open(c0833428 c5a6b9e0) (pid 460) got c5bbf000
binder_open(c0833428 c5a6b2e0) (pid 474) got c4716000
android_power: auto off timeout set to 604800 seconds
Descriptor2Node failed secondary: desc=4, max=32, node=c5bc0350, weak=0
binder_open(c0833428 c4f533a0) (pid 510) got c4754000
binder_open(c0833428 c4f53920) (pid 511) got c3a30000
binder_open(c0833428 c3421860) (pid 527) got c3428000

Create adb shell in android emulator

Type the following command to start the adb shell:
# adb shell
For the full usage of adb, please refer the following link: Android Debug Bridge Tool

Rotate Android Screen to Landscape/Portrait

Here are some tips of android screen rotation.

On the emulator, after the Android system is started up, open another command window, type the following command line in the adb shell to change the screen to landscape:
# service call window 18 i32 1
type the following command line to change the screen to portrait:
# service call window 18 i32 0