Themes: Build icon cache when applying icons

The theme service will schedule building of the icon cache when
an icon pack is applied.  This will allow the icon cache to be
populated immediately after icons are applied rather than build
it up as icons are requested.

Change-Id: I453eda5f6298ff79e22827c622a0eddcab9c721d
Themes: Pass resource IDs instead of bitmaps [1/2]

Rather than passing around bitmaps in the ComposedIconInfo we
can pass the resource IDs associated with each of the components
and retrieve those drawables when composing the icon.

Change-Id: If855e60e505571f25316e6728e423fbee62c32d3
SettingsProvider: add default overlay entry for SEND_ACTION_APP_ERROR

Add a default entry for Settings.Global.SEND_ACTION_APP_ERROR so that it
can be overlayed elsewhere if needed.

Change-Id: Ieffc2f4a1ad8ad0df04a9e33b575150a680478af
Signed-off-by: Roman Birg <roman@cyngn.com>
Themes: Allow clearing the wallpaper and ls wallpaper

By providing an empty string for the MODS_LAUNCHER and
MODS_LOCKSCREEN components, the theme service will clear out any
existing wallpaper the user had set.  This provides the same
functionality as if the user was picking "No wallpaper" from the
picker.

Change-Id: I0c349ad4afa2bcef2c302105315709786510c0aa
Themes: setUserRequired(false) when updating audibles

This prevents the following exception
F/Environment(18007): Path requests must specify a user by using UserEnvironment
F/Environment(18007): java.lang.Throwable
F/Environment(18007):   at android.os.Environment.throwIfUserRequired(Environment.java:787)

Change-Id: Ic6ac7537079ed27912c40683c877e05992b708e9
Fix camera usage tracking.

When a Camera object is finalized, it notifies the torch service that
it's no longer using the camera. This call used to not check whether the
caller actually is still using the camera and called release() before,
so depending on timing of the finalizer, it could happen that e.g. the
camera app released the camera user record of the torch app, leading to
the torch usage not being detected on next usage of the camera app.

Fix that by checking whether the caller of onCameraClosed() actually
owned the camera prior to releasing the record.
Also fix synchronization between accesses.

Change-Id: Ic01cbc3c89ab8d855e4613bfa1b2f548de919b73
Fix ressource leak in getFileCrC

Change-Id: If8a63fa355664d360aab6ecba92c82cd56b745b8
PowerManager : Make proximity check opt-in

Change-Id: I7cf64a82530da2e655018e43683ba7a5584d54f8
Make sure ThemeConfig is non-null when loading resources

When the device boots into safemode, the theme config will end up
being null and we need to check that prior to using it to retrieve
resources for the StatusBarIconView

This fixes CYAN-5009

Change-Id: I1a90bc9f9c65cb41a6e58947bbd1b6d7728a952b
Themes: Add ability to apply color filters to composed icons

Themes can include one or more of the following filter tags in
assets/icons/res/xml/appfilter.xml

    <!-- HUE filter
         Integer value between -180 and 180 representing the degree.
         0 = no change
    -->
    <filter name="hue">0</filter>

    <!-- SATURATION filter.
         0 = grayscale, 100 = no change, 200 = over saturated
    -->
    <filter name="saturation">0</filter>

    <!-- BRIGHTNESS filter.
         0 = pitch black, 100 = no change, 200 = 200% brightness
    -->
    <filter name="brightness">100</filter>

    <!-- CONTRAST filter.
         -100 = minimal contrast, 0 = no change, 100 = maximum contrast
    -->
    <filter name="contrast">100</filter>

    <!-- ALPHA filter.
         0 = transparent, 100 = opaque
    -->
    <filter name="alpha">75</filter>

    <!-- INVERT filter.
         Valid values are true or false
         true = invert colors
    -->
    <filter name="invert">false</filter>

    <!-- TINT filter.
         A hexadecimal value representing ARGB
    -->
    <filter name="tint">#ff0000ff</filter>

Change-Id: I2431237dd2766176be16c730020557ce87d623e4
Revert "QuickSettings : Register/unregister cast tile one time"

This causes a CTS failure: android.security.cts.ListeningPortsTest
  testNoRemotelyAccessibleListeningUdp6Ports

This reverts commit e037c1fe6dbdcd077719f7fc7b1902a887b56c23.

Change-Id: Idc145b6fb17490664fb5614d44e1ae92c98df844
SystemUI: make long pressing recent switch to last app

With this patch, long pressing the recents key on the navigation bar
will attempt to switch to your last application in the activity stack
before the active one.

The user's current home launcher package is ignored as well as SystemUI (so that
RecentsActivity does not influence the behavior).

Change-Id: I38771e0fce16b55bb5186af47115b4e812cb60b0
Signed-off-by: Roman Birg <roman@cyngn.com>
advanced reboot: add soft reboot option

Adds a "Soft reboot" option which restarts zygote, as requested in JIRA
CYAN-3998

Change-Id: Ia6e5ed9b053e1c5ebd1fc55e5692858b97f7e0fc
Signed-off-by: Roman Birg <roman@cyngn.com>
Themes: Fix icon filters clamping to wrong values

Change-Id: Iab3cce465f8bdfd7c30a020fda254728349c5ebe
Themes: Make sure composed icon info is meaningful

We don't want to try and create a composed icon if the parts that
make up a composed icon are not valid or set.

Change-Id: I3d9e7432e4b351de9c0a4e662e028932ee7f08e2
ShutdownThread: set soft reboot trigger accordingly

Change-Id: I72bd52aa1492d356e368e8c60897002c1f110172
frameworks:base: SystemUI: cleanup a duplicate permission

these permissions are duplicated which i found using a script to check for
duplicate permissions.

submitted to AOSP here: https://android-review.googlesource.com/#/c/104810/

Change-Id: I598ed68836303e3ebc5313342f3ddaee6ccea9b2
Revert "frameworks: set default expanded desktop style"

There's currently some funky behavior related to this. The power menu 
option gets automatically added to the power menu when entering 
"Display" settings, no matter what.

This reverts commit a0c3610e16bb31c0ac4f909f522cb8d4cc718cd1.

Change-Id: I958e0e6f92cb8b90485af96ad55c221214007336
Themes: Fix blurry composed icons

In a composed icon the original icon could be scaled incorrectly
due to a density mismatch resulting in blurry icons.

For example, Grouper has a screen density of 213 dpi but Trebuchet will want to show a larger icon and therefore
requests to the framework to load app icons with a slightly higher density of 320dpi (XHDPI bucket).

When Resources.loadDrawable(TypedValue value, ...) is called, it will use observe value.density. Since the image
is from the XHDPI bucket it will have a TypedValue.density of 320dpi, much higher than the screen's 213dpi, and therefore
loadDrawablei() will configure BitmapFactory to scale down the image to match the screen density. This is not what we want,
so this patch modifies the density value to prevent scaling, much the same way getDrawableForDensity() does.

Change-Id: Ie638c8576872f9115dc029bb4823b50bb31ecebf
Themes: Load missing style attributes from original style

If a theme overrides a style in an app and does not include all
the attributes found in the original, it is possible for the app
to crash because it cannot locate an attribute it is expecting.

To overcome this we need to check the attributes in the original
style's bag and add any missing attributes to the current bag being
populated.  Currently we have only seen one theme that causes this
behavior, but there could be others out there or we may eventually
see this happen in the wild as apps update and the themes have not
had a chance to incorporate the new additions from the app.

Change-Id: Id44aa83a6c58a0b042d2b32171bed5e794352670