frameworks/base: Fix the random UI corruption

On low memory device, when a view goes to background. Its HW layer cache
will be destroyed to release memory. There is a very rare case that the
hardware render is not valid when destroy the layer, so the layer is not
destroyed and reused when the view comes to foreground. But the GL
context has changed, so the view is not rendered correctly due to its
HW layer cache. To fix this issue, destroy the layer in a safelyRun. Make
sure the layer is destroyed correctly.

Change-Id: I1c714e1d53db7353d5169e874a7cd0f527c3f67b
CRs-Fixed: 623239
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>