Report right battery status on lock screen.

Currently, the UI shows 'charging' in lock screen though the charging
has been stopped due to some reason. But it should actually check
the battery status also to find out if the device is actually 'charging'.
This patch is to show 'plugged in, not charging' if the device is not
charging while plugged in.

Orig-Change-Id: I77f560f9ae5b53f0e88a47beaa4b07ffbad21411

Change-Id: I3a392c5dfc0fa6f6d6eda7f26926c12e0978e3d8
Signed-off-by: Pavan Kumar S <pavan.kumar.s@intel.com>
Signed-off-by: Jian Luo <jian.luo@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
Signed-off-by: Jack Ren <jack.ren@intel.com>
Author-tracking-BZ: 55683
ShutdownThread: Turn screen on during shutdown

Screen should wake up from low power mode during shutdown,
to notify the user that the phone is shutting down.
This will result in better user experience.

Orig-Change-Id: I06b2c5c7a56795a65c6f49470d9b68b03b65c669

Change-Id: I265cfbb939e1109fbba609b133bcc3f418ef0bcd
Signed-off-by: Pavan Kumar S <pavan.kumar.s@intel.com>
Signed-off-by: Jian Luo <jian.luo@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
Signed-off-by: Jack Ren <jack.ren@intel.com>
Author-tracking-BZ: 103672
Document that OnSharedPreferenceChangeListener is weakly referenced

A SharedPreferences object stores the listeners inside a WeakHashMap.
This is untypical for a listener pattern. Users may use an anonymous
inner class to create the listener which gets gc-ed after a short period
of time.

This patch describes this behaviour in the official documentation. Fixes
AOSP issue #6052.

Change-Id: If9c0235205fbff990d67a0cd6729677f16a75313
BatteryStatsImpl: Avoid memory corruption due to Parcel Recycling

While processing batterystatsfile, in present code there is a race where a parcel
might be recycled while it is being written to disk in another thread.

The write process is done in 2 steps:
- write into a Parcel (memory block)
- then write this Parcel to disk using Journaled API.
The Journaled API ensures robustness against file-system issues due to power cut.
The writing is done in batch using a thread running commitPendingDataToDisk().
This function writes the parcel to disk but this parcel is a global variable
initialized by writeLocked(). If the writing takes too long time and two write
threads are launched, the parcel is freed by the second writeLocked() call;
which could cause the memory corruption.

Hence, change global Parcel variable by a Parcel parameter to commitPendingDataToDisk()
and only this function will be allowed to recycle the parcel.

Orig-Change-Id: I0e76441399f1ce74b83566edb8cf4f977dce58bf

Change-Id: I1884141d7d9c61601e2c8e07523a6e9aa6709afc
Signed-off-by: Pavan Kumar S <pavan.kumar.s@intel.com>
Signed-off-by: Jian Luo <jian.luo@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
Signed-off-by: Jack Ren <jack.ren@intel.com>
Author-tracking-BZ: 47466
EM/PowerUI: Screen will be turned on at low battery status

When Screen is off, then low battery popup is not visible to user.
With this patch we make the screen turn on just before popup and
it will remain in this state for 3 sec.
Also, if in silent-mode, then vibra will be turned on for 0.5 sec.

Orig-Change-Id: If665f47f27d933f59ce5f5895dac91091e7f2fdf

Change-Id: I618c8544229adb71870010f26407022450137a98
Signed-off-by: Pavan Kumar S <pavan.kumar.s@intel.com>
Signed-off-by: Jian Luo <jian.luo@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
Signed-off-by: Jack Ren <jack.ren@intel.com>
Author-tracking-BZ: 52107