New Theme Engine [1/6]

[Summary]
Took the T-mobile theme engine, replaced redirection mechanism with a modified Sony idmap and then extended the feature set.

The new theme engine allows the following:
1. Simple creation of themes by compiling on the device
2. System level icon packs.
3. Font packs
4. Swappable boot animations
5. Lockscreen wallpaper
6. Alarms
7  Of course all the things the previous engine could do including skins, ringtones and
notifications. There is also legacy support for old themes.

[Theme Format]
For the time being themes are APKs with all theme elements in the assets folder. Since these resources
are compiled at runtime there is no reason we can't change it to a zip but creating an APK is well
understood by themers.

The directory structure looks like this:

AndroidManifest.xml
src/
res/
assets/
  boot-animation/
  fonts/
  icons/
    res/ (note: same dir structure as res/ in trebuchet icon packs)
  wallpapers/
  ringtones/
  notifications/
  alarms/
  overlays/
      [target-pkg-name1]
          res/
           drawable/
           drawable-hdpi/
           ...
           layouts/
           xml/
      [target-pkg-name2]
          res/

Where [target-pkg-name] is the package of the app you are trying to overlay. For example, to overlay
facebook's app you would make a directory under overlay called "com.facebook.katana". For frameworks
resources use the target name "android".

Under each target pkg is a res/ folder which follows the same format as a typical APK's res/. During
install time AAPT will actually compiling these res/ folders individually.

There are also non-overlay folders like boot-animation, wallpaper, fonts etc.

A theme APK is identified by meta-value data in AndroidManifest.xml. Here is an example:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.me.andytheme2"
    android:versionCode="1"
    android:versionName="1.0" >
    <uses-feature android:name="org.cyanogenmod.theme" />
    <meta-data android:name="org.cyanogenmod.theme.name" android:value="My Blue Theme"/>
    <meta-data android:name="org.cyanogenmod.theme.author" android:value="John Doe" />
</manifest>

By using meta-data we do not require special new tools.

[Changes to PackageManagerService]
During install time PackageManagerService will scan meta-data values in the manifest. If it finds
a meta-data name of "org.cyanogenmod.theme.name" then it will assume the APK is a theme and mark it as such.

Then PM will find all overlays from the theme. For each overlay target it will generate a resource table
and an idmap via Installd. Aapt will also run to compile 9patch and xml files. The new restable, idmap, and compiled resources
are stored under /data/resource-cache

[Changes to aapt]
Aapt has been extended to read zip entries and accept file descriptors to work with installd.

[Changes to frameworks/core]
Most of what TMO has done already here for runtime theme changes is kept so most changes
are simply plumbing to make Sony's overlays work at runtime. Additionally changes were made
to TMO classes to support mix n match better.

[Changes to libandroidfw]
Sony's idmap concept is one overlay apk -> one target apk, but themes support multiple target apks. So
most of the changes here are for support this. Also we support runtime overlay changes so functionality
had to be added to add/remove to the resource table during a configuration change.

[Security]
We run aapt in reduced priveledges via Installd. At the moment however a theme can overlay any resource. This
includes strings and layouts so any malicous theme could cause serious crashes to the device.

[See Also]
frameworks/native
external/skia
build
vendor/tmobile/providers/ThemeManager
vendor/tmobile/libs/com.tmobile.themes

[Contributors]
Andrew Mast <andy@cyngn.com>
Clark Scheff <clark@cyngn.com>
Special thanks to the T-Mobile theme team. This would not be possible without their efforts.
Special thanks to Mårten Kongstad and the rest of the Sony team for their work in idmap.

Change-Id: I812a3757bdb56c429b5870ff922485439ae00f8d

Conflicts:

	core/java/android/app/ContextImpl.java
	core/java/android/content/Context.java
	packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
	packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
	policy/src/com/android/internal/policy/impl/GlobalActions.java
Fix theme like this for now

Change-Id: Icf4ae46bcf01dbfa267b8c6768f5b54901f01379
add Custom Lockscreen switch

Change-Id: I3cc14cacf5462f589373b686f0dd87100507d524

Conflicts:

	core/java/android/provider/Settings.java
Wallpaper Overscroll and Transparent NavBar

Now possible to offset wallpaper windows by more than the size of the wallpaper
and add added a transparent mode to the NavigationBar

Change-Id: I2b0f1129a4cf73b8def35abb7072d0472a9cc972

Conflicts:

	packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
	packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
wallpaper: add missing @hides

Add missing @hides to setWallpaperOverscroll and setWallpaperOverscrollOffsets

Change-Id: I1cfe876272d7c0a94bef122567da30318eac9400
SysUI: Don't recreate controllers.

