frameworks/base: move the traces file to avoid data loss.

If an ANR comes just after the framework reboot, the traces for
the framework reboot will get over-written with the ANR traces.
So, We are missing the traces for the framework reboot which
makes debugging the framework reboot difficult.

This patch will rename this trace file for the framework reboot
once the ActivityManager collects the traces.

Change-Id: Iee07b13ba02d8aab9cc43567aa5df131cc43c737
(cherry picked from commit 93348d7b1f48f1b3f6759bcff73153dce5709ded)
(cherry picked from commit 1c7cad9ce8b66eebe556c76c01a9396d449411cf)
frameworks/base: creating sperate files for ANRs traces

If an ANR comes just after the framework reboot, the traces for the
framework reboot will get over-written with the ANR traces. So, We
are missing the traces for the framework reboot which makes debugging
the framework reboot difficult.

Even for multiple ANRs in different apps, we will get the traces for
the last ANR.

Most of the time traces show that the call is stuck in some native call
and we do not have any info about the native call stack becuase we do
not collect the tombstones for teh ANR.

This patch will create one trace file for each application in case of ANR
and the filename would be traces_<app_name>.txt and the traces for
framework reboot will be stored in traces.txt

Change-Id: I5b78ce62b26f25d3dc14097e2988ba12c2d77826
(cherry picked from commit ea06416e430a85bef7cd21367e5948251f17c225)
(cherry picked from commit d678e40d53f0788b2883aa7c524da666ac2a8b4d)
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