[1/2] SystemUI: Add brightness slider to notification drawer

adds a brightness slider below the expanded statusbar header and
(if enabled) quick settings ribbons

also wrap an if around gesture recorder in the fling methods, only
call them if DEBUG is enabled.

AICPfy

Change-Id: I76a4f52a7cb97bbf6da42ac38ac5e3bad9e69672
Merge "Themes: Fix setting wallpaper from a legacy theme" into kitkat
[ActivityManager] Fix race condition in pss collection

Symptom:
There has a race condition that two threads are accessing
the mPendingPssProcesses simultaneously. One of the thread
is collecting the process pss by looping the mPendingPssProcesses.
The other thread is requesting to collect pss of all processes,
which clears mPendingPssProcesses and adding processes back.

Solution:
Avoid race condition by adding synchornized protection.

Change-Id: Ifb090eda9c4a1b8e3fd980fe0171e9dd77773b46
Merge "[ActivityManager] Fix race condition in pss collection" into kitkat
Merge "Themes: Track NotFoundException on app launch failure" into kitkat
Keyguard: add smart cover support

Change-Id: I436eba7678b923a9f293e15d786447214bc9bdcb
Signed-off-by: Roman Birg <roman@cyngn.com>
policy: respect FLAG_TURN_SCREEN_ON flag with device flip covers

If an application uses WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
and the device supports covers and the cover is closed, then after the
screen would turn on due to this flag, it would immediately be turned off
because PhoneWindowManager thinks the cover is closed, so it puts the device to
sleep.

Respect this flag and do nothing if it is detected.

Change-Id: I7eb36ce676730e47c551518e214b08561c401ea5
Signed-off-by: Roman Birg <roman@cyngn.com>
Settings: Pie: Screenshot and Torch targets [1/2]

Change-Id: I0873330ebbf0857bdb87b78f831c1c4fff35114d
Themes: Fix setting wallpaper from a legacy theme

Change-Id: I3bfc9ee24d2a3ee5c1bdb97f2c07427e6d723206
Themes: Track NotFoundException on app launch failure

We should probably keep an eye on NotFoundExceptions too since they
are a common exception thrown when a bad theme is applied.

Change-Id: I2ccaed0349a90ab99b99fb83cef0c9183d598088
Themes: Remove listener if exception is thrown

If something goes wrong and a client does not remove itself, the
theme manager may still have a reference to the listener and an
exception is thrown while trying to call one of the listener's methods.
When this happens, we should not only log it but remove the bad listener.

Change-Id: I052cdcc10b0eaa75ebf076b3ece5f8a668d3868e
Merge "Themes: Remove listener if exception is thrown" into kitkat
PowerManager : Make proximity check opt-in

Change-Id: I7cf64a82530da2e655018e43683ba7a5584d54f8
Merge "PowerManager : Make proximity check opt-in" into kitkat
[ActivityManager] Fix ServiceRecord leakage

Symptom:
The first step of cleaning up application services is
to clear the app state from services (which set sr.app
to null). Then it clean up the service connections.
In some scenario, the Service might be removed during
the connection cleanup (i.e. the Service is no longer
needed). In that case, the Service will be removed from
ServiceMap, but won't be removed from r.app.services
(line 1612) because the r.app is null.

Solution:
Remove the service connection first.

Change-Id: I644d73af58fe0e7c1c4a6c9779fe6b5d747b880d
BootMessage: Only display package name during optimization.

The previous implementation caused the package name to show up for
other messages such as "Starting apps." or "Finishing boot.". Now
we check if the base message starts with "Optimizing" and only
display the package name if that is true.

Change-Id: I2a9c9df8ce06c5016557e2f227c7f308f688ce8a
Merge "BootMessage: Only display package name during optimization." into kitkat
Fix HTC headset handling.

HTC's headset driver adds additional bits to the switch state, which
we're unable to deal with. Fix that by masking out those bits and
keeping only the valid ones.

Change-Id: Idd4c050b0497f7ef4373ec3cb5e5f26cfe12643d
frameworks: add persistent notification when USB OTG is connected

Tapping the notification will take the user into Storage settings, and
highlight the 'Unmount' option.

Change-Id: I650f3874a8295b2b8ffdaef78aff4b68e9cd574e
Signed-off-by: Roman Birg <roman@cyngn.com>
Themes: Fix native crash in libandroidfw

If a missing attribute needs to be added in somewhere in the middle
of the bag, a segfault would occur because we change curEntry to a
value that is beyond the set's allocated space.  This patch stores
curEntry in prevEntry before changing it's value and memmove uses
prevEntry to index the set.

Change-Id: Ie70f2ad465097c3acf76caa729999c424fb01ee2