Research and Design of Universal and Open Software Development Platform for Digital Home CaiFeng Cao School of Computer Wuyi University, Jiangmen 529020, China cfcao@126.com Abstract. With the development of digital home system, building a universal, independent, and open design platform can help to promote the efficiency of the system development and is beneficial to interconnection and intercommunication among devices in it. In this paper, the core technologies of Android system are investigated; referencing Android, it puts forward the architecture and key technologies of the platform. The platform can configure flexibly different hardware structures and operating systems, fully integrate the third party softwares, then provides the development support of system and application software for different electronic equipments. Keywords: digital home, general independent open platform, Android. 1 Introduction There are many kinds of electronic equipments in digital home system, which widely use embedded software development techniques. Building unified development platform becomes the focus of research and development of the industry. Android is the open source platform of intelligence mobile phone launched by Google. It includes operating system, user interface, middleware and application software[1]. Its openness, portability, rich application software, convenient development environment and many other advantages make it as the one of the world's most popular smartphone development and operation platforms just in two or three years. Its embedded software development technology has achieved great success. The research and application on Android is never stop. This paper studies Android design technologies, makes full use of its existing resources and system mechanism, then expands the development area, finally makes a new strong open software design platform for digital home. The platform supports different hardware environment and integrates the third party software. Through this platform, users can develop various kinds of systems on independent hardware, such as differentiation middleware, individual application. The platform is called UOSDP. 2 Analysis of Android System Android system integrates Java and C/C++ advantages, forms a easy to use and efficient smartphone development platform. This platform applies to both system developers and application developers and can be conveniently referred. D. Jin and S. Lin (Eds.): Advances in CSIE, Vol. 2, AISC 169, pp. 381 386. springerlink.com Springer-Verlag Berlin Heidelberg 2012
382 C. Cao Firstly, Android system has a good architecture, which can be divided into 5 levels from bottom to top. The first layer is Linux kernel, completes operation system function. This layer cuts Linux OS and adds related driver program, such as YAFFS2 Flash, Binder IPC driver, WiFi, bluetooth driver etc. The second is hardware abstraction layer, which provides hardware call interface for upper native framework. It realizes the calls of kernel hardware drivers by the methods of hardware module, hardware_legacy, or C++ inheritance realization.the third layer includes native libraries with C/C++ interface, JNI (Java Native Interface) and Java runtime environment. The libraries such as SQLite, WebKit, OpenGL etc[2]. can communicate with the upper layer through JNI. The base Java library and virtual machine Dalvik form Java runtime environment. The fourth is application framework layer, includes SDK and some class libraries[3]. It is the embodiment of the core mechanism of Android platform. The fifth is application layer, including applications provided by the system and the third party. Secondly, Dalvik virtual machine provides an running environment for Android java program, which executes.dex file. Google's Dalvik has characteristics of efficiency, conciseness and saving resources, is very suitable for embedded system with limited resources. Dex format is a compressed format, suitable for the system of limited memory and processor with limited speed [4]. Dalvik can run multiple processes, each application thread is corresponding to a Linux thread, each application is running in its own sandbox. Dalvik virtual machine is a highly modular system, which can be replaced by a separate different realization. Dalvik bases Linux, but has a certain commonality. At present it can support systems based on UNIX, Linux, BSD, Mac OSX. 3 UOSDP and Its Architecture With the popularity of Android, people hope Android can adapt to different hardware environment, combine with the third party software, and support different customers and other network environments. So far more than 170 kinds of Android devices are on the global market, which has proved the Android s high openness and expansibility. There is no doubt that Android developers will face the expansion demand of more bottom modules and the upper frames in the future. Therefore, to build general, open and independent design platform is necessary and urgent. General independent design platform has flexibility and modular structure, the user can combine system modules autonomously, then form development platform and real machine running environment, which can be suitable for different electronic products and different type developers. We can use and expand Android original ecological system, set up new Android software stack, then provide the industry general framework and application development platform irrelevant to equipment. Using its dynamic open source development community around it, developers can easily and quickly create new applications for their devices; OEM (Original Equipment Manufacturer) will be able to use more and more applications. Using the new ecological system, OEM will be able to fast rebuild and optimize particular development platform.
Research and Design of Universal and Open Software Development Platform 383 For large, complex software system, a clear system structure is very important. This structure will have features of open platform oriented service, open kernel and framework, open hardware platform. Using new platform, the third party software developers can develop applications based on their own core functions, can customize middleware system and operating system. UOSDP system architecture makes full use of the Android system success mode, still is divided into five layers. The first layer includes the OS based on Linux kernel, other OS and various device drivers. It realizes process scheduling, memory management, network communication, process communication and the function of virtual file system. The Binder process communication, YAFFS2 file system, Low Memory management (Low Memory Killer), anonymous Memory sharing (Ashmem) are increased in it. Device drivers include general equipment drivers such as flash driver, USB driver, and personalized device drivers such as display driver, keyboard driver in digital home system. This layer realizes free choosing OS, loading external equipments and device drivers, provides open hardware interface, supports different processor system structure. Especially for OS based on Linux, the processor system code is installed in the folder /arch /, equipment node in the folder /dev/. All equipments register in Platform_device file, device drivers in Platform_driver file. The second layer is hardware abstraction layer, which realizes driver calls and provides hardware calls interface for upper native frame. Same function realization can have different drivers. Hardware abstraction layer includes dynamically loadable libhardware.so (DLL) and its interface, different hardware abstract module (*. so or *.dll ) and its interface. Android native frame gets hardware modules id through libhardware interface, then dynamically opens hardware module and its interface, and calls kernel drivers through the method open( ) of hardware module. This layer realizes different hardware support in the way of adding hardware abstraction module, which embodies the openness and expansibility. The third layer is C++/C class library and Java runtime environment. In addition to the original SQLite, WebKit, OpenGL, it will expand the native library and service by using the existing mechanism to meet the development needs of different electronic equipment in digital home. The running environment still adopts Dalvik virtual machine. Expanding Dalvik is nessary to meet the needs of different operating systems and processors. This layer openness is reflected in the native software integration and the support to different processors and operating systems. The fourth is multiapplication framework layer. This layer contains different SDK to support the application development of different electronic equipment. The existing application frameworks will be expanded through new subclasses, overloading methods or new packages. This layer is developed by Java language, which realizes the aggregation and richness of application frameworks in the open-source way. The fifth is application layer, which contains various kinds of applications about different electronic equipments. After reconstruction, the UOSDP system architecture is as shown in figure1.
384 C. Cao Fig. 1. Platform system architecture 4 Key Technology of UOSDP 4.1 JNI Expansion As adding a new native library, its DLL with JNI mechanism must be constructed. JNI needs to be expanded. Android simplifies JNI development. Its main support library is nativehelper. The head file JNI.h defines the structure type JNINativeMethod which fulfills functions mapping. The structure is as follow[4]: Typedef struct {Const char * name; Const char * signature; Void * fnptr;} JNINativeMethod; The first variable stores a Java function name. The second variable stores function parameters and return value in string type. The third variable fnptr points to C function. Extension JNI algorithm for native library is as follows. 1) to build up native library API file, such as api1.cpp, in which the JNINativeMethod array is defined, each element realizes a pair of functions mapping.
Research and Design of Universal and Open Software Development Platform 385 2) to establish registration file, such as, using function registernativemethods owned by AndroidRuntime registers the array. 3) by using C++ development tools, the API file and related file will be compiled into DLL, then storing it in the module s JNI directory. 4) to write Java class with native methods, so that C++ native codes can be called in Java program. 4.2 Combination of Android System and Different Hardware Environment At present Dalvik supports platform Linux, BSD, Mac OSX and the system based on UNIX. For different processors under these OS, the first is to construct the interpreter for specific architecture CPU. Assumed that the name of the CPU architecture is called Myarch, the main procedure is as follows. 1) building a new compiling configuration file config-myarch for Myarch. To the file content we can copy existing file config-allstubs, and make the necessary changes. 2) using the tool gen-mterp. py provided by the system, through the configuration file config-myarch, then generating interpreters InterpAsm-Myarch.S of assembly language edition and InterpC-Myarch.C of C language version. 3) expanding the file /dalvik/vm/dvm. mk, adding processor architecture code files and interpreter files. The statements are described as follows: Ifeq ($(dvm_arch), Myarch) # dvm_arch_variant: = Myarch MTERP_ARCH_KNOWN: = true LOCAL_SRC_FILES + = \ # processor architecture interface code files Arch / $(dvm_arch_variant) /CallMyarchABI. S Arch / $(dvm_arch_variant) /HintMyarchABI. C # interpreter file mterp/out/interpasm-myarch. S mterp/out/interpc-myarch. C endif 4.3 Combination of Different Operating Systems and Android Middleware For different operating systems, such as operating system supporting set-top box, Dalvik virtual machine needs transplantation and modification. Dalvik virtual machine is based on Apache Harmony technical architecture with stratified and modular structure[4]. In the structure, the top is Java library, the middle is virtual machine, the lower is operating system. In virtual machine, the portability layer encapsulates the differences of different operating system, which provides unified interface accessing low-level system. Specifically, Dalvik virtual machine has process mechanism. On the one hand, it retains traditional Java process control API, on the other hand it combines the characteristics of Linux operating system and adds special process control API [4]. Dalvik provides the class dalvik.system.zygote, Zygote has the zygote interface that is used to access Dalvik virtual machine. Zygote packages the function fork( ) owned by Linux system, which is used to create a new instance of
386 C. Cao virtual machine process and run Android application. So, for different operating system, we only need to modify Zygote, rewrite fork( ) function and interface class. The expanded Portability layer can adapt to different operating systems. 5 Conclusion After achieving initial success in the mobile phone market, Android now start entering into other digital equipment field. In digital home system, the traditional DTV, set-top box and blue light have finite application, Android can easily extend the applications taking network as the center, make equipments have Internet connectivity. They not only have local functions, but also have new network services. Basing on Android, the open design platform UOSDP will provide a deviceindependent, flexible structure, modular customization and commonality support system. The platform structure in this paper proposes opening strategy in every level for different kinds developers to participate in and build it. Acknowledgement. This work is supported by National Engineering Research Center of Digital Life, Guangzhou 510006, China, under Grant No. 2011NERCDL001. References 1. Chenjing, Chen, P., Li, W.: Analysis of Android Kernel. Modern Computer, 112 114 (November 2009) 2. Hanchao, Lianquan: Android Deep Development in System Level, pp. 12 13. Publishing House of Electronics Industry, Beijing (2011) 3. Wang, Y.: Development Travel on Android Platform, pp. 3 4. Publishing House of Electronics Industry, Beijing (2011) 4. Yang, F.: Android Internals: System, pp. 468 524. China Machine Press, Beijing (2011) 5. Yi, P.: Research on Structure and Performance of Dalvik Virtual Machine[EB/OL]. Jiling University (April 2011), http://dlib.cnki.net/kns50/detail.aspx? dbname=cmfd2011&filename=1011100372.nh 6. Zou, G.: Porting and Optimization of Dalvik Virtual Machine of Android on Loongsonbased platform[eb/ol]. China University of Petroleum (May 2011), http://d.g.wanfangdata.com.cn/thesis_y1875804.aspx 7. Android Open Source Project[EB/OL], http://source.android.com/ 8. McFadden, A.: Dalvik Porting Guide[EB/OL], http://android.git.kernel.org