Correct button measuring

Test: set wallpaper to white, black, look at AOD
Change-Id: If0e0da4315240fcc26be6cad3de717f37d5d1864
Fixes: 74393005
diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_status_area.xml b/packages/SystemUI/res-keyguard/layout/keyguard_status_area.xml
index 828c9df..611aa43 100644
--- a/packages/SystemUI/res-keyguard/layout/keyguard_status_area.xml
+++ b/packages/SystemUI/res-keyguard/layout/keyguard_status_area.xml
@@ -22,7 +22,7 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_marginStart="16dp"
     android:layout_marginEnd="16dp"
-    android:layout_width="wrap_content"
+    android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_gravity="center_horizontal"
     android:clipToPadding="false"
@@ -37,7 +37,8 @@
               android:textColor="?attr/wallpaperTextColor"
               android:theme="@style/TextAppearance.Keyguard"
     />
-    <LinearLayout android:id="@+id/row"
+    <view class="com.android.keyguard.KeyguardSliceView$Row"
+              android:id="@+id/row"
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:orientation="horizontal"
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSliceView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSliceView.java
index 6b99206..f0952f9 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSliceView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSliceView.java
@@ -331,6 +331,37 @@
         updateVisibility();
     }
 
+    public static class Row extends LinearLayout {
+
+        public Row(Context context) {
+            super(context);
+        }
+
+        public Row(Context context, AttributeSet attrs) {
+            super(context, attrs);
+        }
+
+        public Row(Context context, AttributeSet attrs, int defStyleAttr) {
+            super(context, attrs, defStyleAttr);
+        }
+
+        public Row(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
+            super(context, attrs, defStyleAttr, defStyleRes);
+        }
+
+        @Override
+        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+            int width = MeasureSpec.getSize(widthMeasureSpec);
+            for (int i = 0; i < getChildCount(); i++) {
+                View child = getChildAt(i);
+                if (child instanceof KeyguardSliceButton) {
+                    ((KeyguardSliceButton) child).setMaxWidth(width / 2);
+                }
+            }
+            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+        }
+    }
+
     /**
      * Representation of an item that appears under the clock on main keyguard message.
      */
@@ -344,7 +375,6 @@
             setPadding(horizontalPadding / 2, 0, horizontalPadding / 2, 0);
             setCompoundDrawablePadding((int) context.getResources()
                     .getDimension(R.dimen.widget_icon_padding));
-            setMaxWidth(KeyguardSliceView.this.getWidth() / 2);
             setMaxLines(1);
             setEllipsize(TruncateAt.END);
         }