Have destroy call freePrefetchedLayers

 Bug: 17208461

 There's a potential race condition between HardwareRenderer.destroy()
 being called (which calls destroyCanvasAndSurface()) and the renderer
 being finalized (which is what calls freePrefetchedLayers), during which
 time it's possible we get a TRIM_MEMORY_COMPLETE and destroy the EGL
 context.

 Fix this race condition by moving stopDrawing() and freePrefetchedLayers()
 into destroyCanvasAndSurface() where they should have been in the first
 place.

 Also, if we hit the assertion failure, dump the current state of
 Caches to try and provide more context for the failure.

Change-Id: Ife0ba3562041e8b08e87e3e13640472b3004eed6
diff --git a/core/java/android/view/ThreadedRenderer.java b/core/java/android/view/ThreadedRenderer.java
index ca08ecc..5d2822d 100644
--- a/core/java/android/view/ThreadedRenderer.java
+++ b/core/java/android/view/ThreadedRenderer.java
@@ -126,7 +126,7 @@
     void destroy() {
         mInitialized = false;
         updateEnabledState(null);
-        nDestroyCanvasAndSurface(mNativeProxy);
+        nDestroy(mNativeProxy);
     }
 
     private void updateEnabledState(Surface surface) {
@@ -488,7 +488,7 @@
     private static native void nSetOpaque(long nativeProxy, boolean opaque);
     private static native int nSyncAndDrawFrame(long nativeProxy,
             long frameTimeNanos, long recordDuration, float density);
-    private static native void nDestroyCanvasAndSurface(long nativeProxy);
+    private static native void nDestroy(long nativeProxy);
     private static native void nRegisterAnimatingRenderNode(long rootRenderNode, long animatingNode);
 
     private static native void nInvokeFunctor(long functor, boolean waitForCompletion);