Merge change I72f1d310

* changes:
  Update to new RS texture API.
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index f07810d..50be606 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -179,6 +179,7 @@
 
     private boolean mWorkspaceLoading = true;
 
+    private boolean mPaused = true;
     private boolean mRestoring;
     private boolean mWaitingForResult;
 
@@ -237,6 +238,9 @@
         // For handling default keys
         mDefaultKeySsb = new SpannableStringBuilder();
         Selection.setSelection(mDefaultKeySsb, 0);
+
+        IntentFilter filter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
+        registerReceiver(mCloseSystemDialogsReceiver, filter);
     }
 
     private void checkForLocaleChange() {
@@ -393,8 +397,7 @@
     protected void onResume() {
         super.onResume();
 
-        IntentFilter filter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
-        registerReceiver(mCloseSystemDialogsReceiver, filter);
+        mPaused = false;
 
         if (mRestoring) {
             mWorkspaceLoading = true;
@@ -409,7 +412,6 @@
         dismissPreview(mPreviousView);
         dismissPreview(mNextView);
         mDragController.cancelDrag();
-        unregisterReceiver(mCloseSystemDialogsReceiver);
     }
 
     @Override
@@ -908,6 +910,8 @@
         
         dismissPreview(mPreviousView);
         dismissPreview(mNextView);
+
+        unregisterReceiver(mCloseSystemDialogsReceiver);
     }
 
     @Override
@@ -1730,7 +1734,11 @@
      *          - from center screen
      *          - from other screens
      *   - Home from all apps
+     *          - from center screen
+     *          - from other screens
      *   - Back from all apps
+     *          - from center screen
+     *          - from other screens
      *   - Launch app from workspace and quit
      *          - with back
      *          - with home
@@ -1751,7 +1759,7 @@
      *   - On all apps, power off
      *   - Launch an app and turn off the screen while in that app
      *          - Go back with home key
-     *          - Go back with back key
+     *          - Go back with back key  TODO: make this not go to workspace
      *          - From all apps
      *          - From workspace
      */
@@ -1886,13 +1894,9 @@
             String reason = intent.getStringExtra("reason");
             if (!"homekey".equals(reason)) {
                 boolean animate = true;
-                /*
-                if ("globalactions".equals(reason)) {
-                    // For some reason (probably the fading), this animation is
-                    // choppy, so don't show it.
+                if (mPaused || "lock".equals(reason)) {
                     animate = false;
                 }
-                */
                 closeAllApps(animate);
             }
         }
diff --git a/src/com/android/launcher2/LauncherProvider.java b/src/com/android/launcher2/LauncherProvider.java
index 47d8991..abd5e5d 100644
--- a/src/com/android/launcher2/LauncherProvider.java
+++ b/src/com/android/launcher2/LauncherProvider.java
@@ -465,28 +465,19 @@
 
         /**
          * Upgrade existing clock and photo frame widgets into their new widget
-         * equivalents. This method allocates appWidgetIds, and then hands off to
-         * LauncherAppWidgetBinder to finish the actual binding.
+         * equivalents.
          */
         private void convertWidgets(SQLiteDatabase db) {
+            final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(mContext);
             final int[] bindSources = new int[] {
                     Favorites.ITEM_TYPE_WIDGET_CLOCK,
                     Favorites.ITEM_TYPE_WIDGET_PHOTO_FRAME,
                     Favorites.ITEM_TYPE_WIDGET_SEARCH,
             };
-            
-            final ArrayList<ComponentName> bindTargets = new ArrayList<ComponentName>();
-            bindTargets.add(new ComponentName("com.android.alarmclock",
-                    "com.android.alarmclock.AnalogAppWidgetProvider"));
-            bindTargets.add(new ComponentName("com.android.camera",
-                    "com.android.camera.PhotoAppWidgetProvider"));
-            bindTargets.add(new ComponentName("com.android.quicksearchbox",
-                    "com.android.quicksearchbox.SearchWidgetProvider"));
 
             final String selectWhere = buildOrWhereString(Favorites.ITEM_TYPE, bindSources);
             
             Cursor c = null;
-            boolean allocatedAppWidgets = false;
             
             db.beginTransaction();
             try {
@@ -524,8 +515,21 @@
 
                         String updateWhere = Favorites._ID + "=" + favoriteId;
                         db.update(TABLE_FAVORITES, values, updateWhere, null);
-                        
-                        allocatedAppWidgets = true;
+
+                        ComponentName cn = null;
+                        if (favoriteType == Favorites.ITEM_TYPE_WIDGET_CLOCK) {
+                            appWidgetManager.bindAppWidgetId(appWidgetId,
+                                    new ComponentName("com.android.alarmclock",
+                                    "com.android.alarmclock.AnalogAppWidgetProvider"));
+                        } else if (favoriteType == Favorites.ITEM_TYPE_WIDGET_PHOTO_FRAME) {
+                            appWidgetManager.bindAppWidgetId(appWidgetId,
+                                    new ComponentName("com.android.camera",
+                                    "com.android.camera.PhotoAppWidgetProvider"));
+                        } else if (favoriteType == Favorites.ITEM_TYPE_WIDGET_SEARCH) {
+                            appWidgetManager.bindAppWidgetId(appWidgetId,
+                                    new ComponentName("com.android.quicksearchbox",
+                                    "com.android.quicksearchbox.SearchWidgetProvider"));
+                        }
                     } catch (RuntimeException ex) {
                         Log.e(TAG, "Problem allocating appWidgetId", ex);
                     }
@@ -540,34 +544,9 @@
                     c.close();
                 }
             }
