Merge pie controls and pie service to cm-10.1-staging

This is a combination of 11 commits.

This commit brings pie service and all pie controls
changes from cm-10.1 into cm-10.1-staging.
It contains all 6 pie controls related commits that were
shipped with RC4 and then were reverted.

Following commits were squashed:

Framworks: disable observer and receiver if PIE is disabled

on high end devices that is maybe not needed. But there
is in general no need to enable the obeserver/receiver
when PIE is disabled (or expanded mode is off)
This change destroy and disables the PIE in most parts
when it is disabled. + a small doubel register
correction

greetings SlimRoms

PatchSet 2:
- remove PieLayout observer completly - thanks Jens

PatchSet 3:
- remove unnecessary call to setupSnapPoints()
- reuse already created snap points

PatchSet 4:
- small corrections on setupSnapPoints() and call
- remove not needed second call of PieController attachTo()
- disable TelephonyManager listener

PatchSet 5:
- fix up detach logic

PatchSet 7:
- cleanup

PatchSet 8:
- Effective Java rule #41
- fixed some pie controller leak

Change-Id: I8ef8797e7d4f8ee73d31a8296f5747415567bbda

Frameworks: Fix do not show snappoints if triggermask disables edge

as the title says do not show on lockscreen or notification
drawer the snappoints on the disabled edges. Pass
trigger slots and mask trough and take into account

PatchSet 2:
- some refactoring

Change-Id: I0413ffe86169c5d1cb906598d6006bbf1463770b

Frameworks: take  mPieScale into account to calculate estimated PIE width

if scaled size of the PIE is over or under the default size
the pie was either no using the whole screen space or
it was cutted off. To solve this take scale value
into account when calculating estimated width

greetings SlimRoms

Change-Id: Iccfc8362c0019e3b6ff4bd8066c313c67116c014

Pie controls: Introducing a pie delivery service

To make pie controls more reliable, it is neccessary to detect
trigger actions directly from the input stream.
This commit introduces a new system service, that filters all
input events in front of the input dispatcher to detect pie activations.

This commit introduces:
* A new system server local API in the input manager service to register
  secondary input filters. These filters are behind the default
  accessibility filter but before the input event dispatching of
  the android framework.
* A new system service, that binds to the new API to listen for pie
  activation gestures.
* A non-public manager class providing access to the newly created pie
  service.

The service manager name of the service is "pieservice". The non-public
AIDL interface of the service is IPieService.aidl. To register a new
pie activation listener the INJECT_INPUT permission is needed. The
service state can be dumped by the "dumpsys pieservice" command.

Note: This commit only introduces the pie service. There is another
commit, that binds the actual pie controls to the pie service.

Patch Set #1:
* The pie service is currently disabled by default and needs to be
  enabled by device overlays (see config.xml / config_allowPieService).

Patch Set #2:
* Activation fixes
* Debug dump improvements

Patch Set #4:
* Added systrace support (TRACE_INPUT_TAG)
* Switch default to enable service on all devices.
* Moved Position to com.internal.android.utils.pie.*
* Some more code rearrangements

Patch Set #5:
* Rebase

Patch Set #6:
* Cover more corner cases on PieInputFilter
* Adjust gesture time out

Patch Set #7:
* Do not send events that are from the past
* Recycle all events

Patch Set #8:
* Handle binder died events in PieService correctly

Patch Set #10:
* Simplified locking
* SYSTEM_UI_FLAG_HIDE_NAVIGATION support
* Fixed ADW Lauchner bug

Change-Id: I6a4a4635bed420e800a3230457ee690131116a11

Pie controls: A new way of activation

Based on "Pie controls: Introducing a pie delivery service" this
commit binds the pie controls to the newly created pie service.

Patch Set #2:
* Fixed glitch when displaying the search panel at the lock
  screen.

Patch Set #5:
* Switch Position to com.android.internal.util.pie.Position
* Removed legacy and unused code

Patch Set #6:
* Fixed lock screen glitch, finally!

Patch Set #7:
* Rebase

Patch Set #9:
* Moved almost all of the pie logic to PieController

Patch Set #10:
* Remove window completely from WindowManager when not shown

Patch Set #13:
* Fixed Taichi's bug
* Removed observers in PieView

Patch Set #14 & #15:
* Rebase

Change-Id: I352f198068807694d95699618597d0927da3f324

Pie Controls: Fix snap points position.

This commit reverts an error, introduced by the second pie
service commit, which causes the positions where the snap points
gets displayed to be inverted.

Change-Id: Iedaf6d4773c9ae45fb685d724fad6c35ecdeddf0

Pie Controls: Fix sound effects.

After the pie service commits, sound effects were broken for
HOME and BACK keys.

This commit fixes this, by moving the play back of the sound
effect from the injection directly to the onClick().

Change-Id: Id59848ccddac20cef80500f6e72d76afa97ae093

Pie controls: Tweaking UX for pie service (1/2)

With the introduction of pie service there is the need to
fine tune the parameters for activation again.

Patch Set #2:
* Base trigger thickness set to 10dp
* User settable activation sensitivity

Patch Set #4:
* Reverted #setSensitivity() in PieGestureTracker
* Added Sensitivity "Very High"

Change-Id: Ief7c1786467195f2ad52dcdb0efd3ad03a48834c

Pie controls: Fix event handling on chained input filters

Enabling accessibility helpers like "Magnification gestures" while
pie controls are active will result in a system reboot. After this
every input event (touch/key) will cause a system restart directly.

This commit fixes this, by making semantics for
sendInputEvent() with one filter equal to the case where more than
one input filter is installed.

Change-Id: Ie8a319e8c9a63c82c77122332c7d5dd71672cc75

Pie controls: Fix flickering nav bar in full screen

On rare occasions the pie service will deadlock. When this
happens, full screen mode can no longer hide the
navigation bar, since it is masked out internally.

This commit switchs from a self cooked mask mechanism within
the WindowManager to the private flag
WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_SHOW_NAV_BAR.

Note that this will avoid flickering when pie service get
stuck in the activation path, but it will not resolve the
deadlock.

Change-Id: I2b64867081b37d9d6070df8086975e4327d97f5d

Pie controls: Catching activation corner cases

As stated before there are still corner cases that may
deadlock pie controls.

This commit makes PieInputFilter respect ACTION_CANCEL,
simplifies monitoring mechanics in PieService and
fixes some corner cases in PieController that allowed that
activations got lost and thus pie controls got stuck.

Test case for PieController:
1) Enable pie controls
2) Enable top/bottom snap position for pie
2) Enable expanded desktop and check if it works
3) Disable expanded desktop
4) Lock your phone
5) Swipe from the top down/bottom up, as if you want to
   activate the pie from that position
6) Dismiss the notification tray and unlock your phone
   again
7) Enable extpanded desktop
8) Pie controls will no longer show up and
   "dumpsys pieservice" will show a active record.

Change-Id: Id9d2df6b2735a743eec2fd1ba809fd72be9474cc

Change-Id: Iaa980f7b5441bc6a990db886277dd041623a6251
Merge "Merge pie controls and pie service to cm-10.1-staging" into cm-10.1-staging