PackageManager: Add option for single threaded dexopt

* Execute all dexopt invocations on the main thread instead of using the
  ExecutorService when persist.sys.dalvik.multithread is set to false.

Change-Id: I3b8499d5af5091ad7abcddf006f8f2837943903b
Themes: Update LoadedApk resources.

Instead of creating a new LoadedApk when resources are not up to
date, we use the existing LoadedApk but recreate mResources.

Change-Id: Ic1ad810863d03c2cedc751c9e84dd7c954daf3d7
Themes: Modify config to support app specific themes [1/4]

Summary of Changes
1. The configuration now supports each app to have their own theme.
Each theme can include icons, styles (ie overlays) and font.

2. The theme config is serialized into a json string and stored
in secure settings.  This entry consolidates what was previously 3 separate
keys (style, icon, font) into a single field.

3. 'CustomTheme' was renamed to 'ThemeConfiguration'.

Note: This commit is for the configuration. Additional work needs to be done to
the framework and UI to support app specific themes.

Credit to @BigBrother1984 for the original cherry pick

Change-Id: I8ac7e83f7cfa60567166bed699d1cb17c547e20d
Themes: Support theming navbar separately from SystemUI

This allows using a different theme for the navbar than the theme
applied to the rest of SystemUI.  This will not affect theming until
we have the front end in place that allows users to change this.

Credit to @BigBrother1984 for the original cherry pick

Change-Id: I753623696cdc017fc66dc5e85079fe80e5f626f9
Add getThemedResourcesForApplicationAsUser()

Credit to @BigBrother1984 for the original cherry pick

Change-Id: I90b7cb441e4056f59b7260ffa55e31eba644e25a
Themes: Allow specifying a theme when creating a Context

A Context normally loads the resources associated with the given
package that this context is for.  This patch allows us to specify
a theme we want attached to a given context's resources.

Credit to @BigBrother1984 for the original cherry pick

Change-Id: Idfb53aba307f58be6e2ed6d404b8a76c31199fc8
Themes: Use systemui's applied theme for notifications.

Notifications contain RemoteViews which are inflated using the
application's context for which this notification belongs to.  This
can look out of place if SystemUI is using a different theme than the
rest of the system.

This patch will use SystemUIs theme when inflating the RemoteViews,
giving us a more consistent look in the notification drawer.

Credit to @BigBrother1984 for the original cherry pick

Change-Id: I91392c76dca2ef08c82c5ccd68a0f6aca64b647a
Themes: Add icon previews to ThemesContract

Credit to @BigBrother1984 for the original cherry pick

Change-Id: Icbfbee3404702a29881ad4933721d8beb39bef30
Themes: Revert "Send broadcast when package is 'about' to be removed"

This reverts commit 238e80a5c7edcb922ce15feebec74ea2475c31cb.
This was a band-aid that is being fixed in a future commit.

Change-Id: I89a928e2fd9cff2b1992a6e85eb5c96c5b8b9b0e
Themes: Partial change: Use ArrayListExtra for broadcasting theme changes [1/2]

Change-Id: I897cfbbe293b73f9e8f069f4b4cefa7c3ffb79ed
Themes: Style, boot animation, and wallpaper previews

Change-Id: I2b367bf5336c03f2a4972a05b68922065cd4a701
Themes: Add method to "apply all" a theme

Change-Id: Ic8feaeade6c52707e6b5b17921b1b577b94ec8cf
Themes: Add URI for querying previews of applied components.

Change-Id: I97417901f3b03fc82df5a823970991ddd8092df2
Themes: Make notification list bg themeable

Thanks Thomas Ekelschot :)

Change-Id: Ic69f17423d6b78054c326a4ef7d324555a9e80fa
Signed-off-by: Carlo Savignano <stevewatersy@gmail.com>
Themes: Allow theming navbar bg color

Change-Id: I256afc30fc018ea752769029c5246bc7310c23a6
Themes: Fix ResourceNotFoundException when updating  applied theme

If the user has a theme applied and there is an update to that theme,
then the themed apps will crash. This is because the theme's APK path changes,
but the apps do not update their resources. Apps were not updating their resources
because updateConfiguration() determined that the config (which only has pkgName) hasn't changed.

The problem is fixed by first applying the default theme config and then re-applying the
updated theme.

SystemUI was crashing with a NPE while verifying this fix, so a NP check was added to SystemUI as well.

Change-Id: I00e32fc1535b4d279fcb37c35f868501ecc1dd19

Conflicts:
	packages/SystemUI/src/com/android/systemui/quicksettings/UserTile.java
IconPackHelper: Respect the original size of bitmap icons

When use icon packs on low-resolution devices, for example, my HDPI
phone, it seems that using the size returned by
getLauncherLargeIconSize() will cause a blurness on
some icons that are not included in the icon pack because of the compose
function.

This patch respects the original size of the icon if the icon is an
instance of BitmapDrawable but use the size returned by
getLauncherLargeIconSize() if the icon is an instance of PaintDrawable.
This will remove icon blurness on low-resolution devices.

Change-Id: Ifcb39020d934a9c7cb409e1206a179d64f99aa37
Restore lazy loading of LoadedApk resources

This was broken in 8fff544ec349593cfa61ae2f5ec59419fff666b6. Since that change,
resources are always initialized in getPackageInfo(), even if they haven't been
loaded before (mResources == null).

It shouldn't be necessary in *any* case to preload the resources at this point.
Anything using the resources should call LoadedApk.getResources(), which will
initialize them just when needed. Setting mResources to null resets the cache
and will force a reload the next time the resources are requested.

Change-Id: I9bc9986297478e99752b1e2b9bd04dab3dcc9656
Themes: Support applying components from multiple themes [1/3]

The current implementation assumes the components being passed
into the ThemeService belong to the same theme.  This patch uses
a Map instead of a List to pass in a mapping of components to
package names, allowing us to apply several components from
different themes.

Requesting a theme change now takes a Map<String, String> which
maps components to the theme package name they will be applied
from.
Example:
    Map<String, String> componentMap = new HashMap<String,String>();
    componentMap.add(ThemesColumns.MODIFIES_ICONS, "com.mytheme.blue");
    componentMap.add(ThemesColumns.MODIFIES_OVERLAYS, "com.mytheme.red");

    ThemeManager tm = (ThemeManager) contex.getSystemService(Context.THEME_SERVICE);
    tm.requestThemeChange(componentMap);

Change-Id: I13fa17eabecb824884fe522d5dc1822a4d7c55f4
Themes: Find wp asset when APK has dir entries

Some APKs are compiled with folders included as zip entries in the APK. This was causing
lockscreen wp to not correctly be set.

Change-Id: I9eca7878b29e3cfcb43abc4a9dab084d9c200b83