Merge change 24101 into eclair

* changes:
  Fix CDMA BCD unit test.
diff --git a/core/java/android/preference/PreferenceManager.java b/core/java/android/preference/PreferenceManager.java
index a7a3eef..fe3471d 100644
--- a/core/java/android/preference/PreferenceManager.java
+++ b/core/java/android/preference/PreferenceManager.java
@@ -134,7 +134,10 @@
     
     private OnPreferenceTreeClickListener mOnPreferenceTreeClickListener;
     
-    PreferenceManager(Activity activity, int firstRequestCode) {
+    /**
+     * @hide
+     */
+    public PreferenceManager(Activity activity, int firstRequestCode) {
         mActivity = activity;
         mNextRequestCode = firstRequestCode;
         
@@ -240,8 +243,9 @@
      *            hierarchies into.
      * @return The root hierarchy (if one was not provided, the new hierarchy's
      *         root).
+     * @hide
      */
-    PreferenceScreen inflateFromResource(Context context, int resId,
+    public PreferenceScreen inflateFromResource(Context context, int resId,
             PreferenceScreen rootPreferences) {
         // Block commits
         setNoCommit(true);
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 5bc5855..97955ae 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -3485,6 +3485,93 @@
                 "google_calendar_sync_window_update_days";
 
         /**
+         * The number of promoted sources in GlobalSearch.
+         */
+        public static final String SEARCH_NUM_PROMOTED_SOURCES = "search_num_promoted_sources";
+        /**
+         * The maximum number of suggestions returned by GlobalSearch.
+         */
+        public static final String SEARCH_MAX_RESULTS_TO_DISPLAY = "search_max_results_to_display";
+        /**
+         * The number of suggestions GlobalSearch will ask each non-web search source for.
+         */
+        public static final String SEARCH_MAX_RESULTS_PER_SOURCE = "search_max_results_per_source";
+        /**
+         * The number of suggestions the GlobalSearch will ask the web search source for.
+         */
+        public static final String SEARCH_WEB_RESULTS_OVERRIDE_LIMIT =
+                "search_web_results_override_limit";
+        /**
+         * The number of milliseconds that GlobalSearch will wait for suggestions from
+         * promoted sources before continuing with all other sources.
+         */
+        public static final String SEARCH_PROMOTED_SOURCE_DEADLINE_MILLIS =
+                "search_promoted_source_deadline_millis";
+        /**
+         * The number of milliseconds before GlobalSearch aborts search suggesiton queries.
+         */
+        public static final String SEARCH_SOURCE_TIMEOUT_MILLIS = "search_source_timeout_millis";
+        /**
+         * The maximum number of milliseconds that GlobalSearch shows the previous results
+         * after receiving a new query.
+         */
+        public static final String SEARCH_PREFILL_MILLIS = "search_prefill_millis";
+        /**
+         * The maximum age of log data used for shortcuts in GlobalSearch.
+         */
+        public static final String SEARCH_MAX_STAT_AGE_MILLIS = "search_max_stat_age_millis";
+        /**
+         * The maximum age of log data used for source ranking in GlobalSearch.
+         */
+        public static final String SEARCH_MAX_SOURCE_EVENT_AGE_MILLIS =
+                "search_max_source_event_age_millis";
+        /**
+         * The minimum number of impressions needed to rank a source in GlobalSearch.
+         */
+        public static final String SEARCH_MIN_IMPRESSIONS_FOR_SOURCE_RANKING =
+                "search_min_impressions_for_source_ranking";
+        /**
+         * The minimum number of clicks needed to rank a source in GlobalSearch.
+         */
+        public static final String SEARCH_MIN_CLICKS_FOR_SOURCE_RANKING =
+                "search_min_clicks_for_source_ranking";
+        /**
+         * The maximum number of shortcuts shown by GlobalSearch.
+         */
+        public static final String SEARCH_MAX_SHORTCUTS_RETURNED = "search_max_shortcuts_returned";
+        /**
+         * The size of the core thread pool for suggestion queries in GlobalSearch.
+         */
+        public static final String SEARCH_QUERY_THREAD_CORE_POOL_SIZE =
+                "search_query_thread_core_pool_size";
+        /**
+         * The maximum size of the thread pool for suggestion queries in GlobalSearch.
+         */
+        public static final String SEARCH_QUERY_THREAD_MAX_POOL_SIZE =
+                "search_query_thread_max_pool_size";
+        /**
+         * The size of the core thread pool for shortcut refreshing in GlobalSearch.
+         */
+        public static final String SEARCH_SHORTCUT_REFRESH_CORE_POOL_SIZE =
+                "search_shortcut_refresh_core_pool_size";
+        /**
+         * The maximum size of the thread pool for shortcut refreshing in GlobalSearch.
+         */
+        public static final String SEARCH_SHORTCUT_REFRESH_MAX_POOL_SIZE =
+                "search_shortcut_refresh_max_pool_size";
+        /**
+         * The maximun time that excess threads in the GlobalSeach thread pools will
+         * wait before terminating.
+         */
+        public static final String SEARCH_THREAD_KEEPALIVE_SECONDS =
+                "search_thread_keepalive_seconds";
+        /**
+         * The maximum number of concurrent suggestion queries to each source.
+         */
+        public static final String SEARCH_PER_SOURCE_CONCURRENT_QUERY_LIMIT =
+                "search_per_source_concurrent_query_limit";
+
+        /**
          * @deprecated
          * @hide
          */
diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java
index 2cdfc66..2e4f1d2 100644
--- a/core/java/android/service/wallpaper/WallpaperService.java
+++ b/core/java/android/service/wallpaper/WallpaperService.java
@@ -377,6 +377,7 @@
                     if (!mCreated) {
                         mLayout.type = mIWallpaperEngine.mWindowType;
                         mLayout.gravity = Gravity.LEFT|Gravity.TOP;
+                        mLayout.setTitle(WallpaperService.this.getClass().getName());
                         mLayout.windowAnimations =
                                 com.android.internal.R.style.Animation_Wallpaper;
                         mSession.add(mWindow, mLayout, View.VISIBLE, mContentInsets);
@@ -558,7 +559,7 @@
                     mSession.remove(mWindow);
                 } catch (RemoteException e) {
                 }
-                mSurfaceHolder.mSurface.clear();
+                mSurfaceHolder.mSurface.release();
                 mCreated = false;
             }
         }
diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java
index 5cecac3..b85667b 100644
--- a/core/java/android/view/Surface.java
+++ b/core/java/android/view/Surface.java
@@ -181,7 +181,7 @@
     public Surface(SurfaceSession s,
             int pid, int display, int w, int h, int format, int flags)
         throws OutOfResourcesException {
-        mCanvas = new Canvas();
+        mCanvas = new CompatibleCanvas();
         init(s,pid,display,w,h,format,flags);
     }
 
@@ -271,8 +271,12 @@
      */
     public native   boolean isValid();
     
-    /** Call this free the surface up. {@hide} */
-    public native   void clear();
+    /** Free all server-side state associated with this surface and
+     * release this object's reference. {@hide} */
+    public native void destroy();
+    
+    /** Release the local reference to the server-side surface. @hide */
+    public native void release();
     
     /** draw into a surface */
     public Canvas lockCanvas(Rect dirty) throws OutOfResourcesException, IllegalArgumentException
@@ -400,6 +404,4 @@
             throws OutOfResourcesException;
 
     private native void init(Parcel source);
-    
-    private native void release();
 }
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index fafe00f..b61465a 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -1575,7 +1575,7 @@
         if (mUseGL) {
             destroyGL();
         }
-        mSurface.clear();
+        mSurface.release();
 
         try {
             sWindowSession.remove(mWindow);
@@ -2532,7 +2532,7 @@
                     }
                 }
 
