services: Add hook to run device specific shutdown code.

Add hook to call OEM specific shutdown synchronously. OEMs need to add
ShutdownOem class and define deviceRebootOrShutdown function in that.

ShutdownThread class would call this OEM defined function just before shutting
down the device.

Change-Id: I620495bfc99c6b0855a98ac54c6ede96e20ff1b8
services: Fix device-specific shutdown hook to support restart

Update device-specific shutdown hook such that it is invoked for
restart as well as for shutdown.

Change-Id: I8c9cbe674000e0d664d41ecc98a341112e1cb060
EMFILE exception in system_server due to socket fd leaks

NativeCrashListener creates a socket connection with debuggerd.
When native crash is observed, NativeCrashListener gets new socket
file descriptor from debuggered. This socket is never closed.
Multiple native crashes are causing "Too many files opened" EMFILE
exception in system_server.

CRs-Fixed: 545566

Change-Id: Idb12e87a4f91c978169435ce95abe11b40c6d0dc
frameworks/base: Fix race conditions on resume/suspend using power key

The wakelock PowerManagerService.Display sometimes cannot be released
after two quick power key pressings like a double click during phone
sleep (the target will resume then supposedly suspend shortly).

The second key event disturbs display power state on resume, as a
result display resources won't get released on suspend, which is fixed
in this change.

CRs-Fixed: 566059
Change-Id: I633fd377ab235f203ebfb649a74449a2385740c4
/platform/frameworks/base: Fix SystemUI crash on Recent App

Issue: SystemUI crash is observed when Context MenuItem is
       selected on the recent apps activity [Long pressing
       two recent apps at same time or Long press, lock and
       unlock the screen]

Fix: Changed the code to make sure that only one context
     menu is active at a time and also dismissed the
     context menu on pause of the RecentsActivity

CRs-Fixed: 539509

Change-Id: Ia50bed7bfad6fde7beeaec37fa6402177eee1d40
Merge pull request #22 from PAC-man/cm-10.2

pac commits