-            
-            // If any appWidgetIds allocated, then launch over to binder
-            if (allocatedAppWidgets) {
-                launchAppWidgetBinder(bindSources, bindTargets);
-            }
         }
 
         /**
-         * Launch the widget binder that walks through the Launcher database,
-         * binding any matching widgets to the corresponding targets. We can't
-         * bind ourselves because our parent process can't obtain the
-         * BIND_APPWIDGET permission.
-         */
-        private void launchAppWidgetBinder(int[] bindSources, ArrayList<ComponentName> bindTargets) {
-            final Intent intent = new Intent();
-            intent.setComponent(new ComponentName("com.android.settings",
-                    "com.android.settings.LauncherAppWidgetBinder"));
-            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-            
-            final Bundle extras = new Bundle();
-            extras.putIntArray(EXTRA_BIND_SOURCES, bindSources);
-            extras.putParcelableArrayList(EXTRA_BIND_TARGETS, bindTargets);
-            intent.putExtras(extras);
-            
-            mContext.startActivity(intent);
-        }
-        
-        /**
          * Loads the default set of favorite packages from an xml file.
          *
          * @param db The database to write the values into
@@ -667,37 +646,9 @@
         }
 
         private boolean addClockWidget(SQLiteDatabase db, ContentValues values) {
-            final int[] bindSources = new int[] {
-                    Favorites.ITEM_TYPE_WIDGET_CLOCK,
-            };
-
-            final ArrayList<ComponentName> bindTargets = new ArrayList<ComponentName>();
-            bindTargets.add(new ComponentName("com.android.alarmclock",
-                    "com.android.alarmclock.AnalogAppWidgetProvider"));
-
-            boolean allocatedAppWidgets = false;
-            
-            // Try binding to an analog clock widget
-            try {
-                int appWidgetId = mAppWidgetHost.allocateAppWidgetId();
-
-                values.put(Favorites.ITEM_TYPE, Favorites.ITEM_TYPE_WIDGET_CLOCK);
-                values.put(Favorites.SPANX, 2);
-                values.put(Favorites.SPANY, 2);
-                values.put(Favorites.APPWIDGET_ID, appWidgetId);
-                db.insert(TABLE_FAVORITES, null, values);
-
-                allocatedAppWidgets = true;
-            } catch (RuntimeException ex) {
-                Log.e(TAG, "Problem allocating appWidgetId", ex);
-            }
-
-            // If any appWidgetIds allocated, then launch over to binder
-            if (allocatedAppWidgets) {
-                launchAppWidgetBinder(bindSources, bindTargets);
-            }
-
-            return allocatedAppWidgets;
+            ComponentName cn = new ComponentName("com.android.alarmclock",
+                    "com.android.alarmclock.AnalogAppWidgetProvider");
+            return addAppWidget(db, values, cn, 2, 2);
         }
         
         private boolean addAppWidget(SQLiteDatabase db, ContentValues values, TypedArray a) {
diff --git a/src/com/android/launcher2/LauncherSettings.java b/src/com/android/launcher2/LauncherSettings.java
index a438d47..9c685ce 100644
--- a/src/com/android/launcher2/LauncherSettings.java
+++ b/src/com/android/launcher2/LauncherSettings.java
@@ -91,8 +91,7 @@
     }
 
     /**
-     * Favorites. When changing these values, be sure to update
-     * {@link com.android.settings.LauncherAppWidgetBinder} as needed.
+     * Favorites.
      */
     static final class Favorites implements BaseLauncherColumns {
         /**