-                mSurface.clear();
+                mSurface.release();
             }
             if (mAdded) {
                 mAdded = false;
diff --git a/core/jni/android_view_Surface.cpp b/core/jni/android_view_Surface.cpp
index 02677f4..40c8aa0 100644
--- a/core/jni/android_view_Surface.cpp
+++ b/core/jni/android_view_Surface.cpp
@@ -214,7 +214,7 @@
     setSurface(env, clazz, rhs);
 }
 
-static void Surface_clear(JNIEnv* env, jobject clazz, uintptr_t *ostack)
+static void Surface_destroy(JNIEnv* env, jobject clazz, uintptr_t *ostack)
 {
     const sp<SurfaceControl>& surface(getSurfaceControl(env, clazz));
     if (SurfaceControl::isValid(surface)) {
@@ -622,7 +622,7 @@
     {"nativeClassInit",     "()V",  (void*)nativeClassInit },
     {"init",                "(Landroid/view/SurfaceSession;IIIIII)V",  (void*)Surface_init },
     {"init",                "(Landroid/os/Parcel;)V",  (void*)Surface_initParcel },
-    {"clear",               "()V",  (void*)Surface_clear },
+    {"destroy",             "()V",  (void*)Surface_destroy },
     {"release",             "()V",  (void*)Surface_release },
 	{"copyFrom",            "(Landroid/view/Surface;)V",  (void*)Surface_copyFrom },
 	{"isValid",             "()Z",  (void*)Surface_isValid },
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index b4f4768..c8ff6cb 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -1207,8 +1207,11 @@
                 || mLowerWallpaperTarget != null;
     }
     
-    boolean adjustWallpaperWindowsLocked() {
-        boolean changed = false;
+    static final int ADJUST_WALLPAPER_LAYERS_CHANGED = 1<<1;
+    static final int ADJUST_WALLPAPER_VISIBILITY_CHANGED = 1<<2;
+    
+    int adjustWallpaperWindowsLocked() {
+        int changed = 0;
         
         final int dw = mDisplay.getWidth();
         final int dh = mDisplay.getHeight();
@@ -1274,12 +1277,12 @@
             if (mWallpaperTarget != null && mWallpaperTarget.mAppToken != null) {
                 if (DEBUG_WALLPAPER) Log.v(TAG,
                         "Wallpaper not changing: waiting for app anim in current target");
-                return false;
+                return 0;
             }
             if (foundW != null && foundW.mAppToken != null) {
                 if (DEBUG_WALLPAPER) Log.v(TAG,
                         "Wallpaper not changing: waiting for app anim in found target");
-                return false;
+                return 0;
             }
         }
         
@@ -1410,7 +1413,13 @@
         while (curTokenIndex > 0) {
             curTokenIndex--;
             WindowToken token = mWallpaperTokens.get(curTokenIndex);
-            token.hidden = !visible;
+            if (token.hidden == visible) {
+                changed |= ADJUST_WALLPAPER_VISIBILITY_CHANGED;
+                token.hidden = !visible;
+                // Need to do a layout to ensure the wallpaper now has the
+                // correct size.
+                mLayoutNeeded = true;
+            }
             
             int curWallpaperIndex = token.windows.size();
             while (curWallpaperIndex > 0) {
@@ -1463,7 +1472,7 @@
                         + " from " + oldIndex + " to " + foundI);
                 
                 localmWindows.add(foundI, wallpaper);
-                changed = true;
+                changed |= ADJUST_WALLPAPER_LAYERS_CHANGED;
             }
         }
         
@@ -1574,7 +1583,12 @@
         while (curTokenIndex > 0) {
             curTokenIndex--;
             WindowToken token = mWallpaperTokens.get(curTokenIndex);
-            token.hidden = !visible;
+            if (token.hidden == visible) {
+                token.hidden = !visible;
+                // Need to do a layout to ensure the wallpaper now has the
+                // correct size.
+                mLayoutNeeded = true;
+            }
             
             int curWallpaperIndex = token.windows.size();
             while (curWallpaperIndex > 0) {
@@ -1999,10 +2013,15 @@
             synchronized (mWindowMap) {
                 WindowState w = windowForClientLocked(session, client);
                 if ((w != null) && (w.mSurface != null)) {
+                    if (SHOW_TRANSACTIONS) Log.i(TAG, ">>> OPEN TRANSACTION");
                     Surface.openTransaction();
                     try {
+                        if (SHOW_TRANSACTIONS) Log.i(
+                                TAG, "  SURFACE " + w.mSurface
+                                + ": transparentRegionHint=" + region);
                         w.mSurface.setTransparentRegionHint(region);
                     } finally {
+                        if (SHOW_TRANSACTIONS) Log.i(TAG, "<<< CLOSE TRANSACTION");
                         Surface.closeTransaction();
                     }
                 }
@@ -2149,13 +2168,17 @@
                     Surface surface = win.createSurfaceLocked();
                     if (surface != null) {
                         outSurface.copyFrom(surface);
+                        if (SHOW_TRANSACTIONS) Log.i(TAG,
+                                "  OUT SURFACE " + outSurface + ": copied");
                     } else {
-                        outSurface.clear();
+                        // For some reason there isn't a surface.  Clear the
+                        // caller's object so they see the same state.
+                        outSurface.release();
                     }
                 } catch (Exception e) {
                     Log.w(TAG, "Exception thrown when creating surface for client "
-                         + client + " (" + win.mAttrs.getTitle() + ")",
-                         e);
+                             + client + " (" + win.mAttrs.getTitle() + ")",
+                             e);
                     Binder.restoreCallingIdentity(origId);
                     return 0;
                 }
@@ -2196,7 +2219,11 @@
                         }
                     }
                 }
