Note 30 july 2009: updated the post. It now reflects the changes made to the repository (dream is now called dream-open)
Note 13 july 2009: Vladimir Stepanov post a reply today, telling me that the media files are already part of the source tree and can be found at ~/mydroid/fameworks/base/data/sounds. Adding the media files is a lot easier this way. I changed this blogpost about how to include those media files inside the system image.
This will be (for now) the last post of the building Android 1.5 for the Android Dev Phone. In the previous posts I explained how to prepare your building environment (Ubuntu 8.04), get the source and make it ready for building, building the source and finaly flash it to your device. Your own build should be working fine, but comparing to the official builds you are missing the Google applications like GMail, Google Maps, Android Market and YouTube. Besides the applications missing there are also no ringtones available on your device.
In this blogpost you will extract the Google Applications and media files from the official HTC Android 1.5 image (this can be done by extracting them from your device or with the use of unyaffs). The extracted files will be added to your own Android image. This results in an Android build which is almost the same as the HTC version.
Note: it is also possible to install the applications and add the media files while your device is running. But the purpose of this blog post is to create your own image which can be flashed over and over again (or even exchanged between other Android Dev Phone users)
Audio Files
In the official HTC image (http://www.htc.com/www/support/android/adp.html) a system/media directory exists which contains audio files for the alarms, notifications, ringtones and ui. These audio files are also part of the source tree but are not included by default.
Inside the ~/mydroid/frameworks/base/data/sounds folder you will find the different audio files. Together with those audio files there are two build scripts: OriginalAudio.mk and AudioPackage2.mk (containing a larger audio pack). Just rename one of those two script to Android.mk.
mv ~/mydroid/frameworks/base/data/sounds/OriginalAudio.mk ~/mydroid/frameworks/base/data/sounds/Android.mk
You can create a new image by running the make command from ~\mydroid location. The make command will not compile everything again. Only the changed files. In our case nothing will be recompiled, only the media files will be added to the system.img.
After the make command is finished you can flash the new image to your phone. If you are already running your own build, you only need to flash the system.img. You can found more details about the flash process at the Flashing The Phone blogpost.
Google Applications
Besides the missing audio files, are also the closed source Google Applications not installed. The following list of applications are not installed
checkin.apk (needed for login with Google Account) Gmail.apk GmailProvider.apk (the synchronization module for GMail) GoogleApps.apk GoogleContactsProvider.apk (replacement for the ContactsProvider. This version will synchronize with your Google Contacts) GooglePartnerSetup.apk GoogleSettingsProvider.apk GoogleSubscribedFeedsProvider.apk (replacement for the SubscribedFeedsProvider.apk) gtalkservice.apk (for Google Talk) Maps.apk (Google Maps) MediaUploader.apk NetworkLocation.apk (for determining your location based on network cells) SetupWizard.apk (for setting up your Google Account connected with your device) Street.apk (Google Maps StreetView) Talk.apk (Google Talk application) Vending.apk (Android Market applicatioN) VoiceSearch.apk (Voice Search) YouTube.apk (YouTube application)
Note: the HTC image does have more application installed by default. But I think those are not relevant for your own build but HTC related: BugReport.apk, DebugTool.apk, FieldTest.apk, HtcLog.apk and QxdmLog.apk. Let me know if you think (with some information) that these packages should be part of your own build. Also the use/need of the Ftp.apk package is not clear. And I did not add the SystemUpdater.apk because this is your own build so you should provide updates for it (and not HTC/Google).
The Google applications make use of extra libraries and permission files. So also these files should be part of our build:
com.google.android.gtalkservice.jar (is placed inside the framework directory of the system image and will be used with GoogleTalk) com.google.android.maps.jar (also part of the framework and is use by Google Maps) com.google.android.gtalkservice.xml (permission file for gtalkservice library, placed inside the etc\permissions directory) com.google.android. maps.xml (permission file for maps library, placed inside the etc\permissions directory)
Just like with the media files, the extracting of these files can be done with adb or unyaffs. The keep thing seperated, I decided to put the extracted files inside the ~/mydroid/vendor/google directory. Because the google directory does not exist, go to the ~/mydroid/vendor location and create the google folder.
cd ~/mydroid/vendor mkdir google cd google
Extracting with adb
The procedure for extracting the files with the adb tool is the same as with the media files. Just create a new script called extract-google-files.sh inside the ~/mydroid/vendor/google folder. Place the following commands inside the file
#!/bin/sh mkdir -p app adb pull /system/app/checkin.apk app/checkin.apk adb pull /system/app/Gmail.apk app/Gmail.apk adb pull /system/app/GmailProvider.apk app/GmailProvider.apk adb pull /system/app/GoogleApps.apk app/GoogleApps.apk adb pull /system/app/GoogleContactsProvider.apk app/GoogleContactsProvider.apk adb pull /system/app/GooglePartnerSetup.apk app/GooglePartnerSetup.apk adb pull /system/app/GoogleSettingsProvider.apk app/GoogleSettingsProvider.apk adb pull /system/app/GoogleSubscribedFeedsProvider.apk app/GoogleSubscribedFeedsProvider.apk adb pull /system/app/gtalkservice.apk app/gtalkservice.apk adb pull /system/app/Maps.apk app/Maps.apk adb pull /system/app/MediaUploader.apk app/MediaUploader.apk adb pull /system/app/NetworkLocation.apk app/NetworkLocation.apk adb pull /system/app/SetupWizard.apk app/SetupWizard.apk adb pull /system/app/Street.apk app/Street.apk adb pull /system/app/Talk.apk app/Talk.apk adb pull /system/app/Vending.apk app/Vending.apk adb pull /system/app/VoiceSearch.apk app/VoiceSearch.apk adb pull /system/app/YouTube.apk app/YouTube.apk mkdir -p etc/permissions adb pull /system/etc/permissions/com.google.android.gtalkservice.xml etc/permissions/com.google.android.gtalkservice.xml adb pull /system/etc/permissions/com.google.android.maps.xml etc/permissions/com.google.android.maps.xml mkdir -p framework adb pull /system/framework/com.google.android.gtalkservice.jar framework/com.google.android.gtalkservice.jar adb pull /system/framework/com.google.android.maps.jar framework/com.google.android.maps.jar
Save and exit the editor. Make sure that your device is connected to Ubuntu. Execute the script by executing the command (from the location ~/mydroid/vendor/google)
./extract-google-files.sh
The different files, needed for the Google applications, will be extracted from your device and placed inside app, etc or framework directory. The build script should be updated so that those files are included inside your own build. This will be explained further in this blog post. First I will explain how to get the files with the use of unyaffs.
Extracting with unyaffs
For the media files I already explained how to use the unyaffs tool. So I presume that the system image is extracted inside the ~/htc directory. You only need to copy the files to the ~/vendor/google location. This will need some more commands than with the media files.
mkdir -p ~/mydroid/vendor/google/app cp ~/htc/app/checkin.apk ~/mydroid/vendor/google/app/checkin.apk cp ~/htc/app/Gmail.apk ~/mydroid/vendor/google/app/Gmail.apk cp ~/htc/app/GmailProvider.apk ~/mydroid/vendor/google/app/GmailProvider.apk cp ~/htc/app/GoogleApps.apk ~/mydroid/vendor/google/app/GoogleApps.apk cp ~/htc/app/GoogleContactsProvider.apk ~/mydroid/vendor/google/app/GoogleContactsProvider.apk cp ~/htc/app/GooglePartnerSetup.apk ~/mydroid/vendor/google/app/GooglePartnerSetup.apk cp ~/htc/app/GoogleSettingsProvider.apk ~/mydroid/vendor/google/app/GoogleSettingsProvider.apk cp ~/htc/app/GoogleSubscribedFeedsProvider.apk ~/mydroid/vendor/google/app/GoogleSubscribedFeedsProvider.apk cp ~/htc/app/gtalkservice.apk ~/mydroid/vendor/google/app/gtalkservice.apk cp ~/htc/app/Maps.apk ~/mydroid/vendor/google/app/Maps.apk cp ~/htc/app/MediaUploader.apk ~/mydroid/vendor/google/app/MediaUploader.apk cp ~/htc/app/NetworkLocation.apk ~/mydroid/vendor/google/app/NetworkLocation.apk cp ~/htc/app/SetupWizard.apk ~/mydroid/vendor/google/app/SetupWizard.apk cp ~/htc/app/Street.apk ~/mydroid/vendor/google/app/Street.apk cp ~/htc/app/Talk.apk ~/mydroid/vendor/google/app/Talk.apk cp ~/htc/app/Vending.apk ~/mydroid/vendor/google/app/Vending.apk cp ~/htc/app/VoiceSearch.apk ~/mydroid/vendor/google/app/VoiceSearch.apk cp ~/htc/app/YouTube.apk ~/mydroid/vendor/google/app/YouTube.apk mkdir -p ~/mydroid/vendor/google/etc/permissions cp ~/htc/etc/permissions/com.google.android.gtalkservice.xml ~/mydroid/vendor/google/etc/permissions/com.google.android.gtalkservice.xml cp ~/htc/etc/permissions/com.google.android.maps.xml ~/mydroid/vendor/google/etc/permissions/com.google.android.maps.xml mkdir -p ~/mydroid/vendor/google/framework cp ~/htc/framework/com.google.android.gtalkservice.jar ~/mydroid/vendor/google/framework/com.google.android.gtalkservice.jar cp ~/htc/framework/com.google.android.maps.jar ~/mydroid/vendor/google/framework/com.google.android.maps.jar
The different files needed for the application are now placed inside the app, etc and framework directory (at ~/mydroid/vendor/google). Next step is to edit the buildscripts
Changing the build script for the Google applications
The htc_dream.mk build script should be edited. I decided to change the htc_dream.mk build script so that it does not depend on the build/target/product/generic.mk script (which depends on the build/target/product.core.mk file). The reason I do this, is that I don’t want to have the generic providers be part of my own build. Those providers will be replaced with the Google specific version (so the ContactsProvider is not needed anymore because the GoogleContactsProvider will be used instead). I could off course remove them from the generic.mk and core.mk files, but I don’t want to edit those files to keep things seperated. Because the core.mk also contains packages which I don’t want to be part of the build, I cannot change the dependency of the htc_dream.mk from generic.mk to core.mk. So the dependencies will be completly removed.
At the point also the SdkSetup package is not needed anymore, because we are using the SetupWizard package. (The SdkSetup package does some small things like making it possible to make phone calls. This functionality is also part of the SetupWizard package).
To add the Google applications a PRODUCT_COPY_FILES section should be added to the htc_dream.mk file. We use PRODUCT_COPY_FILES because the packages are already in a binary format and only need to be copied to the system image.
One of the packages is the NetworkLocation package. This package contains functionality to determine your position based on network GSM cells. To get this package working an extra build property should be set. This can be done by adding the PRODUCT_PROPERTY_OVERRIDES variable to the htc_dream.mk file which contains the property ro.com.google.locationfeatures=1
The complete htc_dream.mk script (which can be find inside the ~/mydroid/vendor/htc/dream-open location) is placed below.
PRODUCT_PROPERTY_OVERRIDES := \
ro.config.notification_sound=F1_New_SMS.ogg \
ro.com.google.locationfeatures=1
PRODUCT_PACKAGES := \
framework-res \
Browser \
Contacts \
Launcher \
HTMLViewer \
Phone \
DownloadProvider \
GoogleSearch \
MediaProvider \
SettingsProvider \
TelephonyProvider \
UserDictionaryProvider \
PackageInstaller \
Bugreport \
AlarmClock \
AlarmProvider \
Calendar \
Camera \
DrmProvider \
LatinIME \
Mms \
Music \
Settings \
Sync \
Updater \
CalendarProvider \
SyncProvider \
Calculator \
Email \
ImProvider \
VoiceDialer
PRODUCT_COPY_FILES := \
vendor/google/app/checkin.apk:system/app/checkin.apk \
vendor/google/app/Gmail.apk:system/app/Gmail.apk \
vendor/google/app/GmailProvider.apk:system/app/GmailProvider.apk \
vendor/google/app/GoogleApps.apk:system/app/GoogleApps.apk \
vendor/google/app/GoogleContactsProvider.apk:system/app/GoogleContactsProvider.apk \
vendor/google/app/GooglePartnerSetup.apk:system/app/GooglePartnerSetup.apk \
vendor/google/app/GoogleSettingsProvider.apk:system/app/GoogleSettingsProvider.apk \
vendor/google/app/GoogleSubscribedFeedsProvider.apk:system/app/GoogleSubscribedFeedsProvider.apk \
vendor/google/app/gtalkservice.apk:system/app/gtalkservice.apk \
vendor/google/app/Maps.apk:system/app/Maps.apk \
vendor/google/app/MediaUploader.apk:system/app/MediaUploader.apk \
vendor/google/app/NetworkLocation.apk:system/app/NetworkLocation.apk \
vendor/google/app/SetupWizard.apk:system/app/SetupWizard.apk \
vendor/google/app/Street.apk:system/app/Street.apk \
vendor/google/app/Talk.apk:system/app/Talk.apk \
vendor/google/app/Vending.apk:system/app/Vending.apk \
vendor/google/app/VoiceSearch.apk:system/app/VoiceSearch.apk \
vendor/google/app/YouTube.apk:system/app/YouTube.apk \
vendor/google/etc/permissions/com.google.android.gtalkservice.xml:system/etc/permissions/com.google.android.gtalkservice.xml \
vendor/google/etc/permissions/com.google.android.maps.xml:system/etc/permissions/com.google.android.maps.xml \
vendor/google/framework/com.google.android.gtalkservice.jar:system/framework/com.google.android.gtalkservice.jar \
vendor/google/framework/com.google.android.maps.jar:system/framework/com.google.android.maps.jar
# Overrides
PRODUCT_NAME := htc_dream
PRODUCT_DEVICE := dream-open
PRODUCT_MANUFACTURER := htc
PRODUCT_BRAND := generic
PRODUCT_POLICY := android.policy_phone
Save the file and exit the editor. The build script for the google applications is now ready. Before running the make command again remove the ~/mydroid/out/target/product/dream-open/system directory first. If you don’t remove this directory when you remove packages (like the SdkSetup) from your build, those packages will still be copied to your final build. The system directory contains the binary version of your system image but when you remove this directory the binary files will not be recompiled again (there are intermediates version inside the ~/mydroid/out/target/product/dream/obj directory
rm -rf ~/mydroid/out/target/product/dream-open/system
Now you can run the make command again (from the ~\mydroid locatin). Like I already said, the make command will not compile everything again. Only the changed files. In our case nothing will be recompiled, only the google files will be added to the system.img.
After the make command is finished you can flash the new image to your phone. If you are already running your own build, you only need to flash the system.img. You can found more details about the flash process at the Flashing The Phone blogpost.
What’s next?
If you start your device with the image containing the Google applications files, the Setup Wizard will be shown. Complete the steps of this wizard to connect your Google Account to your device. You will now have an image running that contains the different Google applications which should run correctly (also the Calendar application should work now).
So that brings us to the end of the Building Android 1.5 series. I hoped you liked it and got enough information for making your own build. If not, just post a reply on one of the blog posts so that I can give you more details. Although this is the final post of this blogpost serie, I will continue writing about Android (and other technologies). So look at my website often or follow me on Twitter to get updates.
Blogpost in the Building Android 1.5 serie



