Simplification of the poolable management utils.

   Before to implement a pool of objects, the pooled class had to implement an
   interface which was leaking the pool management APIs. This requires
   hiding APIs - inconvenient at best. Further, each client had to
   implement the chaining of pooled instances which means adding a couple
   of member variables which are manipulated by the implemented interface
   methods. As a consequence the client is aware of how pooling is
   implemented which is error prone and breaks encapsulation. Now the
   pool objects are responsible for managing pooling state via reusable
   wrapper objects and the clients are oblivious of how pooling is done.
   Creating a thin cached wrapper for each pooled object has minimal
   performance impact while making the code more maintainable. Actually
   implementing of the old version of the APIs was taking as much code
   as implementing the pooling yourself.

   Also clients had to implement a poolable manager whose responsibility
   was to create new instances and provide callbacks when an instance
   is added to or removed from the pool. Now, the clinet class should
   create a static member for the pool and expose obtain/aquire and
   release/recycle methods in which it should create a new instance if
   the pool did not return one and clear the state of the host when
   it is returned to the pool. Updated the JavaDoc with a best practice.

   The pooling was composed of several interfaces and classes scattered
   over a few files, now all this is in a single small file.

   Update all usages of the pooling APIs in the framework.

Also one had to write a poolable
   manager which

Change-Id: Ib8dc286040eb3d7cb7d9668ba76fead05cb97647
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 181fce9..23c3ad3 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -52,10 +52,7 @@
 import android.util.AttributeSet;
 import android.util.FloatProperty;
 import android.util.Log;
-import android.util.Pool;
-import android.util.Poolable;
-import android.util.PoolableManager;
-import android.util.Pools;
+import android.util.Pools.SynchronizedPool;
 import android.util.Property;
 import android.util.SparseArray;
 import android.util.TypedValue;
@@ -10748,7 +10745,7 @@
         // if we are not attached to our window
         final AttachInfo attachInfo = mAttachInfo;
         if (attachInfo != null) {
-            final AttachInfo.InvalidateInfo info = AttachInfo.InvalidateInfo.acquire();
+            final AttachInfo.InvalidateInfo info = AttachInfo.InvalidateInfo.obtain();
             info.target = this;
             info.left = left;
             info.top = top;
@@ -10797,7 +10794,7 @@
         // if we are not attached to our window
         final AttachInfo attachInfo = mAttachInfo;
         if (attachInfo != null) {
-            final AttachInfo.InvalidateInfo info = AttachInfo.InvalidateInfo.acquire();
+            final AttachInfo.InvalidateInfo info = AttachInfo.InvalidateInfo.obtain();
             info.target = this;
             info.left = left;
             info.top = top;
@@ -17696,25 +17693,11 @@
          * POOL_LIMIT objects that get reused. This reduces memory allocations
          * whenever possible.
          */
-        static class InvalidateInfo implements Poolable<InvalidateInfo> {
+        static class InvalidateInfo {
             private static final int POOL_LIMIT = 10;
-            private static final Pool<InvalidateInfo> sPool = Pools.synchronizedPool(
-                    Pools.finitePool(new PoolableManager<InvalidateInfo>() {
-                        public InvalidateInfo newInstance() {
-                            return new InvalidateInfo();
-                        }
 
-                        public void onAcquired(InvalidateInfo element) {
-                        }
-
-                        public void onReleased(InvalidateInfo element) {
-                            element.target = null;
-                        }
-                    }, POOL_LIMIT)
-            );
-
-            private InvalidateInfo mNext;
-            private boolean mIsPooled;
+            private static final SynchronizedPool<InvalidateInfo> sPool =
+                    new SynchronizedPool<InvalidateInfo>(POOL_LIMIT);
 
             View target;
 
@@ -17723,29 +17706,15 @@
             int right;
             int bottom;
 
-            public void setNextPoolable(InvalidateInfo element) {
-                mNext = element;
+            public static InvalidateInfo obtain() {
+                InvalidateInfo instance = sPool.acquire();
+                return (instance != null) ? instance : new InvalidateInfo();
             }
 
-            public InvalidateInfo getNextPoolable() {
-                return mNext;
-            }
-
-            static InvalidateInfo acquire() {
-                return sPool.acquire();
-            }
-
-            void release() {
+            public void recycle() {
+                target = null;
                 sPool.release(this);
             }
-
-            public boolean isPooled() {
-                return mIsPooled;
-            }
-
-            public void setPooled(boolean isPooled) {
-                mIsPooled = isPooled;
-            }
         }
 
         final IWindowSession mSession;