Squashed commit of the theme engine support.

Updated 4.2 support for the old T-Mobile theme engine, as usual
needs the provider and switcher apps installed as well.

I'm finally dropping the 400+ commit history on this, since everybody
else keeps picking it up from CM as a single patch anyway... But
for the record, nothing of this would be possible without Josh, Ed,
and the rest of the TMo guys who wrote and maintained it until 2.2:

amit chabra <amit.chabra@t-mobile.com>
Amit Kohli <amit.kohli@t-mobile.com>
Chris Cogar <chriscogar@t-mobile.com>
Dirk Sigurdson <dirk.sigurdson@t-mobile.com>
Ed Carrigan <edward.carrigan@t-mobile.com>
Gaurav Sharma <gaurav.sharma3@t-mobile.com>
Hui Feng <hui.feng@t-mobile.com>
John Ritz <john.ritz1@t-mobile.com>
Josh Guilfoyle <josh.guilfoyle@t-mobile.com>
Mark Roberts <mark.roberts48@t-mobile.com>
Pankaj Kumar <Pankaj.kumar6@t-mobile.com>
Samuel Cheung <samuel.cheung@t-mobile.com>
Sergey Ten <sergey.ten6@t-mobile.com>

Change-Id: I7148d51be48f28a2dc4bdf9ec9018f04b268ffc4

Framework: Remove orphaned Theme related code

Change-Id: I930d4cc75e655c5bc37532e6a1425d27bd1ee661

Check themes of current user, not user 0.

Change-Id: I5d685a04289b434a12e460b4fdacc43a41ff2be1
JIRA:CYAN-1303

Fix theme provider crashing for non-primary user.

PackageManagerService's context is for user 0, so if the theme provider
for other users was invoking the getInstalledThemePackages() method, the
themes provider crashed as it doesn't have the INTERACT_ACROSS_USERS
permission.
Fix that (and simplify code) by making getInstalledThemePackages()
return the installed themes for the current user, which was probably the
intent anyway.

Change-Id: I02002cee005b74128f3b2f7cc7a93b9b8514f1f3

ThemeUtils: Retain the original package name in themed UI context

In order for themes to reflect on system elements, we're changing
their context, including the package name.

This breaks anything that tries to identify system elements,
most notably any users of the uiautomator. Trying to do
'UiSelector().packageName("android")' to find, for example,
a force-close dialog will fail.

Fixes com.android.cts.uiautomatortest.CtsUiAutomatorTest#testUiWatcher

Change-Id: Ic05c3024b20ac3772ed5597846fbfa4a184ebb0d

platform: Fix the gid for the theme manager service

It was mismatched with fs_config, resulting in attribution of the
"-1" gid

Change-Id: Ia6d55af0b39f659da2965f9bc0bda0df5c775ba4

PackageManager: Let com.tmobile.thememanager access privileged permissions

Needed for CHANGE_CONFIGURATION

Change-Id: If50b0926d77e15e18ef5e88d7efac1b7f209d6e4

ResourcesManager: Fix theme insertion at boot

This was lost during the 4.4 ActivityThread reshuffle, put it back

Change-Id: I96eadf691973e9a2daa099b55816fc103d129be7

SystemUI: Reinflate on theme change

Reflect the updated assets immediately once the config_changed
notification happens

Change-Id: I480a719fbdd45875277871af39ce65849918ec0a

Fix various broken bits from the rebase

Change-Id: Ib7737d6aebde195b2b01892d95d6ec0e7f91f731

PackageManager: Prevent themes from going into ASEC containers

Themes on ASEC cause all kinds of random timing/racey issues at boot
time, and more kinds of racey concurrency issues at uninstall/upgrade
time. Stop them from getting into containers at all.

Change-Id: Ib7737d6aebde195b2b01892d95d6ec0e7f91f731

AssetRedirectionManager: Accept redirections only for whitelisted resource types

Change-Id: Idf1ea739a81719b6a196f0114c9fc3b7c7ff428c

AssetAtlas: Fix NPE when there are no preloaded resources

Change-Id: Idf1ea739a81719b6a196f0114c9fc3b7c7ff428c

Conflicts:
	core/jni/AndroidRuntime.cpp
	packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
	services/java/com/android/server/NotificationManagerService.java
	services/java/com/android/server/SystemServer.java
	services/java/com/android/server/wm/WindowManagerService.java

Conflicts:
	core/jni/AndroidRuntime.cpp
	packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
	packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
	policy/src/com/android/internal/policy/impl/GlobalActions.java
	services/java/com/android/server/SystemServer.java
	services/java/com/android/server/am/ActivityManagerService.java
	services/java/com/android/server/pm/PackageManagerService.java
	services/java/com/android/server/wm/WindowManagerService.java
Frameworks: Port CM Quiet Hours (1/2)

Change-Id: I40f46d8fd4b74dfc00654058e49a11a6c11f52a4

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

Add Battery as well!

Conflicts:
	core/java/android/provider/Settings.java
	services/java/com/android/server/BatteryService.java

PS1: Quiet Hours: additional features
Change-Id: I4051a84007c517dcf1197801c0b0223718ddb8ec

Conflicts:
        core/java/android/provider/Settings.java
        services/java/com/android/server/BatteryService.java
        services/java/com/android/server/NotificationManagerService.java

PS2: Quiet Hours: Bring current to CyanogenMod
Change-Id: Ic7671acee2582600e725630b34bf262d3c08eb01

Conflicts:
        core/java/android/provider/Settings.java
Frameworks: Slims ElectronBeam get some love (1/2)

Features:
- You can select different crt off animation modes if device overlay does not disable it at all
- disabled
- always horizontal (stock behaviour)
- always vertical (screen collapse from left and right to the middle)
- orientation dependent (means portrait = horizontal animation, landscape = vertical animation)
- some minor fixes/code style improvements to 4.3 implementation

PatchSet:

- fix merge derp

Change-Id: I02543a242f8f570438f2ab97a19b6ffe1b4dba1c

Conflicts:
	services/java/com/android/server/power/PowerManagerService.java

Conflicts:
	core/java/android/provider/Settings.java
	services/java/com/android/server/power/ElectronBeam.java
QuietHours: disable volume change tone during quiet hours

* Its quiet time, you're trying to be quiet, why would the volume
  change make noise when you're being quiet?
* Turn this off when system sounds are disabled during quiet hours

Change-Id: I6c7eb9d52f5dab9349bf2b8f72ddcb0ab45834fa
fb: TRDS 3.0 and new theme engine preparation (1/4)

For the one who do not know this feature see as reference
the first two versions here:

https://github.com/SlimRoms/frameworks_base/commit/b330fde28306286572ba390e451a72539c0c3576

https://github.com/SlimRoms/frameworks_base/commit/3194015737b7944b4185fca007b8d167a0675cd8

we got now over a year now a lot experience how to handle the qualifier fallback
as well how to theme it and how to handle other apps. Based on this knowledge we
redid some parts of TRDS engine with following new features/additions and fixes
to have now a final perfect working TRDS

- compared to the old versions where it was needed on some apps to restart them
  in background this is not needed any more. All is handled about the internal
  AOSP resource handling and on qualifier change the caches are cleared
  and the apps get an onconfigurationchanged to restart the activity
  like it is doing on orientation change eg
- inverted folder is now depreciated and the new folders are holodark
  and hololight which allows on the one hand a dark theme (at least
  how TRDS started) and a light based theme hololight
- This name change is mainly because of the new theme engine which
  will come which uses this as base to add 2 external themes at the same
  time and give the user the ability to switch between them. But this is
  still in early stages and this commit is just the preparation for it
- Two new automodes are now integrated. User can enable the twilight modus
  which enables/disables holodark/hololight depending on the daytime...means
  on the evening it switches to holodark on normal day it is hololight.
  The other automode is based on light conditions....means that if it is
  dark outside it switches to holodark....if we have bright light conditions
  it switches immediatelly to hololight. Due of the resource cache handling now
  this happens immediatelly for the user and feels completly system integrated
  and happens without delay. A bit comparable to some navigation tool for cars
  which can switch automatically from dark to light and back
- currently the auto modes as well the manual mode switches between holodark
  and hololight. Due that we do not have currently anything hololight themed
  in the source hololight = stock theme. We will give the user the ability
  later when done to choose between which modes the user want to switch
  (stock/holodark/hololight). But this does not make sense at the moment.
  As soon as we have done the light theme or theme engine (lets see what
  comes first) we will open the ability to choose it. This is only a small code change
- a lot small tweaks and fixes went as well into the new version

Whatever this commit as usual adds the support for it. The themeing is done in the
other commits by kroz which is as well way more extended then on the older versions

cheers

PatchSets:
- minor code cleanup

PatchSet5:
- use one value for auto modes

PatchSet6:
- kill resource caches on configuration change

PatchSet7:
- register settings observer lol

PatchSet8:
- fix not assigment of config mode change (typo lol)

PatchsSet 9 -11:
- playing around aosp qualifier is not that flexible then I thought
whatever back in most parts to original implementation handling

PatchSet 12:
- now no restarts of any application needed any more like it was on 4.3...yeaaah
- fix wrong shifting in native adapter
- fix wrong call of twilightmode
- disable debug
- cleanup

PatchSet 13:
- fix lightsensor

Patchset 14:
- no need currently to recreate the navbar we can do if a theme needs it

Patchset 16:
- synchronize on sending config change
- only send if system is ready
- fire first update when system is ready

-rebase

Change-Id: Ic88838247c47d2a92b55d1cb1b00330f2d62fb88

Conflicts:
	core/java/android/app/ResourcesManager.java
	core/java/android/content/res/Resources.java
	core/java/android/provider/Settings.java
	core/res/res/values/slim_symbols.xml
	packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
	services/java/com/android/server/UiModeManagerService.java

Conflicts:
	core/res/res/values/pa_symbols.xml
fb: TRDS dark base theme

Change-Id: Ie25abfbf5258ac479ca8bc91033f6892bbbc6741
TRDS: Squashed commit of the following

    TRDS: fixup slim adoptions

    Change-Id: I62859e86403a653948ef8bdee4c112b9c7b9dc4e

    TRDS: some PA love
    PS1: swap wallpapers as well

    Change-Id: I71628bbed49545ff9a688d655763b1b02d9fc2cc

    TRDS: Dark DocumentsUI

    for Downloads app

    PS:
    - fix settings

    Author: kroz <46.kroz@gmail.com>
    Date:   Mon Dec 23 16:06:58 2013 +0100

    Change-Id: I87d49e97b8a0a67bd4d85f0137eb0960155428cb

    trds: improve dialogs and menu popups

    Author: kroz <46.kroz@gmail.com>
    Date:   Tue Dec 31 05:20:22 2013 +0100

    Change-Id: I54da4ac0236dfe16ee964ccb070944206d0544e2

    trds: consistent glow for menu dropdown and popup

    Author: kroz <46.kroz@gmail.com>
    Date:   Mon Jan 6 12:49:47 2014 +0100

    Change-Id: I248872cbd67471495f8b95036d995f25e2ca4459

    fb: TRDS change auto detect light conditions method

    Currently on critical light conditions it still switches to often between
    on and off which results in bad UX and in worse cases to unusable phone
    due that it is permanently switching. To prevend that slacken the light mode
    level detection and set it when it goes to dark mode way more higher (LIGHT_
    and when into light mode back to lower level (DARK_CONDITION)

    PS
    - 25 looks good

    Author: Lars Greiss <kufikugel@googlemail.com>
    Date:   Fri Jan 24 16:24:51 2014 +0100

    Change-Id: I665f3141fe31f26ca371d10593ff95174d68fc9e

Change-Id: I9d5ad43354d28fc4c73148b87aec7554dde58e41
Quiet Hours: Allow disabling phone ringer (1/3)

Change-Id: I73746443d1797c0f73a13faea2c422f5759b64a5

PS1: remove duplicates
Add lockscreen rotation as an optional rotation setting (1/2)

This will allow the user to select wether or not to use the
rotation settings for the lockscreen.  This is dependent
upon the rotation setting being checked.

Forward port from cm-10.2, adjusted for 4.4

Signed-off-by: Michael Bestas <mikeioannina@gmail.com>

Change-Id: Ibd7c69b0af1e0a7d91b985f2b21ea0b5bc619a70
JIRA: CYAN-339

Conflicts:
	core/java/android/provider/Settings.java
	packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java

Forward Port full display options
Custom Carrier Label [1/2]

PS 3 : Fix code style
PS 5 : Rebase
PS 6 : Fix derp

Change-Id: I0100d9af03d33ccacc70a960580ce9a7fca6b61c

Conflicts:
	packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
[1/2] Base: Clock tweaks

PS5: changed to slim as base for commit:
- Clock and date enable/disable
- Clock and date position
- AM/PM styles multilang support
- color
- Date format
- Date style

PS6:
- Fixed build
- Removed color options because we don't have it for any other
statusbar objects.

PS7:
- fixed clock on lockscreen after reboot
- fixed clock transition
- cleanup

OmniGears: https://gerrit.omnirom.org/#/c/4939/

Change-Id: I9129067775d65119d27085f93efb798a7124ae2c

Conflicts:
	core/java/android/provider/Settings.java
	packages/SystemUI/res/layout/status_bar_expanded_header.xml
	packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarTransitions.java
Base: fix icon overflowing with centre clock

Based on @maxwen commits
1 - https://github.com/maxwen/frameworks_base/commit/5b4d7714ea5fcc493712b569f456f655bf696076
2 - https://github.com/maxwen/frameworks_base/commit/5b4d7714ea5fcc493712b569f456f655bf696076
3 - https://github.com/maxwen/frameworks_base/commit/b5f7820e50fd03522b5462777779a4520594c796

All credits goes to him.

Change-Id: I86dd9b133adc917d8590a7b3c28abd30ccea48f4
AppOps: squashed port of various features from CyanogenMod

Change-Id: I36c506988a5bee0137ee142e95fbdb1b34214d68
Sounds: add oldspice notification

Change-Id: Id8d509883b1779120a8f83f5d6186462b0e56d09
base: squashed commit of what remains

    Upload/Download anims - SlimRoms
    Performance profiles - CyanogenMod
    CPU overlay - CyanogenMod
    Lower back to kill
    Misc fixes

Change-Id: Iecd933f5821f12c1deb2b6a858e83418f61f5d66
base: fix instant notification LED test

Change-Id: Ibdefb772163f13de4389a22ab073e8ab440bc850
Merge remote-tracking branch 'github/kitkat' into GIT