-                outSurface.clear();
+                // We are being called from a local process, which
+                // means outSurface holds its current surface.  Ensure the
+                // surface object is cleared, but we don't want it actually
+                // destroyed at this point.
+                outSurface.release();
             }
 
             if (focusMayChange) {
@@ -2217,7 +2244,7 @@
                 }
             }
             if (wallpaperMayMove) {
-                if (adjustWallpaperWindowsLocked()) {
+                if ((adjustWallpaperWindowsLocked()&ADJUST_WALLPAPER_LAYERS_CHANGED) != 0) {
                     assignLayers = true;
                 }
             }
@@ -6281,6 +6308,8 @@
                 if (localLOGV) Log.v(
                     TAG, "First window added to " + this + ", creating SurfaceSession");
                 mSurfaceSession = new SurfaceSession();
+                if (SHOW_TRANSACTIONS) Log.i(
+                        TAG, "  NEW SURFACE SESSION " + mSurfaceSession);
                 mSessions.add(this);
             }
             mNumWindow++;
@@ -6298,6 +6327,8 @@
                     if (localLOGV) Log.v(
                         TAG, "Last window removed from " + this
                         + ", destroying " + mSurfaceSession);
+                    if (SHOW_TRANSACTIONS) Log.i(
+                            TAG, "  KILL SURFACE SESSION " + mSurfaceSession);
                     try {
                         mSurfaceSession.kill();
                     } catch (Exception e) {
@@ -6794,6 +6825,12 @@
                     mSurface = new Surface(
                             mSession.mSurfaceSession, mSession.mPid,
                             0, w, h, mAttrs.format, flags);
+                    if (SHOW_TRANSACTIONS) Log.i(TAG, "  CREATE SURFACE "
+                            + mSurface + " IN SESSION "
+                            + mSession.mSurfaceSession
+                            + ": pid=" + mSession.mPid + " format="
+                            + mAttrs.format + " flags=0x"
+                            + Integer.toHexString(flags));
                 } catch (Surface.OutOfResourcesException e) {
                     Log.w(TAG, "OutOfResourcesException creating surface");
                     reclaimSomeSurfaceMemoryLocked(this, "create");
@@ -6823,6 +6860,8 @@
                         mSurface.setLayer(mAnimLayer);
                         mSurface.hide();
                         if ((mAttrs.flags&WindowManager.LayoutParams.FLAG_DITHER) != 0) {
+                            if (SHOW_TRANSACTIONS) Log.i(TAG, "  SURFACE "
+                                    + mSurface + ": DITHER");
                             mSurface.setFlags(Surface.SURFACE_DITHER,
                                     Surface.SURFACE_DITHER);
                         }
@@ -6868,7 +6907,7 @@
                         Log.i(TAG, "  SURFACE " + mSurface + ": DESTROY ("
                                 + mAttrs.getTitle() + ")", ex);
                     }
