Parallel shutdown

Decrease shutdown time by doing some shutdown tasks in parallel.

There are two threads executing during the shut down: the ShutdownThread
and a separate thread for the radio shutdown. However, the execution is
done in serial, as the ShutdownThread immediately joins on the radio
thread.

This commit will move the shutdown of the radio to the beginning of
shutdown and execute it in parallel to the shutdown of the rest of the
system.

The flow of the two threads during shutdown is now:

Radio Thread
  * Start shutdown of the radio
  * Wait for radio off or time out
  * Notify that the radio is done
ShutdownThread
  * Broadcast ACTION_SHUTDOWN as a parallel broadcast. (The receivers
    will get as much time to handle onReceive as it takes execute the
    rest of the tasks in the shut down flow. If they are not done in
    that time, we don't care.)
  * Shutdown ActivityManager
  * Shutdown MountService
  * Wait for MountService and radio to notify done
  * Vibrate
  * Low level shutdown

Change-Id: Ifdd8a9c75337fd9d00148a0d2b9917e10fa60634
Appears black screen fix for a while

This issue is side-effect of added google patch on KK MR1.

Fix a couple of issues with mOpeningApps.
https://android.googlesource.com/platform/frameworks/base/+/a8ee262c04749db4f32f73d2b9e7f58989c4638b%5E%21/#F0

[Reproduce path]
Settings -> Location -> Location OFF -> Location ON -> "Location consent Dialog" Popup-> "Agree btn" press
-> Black screen appears for a while

Change-Id: I14efdce87e8d78d38f9aae48568f69937e4fe1fa
Speed up notification pullup & pulldown

based on an idea by Mr.Nigma @xda:
http://forum.xda-developers.com/showthread.php?t=2267307

Change-Id: I61213058b5cedddf90e974713af05c038e3af039
Smoother Upload and Download Animation

Change-Id: I6e6409cc85ad951019dbac10156d4aed92f4c5bc
Speed up glowpad just a little bit
Smooth Spinners: Makes the loading "spinner" animation smoother in non-holo apps

The loading "spinner" animation is quite jerky by default when the progress xml's from
drawable are called in applications that don't use the holo progress animation. The holo
"spinner" animation is already smooth by default. This makes every other "spinner"
animation smooth.

We've been changing this value in all ROM's we release, both AOSP and CM based ones
as well as stock ROM's, since it gives a more polished look to the entire system. In the past
3 years we've been using this small tweak we have not noticed anything that would
adversely affect battery life or system operations as a whole.

Rebased to cm-10.1 by Kristof Petho

Change-Id: I617d197c2ff4f1a27e96dbc206c24c27036e18d6
Keyguard: don't refresh ui when screen off

KeyguardStatusView is doing refresh all the time,
which cause high power when screen off.

Change-Id: Ifabdde4419a23e919cd52fe77e78ec3160575af1
framework-res: Remove gingerbread scrolls
Revert "Rework QuickBoot longpress shutdown and actually move long press reboot to reboot key lol"

This reverts commit 0e970cc86cc03b95bc6259c35ab800519a65dfb8.
1. base: properly check that quickboot is enabled
2. base: rework onlongpress for reboot
3. misc.

Change-Id: I0c9e54ee2cdf4efb5097cd101a0fa274f493d816
Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
IndexOutOfBoundsException observed rarely in ProcessStats

Sometime IndexOutOfBoundsException is observed in ProcessStats
while allocating longs array. This could be due to synchronization.
This fix will return if array index is >= size.

Change-Id: I1df34152c95f2ff61829da07f750e79a6f1efab3
CRs-fixed: 626638
Signed-off-by: houst0nn <houstonn@gmail.com>
pm: Prevent a system_server crash is package name is null

 * If an app is placed on the system partition and it doesn't specify a
   valid package name, system_server will crash forever. Just skip it.

Change-Id: I9b911d40b3c4d7cf6fac8cc0166a2ba359329b7b
ActionBar: Compute required items prior to optional items

When computing if a item should be shown in the action bar, required items need to be compute prior
to optional ones. Otherwise, in some cases (when the optional menu goes to the left of required
items then the algorithm could determine that optional has space to be shown and force the show of
required items, causing the required items to not be shown).
A concrete case is in the Email app. In the message_view_fragment_option.xml are defined 5 menus,
that when are all shown (xe: in Exchange mailbox account type) the bar is complete filled. But if
the overflow button is forced to be shown (the device has no permanent menu key) the overflow button
overlaps the older button, because space of 'ifRoom' items are wrong computed.

Change-Id: I6fc8e3e202d76f9704d7ec2383c7ee6f7b05ba76
PIE 2.0

Pie is an alternative navigation and system info interface. It replaces the
standard navbar/statusbar with a navigation arc decorated with statusbar info.

Important notes for developers:
* When PIE is enabled apps don't even have to support immersive mode, they just have
  to check for configuration updates (sadly not even this is done by all apps).
  When PIE is disabled, apps have to setup an "onSystemUiVisibilityChangeListener"
  (best practice for PIE enabled, too).
* Changed how ActivityInfo handles apps capabilities like recalculate screen
  size etc. Check code comment(s).

Some info:
* Quicksettings and notification panels are not available anymore, google now
  replace swipe up gesture.
* Switched to kitkat colors.
* General improvement to the code, reorganize classes.
* Cleanup a lot and remove useless code.
* Merge with immersive mode, they live in a homogenized state.
* Improve immersive code a bit.
* Upon first activation, toggling immersive tile, the user is presented with a dialog asking
  to enable or disable the feature. The preference can be resetted in "Backup & restore" in settings.
* Reduce and center its trigger area.
* While pie is triggered screen is keept on.
* Depending on immersive mode, will show full or lite pie.
* New circled snap points.
* Detach pie on every rotation and/or when screen goes off while you have it triggered.
* What else, what some slices?

Key contributors:
@BigBrother1984
@D4rKn3sSyS
@Anu6is
@David96
@drcmda

Signed-off-by: Carlo Savignano <stevewatersy@gmail.com>
Signed-off-by: Jesus David <jesdga95@gmail.com>
Signed-off-by: Curtis Mayers <curtis.mayers@gmail.com>
Signed-off-by: David L.-W. <david.leppla.weber@gmail.com>
Signed-off-by: Paul Henschel <drcmda@gmail.com>
Change-Id: I6d09b1e2124d14e6cec48b40ea0c7948ebbb02b3
PIE: Fix random showing of navbar when swiping from top.

We need to condition here aswell to be sure top swipe doesn't trigger up
navbar at all even if we set its height to 0 is an useless call.

Addressing JIRA AOSPA-151 issue.

Signed-off-by: Carlo Savignano <stevewatersy@gmail.com>
Fix: SysUi crash on Pie recents

https://paranoidandroid.atlassian.net/browse/AOSPA-79

When toggling recent apps using pie controls on secondary user account,
system ui crashes.

Change-Id: Id43b79dadf4cc4a88534aa18e1138b1daa7eece8
Fix: Graphics error when switching to recents using Pie controls

Attempt to fix https://paranoidandroid.atlassian.net/browse/AOSPA-65

I've never been able to reproduce the problem on Hammerhead, Mako or
Grouper, so I can't guarantee that this solves it.

Feedback is needed from a user that constantly experiences this bug.

Change-Id: I950e94dbb9b9d07dedee9b9f8cab6c5b6bceb6b0
PIE: Prevent a rare freeze that appears on quick iterations.

Signed-off-by: Carlo Savignano <stevewatersy@gmail.com>
PIE: Disable orientation sensor when we don't need it

Orientation sensor always enabled causing some device keep awake and
battery drain. This commit fix this issue.

  * Disable/Enable orientation listener when screen turn off/on if PIE
is enabled.
  * If PIE is disabled, recycle it.

Change-Id: I6bda168b3fd62d9f7047ffc3a3c6bfd08e655543
[TEMP] PIE: fix a freezing bug

How to reproduce:
- Enable PIE;
- Toggle between on/of;
- Without close expanded status bar click any tile that use one of this methods -> private void startSettingsActivity(String action) or private void startSettingsActivity(Intent intent);
- System will freez for some seconds and soft reboot;

Solution:
- When deteced PIE mode enabled use a runnable with a less time possible to give time to system colapse panels and perform needed actions

Change-Id: Idc5f112873aa7a31993e7a3c82a1760bb45f8b9b