SlideShare una empresa de Scribd logo
1 de 18
Descargar para leer sin conexión
AOSP Plus
AOSP builds with batteries included
James Puderer
Ottawa Android User Group
May 13th, 2013
+
What is AOSP?
● AOSP is the Android Open Source Project.
● It contains all of the open sourced components of
Android.
● You are free to download, modify, build, and distribute
AOSP1
● You can find instructions on downloading and building
AOSP at http://source.android.com
● AOSP can be built for most of the recent Google
branded devices (Nexus).
○ Nexus Galaxy
○ Nexus 4, 7, 10
○ Nexus S (<= 4.1)
○ Motorola Xoom (<= 4.1)
What AOSP isn't?
What is it missing?
● It may be missing some drivers
○ You can get some of the proprietary drivers for your build: https:
//developers.google.com/android/nexus/drivers
○ Not all of the drivers are are available. (e.g. Camera and GPS don't
work on Galaxy Nexus.)
● It doesn't contain many of the Google applications and
frameworks:
○ Play Store
○ Google Maps
○ Youtube
○ Face unlock
○ etc.
● Not exactly the same as a commercial device
○ In fact, it looks pretty much like the emulator.
Why? (does this matter)
● Making changing to AOSP
● Seeing what kind of effect these would have
on a real phone.
● For example:
○ Enabling SEAndroid enforcement and to see what
effect it would have on a real phone (with the Play
store).
○ Developing an Embedded Android system, but gosh
it would be nice if your device had the Play store
during development
How?
1. Build AOSP1
2. Create vendor directories2
3. Extract factory system image
4. Deodex APK and framework files
5. Identify the components you need
6. Tailoring the vendor Makefiles
7. Profit!
If you're new to building AOSP
I recommend this book!
Build AOSP
Go here: http://source.android.com/source/index.html
...and do what it says.1
If you haven't done this before, I'll see you in a day or
two.
If you're successful, you should be able to flash a basic
AOSP image onto your device.
OK? Good?
The aospplus templates include directories and Makefiles for
Nexus Galaxy, Nexus 4, and Nexus 7
For the purposes of this tutorial, we'll focus on building for the
Nexus 4 (codename: mako).
However, the same approach could be used for any of the
other device, and extended to include new devices.
Create the vendor directories
Use my template on Github
$ cd $ANDROID_BUILD_TOP
$ cd vendor 1
$ git clone git://github.com/jpuderer/vendor-aospplus.git aospplus
Include our directory in the build
--- BoardConfigVendor.mk.orig 2013-05-03 17:11:09.705229512 -0400
+++ BoardConfigVendor.mk 2013-05-03 17:14:37.085224121 -0400
@@ -17,3 +17,4 @@
-include vendor/broadcom/$(LOCAL_STEM)
-include vendor/lge/$(LOCAL_STEM)
-include vendor/qcom/$(LOCAL_STEM)
+-include vendor/aospplus/$(LOCAL_STEM)
--- device-vendor.mk.orig 2013-05-03 17:10:30.393230534 -0400
+++ device-vendor.mk 2013-05-03 17:09:51.393231548 -0400
@@ -17,3 +17,4 @@
$(call inherit-product-if-exists, vendor/broadcom/$(LOCAL_STEM))
$(call inherit-product-if-exists, vendor/lge/$(LOCAL_STEM))
$(call inherit-product-if-exists, vendor/qcom/$(LOCAL_STEM))
+$(call inherit-product-if-exists, vendor/aospplus/$(LOCAL_STEM))
In order for our aospplus components to be added to the build,
we need make sure they get included by one of the mako
device's Makefiles.1
Extract factory system image
Download factory image and extract system.img file
Download a factory image for your device. For Nexus
devices, these can be downloaded from here:
https://developers.google.com/android/nexus/images
The factory image will contain a zip file, which will contain a
system.img file. This file contains the compressed ext4
filesystem for the device's /system directory.
Make a copy of this file somewhere you can work on it.
Extract factory system image
Extract the file tree from the system.img
$ cp $ANDROID_BUILD_TOP/out/host/linux-x86/bin/simg2img ~/bin
$ simg2img system.img system.full.img
$ mkdir system.mnt
$ mkdir system.factory
$ sudo mount -n -o loop system.full.img system.mnt
$ sudo cp -r system.mnt/* system.factory
$ sudo umount -n system.mnt
$ sudo chown -R ${USER}. system.factory 1
$ rmdir system.mnt
$ rm -r system.full.img
The system.img file packaged with most phones is effectively a
ext4 filesystem that has been compressed. You can expand it
by using the simg2img tool that is built as part of AOSP. Once
the image has been expanded you can loopback mount it as you
would any other filesystem image.
Compare system images
Figure out what AOSP is missing
Next, we want to compare the AOSP system directory with the factory system directory, to see what
components and configuration files we might be missing.1
I usually keep a pristine copy of system.factory and a system.aosp directory around for this purpose.
$ cp -r $ANDROID_BUILD_TOP/out/target/product/ mako/system system.aosp
$ diff -qr system.aosp system.factory
$ ...
You will need to use this information later to configure the vendor/aospplus/device/Makefiles. You'll want to come back
to this when you start modifying the Makefiles.
If you're using the aospplus template for one of the defined devices, you may not need to wory about this. Since we're
assuming the mako device (Nexus 4), this analysis has already been done for you.
Deodex the APK and framework files
...but first, what is odexing/deodexing?
An odexed file is basically an APK that has been preoptimized for fast loading. The .dex file that
normally exists inside the APK or JAR file (which are really just a zip files) is removed from the APK,
optimized, and is placed next to the .apk as an .odex file.
The Android build system can be configured to preoptimize the files on APK files in /system/app, and
this is exactly what's happened to the factory images.1
The documentation for dexopt details the optimizations:
https://github.com/android/platform_dalvik/blob/master/docs/dexopt.html
Unfortunately for us (and themers in general), the optimized .odex file has dependencies on the
classes in bootstrap class path, which for Android is everything under /system/framework. If we
change the framework files, the .odex files will not work.
So we need to "deodex" the the .odex files, and package them back into the APK and JAR files.
To do that, we need to use some tools to recompile the odex files back into odex files.
You can find the tools here:2
https://code.google.com/p/smali
Deodex the APK and framework files
Using the deodex.py script provided with the aospplus templates
$ cd $ANDROID_BUILD_TOP/vendor/aospplus/
$ cp -r $MY_SCRATCH_DIR/system.factory mako/proprietary/system
$ utils/deodex.py mako/proprietary/system
Feel free to do some cleanup of the system directory if you wish, since not all files are needed.
$ cd mako/proprietary/system
$ rm -Rf bin build.prop fonts lost+found xbin
Tailoring the Makefiles
Android.mk and device-partial.mk
There are two make files that you will need to tailor for your device.
vendor/aospplus/mako/proprietary/Android.mk tells AOSP how to install the prebuild each of the APKs
from the factory image.
vendor/aospplus/mako/device-partial.mk actually declares what will be added to the final system
image for our device.
● List of APKs to install1
List of files to copy
● Overrides for the device's system properties
Tailoring the Makefiles
Android.mk
LOCAL_PATH:=$(call my-dir)
ifeq ($(TARGET_DEVICE),mako)
...
include $(CLEAR_VARS)
LOCAL_MODULE := CalendarGoogle 1
LOCAL_SRC_FILES := system/app/$(LOCAL_MODULE).apk
LOCAL_OVERRIDES_PACKAGES := Calendar 2
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_OWNER := google 3
LOCAL_MODULE_TAGS := optional
LOCAL_CERTIFICATE := PRESIGNED
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
include $(BUILD_PREBUILT)
...
endif
Declare the prebuild APKs you wish to include from the factory
image.
Tailoring the Makefiles
device-partial.mk
PRODUCT_COPY_FILES += 
vendor/google/mako/proprietary/system/media/bootanimation.zip:
system/media/bootanimation.zip:google 1
...
PRODUCT_PACKAGES += 
Books 
BrowserProviderProxy 
CalendarGoogle 
... 2
PRODUCT_PROPERTY_OVERRIDES += 
ro.facelock.black_timeout=1250 
ro.facelock.det_timeout=1500 
...
Declare the APKs and other files you wish to include in your
build, along with any system properties you need to override.
That's it!
Build and be merry.
This should do it:
$ cd $ANDROID_BUILD_TOP
$ make installclean & make -j8
For the truly paranoid:
$ make clobber & make -j8
Questions?
Rebuild AOSP for your device as you did at the beginning.

Más contenido relacionado

La actualidad más candente

Embedded Android Workshop with Nougat
Embedded Android Workshop with NougatEmbedded Android Workshop with Nougat
Embedded Android Workshop with NougatOpersys inc.
 
Android Things Internals
Android Things InternalsAndroid Things Internals
Android Things InternalsOpersys inc.
 
Enhancing and modifying_the_core_android_os
Enhancing and modifying_the_core_android_osEnhancing and modifying_the_core_android_os
Enhancing and modifying_the_core_android_osArnav Gupta
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and DevelopmentOpersys inc.
 
Brillo / Weave Internals
Brillo / Weave InternalsBrillo / Weave Internals
Brillo / Weave InternalsOpersys inc.
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and DevelopmentOpersys inc.
 
Android's HIDL: Treble in the HAL
Android's HIDL: Treble in the HALAndroid's HIDL: Treble in the HAL
Android's HIDL: Treble in the HALOpersys inc.
 
Android OTA updates
Android OTA updatesAndroid OTA updates
Android OTA updatesGary Bisson
 
Customizing Android's UI
Customizing Android's UICustomizing Android's UI
Customizing Android's UIOpersys inc.
 
Is Android the New King of Embedded OSes at Embedded World 2014
Is Android the New King of Embedded OSes at Embedded World 2014Is Android the New King of Embedded OSes at Embedded World 2014
Is Android the New King of Embedded OSes at Embedded World 2014Opersys inc.
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and DevelopmentOpersys inc.
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and DevelopmentOpersys inc.
 
Customizing AOSP For Different Embedded Devices And Integration at Applicatio...
Customizing AOSP For Different Embedded Devices And Integration at Applicatio...Customizing AOSP For Different Embedded Devices And Integration at Applicatio...
Customizing AOSP For Different Embedded Devices And Integration at Applicatio...ijafrc
 
Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?Opersys inc.
 
Making a Headless Android Device (Oslo Embedded Meetup 2018)
Making a Headless Android Device (Oslo Embedded Meetup 2018)Making a Headless Android Device (Oslo Embedded Meetup 2018)
Making a Headless Android Device (Oslo Embedded Meetup 2018)Patricia Aas
 
Making a Headless Android Device
Making a Headless Android DeviceMaking a Headless Android Device
Making a Headless Android DevicePatricia Aas
 
Enhancing and modifying_the_core_android_os
Enhancing and modifying_the_core_android_osEnhancing and modifying_the_core_android_os
Enhancing and modifying_the_core_android_osArnav Gupta
 
Accessing Hardware on Android
Accessing Hardware on AndroidAccessing Hardware on Android
Accessing Hardware on AndroidGary Bisson
 
Introduction to Flutter - truly crossplatform, amazingly fast
Introduction to Flutter - truly crossplatform, amazingly fastIntroduction to Flutter - truly crossplatform, amazingly fast
Introduction to Flutter - truly crossplatform, amazingly fastBartosz Kosarzycki
 
Is Android the New Embedded Linux? at AnDevCon V
Is Android the New Embedded Linux? at AnDevCon VIs Android the New Embedded Linux? at AnDevCon V
Is Android the New Embedded Linux? at AnDevCon VOpersys inc.
 

La actualidad más candente (20)

Embedded Android Workshop with Nougat
Embedded Android Workshop with NougatEmbedded Android Workshop with Nougat
Embedded Android Workshop with Nougat
 
Android Things Internals
Android Things InternalsAndroid Things Internals
Android Things Internals
 
Enhancing and modifying_the_core_android_os
Enhancing and modifying_the_core_android_osEnhancing and modifying_the_core_android_os
Enhancing and modifying_the_core_android_os
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Brillo / Weave Internals
Brillo / Weave InternalsBrillo / Weave Internals
Brillo / Weave Internals
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Android's HIDL: Treble in the HAL
Android's HIDL: Treble in the HALAndroid's HIDL: Treble in the HAL
Android's HIDL: Treble in the HAL
 
Android OTA updates
Android OTA updatesAndroid OTA updates
Android OTA updates
 
Customizing Android's UI
Customizing Android's UICustomizing Android's UI
Customizing Android's UI
 
Is Android the New King of Embedded OSes at Embedded World 2014
Is Android the New King of Embedded OSes at Embedded World 2014Is Android the New King of Embedded OSes at Embedded World 2014
Is Android the New King of Embedded OSes at Embedded World 2014
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Customizing AOSP For Different Embedded Devices And Integration at Applicatio...
Customizing AOSP For Different Embedded Devices And Integration at Applicatio...Customizing AOSP For Different Embedded Devices And Integration at Applicatio...
Customizing AOSP For Different Embedded Devices And Integration at Applicatio...
 
Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?
 
Making a Headless Android Device (Oslo Embedded Meetup 2018)
Making a Headless Android Device (Oslo Embedded Meetup 2018)Making a Headless Android Device (Oslo Embedded Meetup 2018)
Making a Headless Android Device (Oslo Embedded Meetup 2018)
 
Making a Headless Android Device
Making a Headless Android DeviceMaking a Headless Android Device
Making a Headless Android Device
 
Enhancing and modifying_the_core_android_os
Enhancing and modifying_the_core_android_osEnhancing and modifying_the_core_android_os
Enhancing and modifying_the_core_android_os
 
Accessing Hardware on Android
Accessing Hardware on AndroidAccessing Hardware on Android
Accessing Hardware on Android
 
Introduction to Flutter - truly crossplatform, amazingly fast
Introduction to Flutter - truly crossplatform, amazingly fastIntroduction to Flutter - truly crossplatform, amazingly fast
Introduction to Flutter - truly crossplatform, amazingly fast
 
Is Android the New Embedded Linux? at AnDevCon V
Is Android the New Embedded Linux? at AnDevCon VIs Android the New Embedded Linux? at AnDevCon V
Is Android the New Embedded Linux? at AnDevCon V
 

Destacado

Embedded Android Workshop with Marshmallow
Embedded Android Workshop with MarshmallowEmbedded Android Workshop with Marshmallow
Embedded Android Workshop with MarshmallowOpersys inc.
 
Learning android with AOSP
Learning android with AOSPLearning android with AOSP
Learning android with AOSPJorge Barroso
 
Android open source project build system phi innovations - android summit 2015
Android open source project build system   phi innovations - android summit 2015Android open source project build system   phi innovations - android summit 2015
Android open source project build system phi innovations - android summit 2015Rafael Coutinho
 
An Introduction to Android Internals
An Introduction to Android InternalsAn Introduction to Android Internals
An Introduction to Android InternalsAnjana Somathilake
 
Fast-paced Introduction to Android Internals
Fast-paced Introduction to Android InternalsFast-paced Introduction to Android Internals
Fast-paced Introduction to Android InternalsHamilton Turner
 
Kid's Way. Safe discovery! (parental control android launcher). Partners deck.
Kid's Way. Safe discovery! (parental control android launcher). Partners deck. Kid's Way. Safe discovery! (parental control android launcher). Partners deck.
Kid's Way. Safe discovery! (parental control android launcher). Partners deck. Kid's Way. Safe discovery!
 
Linux-without-a-bootloader
Linux-without-a-bootloaderLinux-without-a-bootloader
Linux-without-a-bootloaderNishanth Menon
 
Learning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device DriverLearning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device DriverNanik Tolaram
 
Linux SD/MMC device driver
Linux SD/MMC device driverLinux SD/MMC device driver
Linux SD/MMC device driver艾鍗科技
 
Android booting sequece and setup and debugging
Android booting sequece and setup and debuggingAndroid booting sequece and setup and debugging
Android booting sequece and setup and debuggingUtkarsh Mankad
 
Learning AOSP - Android Booting Process
Learning AOSP - Android Booting ProcessLearning AOSP - Android Booting Process
Learning AOSP - Android Booting ProcessNanik Tolaram
 
Understanding the Android System Server
Understanding the Android System ServerUnderstanding the Android System Server
Understanding the Android System ServerOpersys inc.
 
Q4.11: Introduction to eMMC
Q4.11: Introduction to eMMCQ4.11: Introduction to eMMC
Q4.11: Introduction to eMMCLinaro
 
Project proposal android operating system
Project proposal android operating systemProject proposal android operating system
Project proposal android operating systemAttiq12
 
Overview of Android binder IPC implementation
Overview of Android binder IPC implementationOverview of Android binder IPC implementation
Overview of Android binder IPC implementationChethan Pchethan
 
Booting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot imagesBooting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot imagesChris Simmonds
 

Destacado (19)

Embedded Android Workshop with Marshmallow
Embedded Android Workshop with MarshmallowEmbedded Android Workshop with Marshmallow
Embedded Android Workshop with Marshmallow
 
Learning android with AOSP
Learning android with AOSPLearning android with AOSP
Learning android with AOSP
 
Android open source project build system phi innovations - android summit 2015
Android open source project build system   phi innovations - android summit 2015Android open source project build system   phi innovations - android summit 2015
Android open source project build system phi innovations - android summit 2015
 
An Introduction to Android Internals
An Introduction to Android InternalsAn Introduction to Android Internals
An Introduction to Android Internals
 
Fast-paced Introduction to Android Internals
Fast-paced Introduction to Android InternalsFast-paced Introduction to Android Internals
Fast-paced Introduction to Android Internals
 
Kid's Way. Safe discovery! (parental control android launcher). Partners deck.
Kid's Way. Safe discovery! (parental control android launcher). Partners deck. Kid's Way. Safe discovery! (parental control android launcher). Partners deck.
Kid's Way. Safe discovery! (parental control android launcher). Partners deck.
 
MMC Booklet
MMC BookletMMC Booklet
MMC Booklet
 
Linux-without-a-bootloader
Linux-without-a-bootloaderLinux-without-a-bootloader
Linux-without-a-bootloader
 
Learning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device DriverLearning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device Driver
 
Android Internals
Android InternalsAndroid Internals
Android Internals
 
Linux SD/MMC device driver
Linux SD/MMC device driverLinux SD/MMC device driver
Linux SD/MMC device driver
 
Android booting sequece and setup and debugging
Android booting sequece and setup and debuggingAndroid booting sequece and setup and debugging
Android booting sequece and setup and debugging
 
Learning AOSP - Android Booting Process
Learning AOSP - Android Booting ProcessLearning AOSP - Android Booting Process
Learning AOSP - Android Booting Process
 
Understanding the Android System Server
Understanding the Android System ServerUnderstanding the Android System Server
Understanding the Android System Server
 
Q4.11: Introduction to eMMC
Q4.11: Introduction to eMMCQ4.11: Introduction to eMMC
Q4.11: Introduction to eMMC
 
Android IPC Mechanism
Android IPC MechanismAndroid IPC Mechanism
Android IPC Mechanism
 
Project proposal android operating system
Project proposal android operating systemProject proposal android operating system
Project proposal android operating system
 
Overview of Android binder IPC implementation
Overview of Android binder IPC implementationOverview of Android binder IPC implementation
Overview of Android binder IPC implementation
 
Booting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot imagesBooting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot images
 

Similar a Aosp+

CodeMotion tel aviv 2015 - android reverse engineering lab
CodeMotion tel aviv 2015 - android reverse engineering labCodeMotion tel aviv 2015 - android reverse engineering lab
CodeMotion tel aviv 2015 - android reverse engineering labRon Munitz
 
Sys ml helperprofile-rhapsody813-obtainandinstall-v1
Sys ml helperprofile-rhapsody813-obtainandinstall-v1Sys ml helperprofile-rhapsody813-obtainandinstall-v1
Sys ml helperprofile-rhapsody813-obtainandinstall-v1Fraser Chadburn
 
More than nexus, better than nexus.
More than nexus, better than nexus.More than nexus, better than nexus.
More than nexus, better than nexus.Young-Ho Cha
 
Mobile development in 2020
Mobile development in 2020 Mobile development in 2020
Mobile development in 2020 Bogusz Jelinski
 
Composer JSON kills make files
Composer JSON kills make filesComposer JSON kills make files
Composer JSON kills make filesropsu
 
Droidcon uk2012 androvm
Droidcon uk2012 androvmDroidcon uk2012 androvm
Droidcon uk2012 androvmdfages
 
Dockerizing Oracle Database
Dockerizing Oracle Database Dockerizing Oracle Database
Dockerizing Oracle Database gvenzl
 
Voxxed days Vilnius 2015 - Android Reverse Engineering Lab
Voxxed days Vilnius 2015 - Android Reverse Engineering LabVoxxed days Vilnius 2015 - Android Reverse Engineering Lab
Voxxed days Vilnius 2015 - Android Reverse Engineering LabRon Munitz
 
Adding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
Adding_GD2_to_PHP_on_OS_X_Server_10_5_LeopardAdding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
Adding_GD2_to_PHP_on_OS_X_Server_10_5_Leopardtutorialsruby
 
Adding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
Adding_GD2_to_PHP_on_OS_X_Server_10_5_LeopardAdding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
Adding_GD2_to_PHP_on_OS_X_Server_10_5_Leopardtutorialsruby
 
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...Alexander Dean
 
Lecture02web 140phpapp01
Lecture02web 140phpapp01Lecture02web 140phpapp01
Lecture02web 140phpapp01letuan9999
 
Open event (show&tell april 2016)
Open event (show&tell april 2016)Open event (show&tell april 2016)
Open event (show&tell april 2016)Jorge López-Lago
 
Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013Opersys inc.
 
How to migrate SourcePro apps from Solaris to Linux
How to migrate SourcePro apps from Solaris to LinuxHow to migrate SourcePro apps from Solaris to Linux
How to migrate SourcePro apps from Solaris to LinuxRogue Wave Software
 

Similar a Aosp+ (20)

Building aosp
Building aospBuilding aosp
Building aosp
 
CodeMotion tel aviv 2015 - android reverse engineering lab
CodeMotion tel aviv 2015 - android reverse engineering labCodeMotion tel aviv 2015 - android reverse engineering lab
CodeMotion tel aviv 2015 - android reverse engineering lab
 
Sys ml helperprofile-rhapsody813-obtainandinstall-v1
Sys ml helperprofile-rhapsody813-obtainandinstall-v1Sys ml helperprofile-rhapsody813-obtainandinstall-v1
Sys ml helperprofile-rhapsody813-obtainandinstall-v1
 
Hacking Android OS
Hacking Android OSHacking Android OS
Hacking Android OS
 
More than nexus, better than nexus.
More than nexus, better than nexus.More than nexus, better than nexus.
More than nexus, better than nexus.
 
Mobile development in 2020
Mobile development in 2020 Mobile development in 2020
Mobile development in 2020
 
Core Android
Core AndroidCore Android
Core Android
 
Composer JSON kills make files
Composer JSON kills make filesComposer JSON kills make files
Composer JSON kills make files
 
Droidcon uk2012 androvm
Droidcon uk2012 androvmDroidcon uk2012 androvm
Droidcon uk2012 androvm
 
Dockerizing Oracle Database
Dockerizing Oracle Database Dockerizing Oracle Database
Dockerizing Oracle Database
 
OpenSolaris 2009.06 Workshop
OpenSolaris 2009.06 WorkshopOpenSolaris 2009.06 Workshop
OpenSolaris 2009.06 Workshop
 
Voxxed days Vilnius 2015 - Android Reverse Engineering Lab
Voxxed days Vilnius 2015 - Android Reverse Engineering LabVoxxed days Vilnius 2015 - Android Reverse Engineering Lab
Voxxed days Vilnius 2015 - Android Reverse Engineering Lab
 
Adding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
Adding_GD2_to_PHP_on_OS_X_Server_10_5_LeopardAdding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
Adding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
 
Adding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
Adding_GD2_to_PHP_on_OS_X_Server_10_5_LeopardAdding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
Adding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
 
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
 
Lecture02web 140phpapp01
Lecture02web 140phpapp01Lecture02web 140phpapp01
Lecture02web 140phpapp01
 
Drupal
DrupalDrupal
Drupal
 
Open event (show&tell april 2016)
Open event (show&tell april 2016)Open event (show&tell april 2016)
Open event (show&tell april 2016)
 
Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013
 
How to migrate SourcePro apps from Solaris to Linux
How to migrate SourcePro apps from Solaris to LinuxHow to migrate SourcePro apps from Solaris to Linux
How to migrate SourcePro apps from Solaris to Linux
 

Último

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 

Último (20)

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 

Aosp+

  • 1. AOSP Plus AOSP builds with batteries included James Puderer Ottawa Android User Group May 13th, 2013 +
  • 2. What is AOSP? ● AOSP is the Android Open Source Project. ● It contains all of the open sourced components of Android. ● You are free to download, modify, build, and distribute AOSP1 ● You can find instructions on downloading and building AOSP at http://source.android.com ● AOSP can be built for most of the recent Google branded devices (Nexus). ○ Nexus Galaxy ○ Nexus 4, 7, 10 ○ Nexus S (<= 4.1) ○ Motorola Xoom (<= 4.1)
  • 3. What AOSP isn't? What is it missing? ● It may be missing some drivers ○ You can get some of the proprietary drivers for your build: https: //developers.google.com/android/nexus/drivers ○ Not all of the drivers are are available. (e.g. Camera and GPS don't work on Galaxy Nexus.) ● It doesn't contain many of the Google applications and frameworks: ○ Play Store ○ Google Maps ○ Youtube ○ Face unlock ○ etc. ● Not exactly the same as a commercial device ○ In fact, it looks pretty much like the emulator.
  • 4. Why? (does this matter) ● Making changing to AOSP ● Seeing what kind of effect these would have on a real phone. ● For example: ○ Enabling SEAndroid enforcement and to see what effect it would have on a real phone (with the Play store). ○ Developing an Embedded Android system, but gosh it would be nice if your device had the Play store during development
  • 5. How? 1. Build AOSP1 2. Create vendor directories2 3. Extract factory system image 4. Deodex APK and framework files 5. Identify the components you need 6. Tailoring the vendor Makefiles 7. Profit!
  • 6. If you're new to building AOSP I recommend this book!
  • 7. Build AOSP Go here: http://source.android.com/source/index.html ...and do what it says.1 If you haven't done this before, I'll see you in a day or two. If you're successful, you should be able to flash a basic AOSP image onto your device. OK? Good?
  • 8. The aospplus templates include directories and Makefiles for Nexus Galaxy, Nexus 4, and Nexus 7 For the purposes of this tutorial, we'll focus on building for the Nexus 4 (codename: mako). However, the same approach could be used for any of the other device, and extended to include new devices. Create the vendor directories Use my template on Github $ cd $ANDROID_BUILD_TOP $ cd vendor 1 $ git clone git://github.com/jpuderer/vendor-aospplus.git aospplus
  • 9. Include our directory in the build --- BoardConfigVendor.mk.orig 2013-05-03 17:11:09.705229512 -0400 +++ BoardConfigVendor.mk 2013-05-03 17:14:37.085224121 -0400 @@ -17,3 +17,4 @@ -include vendor/broadcom/$(LOCAL_STEM) -include vendor/lge/$(LOCAL_STEM) -include vendor/qcom/$(LOCAL_STEM) +-include vendor/aospplus/$(LOCAL_STEM) --- device-vendor.mk.orig 2013-05-03 17:10:30.393230534 -0400 +++ device-vendor.mk 2013-05-03 17:09:51.393231548 -0400 @@ -17,3 +17,4 @@ $(call inherit-product-if-exists, vendor/broadcom/$(LOCAL_STEM)) $(call inherit-product-if-exists, vendor/lge/$(LOCAL_STEM)) $(call inherit-product-if-exists, vendor/qcom/$(LOCAL_STEM)) +$(call inherit-product-if-exists, vendor/aospplus/$(LOCAL_STEM)) In order for our aospplus components to be added to the build, we need make sure they get included by one of the mako device's Makefiles.1
  • 10. Extract factory system image Download factory image and extract system.img file Download a factory image for your device. For Nexus devices, these can be downloaded from here: https://developers.google.com/android/nexus/images The factory image will contain a zip file, which will contain a system.img file. This file contains the compressed ext4 filesystem for the device's /system directory. Make a copy of this file somewhere you can work on it.
  • 11. Extract factory system image Extract the file tree from the system.img $ cp $ANDROID_BUILD_TOP/out/host/linux-x86/bin/simg2img ~/bin $ simg2img system.img system.full.img $ mkdir system.mnt $ mkdir system.factory $ sudo mount -n -o loop system.full.img system.mnt $ sudo cp -r system.mnt/* system.factory $ sudo umount -n system.mnt $ sudo chown -R ${USER}. system.factory 1 $ rmdir system.mnt $ rm -r system.full.img The system.img file packaged with most phones is effectively a ext4 filesystem that has been compressed. You can expand it by using the simg2img tool that is built as part of AOSP. Once the image has been expanded you can loopback mount it as you would any other filesystem image.
  • 12. Compare system images Figure out what AOSP is missing Next, we want to compare the AOSP system directory with the factory system directory, to see what components and configuration files we might be missing.1 I usually keep a pristine copy of system.factory and a system.aosp directory around for this purpose. $ cp -r $ANDROID_BUILD_TOP/out/target/product/ mako/system system.aosp $ diff -qr system.aosp system.factory $ ... You will need to use this information later to configure the vendor/aospplus/device/Makefiles. You'll want to come back to this when you start modifying the Makefiles. If you're using the aospplus template for one of the defined devices, you may not need to wory about this. Since we're assuming the mako device (Nexus 4), this analysis has already been done for you.
  • 13. Deodex the APK and framework files ...but first, what is odexing/deodexing? An odexed file is basically an APK that has been preoptimized for fast loading. The .dex file that normally exists inside the APK or JAR file (which are really just a zip files) is removed from the APK, optimized, and is placed next to the .apk as an .odex file. The Android build system can be configured to preoptimize the files on APK files in /system/app, and this is exactly what's happened to the factory images.1 The documentation for dexopt details the optimizations: https://github.com/android/platform_dalvik/blob/master/docs/dexopt.html Unfortunately for us (and themers in general), the optimized .odex file has dependencies on the classes in bootstrap class path, which for Android is everything under /system/framework. If we change the framework files, the .odex files will not work. So we need to "deodex" the the .odex files, and package them back into the APK and JAR files. To do that, we need to use some tools to recompile the odex files back into odex files. You can find the tools here:2 https://code.google.com/p/smali
  • 14. Deodex the APK and framework files Using the deodex.py script provided with the aospplus templates $ cd $ANDROID_BUILD_TOP/vendor/aospplus/ $ cp -r $MY_SCRATCH_DIR/system.factory mako/proprietary/system $ utils/deodex.py mako/proprietary/system Feel free to do some cleanup of the system directory if you wish, since not all files are needed. $ cd mako/proprietary/system $ rm -Rf bin build.prop fonts lost+found xbin
  • 15. Tailoring the Makefiles Android.mk and device-partial.mk There are two make files that you will need to tailor for your device. vendor/aospplus/mako/proprietary/Android.mk tells AOSP how to install the prebuild each of the APKs from the factory image. vendor/aospplus/mako/device-partial.mk actually declares what will be added to the final system image for our device. ● List of APKs to install1 List of files to copy ● Overrides for the device's system properties
  • 16. Tailoring the Makefiles Android.mk LOCAL_PATH:=$(call my-dir) ifeq ($(TARGET_DEVICE),mako) ... include $(CLEAR_VARS) LOCAL_MODULE := CalendarGoogle 1 LOCAL_SRC_FILES := system/app/$(LOCAL_MODULE).apk LOCAL_OVERRIDES_PACKAGES := Calendar 2 LOCAL_MODULE_CLASS := APPS LOCAL_MODULE_OWNER := google 3 LOCAL_MODULE_TAGS := optional LOCAL_CERTIFICATE := PRESIGNED LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX) include $(BUILD_PREBUILT) ... endif Declare the prebuild APKs you wish to include from the factory image.
  • 17. Tailoring the Makefiles device-partial.mk PRODUCT_COPY_FILES += vendor/google/mako/proprietary/system/media/bootanimation.zip: system/media/bootanimation.zip:google 1 ... PRODUCT_PACKAGES += Books BrowserProviderProxy CalendarGoogle ... 2 PRODUCT_PROPERTY_OVERRIDES += ro.facelock.black_timeout=1250 ro.facelock.det_timeout=1500 ... Declare the APKs and other files you wish to include in your build, along with any system properties you need to override.
  • 18. That's it! Build and be merry. This should do it: $ cd $ANDROID_BUILD_TOP $ make installclean & make -j8 For the truly paranoid: $ make clobber & make -j8 Questions? Rebuild AOSP for your device as you did at the beginning.