turtletramp's blog

Tips & Tricks - Android Core Development

With Android Core Development I mean Tips & Tricks where to look at if your building a Core Android OS from scratch. I am not talking about app development here.

  1. research topics
  2. handling system certificates
    1. create the platform dependent keys
    2. create a keystore for creating correctly signed system applications for easier debugging
      1. steps to create the keystore
      2. use the new keystore in eclipse
  3. handling key events
    1. Goal
    2. Invovled classes

research topics

Android Build System
porting clockworkmod recovery
cyanogen mod build basics

handling system certificates

create the platform dependent keys

details see http://vanuitert.org/wordpress/platform/how-to-replace-the-test-keys-in-the-aosp/

create a keystore for creating correctly signed system applications for easier debugging

If you add apps to the system image they are directly part of the image and will be signed with the platform key. To being able to extend and debug such an app you need to be able to sign the new app with the same key. So you need to add the platform key to your local keystore to use it in eclipse.

steps to create the keystore

  1. copy the platform.pk8 and platform.x509.pem file to a new tmp directory
  2. run openssl pkcs8 -inform DER -nocrypt -in platform.pk8 -out platform.key.pk8
  3. run openssl pkcs12 -export -in platform.x509.pem -inkey platform.key.pk8 -out platform.p12 -password pass:android -name androiddebugkey It's very important to name it androiddebugkey or it will not be recognized by eclipse as such.
  4. run keytool -importkeystore -destkeystore platform.keystore -srckeystore platform.p12 -srcstoretype PKCS12 -srcstorepass android
  5. run keytool -list -v -keystore platform.keystore to verify that the new platform.keystore really holds the data.

use the new keystore in eclipse

  1. copy the platform.keystore to your local ~/.android/ directory
  2. in eclipse adt go to "Window / Preferences / Android / Build"
  3. assign your newly created platform keystore in the field "Custom debug keystore"

handling key events

This is just a rudimentary note and may not be true at all. The goal is to note it down for later research on this topic.

Goal

You want to be able to change the way how system wide key presses are handled. For example if you intend to change the way how the HOME button of your Android core system works.

Invovled classes

WindowManager (?) --> ?.?.PhoneWindowManager (?)
Window (abstract base class) --> android.policy.PhoneWindow (implementation)

  • The PhoneWindowManager handles all windows in the system. The PhoneWindow is running inside your app. To change system wide key events you need to modify the PhoneWindowManager.
  • If you intend to be able to modify the system wide behaviour of key handling in your app the PhoneWindow has to be modified.

In case of the HOME key it means:

  • the default handling must be removed from PhoneWindowManager so that the HOME key is received by apps.
  • If an app does not handle the HOME key you can modify the PhoneWindow to act on the HOME key.

This way you can use the HOME key in your app and if nobody handles it you can run a default action from the PhoneWindow.