The various controllers, such as mLocationController, get recreated
every time the status bar is recreated due to a theme change.  We
should only need to create these if they are null, otherwise use
the controller as is.  Also, each of these controlers registers
themselves as a broadcast receiver and are never unregistered before
recreating them.

Change-Id: I6215aae5a82b7ced8f0f25cf592a804d38825260

Conflicts:

	packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
Move theme strings to cm_strings.xml

Also correct application->app

Change-Id: I13afe2b810ccb8f9a5fa9484a5cd93ec9820ed6e

Conflicts:

	core/res/res/values/cm_strings.xml
CM11 Themes: Take into account ALL res/xml dirs

Only res/xml was being searched for redirection XML files, which
causes themes that use xml-v14, xml-v19, etc to be overlooked and
resources not being mapped.

Change-Id: I8ccad5770250150a95ec3b89be56f8d01025b126
revert camera icon disable when Settings.System.LOCKSCREEN_MODLOCK_ENABLED was set to 1

Change-Id: I0f6e318c5da7b526e24f8c0c73102e3d7d826a46
CM11 Themes: Use 32bit hash to decide if idmap should be created

Using the last modified time of the package to determine if an idmap
should be created is not always valid for system packages.  We have
observed some packages having a time stamp of 08/01/2008 even if the
package has changed.  This causes system packages, such as
frameworks-res.apk to not be properly mapped if IDs changed in this
package.

This patch will generate a 32 bit hash code based on the file's
MD5 sum.  This hash code is then provided to idmap for writing these
values into the idmap header for future comparison.

This patch requires the following change found in frameworks/native
http://review.cyanogenmod.org/62566

Change-Id: Ie9e0273aef96217f06b08774623dd5f1b290a3da
fonts: Add LBhashitaComplexSans font for Sinhala

* From http://www.siyabas.lk/files/Bhashitha_Linux.zip

Change-Id: I293bfe84efd663d5a105541196e2bb3b123ee192
Cleanup theme assets when done with them

Before this patch if phone was left on long enough it would reboot
when a theme was applied due to files being left open.

Change-Id: I4c242249fcf6e8097789c3dd6690104296485784
Add the missing drawables that caused some FC for some devices

Change-Id: Ic2920d697d3084e5130e7bf731e27627742dd2db
Signed-off-by: Lokesh Chamane <lokesh.c703@gmail.com>
Update the GPS tile to use the appropriate location modes

With 4.4, there were new location modes this tile did not support
Update it to turn the GPS on/off without changing the network-based location
option, and use a new icon for battery saving mode.

The tile will now either toggle between high accuracy and battery saving,
or location off and device sensors only.

Change-Id: Ifdfb9832c77671ab1f0c415ea2c25dfee2888578
QS: let's welcome LocationTile to 4.4
we already modified to use the basic 4.4 location mechanism. Still
it was very basic. Now using the same attempt like in Settings to
controll location mode (high accuracy, battery saving, device only) and on/off state

longpress switches between the states. Normal click turns it on/off
Compared to settings turning on will recover last state where it was turned off. As
well it respects the sharing location warning dialog either when you switch on into
a mode which use it or you switch into a mode which uses it and it was not confimed.

Slight corrections to original AOSP code to reflect the changes in LocationController
even though this code is non operational

PatchSet:
- moved the complete handling into the LocationController. Way better
  to have in centralized. Who knows for what we will use it later.
PatchSet:
- cleanup

PatchSet:
- added drawables from kroz :)

Change-Id: I3c7c51c8d7e3a8c003c37d1b55a6503a9bbeaf64
SysUI: Use LocationController from status bar service for GPSTile.

Change-Id: Iaf24f25432ec2238bc8b0785b78f6acb21bb78cb
ConnectivtyService : Execute connectivityCheck in thread pool

Since this async task takes long when doing things like waiting for
network connectivity...etc, rather than holding up the single executor
of async task for the framework (app_process), run it on a thread from
the pool so other tasks can execute in parallel.

Change-Id: I7b88a4837c7e117ef47014a20c57f828b811edfb
Framework: Allow Power Notification Sounds For Wireless

Fixes an issue where wireless charging would play the
	power sound and the default wireless charging
	sound at the same time.

Change-Id: I36a20a3ba227d0682a8854935a53e30f132a9b7f
remove duplicated strings

Change-Id: I050e7705c6fce179dd76b2cc705f039d190fd366
Show package names during dexopt

ps2: Attempt to determine localized package label, and print that.
     If unavailable, print packageName

Change-Id: If9ca78fe312acd674bdcee160f914b4445d5c85f