Fix themes not sticking on reboot if using Xposed framework.
Credit goes to @rovo89 for the fix

Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
Themes: Add method to "apply all" a theme

Change-Id: Ic8feaeade6c52707e6b5b17921b1b577b94ec8cf
Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
Themes: Add URI for querying previews of applied components.

Change-Id: I97417901f3b03fc82df5a823970991ddd8092df2
Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
WallpaperCropper: load wallpapers in the background

Change-Id: I134d94a85f25bf5db4c15fa9a89265c53e5b0c1d
Signed-off-by: Roman Birg <roman@cyngn.com>
Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
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
Signed-off-by: Chet Kener <Cl3Kener@gmail.com>

Conflicts:
	packages/SystemUI/src/com/android/systemui/quicksettings/UserTile.java

Conflicts:
	packages/SystemUI/src/com/android/systemui/quicksettings/UserTile.java
	services/java/com/android/server/ThemeService.java

Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
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
Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
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
Signed-off-by: Chet Kener <Cl3Kener@gmail.com>

Conflicts:
	services/java/com/android/server/ThemeService.java

Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
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
Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
Catch all exceptions when retrieving ComposedIconInfo

It is possible to receive a TransactionTooLargeException when
getting the composed icon info from the package manager service.
We should catch these exceptions to avoid unnecessary crashes.

For reference:
The Binder transaction buffer has a limited fixed size, currently 1Mb,
which is shared by all transactions in progress for the process.
Consequently this exception can be thrown when there are many transactions
in progress even when most of the individual transactions are of moderate size.

see http://developer.android.com/reference/android/os/TransactionTooLargeException.html
for more details.

Change-Id: I70d35dc4926125bfbef5d8c5fb8ed6d6fcdbf159
Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
Add SET_WALLPAPER permission to SystemUI

Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
Themes: Add STYLE_THUMBNAIL to PreviewColumns

Change-Id: Ie18264cbede92220335400428e67735866cd442d
Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
frameworks/base: Fix the random UI corruption

On low memory device, when a view goes to background. Its HW layer cache
will be destroyed to release memory. There is a very rare case that the
hardware render is not valid when destroy the layer, so the layer is not
destroyed and reused when the view comes to foreground. But the GL
context has changed, so the view is not rendered correctly due to its
HW layer cache. To fix this issue, destroy the layer in a safelyRun. Make
sure the layer is destroyed correctly.

Change-Id: I1c714e1d53db7353d5169e874a7cd0f527c3f67b
CRs-Fixed: 623239
Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
Mark constructor as accessible in LayoutInflater.

Needed to bypass new access checks for fields, methods, and
constructors.

Change-Id: I8ff0b44a6cb4f4af1c72734bca366d8b89528030
Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
InputWrapper: opt out early if session == null

Change-Id: If111195ba6425ad6b8663601566f9f260738ec77
Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
Themes: Add helper methods for creating complete component maps

These methods can be used to apply a theme while replacing any
components not found in the theme with the defaults.

Default components come from the default theme for the system
with any missing components in that default theme coming from HOLO.

Change-Id: Idea55cc684ccc8304b01a991c36b6993f55b8880
Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
Themes: Make notification list bg themeable

Thanks Thomas Ekelschot :)

Screen of themed resource https://imgur.com/c8t1Zn0

PS2: Add Clark's proposed changes
PS3: Cleanup old color resource in main xml
PS4: Add informative screen

Signed-off-by: Carlo Savignano <stevewatersy@gmail.com>
Change-Id: I8eb4427747c3eb035b416860c3ca47122e45c16f
Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
IconPackHelper: Don't respect an icons original size if too large.

  - Otherwise, if an application isn't following app icon guidelines,
  it can create an OOM situation when creating the new icon based
  on the original resource's height and width.

Change-Id: I9430445da5e393cdbf76ed9ebd9698bf30df6a95
Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
Themes: Whitelist animations

Change-Id: I981a8e4741cf03d8649bc4828e597d1a7035e080
Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
Load original drawable if cached icon throws NotFoundException

If for some reason we get a NotFoundException while trying to retrieve
a cached icon we will attempt to load the original.

Change-Id: I36a708d3e653fed12e88fe93c6d0a7f8e46726c9
Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
WallpaperCropper: fix lockscreen wallpaper "Set wallpaper" string

The string is wrong and does not reflect the correct action the user is
about to apply.

Change-Id: I91eba87a38546563d6cf88138a0ed07219ec794f
Signed-off-by: Roman Birg <roman@cyngn.com>
Signed-off-by: Chet Kener <Cl3Kener@gmail.com>