Merge change 24060 into eclair

* changes:
  Integrated the profiler into the framework. We run it all the time if the persist.sampling_profiler system property is set. Saves snapshots to the SD card.
diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c
index 6a00e3e..c211b47 100644
--- a/cmds/dumpstate/dumpstate.c
+++ b/cmds/dumpstate/dumpstate.c
@@ -333,10 +333,18 @@
 static void dump_kernel_log(const char *path, const char *title) 
 
 {
-	printf("------ KERNEL %s LOG ------\n", title);
-        if (access(path, R_OK) < 0)
-		printf("%s: %s\n", path, strerror(errno));
-	else
-        	DUMP(path);
+    printf("------ KERNEL %s LOG ------\n", title);
+    if (access(path, R_OK) < 0)
+        printf("%s: %s\n", path, strerror(errno));
+    else {
+        struct stat sbuf;
+
+        if (stat(path, &sbuf) < 0)
+            printf("%s: stat failed (%s)\n", path, strerror(errno));
+        else
+            printf("Harvested %s", ctime(&sbuf.st_ctime));
+    
+        DUMP(path);
+    }
 }
 
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 64e47eb..5bc5855 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -2984,13 +2984,15 @@
                 "gtalk_max_conn_history_records";
 
         /**
-         * This is gdata url to lookup album and picture info from picasa web.
+         * This is gdata url to lookup album and picture info from picasa web. It also controls
+         * whether url scraping for picasa is enabled (NULL to disable).
          */
         public static final String GTALK_PICASA_ALBUM_URL =
                 "gtalk_picasa_album_url";
 
         /**
-         * This is the url to lookup picture info from flickr.
+         * This is the url to lookup picture info from flickr. It also controls
+         * whether url scraping for flickr is enabled (NULL to disable).
          */
         public static final String GTALK_FLICKR_PHOTO_INFO_URL =
                 "gtalk_flickr_photo_info_url";
@@ -3002,12 +3004,19 @@
                 "gtalk_flickr_photo_url";
 
         /**
-         * This is the gdata url to lookup info on a youtube video.
+         * This is the gdata url to lookup info on a youtube video. It also controls
+         * whether url scraping for youtube is enabled (NULL to disable).
          */
         public static final String GTALK_YOUTUBE_VIDEO_URL =
                 "gtalk_youtube_video_url";
 
         /**
+         * Enable/disable GTalk URL scraping for JPG images ("true" to enable).
+         */
+        public static final String GTALK_URL_SCRAPING_FOR_JPG =
+                "gtalk_url_scraping_for_jpg";
+
+        /**
          * Chat message lifetime (for pruning old chat messages).
          */
         public static final String GTALK_CHAT_MESSAGE_LIFETIME =
diff --git a/libs/surfaceflinger/SurfaceFlinger.cpp b/libs/surfaceflinger/SurfaceFlinger.cpp
index a72294a..c78921a 100644
--- a/libs/surfaceflinger/SurfaceFlinger.cpp
+++ b/libs/surfaceflinger/SurfaceFlinger.cpp
@@ -573,8 +573,10 @@
     // do this without lock held
     const size_t count = ditchedLayers.size();
     for (size_t i=0 ; i<count ; i++) {
-        //LOGD("ditching layer %p", ditchedLayers[i].get());
-        ditchedLayers[i]->ditch();
+        if (ditchedLayers[i] != 0) {
+            //LOGD("ditching layer %p", ditchedLayers[i].get());
+            ditchedLayers[i]->ditch();
+        }
     }
 }
 
@@ -1082,6 +1084,8 @@
 
 status_t SurfaceFlinger::addLayer_l(const sp<LayerBase>& layer)
 {
+    if (layer == 0)
+        return BAD_VALUE;
     ssize_t i = mCurrentState.layersSortedByZ.add(
                 layer, &LayerBase::compareCurrentStateZ);
     sp<LayerBaseClient> lbc = LayerBase::dynamicCast< LayerBaseClient* >(layer.get());