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
frameworks/base: Fix change propagating issue

destroyLayer() function has been modified in kk. It is not correct
to propagate the UI corruption fix from jb to kk without considering
the new changes made in kk. This change is to make it align with
the new code in kk.

Change-Id: I34d11b230b9390fe8a989ab6f9c7d3a48d586205
Merge "frameworks/base: Fix the random UI corruption" into kitkat
Merge "frameworks/base: Fix change propagating issue" into kitkat
Merge branch 'kitkat' of https://github.com/AOSPA/android_frameworks_base into kitkat
MediaFile: support more media types

Change-Id: Ib3109c5ebc762b97e45bd0bb5fa82ad77b0e6822
Merge remote-tracking branch 'PA/kitkat' into legacy-staging