My DIY Android journey-Android Application Layer app calls underlying driver instances (bitter history)

Source: Internet
Author: User

In this era of smart phones, I believe that a mobile phone with its own personality can attract its users, the iPhone has built its own IOS mobile operating system on the basis of innovative and personalized hardware, giving users a very special user experience, thus winning the market and the rapid development of Android, various types of Android mobile phones are continuously launched, and the market share is constantly rising. In addition, Android mobile phone shipments are also growing dramatically, and mobile phone operating systems are already in the Three-Point world, and the Android Market is constantly increasing. Windows Phone 8 led by Nokia has its own Metro style. Apple's iPhone has won the market with its excellent user experience. Android is open and personalized with it, and a better user experience will win more users, and in this process, our Android-driven development engineers will integrate more and more excellent and interesting hardware into the Android system to make Android phones with better personality.

At the beginning, I started to learn about Android development. I suggest you study the course of compiling the Linux kernel driver by Lao Luo and accumulate some basic knowledge about Android driver development.

I. after learning about the android driver development program, I suggest you first read the reference books for basic Android driver development: Linux Device Drivers (strongly recommended five-star recommendation) and several other good reference books: android driver development and porting practices.

II. refer to Lao Luo's driver compiling tutorial, compile the driver and implement the service framework at the framework layer, create a hello Android project in eclipse, and set the R. copy Java to the out/target/common/r directory. When copying a project from eclipse, delete the gen directory. Otherwise, the R class definition will be repeated. When copying a project from eclipse to the android source code directory, only androidmanifest is left. the XML file and the res and SRC folders can be deleted, and other files can be deleted, and then an android. MK file.

For more information, see Lao Luo's blog: http://blog.csdn.net/luoshengyang/article/details/6567257

Compilation went smoothly and no errors were found!

Then run the simulator to check whether the application layer app has successfully called the underlying layer,Emulator-kernel. /prebuilt/Android-arm/kernel-qemu-Sysdir. /out/target/product/generic-system. IMG-data userdata. IMG-ramdisk. IMG

It has been found that the simulator has been unable to enter the system for a long time and remains on the android character interface. It can also be seen that the simulator has been restarted repeatedly, I thought an error occurred in the written driver and framework-layer code. I checked it carefully from the beginning and suspected that the compilation was not running properly, I decided to re-compile the entire android source code. Ah, Lili's compilation has passed several hours and everything is normal. It hasn't solved this problem that has been stuck on the android boot interface.

I am struggling to go around on csdn and look up various materials

After a few days, I still cannot solve the problem!

