@@ -1376,12 +1376,59 @@ void stopTracking() {
13761376 if (!mTracking )
13771377 return ;
13781378 mTracking = false ;
1379- mPile . setLayerType (View .LAYER_TYPE_NONE , null );
1379+ setPileLayers (View .LAYER_TYPE_NONE );
13801380 mVelocityTracker .recycle ();
13811381 mVelocityTracker = null ;
13821382 mCloseView .setPressed (false );
13831383 }
13841384
1385+ /**
1386+ * Enables or disables layers on the children of the notifications pile.
1387+ *
1388+ * When layers are enabled, this method attempts to enable layers for the minimal
1389+ * number of children. Only children visible when the notification area is fully
1390+ * expanded will receive a layer. The technique used in this method might cause
1391+ * more children than necessary to get a layer (at most one extra child with the
1392+ * current UI.)
1393+ *
1394+ * @param layerType {@link View#LAYER_TYPE_NONE} or {@link View#LAYER_TYPE_HARDWARE}
1395+ */
1396+ private void setPileLayers (int layerType ) {
1397+ final int count = mPile .getChildCount ();
1398+
1399+ switch (layerType ) {
1400+ case View .LAYER_TYPE_NONE :
1401+ for (int i = 0 ; i < count ; i ++) {
1402+ mPile .getChildAt (i ).setLayerType (layerType , null );
1403+ }
1404+ break ;
1405+ case View .LAYER_TYPE_HARDWARE :
1406+ final int [] location = new int [2 ];
1407+ mNotificationPanel .getLocationInWindow (location );
1408+
1409+ final int left = location [0 ];
1410+ final int top = location [1 ];
1411+ final int right = left + mNotificationPanel .getWidth ();
1412+ final int bottom = top + getExpandedViewMaxHeight ();
1413+
1414+ final Rect childBounds = new Rect ();
1415+
1416+ for (int i = 0 ; i < count ; i ++) {
1417+ final View view = mPile .getChildAt (i );
1418+ view .getLocationInWindow (location );
1419+
1420+ childBounds .set (location [0 ], location [1 ],
1421+ location [0 ] + view .getWidth (), location [1 ] + view .getHeight ());
1422+
1423+ if (childBounds .intersects (left , top , right , bottom )) {
1424+ view .setLayerType (layerType , null );
1425+ }
1426+ }
1427+
1428+ break ;
1429+ }
1430+ }
1431+
13851432 void incrementAnim (long frameTimeNanos ) {
13861433 final long deltaNanos = Math .max (frameTimeNanos - mAnimLastTimeNanos , 0 );
13871434 final float t = deltaNanos * 0.000000001f ; // ns -> s
@@ -1421,7 +1468,7 @@ void prepareTracking(int y, boolean opening) {
14211468 mCloseView .setPressed (true );
14221469
14231470 mTracking = true ;
1424- mPile . setLayerType (View .LAYER_TYPE_HARDWARE , null );
1471+ setPileLayers (View .LAYER_TYPE_HARDWARE );
14251472 mVelocityTracker = VelocityTracker .obtain ();
14261473 if (opening ) {
14271474 makeExpandedVisible (true );
0 commit comments