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
frameworks/base: Fix memory leak in BitmapRegionDecoder

When un-supported image is passed to bitmap decoder, mStream object
of SkMemoryStream class is leaking its resources. This is getting
called frequently when gallery app is trying to render thumbnails
in album view and due to this frequent sigkills were seen on
gallery3d app with adj 0 value

CRs-Fixed: 551617
Change-Id: I1d9401310566b529d81b406213f4e37be3104d95
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