Finally got the netizen lovebeyond1014 (csdn blog column: http://blog.csdn.net/lovebeyond1014) Help, In this thank you! It may be a compilation command error.

Try to use make droidcore to compile as prompted by netizens...

I used make droidcore to compile the entire project. The Code has been fully compiled!

PS: I found that systemimage was executed at the beginning, so I tried to use make
Systemimage to compile:
Modify the source code in the framework, mm in the framework/base, return to the source code root directory, make systemimage, start the simulator, and the modification effect is displayed successfully.
1. It seems that the execution of make Snod (systemimage no dependence) is not good. It seems that dependence must be compiled.
2. After make systemimage, you must disable the simulator and restart it. Execute ADB shell stop, and neither can ADB shell start.

The simulator will still stop on the android boot interface. When I checked the information, I suddenly realized that the simulator itself could get logs to analyze the running information! Fainted. I forgot this one a few days ago and tried to get logs. I even thought of installing my compiled SDK in eclipse and trying to get the simulator running logs through eclipse, it's really brain !!!

Run ADB Shell

# Logcat

D/SensorService(   67): nuSensorService starting...E/SensorService(   67): couldn't open device for module sensors (Invalid argument)I/sysproc (   67): System server: starting Android runtime.I/sI/Installer(   67): connecting...I/installd(   40): new connectionW/PackageManager(   67): Unknown permission com.google.android.googleapps.permission.GOOGLE_AUTH in package com.android.providers.contactsW/PackageManager(   67): Unknown permission com.google.android.googleapps.permission.GOOGLE_AUTH.cp in package com.android.providers.contactsW/PackageManager(   67): Unknown permission com.google.android.gm.permission.WRITE_GMAIL in package com.android.settingsW/PackageManager(   67): Not granting permission android.permission.DEVICE_POWER to package com.android.deskclock (
I/SystemServer(   67): System Content ProvidersI/ActivityThread(   67): Pub settings: com.android.providers.settings.SettingsProviderI/SystemServer(   67): Battery ServiceW/dalvikvm(   67): No implementation found for native Lcom/android/server/BatteryService;.native_update ()VW/dalvikvm(   67): threadid=9: thread exiting with uncaught exception (group=0x40015560)E/AndroidRuntime(   67): *** FATAL EXCEPTION IN SYSTEM PROCESS: android.server.ServerThreadE/AndroidRuntime(   67): java.lang.UnsatisfiedLinkError: native_updateE/AndroidRuntime(   67): at com.android.server.BatteryService.native_update(Native Method)E/AndroidRuntime(   67): at com.android.server.BatteryService.update(BatteryService.java:209)E/AndroidRuntime(   67): at com.android.server.BatteryService.<init>(BatteryService.java:135)E/AndroidRuntime(   67): at com.android.server.ServerThread.run(SystemServer.java:172)E/AndroidRuntime(   67): Error reporting crashE/AndroidRuntime(   67): java.lang.NullPointerExceptionE/AndroidRuntime(   67): at android.os.DropBoxManager.isTagEnabled(DropBoxManager.java:288)E/AndroidRuntime(   67): at com.android.server.am.ActivityManagerService.addErrorToDropBox(ActivityManagerService.java:6775)E/AndroidRuntime(   67): at com.android.server.am.ActivityManagerService.handleApplicationCrash(ActivityManagerService.java:6492)E/AndroidRuntime(   67): at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:76)E/AndroidRuntime(   67): at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:854)E/AndroidRuntime(   67): at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:851)I/Process (   67): Sending signal. PID: 67 SIG: 9I/Zygote  (   37): Exit zygote because system server (67) has terminatedE/installd(   40): eofE/installd(   40): failed to read sizeI/installd(   40): closing connectionI/ServiceManager(   32): service 'usagestats' diedI/ServiceManager(   32): service 'sensorservice' diedI/Netd    (   96): Netd 1.0 startingD/AndroidRuntime(   97): D/AndroidRuntime(   97): >>>>>> AndroidRuntime START com.android.internal.os.ZygoteInit <<<<<<D/AndroidRuntime(   97): CheckJNI is ON
I/gralloc (  105): refresh rate = 651.04 HzD/libEGL  (  105): egl.cfg not found, using default configD/libEGL  (  105): loaded /system/lib/egl/libGLES_android.soI/SurfaceFlinger(  105): EGL informations:I/SurfacI/SystemServer(  105): Telephony RegistryI/SystemServer(  105): Package ManagerI/Installer(  105): connecting...I/installd(   40): new connectionD/dalvikvm(  105): GC_CONCURRENT freed 181K, 51% free 2783K/5639K, external 716K/1038K, paused 6ms+10msW/PackageManager(  105): Running ENG build: no pre-dexopt!

After carefully checking the data analysis, the system restarts repeatedly because of initialization problems. The system restarts the connection repeatedly due to the protection mechanism, and starts to suspect that the permission problem is caused, and then checks the information on the Internet. Finally, we carefully analyzed logcat and found that the possible cause was a problem with the battery service registration at the framework layer. We found the framework-Layer Code, android2.3/frameworks/base/services/JNI/onload. CPP. Check it carefully and find that the registration function of the battery service is faulty. I may have deleted the registration function of the battery service when modifying the framework layer code. The tragedy is ....

Modify the code and compile the entire project code. Note that make droidcore is used instead of make Snod!

Restart the simulator, emulator-kernel. /prebuilt/Android-arm/kernel-qemu-Sysdir. /out/target/product/generic-system. IMG-data userdata. IMG-ramdisk. IMG,

Detected driver I/systemserver (69): appwidget Service
I/systemserver (69): recognition Service
I/systemserver (69): diskstats Service
I/systemserver (69): Hello Service
I/helloservice (69): Hello JNI: initializing ......
E/helloservice (69): Hello JNI: failed to get Hello stub module.
I/windowmanager (69): Safe mode not enabled

It is estimated that make clean clears the "component" generated by the driver and recompiles the driver-layer code.

3. The supervisor is not installed in the built-in image of the system. I checked the information online and found that the simulator can install a custom Android Application. Then I directly executed # ADB install-r hello.apk and found that hello.apk is properly installed, alas, I sigh that this is also true for pods, but there are more gorgeous interfaces and some new functions.

Reference: http://www.miui.com/thread-656871-1-1.html

Running the hello application, I found that the underlying driver can be normally called. It was a great success. What a bitter journey !!!

Next, take a closer look at the knowledge of Android driver development and continue to develop ....

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.