CM11 Themes: Fix how common resources are found

During the boot process, application info may not be fully
available and createPackageContext can throw a null pointer which
causes a theme's resource-cache to be cleared.  If this theme is
in /system/app or /system/priv-app the theme will still be installed
but applying it will result in styles not being applied.

Change-Id: I4094bdd923edc1d829024404a4ce1b72709bd4f1
Themes: Support launcher based icon packs [1/2]

Before this patch, icon packs written for Trebuchet/Nova/Apex could not be used
with the new theme engine as the formats were different. Particularly the icon package IDs are 7F,
the same ID as as regular apps. Furthermore the location of resources in these icon packs was different
from what the theme engine expects. This patch adds support for these icon packs by overriding
the pkg id.

AssetManager now can override package ids without requiring aapt to recompile the APK.
Note: XML references will still use the original id compiled with AAPT, so it is only useful for resources
which do not use xml drawables (such as icon packs).

PackageInfo now has a new member identify "legacy" (3rd party icon packs) written
for launcher's like Trebuchet, Nova, and Apex.

Change-Id: Icd12c097e156c9626df0772abeb50e00f7b61f64
Send broadcast when package is 'about' to be removed

If a theme package is removed and it is the currently applied
theme, some apps will crash because the theme resources are
no longer available, since they were cleaned up by the package
manager.  The themes provider will receive this broadcast and
take care of switching back to the default theme for components
that are using the package about to be removed.

Change-Id: I968c25e19eb17ec87e7ddcba5ac0fd81745cef20
CM11 Themes: Allow defining a custom default theme [1/3]

Change-Id: I6b794d6c9c27b2d6436bdf4fec51c84a7859c134
Allow configuration of the default screen-off animation style

Change-Id: Ib59f8fce45c11193104682b975ff6467df8cfc15
settingsprovider: Set default value of animator duration scale

 * In case some crazy person wants to overlay it.

Change-Id: I8072a794a7530012e99e1d3fa42f8757e7fad853
CM11 Themes: Reduce "unable to load asset" log spam

With the introduction of a "common" resource folder for themes,
we always try to attach the common resource table and if it does
not exist it won't be attached but we would see this log spam.

Change-Id: Ida4e815523fd71b34fe8f3b41cef3432e6e07b64
immersive mode: don't unconfirm a package, that's just dumb

* This is very annoying for specialized apps
* See here for a great explanation http://stackoverflow.com/a/20309721
* The fact that it doesn't even notify the user until the NEXT time they
  run it makes it completely pointless in my opinion anyway.

Change-Id: I423611efc07d467e1d81c66d58adcff331be8b38
CM11 Themes: Get proper package name in attachThemeAssets

Change-Id: Ic77ff41519b22e3b20c4571785a1368cdf4d14d2
Cleanup themes that fail to install

Themes which fail to install due to aapt or idmap errors
would not be properly cleaned up. This caused subsequent installs
to give a INSTALL_FAILED_UID_CHANGED (-24) error.

This patch also adds install error codes specifically for themes.

Change-Id: Ie03b92ca0a7dec8c4a5e3725b717943d36abb349
Themes: Fix -110 install error [2/2]

aapt was being called from PM with a ' ' at the end of the cmd. This would
cause installd to read unexpected parts of memory which sometimes
causes it to parse the command incorrectly.

Change-Id: I85bf93045370478fd9baaf5db784c0cc3a4a03b9
CM11 Themes: Expose applyDefaultTheme to public service

Change-Id: I952870fb984d51d554e560566a8cadbe2c49cc6b
Avoid app install failures from malformed themes

When an app is installed we create idmaps between it and all the themes
that theme the app. If the theme is really badly written it could
potentially fail idmap generation, but we should not block the app
itself from being installed just because a bad theme is on the device.

Change-Id: I0e38fd373dfd294aac17fab1cf07ba49934a8859
CM11 Themes: Fix applyDefaultTheme implementation

Change-Id: I718be5db58166df48cca5578d6ad5088b91bc1e2
Notify callbacks on "any" wallpaper change

Callbacks are not notified when the wallpaper is changed to
a live wallpaper.  This patch notifies callbacks of the change
regardless of the type of wallpaper be set.

Change-Id: Icbb7b825cd7e7096c90c5498b6fee0bc61a3de3b
CM11 Themes: Clear wallpaper mixnmatch entry on external change

If a wallpaper is applied from a theme and the wallpaper is changed
from an external source, the theme is still shown to have its
wallpaper applied.  This patch will clear this value out when a
wallpaper change is detected that is not from the ThemeService.

Change-Id: I3d32bb3c0ac96db3f940989bc7ad4eda5e4a71f7
Themes: Fix bad idmaps for system themes

For a system installed theme or a user who cleared his resource-cache,
there were empty idmaps for some packages.

[Details]
During startup PM could reach the theme package first before the target app was scanned in yet. This
would cause aapt to be skipped. Then when the target app is being installed in startup,
PM would try to create idmap pairs but it would fail since the resources from the theme
were not compiled for that target app.

Also cleaned up PM idmap/aapt creation a little bit more

Change-Id: I6a7dbd7c5d51a2d1336e3289c1e03bb3ed5d762e
Avoid calling idmap w/ trailing whitespace [1/2]

installd performs a buffer over-read if trailing ws is sent to it.
No observable effect found yet for idmap, but until installd is
fixed upstream, best to play it safe.

Change-Id: I56c9b4bd956ca6f59935253c6d2c90c4dba0ae94
Themes: Map themed icon to app after upgrade

Before this patch, applying an icon theme and then upgrading an app would
cause the app to lose its themed icon.

Change-Id: Ia76a33d0fb731720aa735e9dd9596bc5d2e75d9f
CM11 Themes: load wp from apk if uri is null

When setting a default theme on first start, the provider may
not have processed the theme and the uri for the wp will be null.
If this happens try to load the wallpaper from the themes assets.

Change-Id: I883b9dd796920e66e4729e78d41cd8899916fa42