am 483041c9: am ecba011f: am c1ae43ad: am f69320a1: Merge "Preventing more than five widgets from being added in the carousel (issue 7502935)" into jb-mr1-dev

* commit '483041c9c4b2812d67de53e567ce059d5e3417bc':
  Preventing more than five widgets from being added in the carousel (issue 7502935)
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
index 964537c..de19bd5 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
@@ -324,6 +324,13 @@
         }
 
         @Override
+        public void onAddView(View v) {
+            if (numWidgets() >= MAX_WIDGETS) {
+                setAddWidgetEnabled(false);
+            }
+        };
+
+        @Override
         public void onRemoveView(View v) {
             if (numWidgets() < MAX_WIDGETS) {
                 setAddWidgetEnabled(true);
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java
index 24eebff..25e2781 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java
@@ -236,6 +236,7 @@
     public interface Callbacks {
         public void userActivity();
         public void onUserActivityTimeoutChanged();
+        public void onAddView(View v);
         public void onRemoveView(View v);
     }
 
@@ -262,6 +263,9 @@
         final int[] pagesRange = new int[mTempVisiblePagesRange.length];
         getVisiblePages(pagesRange);
         boundByReorderablePages(true, pagesRange);
+        if (mCallbacks != null) {
+            mCallbacks.onAddView(v);
+        }
         // Subtract from the index to take into account pages before the reorderable
         // pages (e.g. the "add widget" page)
         mBackgroundWorkerHandler.post(new Runnable() {