® BOOKS FOR PROFESSIONALS BY PROFESSIONALS Cohen Wang Android Application Development for the Intel® Platform The number of Android devices running on Intel processors has increased since Intel and Google announced, in late 2011, that they would be working together to optimize future versions of Android for Intel Atom processors. Today, Intel processors can be found in Android smartphones and tablets made by some of the top manufacturers of Android devices, such as Samsung, Lenovo, and Asus. The increase in Android devices featuring Intel processors has created a demand for Android applications optimized for Intel architecture: Android Application Development for the Intel® Platform is the perfect introduction for software engineers and mobile app developers. Through well-designed app samples, code samples, and case studies, the book teaches Android application development based on the Intel platform—including smartphones, tablets, and embedded devices—covering performance tuning, debugging, and optimization. This book is jointly developed for individual learning by Intel Software College and China Shanghai JiaoTong University. What You’ll Learn: • Comprehensive introduction to the Intel® embedded and mobile hardware platform • Android app GUI design principles and guidelines • The latest Intel Android development tools, including Intel Beacon Mountain version 0.6 and the Intel Compiler • NDK and C/C++ optimization • Designing and optimizing for low power consumption ISBN 978-1-4842-0101-5 53999 Shelve in Mobile Computing User level: Beginning–Advanced 9781484201015 For your convenience Apress has placed some of the front matter material after the index. Please use the Bookmarks and Contents at a Glance links to access them. Contents at a Glance About the Lead Project Editor ��������������������������������������������������������xvii About the Lead Contributing Author �����������������������������������������������xix About the Technical Reviewer ��������������������������������������������������������xxi Introduction ����������������������������������������������������������������������������������xxiii ■ Chapter 1: Overview of Embedded Application Development for Intel Architecture ����������������������������������������������������������������������1 ■ Chapter 2: Intel Embedded Hardware Platform ����������������������������19 ■ Chapter 3: Android Application Development Processes and Tool Chains for Intel® Architecture ��������������������������������������������47 ■ Chapter 4: Real Device Environment Installation �������������������������85 ■ Chapter 5: The Android OS����������������������������������������������������������131 ■ Chapter 6: Customization and Installation of Android ����������������191 ■ Chapter 7: GUI Design for Android Apps, Part 1: General Overview �����������������������������������������������������������������������203 ■ Chapter 8: GUI Design for Android Apps, Part 2: The Android-Specific GUI ������������������������������������������������������������235 ■ Chapter 9: GUI Design for Android Apps, Part 3: Designing Complex Applications ������������������������������������������������271 ■ Chapter 10: GUI Design for Android Apps, Part 4: Graphic Interface and Touchscreen Input �����������������������������������305 v ■ Contents at a GlanCe ■ Chapter 11: Performance Optimization for Android Applications on x86 �����������������������������������������������������������������������335 ■ Chapter 12: NDK and C/C++ Optimization ����������������������������������391 ■ Chapter 13: The Low-Power Design of Android Application and Intel Graphics Performance Analyzers (Intel GPA): Assisted Power Optimization ���������������������������������������������������������445 Index ����������������������������������������������������������������������������������������������483 vi Introduction The number of Android devices running on Intel processors has gradually increased ever since Intel and Google announced, in late 2011, that they would be working together to optimize future versions of Android for Intel Atom processors. Today, Intel processors can be found in Android smartphones and tablets made by some of the top manufacturers of Android devices, such as Samsung, Lenovo, and Asus. The increase in Android devices featuring Intel processors has created a demand for Android applications optimized for Intel architecture. This book was written to help introduce developers of all skill levels to the tools they need to develop and optimize applications for the Intel platform. Chapter 1 This chapter discusses principles for embedded systems, the architecture of SoC, and some pros and cons of platforms such as ARM and x86/x64. Chapter 2 This chapter goes into detail about specific Intel hardware platforms. It covers Intel Atom processors, Intel SoCs, and retail devices. Chapter 3 This chapter introduces Android application development on Intel hardware platforms. It also covers installing the development environment tools for an emulator target machine by showing each tool and application and how to download and install them. Chapter 4 This chapter discusses how to set up and configure the application development software on a host system and install USB drivers for a real Android device, so that you can build the connection between the device and host system to allow testing and debugging of applications. It also discusses how to use the Intel emulator and the steps required to accelerate the emulator and work with it. xxiii ■ IntroduCtIon Chapter 5 This chapter covers the Android OS and helps build your understanding for subsequent development of embedded applications. Chapter 6 This chapter discusses customization in an embedded OS and then explains how to customize Android, specifically. Chapter 7 This chapter introduces the general GUI design method for desktop systems and then shows how designing the UI and UX for embedded systems is different. It also discusses general methods and principles of GUI design for Android applications. Chapter 8 This chapter introduces Android interface design by having you create a simple application called GuiExam. You learn about the state transitions of activities, the Context class, intents, and the relationship between applications and activities. Finally, the chapter shows how to use the layout as an interface by changing the layout file activity_main.xml, and how the button, event, and inner event listeners work. Chapter 9 In this chapter, you learn how to create an application with multiple activities. This application is used to introduce the explicit and implicit trigger mechanisms of activities. Next, you see an example of an application with parameters triggered by an activity in a different application, which will help you understand of the exchange mechanism for the activity’s parameters. Chapter 10 This chapter introduces the basic framework of drawing in the view, how the drawing framework responds to touchscreen input, and how to control the display of the view as well as the multi-touch code framework. Examples illustrate the multi-touch programming framework and keyboard-input responses. You also learn how to respond to hardware buttons on Android devices, such as Volume +, Volume –, Power, Home, Menu, Back, and Search. After that, you see the three different dialog boxes for Android, including the activity dialog theme, specific dialog classes, and toast reminders. Finally, you learn how to change application property settings. xxiv ■ IntroduCtIon Chapter 11 This chapter introduces the basic principles of performance optimization, optimization methods, and related tools for Android application development. Chapter 12 This chapter introduces the Android NDK for C/C++ application development, along with related optimization methods and optimization tools. It talks about how the Intel mobile hardware and software provide a basis for low-power design and how the Intel Atom processor provides hardware support for low power, which is a major feature of the Android operating system. Chapter 13 This chapter provides an overview of and introduction to low-power design, followed by a discussion of Android power-control mechanisms. Finally, it covers how to achieve the goal of low-power application design. The hope is that this book will help developers to create amazing Android applications that are optimized for the Intel platform. You can find further information on developing applications for Intel architecture at the Intel Developer Zone web site (https://software.intel.com/en-us/android). xxv Chapter 1 Overview of Embedded Application Development for Intel Architecture Embedded systems, an emerging area of computer technology, combine multiple technologies, such as computers, semiconductors, microelectronics, and the Internet, and as a result, are finding ever-increasing application in our modern world. With the rapid development of computer and communications technologies and the growing use of the Internet, embedded systems have brought immediate success and widespread application in the post-PC era, especially as the core components of the Internet of Things. They penetrate into every corner of modern life from the mundane, such as an automated home thermostat, to industrial production, such as in robotic automation in manufacturing. Embedded systems can be found in military and national defense, healthcare, science, education, and commercial services, and from mobile phones, MP3 players, and PDAs to cars, planes, and missiles. This chapter provides the concepts, structure, and other basic information about embedded systems and lays a theoretical foundation for embedded application development, of which application development for Android OS is becoming the top interest of developers. Introduction to Embedded Systems Since the advent of the first computer, the ENIAC, in 1946, the computer manufacturing process has gone from vacuum tubes, transistors, integrated circuits, and large-scale integration (LSI), to very-large-scale integration (VLSI), resulting in computers that are more compact, powerful, and energy efficient but less expensive (per unit of computing power). After the advent of microprocessors in the 1970s, the computer-using world witnessed revolutionary change. Microprocessors are the basis of microcomputers, and personal computers (PCs) made them more affordable and practical, allowing many private users to own them. At this stage, computers met a variety of needs: they were sufficiently versatile to satisfy various demands such as computing, entertainment, information sharing, and office automation. As the adoption of microcomputers was 1 Chapter 1 ■ Overview Of embedded appliCatiOn develOpment fOr intel arChiteCture occurring, more people wanted to embed them into specific systems to intelligently control the environment. For example, microcomputers were used in machine tools in factories. They were used to control signals and monitor the operating state through the configuration of peripheral sensors. When microcomputers were embedded into such environments, they were prototypes of embedded systems. As the technology advanced, more industries demanded special computer systems. As a result, the development direction and goals of specialized computer systems for specific environments and general-purpose computer systems grew apart. The technical requirement of general-purpose computer systems is fast, massive, and diversified computing, whereas the goal of technical development is faster computing speed and larger storage capacity. However, the technical requirement of embedded computer systems is targeted more toward the intelligent control of targets, whereas the goal of technical development is embedded performance, control, and reliability closely related to the target system. Embedded computing systems evolved in a completely different way. By emphasizing the characteristics of a particular processor, they turned traditional electronic systems into modern intelligent electronic systems. Figure 1-1 shows an embedded computer processor, the Intel Atom N2600 processor, which is 2.2 × 2.2 cm, alongside a penny. Figure 1-1. Comparison of an embedded computer chip to a US penny. This chip is an Intel Atom processor The emergence of embedded computer systems alongside general-purpose computer systems is a milestone of modern computer technologies. The comparison of general-purpose computers and embedded systems is shown in Table 1-1. 2 Chapter 1 ■ Overview Of embedded appliCatiOn develOpment fOr intel arChiteCture Table 1-1. Comparison of General-Purpose Computers and Embedded Systems Item General-purpose Embedded systems computer systems Hardware High-performance hardware, Diversified hardware, large storage media single-processor solution Software Large and sophisticated OS Streamlined, reliable, real-time systems Development High-speed, specialized Broad development sectors development team Today, embedded systems are an integral part of people’s lives due to their mobility. As mentioned earlier, they are used everywhere in modern life. Smartphones are a great example of embedded systems. Mobile Phones Mobile equipment, especially smartphones, is the fastest growing embedded sector in recent years. Many new terms such as extensive embedded development and mobile development have been derived from mobile software development. Mobile phones not only are pervasive but also have powerful functions, affordable prices, and diversified applications. In addition to basic telephone functions, they include, but are not limited to, integrated PDAs, digital cameras, game consoles, music players, and wearables. Consumer Electronics and Information Appliances Consumer electronics and information appliances are additional big application sectors for embedded systems. Devices that fall into this category include personal mobile devices and home/entertainment/audiovisual devices. Personal mobile devices usually include smart handsets such as PDAs, as well as wireless Internet access equipment like mobile Internet devices (MIDs). In theory, smartphones are also in this class; but due to their large number, they are listed as a single sector. Home/entertainment/audiovisual devices mainly include network television like interactive television; digital imaging equipment such as digital cameras, digital photo frames, and video players; digital audio and video devices such as MP3 players and other portable audio players; and electronic entertainment devices such as handheld game consoles, PS2 consoles, and so on. Tablet PCs (tablets), one of the newer types of embedded devices, have become favorites of consumers since Apple released the iPad in 2010. The affordability of consumer electronics truly reflects the cost-effectiveness of embedded system design. 3
Description: