HOVER: A few improvements

- Better touch outside touch input handling
- On touch outside hide both case (expanded and non) in 1.25 secs
- Tweak clear foreground notification when we are on the same app
- Code style
- Tiny cleanup

Signed-off-by: Carlo Savignano <stevewatersy@gmail.com>
Change-Id: Ibb0c7c09ae3256bbf744f359cca651c8cb8112d9
Merge "Themes: Build icon cache when applying icons" into kitkat
Hover: dismiss to left remove from all (status bar and notif drawer) and from right only from hover

Partialy ported from SlimKat Heads up idea with a huge thanks to @kufikugel.
A boolean is used to determine the dismiss direction and further dismiss the notification completely or only from hover.

Change-Id: Iba7c1841ffaec360d204dc3326f24e91fa1a4310
User defined wifi/usb tether network. [1/2]

Change-Id: I1989c5332ba598a04094b03d6a5de32d72f7fa1c
Merge "User defined wifi/usb tether network. [1/2]" into kitkat
Option to always show heads up in expanded mode [1/2]

Change-Id: If8de4d34b4af89741a676bfb6400132f23826424
FB: Slimrecents background color && transparency [2/2]

PS: now setting sticks through reboots and TRDS state
        changes. also, add reset to default color option.

PS: when resetting to default, use TRDS (png) resources
        instead of custom color

PS: remove LSN dependency

PS: make default background setting cognizant of
        recent panel gravity setting to display
        correct background resource
Change-Id: Icf0259ce45d416364d6e7a7a8c2038f6c4c0cbde
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
Merge "Themes: Pass resource IDs instead of bitmaps [1/2]" into kitkat
[ActivityManager] Prevent provider creating twice.

Root Cause:
If a process which contains provider is starting by not
from accessing provider, e.g. service/activity/receiver,
its providers' will be created during handleBindApplication.
And before the process complete publish provider to
ActivityManagerService, if there is an access to its provider,
these providers will be created again (there will have 2nd onCreate).

Solution:
Check if provider record is existed, do not schedule install provider,
becuase it is already creating and will be published later.

Change-Id: Ic200ceae042c014c86e7edee0acd013b513af334
framework/base : Fix for Wi-Fi grayed out issue

During the initialization WiFiMonitor shall try to open the
control / monitor socket interface with the supplicant.On a
failed attempt to open the control interface WiFiMonitor
thread shall trigger an event SUP_DISCONNECTION_EVENT to
WiFiStateMachine with the expectation that the connection
attempt is restarted.In addition , it shall also remove the
interface from the mIfaceMap. During the restart , WiFiMonitor
shall not proceed to open the control interface with the
supplicant if the mIfaceMap does not point to the interface.
  Thus , do not remove the interface from mIfaceMap on a failed
attempt to create a control interface with the supplicant to
provision a reinitialization attempt.

Change-Id: Ia571a386c22e860b3e31f5153ae33f622b5d5973
CRs-Fixed: 642586
ActivityManagerService: Penalise large apps going to background

Large applications (PSS more than a given threshold) when closed are
penalised with higher ADJ. Now, they will be more prone to be killed by
lowmemorykiller during memory pressure levels. This ensures better app
concurrency and improved subsequent latencies as it leaves some more room
for other smaller bg apps to be alive

Change-Id: I448fa12f55370949b22075595cd75b9c29e5d4b5
ActivityManagerService: Fix heavy games kill during incoming call

Force heavy apps penalisation only to large "cached" apps. Donot
include "previous" app in this category. This ensures large apps
are not killed during special incoming alerts like incall, sms.

Change-Id: I51b4a238415efad63ef36f7e0cd056823a72a47d
Magnification: Fix screen freeze after activity resumes from rotation

mMagnifedViewport.onRotationChangedLocked() will call setShown(),
and then cancel a anime. As the anime should be only canceled in
a looper, if it is executed in the onRotationChangedLocked() of
DisplayMagnifier, a crash will be caused. Therefore when the
magnification is enabled, the activity will crash after rotation.

Move mMagnifedViewport.onRotationChangedLocked() from main thread
into the handler. When MESSAGE_NOTIFY_ROTATION_CHANGED is received,
execute it. As handler is created with a looper, the crash will be
fixed.

CRs-Fixed: 541799

Change-Id: I2a78f24f73d5a9b8693e557d18e2fb01fcaec8fa
lowmemorykiller: Overwrite LMK parameters for low-tier devices

LMK parameters calculated by default algorithm were not optimal for
low-tier devices. Values mentioned here were well tested and
evaluated w.r.t memory and performance for such setups.

Change-Id: I40ed92d204aae6e758028ea1e9bd4ec7226dbe2b
SystemServer: Move sensor init to a new thread.

Move Sensor init to a separate thread so that it doesn't block the
critical booting path.

Initializing Sensors in separate thread has been seen to improve boot
time on customer devices with low-tier / ult chipsets(less cpu cores)

Change-Id: I5c46a5805c04ffe551019b4683523e3bf70274a2
DocumentsUI: The title disappears after rotation

The onItemCheckedStateChanged() method in DirectoryFragment.java
called the setTitle() of ActionMode to modify the title of the
action bar. But this change is not redone after the activity is
recreated. Therefore, when the orientation is changed, the change
in title will be lost.

Set the android:configChanges for DocumentsActivity to avoid
recreating this activity.

CRs-Fixed: 641604

Change-Id: I768422b63a07fcb3ac2c8fa5c6007e49965ff713
Add looper to the thread to fix system_server crash

Toast message internally creates handler and we can't create
handler inside thread that has not called Looper.prepare().
Thus, we added looper to the thread to avoid system_server
carsh.

Change-Id: I09b9c4923c109f0b2707f8346e091efbd24b5089
CRs-Fixed: 669467
Add reboot reason to detect device shutdown

This change will detect silent device shutdown

Change-Id: Ia3c13e372b02dd4d3ec4a99d1c1f7c4787977ac3