-                    mSurface.clear();
+                    mSurface.destroy();
                 } catch (RuntimeException e) {
                     Log.w(TAG, "Exception thrown when destroying Window " + this
                         + " surface " + mSurface + " session " + mSession
@@ -8840,6 +8879,8 @@
                         if (w.commitFinishDrawingLocked(currentTime)) {
                             if ((w.mAttrs.flags
                                     & WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER) != 0) {
+                                if (DEBUG_WALLPAPER) Log.v(TAG,
+                                        "First draw done in potential wallpaper target " + w);
                                 wallpaperMayChange = true;
                             }
                         }
@@ -9134,10 +9175,23 @@
                 }
                 
                 if (wallpaperMayChange) {
-                    if (adjustWallpaperWindowsLocked()) {
+                    if (DEBUG_WALLPAPER) Log.v(TAG,
+                            "Wallpaper may change!  Adjusting");
+                    int adjResult = adjustWallpaperWindowsLocked();
+                    if ((adjResult&ADJUST_WALLPAPER_LAYERS_CHANGED) != 0) {
+                        if (DEBUG_WALLPAPER) Log.v(TAG,
+                                "Wallpaper layer changed: assigning layers + relayout");
+                        restart = true;
+                        mLayoutNeeded = true;
                         assignLayersLocked();
+                    } else if ((adjResult&ADJUST_WALLPAPER_VISIBILITY_CHANGED) != 0) {
+                        if (DEBUG_WALLPAPER) Log.v(TAG,
+                                "Wallpaper visibility changed: relayout");
+                        restart = true;
+                        mLayoutNeeded = true;
                     }
                     if (mLayoutNeeded) {
+                        restart = true;
                         performLayoutLockedInner();
                     }
                 }
@@ -9184,6 +9238,10 @@
                         w.mLastRequestedHeight = height;
                         w.mLastShownFrame.set(w.mShownFrame);
                         try {
+                            if (SHOW_TRANSACTIONS) Log.i(
+                                    TAG, "  SURFACE " + w.mSurface
+                                    + ": POS " + w.mShownFrame.left
+                                    + ", " + w.mShownFrame.top);
                             w.mSurface.setPosition(w.mShownFrame.left, w.mShownFrame.top);
                         } catch (RuntimeException e) {
                             Log.w(TAG, "Error positioning surface in " + w, e);
@@ -9196,14 +9254,6 @@
                         width = w.mShownFrame.width();
                         height = w.mShownFrame.height();
                         w.mLastShownFrame.set(w.mShownFrame);
-                        if (resize) {
-                            if (SHOW_TRANSACTIONS) Log.i(
-                                    TAG, "  SURFACE " + w.mSurface + ": ("
-                                    + w.mShownFrame.left + ","
-                                    + w.mShownFrame.top + ") ("
-                                    + w.mShownFrame.width() + "x"
-                                    + w.mShownFrame.height() + ")");
-                        }
                     }
 
                     if (resize) {
@@ -9211,6 +9261,12 @@
                         if (height < 1) height = 1;
                         if (w.mSurface != null) {
                             try {
+                                if (SHOW_TRANSACTIONS) Log.i(
+                                        TAG, "  SURFACE " + w.mSurface + ": POS "
+                                        + w.mShownFrame.left + ","
+                                        + w.mShownFrame.top + " SIZE "
+                                        + w.mShownFrame.width() + "x"
+                                        + w.mShownFrame.height());
                                 w.mSurface.setSize(width, height);
                                 w.mSurface.setPosition(w.mShownFrame.left,
                                         w.mShownFrame.top);
@@ -9239,6 +9295,22 @@
                             w.mLastFrame.set(w.mFrame);
                             w.mLastContentInsets.set(w.mContentInsets);
                             w.mLastVisibleInsets.set(w.mVisibleInsets);
+                            // If the screen is currently frozen, then keep
+                            // it frozen until this window draws at its new
+                            // orientation.
+                            if (mDisplayFrozen) {
+                                if (DEBUG_ORIENTATION) Log.v(TAG,
+                                        "Resizing while display frozen: " + w);
+                                w.mOrientationChanging = true;
+                                if (mWindowsFreezingScreen) {
+                                    mWindowsFreezingScreen = true;
+                                    // XXX should probably keep timeout from
+                                    // when we first froze the display.
+                                    mH.removeMessages(H.WINDOW_FREEZE_TIMEOUT);
+                                    mH.sendMessageDelayed(mH.obtainMessage(
+                                            H.WINDOW_FREEZE_TIMEOUT), 2000);
+                                }
+                            }
                             // If the orientation is changing, then we need to
                             // hold off on unfreezing the display until this
                             // window has been redrawn; to do that, we need
@@ -9340,7 +9412,11 @@
                         w.mLastVScale = w.mVScale;
                         if (SHOW_TRANSACTIONS) Log.i(
                                 TAG, "  SURFACE " + w.mSurface + ": alpha="
-                                + w.mShownAlpha + " layer=" + w.mAnimLayer);
+                                + w.mShownAlpha + " layer=" + w.mAnimLayer
+                                + " matrix=[" + (w.mDsDx*w.mHScale)
+                                + "," + (w.mDtDx*w.mVScale)
+                                + "][" + (w.mDsDy*w.mHScale)
+                                + "," + (w.mDtDy*w.mVScale) + "]");
                         if (w.mSurface != null) {
                             try {
                                 w.mSurface.setAlpha(w.mShownAlpha);
@@ -9571,6 +9647,8 @@
                 i--;
                 WindowState win = mResizingWindows.get(i);
                 try {
+                    if (DEBUG_ORIENTATION) Log.v(TAG, "Reporting new frame to "
+                            + win + ": " + win.mFrame);
                     win.mClient.resized(win.mFrame.width(),
                             win.mFrame.height(), win.mLastContentInsets,
                             win.mLastVisibleInsets, win.mDrawPending);
@@ -9642,7 +9720,7 @@
             mH.sendEmptyMessage(H.REPORT_LOSING_FOCUS);
         }
         if (wallpaperDestroyed) {
-            needRelayout = adjustWallpaperWindowsLocked();            
+            needRelayout = adjustWallpaperWindowsLocked() != 0;
         }
         if (needRelayout) {
             requestAnimationLocked(0);
@@ -9720,7 +9798,7 @@
                                 + " token=" + win.mToken
                                 + " pid=" + ws.mSession.mPid
                                 + " uid=" + ws.mSession.mUid);
-                        ws.mSurface.clear();
+                        ws.mSurface.destroy();
                         ws.mSurface = null;
                         mForceRemoves.add(ws);
                         i--;
@@ -9730,7 +9808,7 @@
                         Log.w(TAG, "LEAKED SURFACE (app token hidden): "
                                 + ws + " surface=" + ws.mSurface
                                 + " token=" + win.mAppToken);
-                        ws.mSurface.clear();
+                        ws.mSurface.destroy();
                         ws.mSurface = null;
                         leakedSurface = true;
                     }
@@ -9766,7 +9844,7 @@
                 // surface and ask the app to request another one.
                 Log.w(TAG, "Looks like we have reclaimed some memory, clearing surface for retry.");
                 if (surface != null) {
-                    surface.clear();
+                    surface.destroy();
                     win.mSurface = null;
                 }
 
@@ -10025,6 +10103,16 @@
                     w.dump(pw, "    ");
                 }
             }
+            if (mResizingWindows.size() > 0) {
+                pw.println(" ");
+                pw.println("  Windows waiting to resize:");
+                for (int i=mResizingWindows.size()-1; i>=0; i--) {
+                    WindowState w = mResizingWindows.get(i);
+                    pw.print("  Resizing #"); pw.print(i); pw.print(' ');
+                            pw.print(w); pw.println(":");
+                    w.dump(pw, "    ");
+                }
+            }
             if (mSessions.size() > 0) {
                 pw.println(" ");
                 pw.println("  All active sessions:");
@@ -10227,7 +10315,8 @@
             mDimSurface.setLayer(w.mAnimLayer-1);
 
             final float target = w.mExiting ? 0 : w.mAttrs.dimAmount;
-            if (SHOW_TRANSACTIONS) Log.i(TAG, "layer=" + (w.mAnimLayer-1) + ", target=" + target);
+            if (SHOW_TRANSACTIONS) Log.i(TAG, "  DIM " + mDimSurface
+                    + ": layer=" + (w.mAnimLayer-1) + " target=" + target);
             if (mDimTargetAlpha != target) {
                 // If the desired dim level has changed, then
                 // start an animation to it.
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 9554a22..badfa30 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -136,6 +136,7 @@
     static final boolean DEBUG_SERVICE = localLOGV || false;
     static final boolean DEBUG_VISBILITY = localLOGV || false;
     static final boolean DEBUG_PROCESSES = localLOGV || false;
+    static final boolean DEBUG_PROVIDER = localLOGV || false;
     static final boolean DEBUG_USER_LEAVING = localLOGV || false;
     static final boolean DEBUG_RESULTS = localLOGV || false;
     static final boolean DEBUG_BACKUP = localLOGV || true;
@@ -7411,9 +7412,13 @@
 
                 final long origId = Binder.clearCallingIdentity();
 
-                // In this case the provider is a single instance, so we can
+                // In this case the provider instance already exists, so we can
                 // return it right away.
                 if (r != null) {
+                    if (DEBUG_PROVIDER) Log.v(TAG,
+                            "Adding provider requested by "
+                            + r.processName + " from process "
+                            + cpr.info.processName);                    
                     r.conProviders.add(cpr);
                     cpr.clients.add(r);
                 } else {
@@ -7471,10 +7476,10 @@
                     return cpr;
                 }
 
-                if (false) {
-                    RuntimeException e = new RuntimeException("foo");
-                    //Log.w(TAG, "LAUNCHING REMOTE PROVIDER (myuid " + r.info.uid
-                    //      + " pruid " + ai.uid + "): " + cpi.className, e);
+                if (DEBUG_PROVIDER) {
+                    RuntimeException e = new RuntimeException("here");
+                    Log.w(TAG, "LAUNCHING REMOTE PROVIDER (myuid " + r.info.uid
+                          + " pruid " + cpr.appInfo.uid + "): " + cpr.info.name, e);
                 }
 
                 // This is single process, and our app is now connecting to it.
@@ -7486,14 +7491,6 @@
                     if (mLaunchingProviders.get(i) == cpr) {
                         break;
                     }
-                    if (false) {
-                        final ContentProviderRecord rec =
-                            (ContentProviderRecord)mLaunchingProviders.get(i);
-                        if (rec.info.name.equals(cpr.info.name)) {
-                            cpr = rec;
-                            break;
-                        }
-                    }
                 }
 
                 // If the provider is not already being launched, then get it
@@ -7524,6 +7521,10 @@
                 mProvidersByName.put(name, cpr);
 
                 if (r != null) {
+                    if (DEBUG_PROVIDER) Log.v(TAG,
+                            "Adding provider requested by "
+                            + r.processName + " from process "
+                            + cpr.info.processName);                    
                     r.conProviders.add(cpr);
                     cpr.clients.add(r);
                 } else {
@@ -7578,8 +7579,9 @@
         synchronized (this) {
             ContentProviderRecord cpr = (ContentProviderRecord)mProvidersByName.get(name);
             if(cpr == null) {
-                //remove from mProvidersByClass
-                if(localLOGV) Log.v(TAG, name+" content provider not found in providers list");
+                // remove from mProvidersByClass
+                if (DEBUG_PROVIDER) Log.v(TAG, name +
+                        " provider not found in providers list");
                 return;
             }
             final ProcessRecord r = getRecordForAppLocked(caller);
@@ -7589,12 +7591,15 @@
                         " when removing content provider " + name);
             }
             //update content provider record entry info
-            ContentProviderRecord localCpr = (ContentProviderRecord) mProvidersByClass.get(cpr.info.name);
-            if(localLOGV) Log.v(TAG, "Removing content provider requested by "+
-                    r.info.processName+" from process "+localCpr.appInfo.processName);
-            if(localCpr.appInfo.processName ==  r.info.processName) {
+            ContentProviderRecord localCpr = (ContentProviderRecord)
+                    mProvidersByClass.get(cpr.info.name);
+            if (DEBUG_PROVIDER) Log.v(TAG, "Removing provider requested by "
+                    + r.info.processName + " from process "
+                    + localCpr.appInfo.processName);
+            if (localCpr.app == r) {
                 //should not happen. taken care of as a local provider
-                if(localLOGV) Log.v(TAG, "local provider doing nothing Ignoring other names");
+                Log.w(TAG, "removeContentProvider called on local provider: "
+                        + cpr.info.name + " in process " + r.processName);
                 return;
             } else {
                 localCpr.clients.remove(r);
@@ -10511,7 +10516,8 @@
             r.app.services.remove(r);
             if (r.app.thread != null) {
                 try {
-                    Log.i(TAG, "Stopping service: " + r.shortName);
+                    if (DEBUG_SERVICE) Log.v(TAG,
+                            "Stopping service: " + r.shortName);
                     bumpServiceExecutingLocked(r);
                     mStoppingServices.add(r);
                     updateOomAdjLocked(r.app);
diff --git a/tests/AndroidTests/src/com/android/unit_tests/SMSTest.java b/tests/AndroidTests/src/com/android/unit_tests/GsmSmsTest.java
similarity index 99%
rename from tests/AndroidTests/src/com/android/unit_tests/SMSTest.java
rename to tests/AndroidTests/src/com/android/unit_tests/GsmSmsTest.java
index 9d44fd9..24698fb 100644
--- a/tests/AndroidTests/src/com/android/unit_tests/SMSTest.java
+++ b/tests/AndroidTests/src/com/android/unit_tests/GsmSmsTest.java
@@ -25,7 +25,7 @@
 
 import java.util.Iterator;
 
-public class SMSTest extends AndroidTestCase {
+public class GsmSmsTest extends AndroidTestCase {
 
     @SmallTest
     public void testOne() throws Exception {