Merge change 1000 into donut

* changes:
  Ignore layout bin directories in git.
diff --git a/core/java/android/backup/BackupService.java b/core/java/android/backup/BackupService.java
index d912d8c..6197182 100644
--- a/core/java/android/backup/BackupService.java
+++ b/core/java/android/backup/BackupService.java
@@ -22,6 +22,7 @@
 import android.backup.IBackupService;
 import android.content.Intent;
 import android.os.IBinder;
+import android.os.ParcelFileDescriptor;
 import android.os.RemoteException;
 import android.util.Log;
 
@@ -59,23 +60,25 @@
      * The application is being asked to write any data changed since the
      * last time it performed a backup operation.  The state data recorded
      * during the last backup pass is provided in the oldStateFd file descriptor.
-     * If oldStateFd is negative, no old state is available and the application
-     * should perform a full backup.  In both cases, a representation of the
-     * final backup state after this pass should be written to the file pointed
+     * If oldState.getStatSize() is zero or negative, no old state is available
+     * and the application should perform a full backup.  In both cases, a representation
+     * of the final backup state after this pass should be written to the file pointed
      * to by the newStateFd file descriptor.
      *
-     * @param oldStateFd An open, read-only file descriptor pointing to the last
-     *                   backup state provided by the application.  May be negative,
-     *                   in which case no prior state is being provided and the
-     *                   application should perform a full backup.
-     * @param dataFd An open, read/write file descriptor pointing to the backup data
-     *               destination.  Typically the application will use backup helper
-     *               classes to write to this file.
-     * @param newStateFd An open, read/write file descriptor pointing to an empty
-     *                   file.  The application should record the final backup state
-     *                   here after writing the requested data to dataFd.
+     * @param oldState An open, read-only ParcelFileDescriptor pointing to the last backup
+     *                 state provided by the application.  May be empty or invalid, in which
+     *                 case no prior state is being provided and the application should
+     *                 perform a full backup.
+     * @param data An open, read/write ParcelFileDescriptor pointing to the backup data
+     *             destination.  Typically the application will use backup helper
+     *             classes to write to this file.
+     * @param newState An open, read/write ParcelFileDescriptor pointing to an empty
+     *                 file.  The application should record the final backup state
+     *                 here after writing the requested data to dataFd.
      */
-    public abstract void onBackup(int oldStateFd, int dataFd, int newStateFd);
+    public abstract void onBackup(ParcelFileDescriptor oldState,
+            ParcelFileDescriptor data,
+            ParcelFileDescriptor newState);
     
     /**
      * The application is being restored from backup, and should replace any
@@ -84,13 +87,13 @@
      * the restore is finished, the application should write a representation
      * of the final state to the newStateFd file descriptor, 
      *
-     * @param dataFd An open, read-only file descriptor pointing to a full snapshot
-     *               of the application's data.
-     * @param newStateFd An open, read/write file descriptor pointing to an empty
-     *                   file.  The application should record the final backup state
-     *                   here after restoring its data from dataFd.
+     * @param data An open, read-only ParcelFileDescriptor pointing to a full snapshot
+     *             of the application's data.
+     * @param newState An open, read/write ParcelFileDescriptor pointing to an empty
+     *                 file.  The application should record the final backup state
+     *                 here after restoring its data from dataFd.
      */
-    public abstract void onRestore(int dataFd, int newStateFd);
+    public abstract void onRestore(ParcelFileDescriptor data, ParcelFileDescriptor newState);
 
 
     // ----- Core implementation -----
@@ -110,17 +113,19 @@
 
     // ----- IBackupService binder interface -----
     private class BackupServiceBinder extends IBackupService.Stub {
-        public void doBackup(int oldStateFd, int dataFd, int newStateFd)
-                throws RemoteException {
+        public void doBackup(ParcelFileDescriptor oldState,
+                ParcelFileDescriptor data,
+                ParcelFileDescriptor newState) throws RemoteException {
             // !!! TODO - real implementation; for now just invoke the callbacks directly
             Log.v("BackupServiceBinder", "doBackup() invoked");
-            BackupService.this.onBackup(oldStateFd, dataFd, newStateFd);
+            BackupService.this.onBackup(oldState, data, newState);
         }
 
-        public void doRestore(int dataFd, int newStateFd) throws RemoteException {
+        public void doRestore(ParcelFileDescriptor data,
+                ParcelFileDescriptor newState) throws RemoteException {
             // !!! TODO - real implementation; for now just invoke the callbacks directly
             Log.v("BackupServiceBinder", "doRestore() invoked");
-            BackupService.this.onRestore(dataFd, newStateFd);
+            BackupService.this.onRestore(data, newState);
         }
     }
 }
diff --git a/core/java/android/backup/IBackupService.aidl b/core/java/android/backup/IBackupService.aidl
index 24544bd..1bde8ea 100644
--- a/core/java/android/backup/IBackupService.aidl
+++ b/core/java/android/backup/IBackupService.aidl
@@ -16,38 +16,44 @@
 
 package android.backup;
 
+import android.os.ParcelFileDescriptor;
+ 
 /**
  * Interface presented by applications being asked to participate in the
  * backup & restore mechanism.  End user code does not typically implement
  * this interface; they subclass BackupService instead.
  *
  * {@hide}
- */
+ */ 
 interface IBackupService {
     /**
      * Request that the app perform an incremental backup.
      *
-     * @param oldStateFd Read-only file containing the description blob of the
+     * @param oldState Read-only file containing the description blob of the
      *        app's data state as of the last backup operation's completion.
+     *        This file is empty or invalid when a full backup is being
+     *        requested.
      *
-     * @param dataFd Read-write file, empty when onBackup() is called, that
+     * @param data Read-write file, empty when onBackup() is called, that
      *        is the data destination for this backup pass's incrementals.
      *
-     * @param newStateFd Read-write file, empty when onBackup() is called,
+     * @param newState Read-write file, empty when onBackup() is called,
      *        where the new state blob is to be recorded.
      */
-    void doBackup(int oldStateFd, int dataFd, int newStateFd);
+    void doBackup(in ParcelFileDescriptor oldState,
+            in ParcelFileDescriptor data,
+            in ParcelFileDescriptor newState);
 
     /**
      * Restore an entire data snapshot to the application.
      *
-     * @param dataFd Read-only file containing the full data snapshot of the
+     * @param data Read-only file containing the full data snapshot of the
      *        app's backup.  This is to be a <i>replacement</i> of the app's
      *        current data, not to be merged into it.
      *
-     * @param newStateFd Read-write file, empty when onRestore() is called,
+     * @param newState Read-write file, empty when onRestore() is called,
      *        that is to be written with the state description that holds after
      *        the restore has been completed.
      */
-    void doRestore(int dataFd, int newStateFd);
+    void doRestore(in ParcelFileDescriptor data, in ParcelFileDescriptor newState);
 }
diff --git a/docs/html/guide/developing/tools/aidl.jd b/docs/html/guide/developing/tools/aidl.jd
index 96e4fec..f370a80 100644
--- a/docs/html/guide/developing/tools/aidl.jd
+++ b/docs/html/guide/developing/tools/aidl.jd
@@ -1,6 +1,25 @@
 page.title=Designing a Remote Interface Using AIDL
 @jd:body
 
+
+<div id="qv-wrapper">
+<div id="qv">
+<h2>In this document</h2>
+<ol>
+  <li><a href="#implementing">Implementing IPC Using AIDL</a>
+    <ol>
+      <li><a href="#aidlsyntax">Create an .aidl File</a></li>
+      <li><a href="#implementtheinterface">Implementing the Interface</a></li>
+      <li><a href="#exposingtheinterface">Exposing Your Interface to Clients</a></li>
+      <li><a href="#parcelable">Pass by value Parameters using Parcelables</a></li>
+    </ol>
+  </li>
+  <li><a href="#calling">Calling an IPC Method</a></li>
+</ol>
+</div>
+</div>
+
+
 <p>Since each application runs in its own process, and you can write a service that
 runs in a different process from your Application's UI, sometimes you need to pass objects
 between processes.  On the Android platform, one process can not normally access the memory
@@ -10,7 +29,7 @@
 <p>The code to do that marshalling is tedious to write, so we provide the AIDL tool to do it
 for you.</p>
 
-<p> AIDL (Android Interface Definition Language) is an <a
+<p>AIDL (Android Interface Definition Language) is an <a
 href="http://en.wikipedia.org/wiki/Interface_description_language">IDL</a>
 language used to generate code that enables two processes on an Android-powered device
 to talk using interprocess communication (IPC). If you have code
@@ -20,12 +39,9 @@
 <p>The AIDL IPC mechanism
     is interface-based, similar to COM or Corba, but lighter weight. It uses a proxy
     class to pass values between the client and the implementation. </p>
-<p>This page includes the following main topics: </p>
-<ul>
-    <li><a href="#implementing">Implementing  IPC Using AIDL</a></li>
-    <li><a href="#calling">Calling an .aidl (IPC) Class  </a></li>
-</ul>
-<h2>Implementing IPC Using AIDL <a name="implementing"></a></h2>
+
+
+<h2 id="implementing">Implementing IPC Using AIDL</h2>
 <p>Follow these steps to implement an IPC service using AIDL.</p>
 <ol>
     <li><strong><a href="#aidlsyntax">Create your .aidl file</a> </strong>- This
@@ -46,7 +62,8 @@
         Service.onBind(Intent)} to return an instance of your class that implements your
         interface. </li>
 </ol>
-<h3>Create an .aidl File  <a name="aidlsyntax"></a></h3>
+
+<h3 id="aidlsyntax">Create an .aidl File</h3>
 <p>AIDL is a simple syntax that lets you declare an interface with one or more
     methods, that can take parameters and return values. These parameters and return
     values can be of any type, even other AIDL-generated interfaces.  <em>However, it
@@ -117,7 +134,7 @@
     int getCustomerList(in String branch, out String[] customerList);
 }</pre>
 
-<h3>Implementing the Interface <a name="implementtheinterface"></a></h3>
+<h3 id="implementtheinterface">Implementing the Interface</h3>
 <p>AIDL generates an interface file for you with the same name as your .aidl
     file. If you are using the Eclipse plugin, AIDL will automatically be run as part of
     the build process (you don't need to run AIDL first and then build your project).
@@ -152,7 +169,7 @@
     <li>Only methods are supported; you cannot declare static fields in an AIDL interface.</li>
 </ul>
 
-<h3>Exposing Your Interface to Clients<a name="exposingtheinterface" id="exposingtheinterface"></a></h3>
+<h3 id="exposingtheinterface">Exposing Your Interface to Clients</h3>
 <p>Now that you've got your interface implementation, you need to expose it to clients.
     This is known as &quot;publishing your service.&quot; To publish a service,
     inherit {@link android.app.Service Service} and implement {@link android.app.Service#onBind
@@ -165,8 +182,8 @@
     exposing_a_service}
 }</pre>
 
-<a name="parcelable"></a>
-<h3>Pass by value Parameters using Parcelables</h3>
+
+<h3 id="parcelable">Pass by value Parameters using Parcelables</h3>
 
 <p>If you have a class that you would like to send from one process to another through
 an AIDL interface, you can do that.  You must ensure that the code for your class is available
@@ -181,25 +198,12 @@
 value in a parcel into your object.</li>
 <li>Add a static field called <code>CREATOR</code> to your class which is an object implementing
 the {@link android.os.Parcelable.Creator Parcelable.Creator} interface.</li>
-<li>Last but not least:
-<ul>
-<li>If you are developing with Eclipse/ADT, follow these steps:
-<ol type="a">
-<li>In the Package Explorer view, right-click on the project.</li>
-<li>Choose <strong>Android Tools</strong> > <strong>Create Aidl preprocess file
-for Parcelable classes</strong>.</li>
-<li>This will create a file called "project.aidl" in the root of the project.
-The file will be automatically used when compiling an aidl file that uses the
-parcelable classes.</li>
-</ol>
-</li>
-<li>If you are developing with Ant or are using a custom build process, create an aidl file
+<li>Last but not least, create an aidl file
 that declares your parcelable class (as shown below). If you are using a custom build process,
 do not add the aidl file to your build. Similar to a header file in C, the aidl file isn't 
 compiled.</li>
-</ul>
-</li>
-</ul>
+</ol>
+
 <p>AIDL will use these methods and fields in the code it generates to marshall and unmarshall
 your objects.</p>
 <p>Here is an example of how the {@link android.graphics.Rect} class implements the
@@ -269,7 +273,7 @@
 <a href="{@docRoot}guide/topics/security/security.html">Security and Permissions</a> for more
 on how to keep your application secure from malware.</p>
 
-<h2>Calling an IPC Method <a name="calling"></a></h2>
+<h2 id="calling">Calling an IPC Method</h2>
 <p>Here are the steps a calling class should make to call your remote interface: </p>
 <ol>
     <li>Declare a variable of the interface type that your .aidl file defined. </li>
diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java
index 0f95318..f5f3561 100644
--- a/services/java/com/android/server/BackupManagerService.java
+++ b/services/java/com/android/server/BackupManagerService.java
@@ -26,15 +26,19 @@
 import android.content.pm.ResolveInfo;
 import android.content.pm.ServiceInfo;
 import android.os.Binder;
+import android.os.Environment;
 import android.os.Handler;
 import android.os.IBinder;
 import android.os.Message;
+import android.os.ParcelFileDescriptor;
 import android.os.RemoteException;
 import android.util.Log;
 import android.util.SparseArray;
 
 import android.backup.IBackupManager;
 
+import java.io.File;
+import java.io.FileNotFoundException;
 import java.lang.String;
 import java.util.HashSet;
 import java.util.List;
@@ -57,6 +61,7 @@
     private HashSet<ServiceInfo> mPendingBackups = new HashSet<ServiceInfo>();
     private final Object mQueueLock = new Object();
 
+    private File mStateDir;
     
     // ----- Handler that runs the actual backup process asynchronously -----
 
@@ -99,12 +104,41 @@
                         if (mTargetService != null) {
                             try {
                                 Log.d(TAG, "invoking doBackup() on " + backupIntent);
-                                // !!! TODO: set up files
-                                mTargetService.doBackup(-1, -1, -1);
+
+                                File savedStateName = new File(mStateDir, service.packageName);
+                                File backupDataName = new File(mStateDir, service.packageName + ".data");
+                                File newStateName = new File(mStateDir, service.packageName + ".new");
+                                
+                                ParcelFileDescriptor savedState =
+                                        ParcelFileDescriptor.open(savedStateName,
+                                                ParcelFileDescriptor.MODE_READ_ONLY |
+                                                ParcelFileDescriptor.MODE_CREATE);
+                                ParcelFileDescriptor backupData =
+                                        ParcelFileDescriptor.open(backupDataName,
+                                                ParcelFileDescriptor.MODE_READ_WRITE |
+                                                ParcelFileDescriptor.MODE_CREATE);
+                                ParcelFileDescriptor newState =
+                                        ParcelFileDescriptor.open(newStateName,
+                                                ParcelFileDescriptor.MODE_READ_WRITE |
+                                                ParcelFileDescriptor.MODE_CREATE);
+
+                                mTargetService.doBackup(savedState, backupData, newState);
+
+                                // !!! TODO: Now propagate the newly-backed-up data to the transport
+                                
+                                // !!! TODO: After successful transport, juggle the files so that
+                                // next time the new state is used as the old state
+                                
+                            } catch (FileNotFoundException fnf) {
+                                Log.d(TAG, "File not found on backup: ");
+                                fnf.printStackTrace();
                             } catch (RemoteException e) {
                                 Log.d(TAG, "Remote target " + backupIntent
                                         + " threw during backup:");
                                 e.printStackTrace();
+                            } catch (Exception e) {
+                                Log.w(TAG, "Final exception guard in backup: ");
+                                e.printStackTrace();
                             }
                             mContext.unbindService(this);
                         }
@@ -138,6 +172,11 @@
         mContext = context;
         mPackageManager = context.getPackageManager();
 
+        // Set up our bookkeeping
+        File dataDir = Environment.getDataDirectory();
+        mStateDir = new File(dataDir, "backup");
+        mStateDir.mkdirs();
+        
         // Identify the backup participants
         // !!! TODO: also watch package-install to keep this up to date
         List<ResolveInfo> services = mPackageManager.queryIntentServices(
diff --git a/tests/DumpRenderTree/run_page_cycler.py b/tests/DumpRenderTree/assets/run_page_cycler.py
similarity index 92%
rename from tests/DumpRenderTree/run_page_cycler.py
rename to tests/DumpRenderTree/assets/run_page_cycler.py
index 9a099b5..2325047 100755
--- a/tests/DumpRenderTree/run_page_cycler.py
+++ b/tests/DumpRenderTree/assets/run_page_cycler.py
@@ -56,10 +56,11 @@
   run_load_test_cmd_postfix = " -w com.android.dumprendertree/.LayoutTestsAutoRunner"
 
   # Call LoadTestsAutoTest::runTest.
-  run_load_test_cmd = run_load_test_cmd_prefix + " -e class com.android.dumprendertree.LoadTestsAutoTest#runTest -e path \"" + path + "\" -e timeout " + timeout_ms + run_load_test_cmd_postfix
+  run_load_test_cmd = run_load_test_cmd_prefix + " -e class com.android.dumprendertree.LoadTestsAutoTest#runPageCyclerTest -e path \"" + path + "\" -e timeout " + timeout_ms + run_load_test_cmd_postfix
 
   (adb_output, adb_error) = subprocess.Popen(run_load_test_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
-  if adb_output.find('INSTRUMENTATION_FAILED') != -1:
+  if adb_output.find('INSTRUMENTATION_FAILED') != -1 or \
+      adb_output.find('Process crashed.') != -1:
     logging.error("Error happened : " + adb_output)
     sys.exit(1)
 
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java
index 39eae02..562b1f3 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java
@@ -16,24 +16,11 @@
 
 package com.android.dumprendertree;
 
-import android.app.Activity;
 import android.app.Instrumentation;
-import android.app.Instrumentation.ActivityMonitor;
-import android.content.ContentResolver;
-import android.content.ContentValues;
 import android.content.Intent;
-
-import android.util.Log;
-import android.view.KeyEvent;
-import android.webkit.WebSettings;
-
 import android.os.Bundle;
-import android.os.Message;
 import android.test.ActivityInstrumentationTestCase2;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.LargeTest;
-
-import com.android.dumprendertree.TestShellActivity;
+import android.util.Log;
 
 import java.io.BufferedOutputStream;
 import java.io.BufferedReader;
@@ -141,6 +128,7 @@
     private Vector<String> mTestList;
     private boolean mRebaselineResults;
     private String mTestPathPrefix;
+    private boolean mFinished;
     
     public LayoutTestsAutoTest() {
       super("com.android.dumprendertree", TestShellActivity.class);
@@ -290,6 +278,7 @@
         activity.setCallback(new TestShellCallback() {
             public void finished() {
                 synchronized (LayoutTestsAutoTest.this) {
+                    mFinished = true;
                     LayoutTestsAutoTest.this.notifyAll();
                 }
             }         
@@ -306,6 +295,7 @@
             resultFile = getAndroidExpectedResultFile(expectedResultFile);
         }
         
+        mFinished = false;
         Intent intent = new Intent(Intent.ACTION_VIEW);
         intent.setClass(activity, TestShellActivity.class);
         intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
@@ -316,9 +306,11 @@
       
         // Wait until done.
         synchronized (this) {
-            try {
-                this.wait();
-            } catch (InterruptedException e) { }
+            while(!mFinished){
+                try {
+                    this.wait();
+                } catch (InterruptedException e) { }
+            }
         }
         
         if (!mRebaselineResults) {
@@ -478,7 +470,7 @@
                 byte[] buf = new byte[2048];
                 int len;
 
-                while ((len = in.read(buf)) > 0 ) {
+                while ((len = in.read(buf)) >= 0 ) {
                     out.write(buf, 0, len);
                 }
                 out.close();
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java b/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java
index b064dbb..5cb5155 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java
@@ -16,52 +16,34 @@
 
 package com.android.dumprendertree;
 
-import android.app.Activity;
 import android.app.Instrumentation;
-import android.app.Instrumentation.ActivityMonitor;
 import android.content.Intent;
 
 import android.util.Log;
 
 import android.os.Bundle;
+import android.os.Debug;
+import android.os.Debug.MemoryInfo;
 import android.test.ActivityInstrumentationTestCase2;
 
 import com.android.dumprendertree.TestShellActivity;
 import com.android.dumprendertree.TestShellCallback;
 
-import java.io.InputStream;
-import java.io.OutputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
-
-class StreamPipe extends Thread {
-    InputStream in;
-    OutputStream out;
-    
-    StreamPipe(InputStream in, OutputStream out) {
-        this.in = in;
-        this.out = out;
-    }
-    
-    public void run() {
-        try {
-            byte[] buf = new byte[1024];
-            int nofb = this.in.read(buf);
-            while (nofb != -1) {
-                this.out.write(buf, 0, nofb);
-                nofb = this.in.read(buf);
-            }          
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-    }
-}
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
 
 public class LoadTestsAutoTest extends ActivityInstrumentationTestCase2<TestShellActivity> {
 
     private final static String LOGTAG = "LoadTest";
     private final static String LOAD_TEST_RESULT = "/sdcard/load_test_result.txt";
-    
+    private boolean mFinished;
+    static final String LOAD_TEST_RUNNER_FILES[] = {
+        "run_page_cycler.py"
+  };
+
     public LoadTestsAutoTest() {
         super("com.android.dumprendertree", TestShellActivity.class);
     }
@@ -74,17 +56,17 @@
         bundle.putBoolean(file, result);
         inst.sendStatus(0, bundle);
     }
-    
+
     // Invokes running of layout tests
     // and waits till it has finished running.
-    public void runTest() {
+    public void runPageCyclerTest() {
         LayoutTestsAutoRunner runner = (LayoutTestsAutoRunner) getInstrumentation();
 
         if (runner.mTestPath == null) {
             Log.e(LOGTAG, "No test specified");
             return;
         }
-        
+
         TestShellActivity activity = (TestShellActivity) getActivity();
 
         // Run tests
@@ -92,48 +74,69 @@
 
         // TODO(fqian): let am instrumentation pass in the command line, currently
         // am instrument does not allow spaces in the command.
-        runPostShellCommand("/system/bin/dumpsys meminfo");
-        
+        dumpMemoryInfo();
+
         // Kill activity
         activity.finish();
     }
 
-    private void runPostShellCommand(String cmd) {
-        if (cmd == null || cmd.length() == 0)
-            return;
-        
+    private void dumpMemoryInfo() {
         try {
-            // Call dumpsys meminfo
-            Process proc = Runtime.getRuntime().exec(cmd);
-            // Append output to LOAD_TEST_RESULT
-            InputStream input = proc.getInputStream();
-            InputStream error = proc.getErrorStream();
-            FileOutputStream out = new FileOutputStream(LOAD_TEST_RESULT, true);
+            Log.v(LOGTAG, "Dumping memory information.");
 
-            StreamPipe p_in = new StreamPipe(input, out);
-            StreamPipe p_err = new StreamPipe(error, System.err);
-            
-            p_in.start();
-            p_err.start();
-            
-            proc.waitFor();
+            FileOutputStream out = new FileOutputStream(LOAD_TEST_RESULT, true);
+            PrintStream ps = new PrintStream(out);
+
+            MemoryInfo mi = new MemoryInfo();
+            Debug.getMemoryInfo(mi);
+
+            //try to fake the dumpsys format
+            //this will eventually be changed to XML
+            String format = "%15s:%9d%9d%9d%9d";
+            String pss =
+              String.format(format, "(Pss)",
+                  mi.nativePss, mi.dalvikPss, mi.otherPss,
+                  mi.nativePss + mi.dalvikPss + mi.otherPss);
+            String sd =
+              String.format(format, "(shared dirty)",
+                  mi.nativeSharedDirty, mi.dalvikSharedDirty, mi.otherSharedDirty,
+                  mi.nativeSharedDirty + mi.dalvikSharedDirty + mi.otherSharedDirty);
+            String pd =
+              String.format(format, "(priv dirty)",
+                  mi.nativePrivateDirty, mi.dalvikPrivateDirty, mi.otherPrivateDirty,
+                  mi.nativePrivateDirty + mi.dalvikPrivateDirty + mi.otherPrivateDirty);
+
+            ps.print("\n\n\n");
+            ps.println("** MEMINFO in pid 0 [com.android.dumprendertree] **");
+            ps.println("                   native   dalvik    other    total");
+            ps.println("           size:    12060     5255      N/A    17315");
+            ps.println("      allocated:    12060     5255      N/A    17315");
+            ps.println("           free:    12060     5255      N/A    17315");
+            ps.println(pss);
+            ps.println(sd);
+            ps.println(pd);
+            ps.print("\n\n\n");
+            ps.flush();
+            ps.close();
+            out.flush();
+            out.close();
         } catch (IOException e) {
             Log.e(LOGTAG, e.getMessage());
-        } catch (InterruptedException e) {
-            Log.e(LOGTAG, e.getMessage());
-        }      
+        }
     }
-    
+
     // A convenient method to be called by another activity.
     private void runTestAndWaitUntilDone(TestShellActivity activity, String url, int timeout) {
         activity.setCallback(new TestShellCallback() {
             public void finished() {
                 synchronized (LoadTestsAutoTest.this) {
+                    mFinished = true;
                     LoadTestsAutoTest.this.notifyAll();
                 }
-            }         
+            }
         });
-        
+
+        mFinished = false;
         Intent intent = new Intent(Intent.ACTION_VIEW);
         intent.setClass(activity, TestShellActivity.class);
         intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
@@ -141,12 +144,41 @@
         intent.putExtra(TestShellActivity.TIMEOUT_IN_MILLIS, timeout);
         intent.putExtra(TestShellActivity.RESULT_FILE, LOAD_TEST_RESULT);
         activity.startActivity(intent);
-        
+
         // Wait until done.
         synchronized (this) {
-            try {
-                this.wait();
-            } catch (InterruptedException e) { }
+            while(!mFinished) {
+                try {
+                    this.wait();
+                } catch (InterruptedException e) { }
+            }
         }
-    }   
+    }
+
+    public void copyRunnerAssetsToCache() {
+        try {
+            String out_dir = getActivity().getApplicationContext()
+                .getCacheDir().getPath() + "/";
+
+            for( int i=0; i< LOAD_TEST_RUNNER_FILES.length; i++) {
+                InputStream in = getActivity().getAssets().open(
+                        LOAD_TEST_RUNNER_FILES[i]);
+                OutputStream out = new FileOutputStream(
+                        out_dir + LOAD_TEST_RUNNER_FILES[i]);
+
+                byte[] buf = new byte[2048];
+                int len;
+
+                while ((len = in.read(buf)) >= 0 ) {
+                    out.write(buf, 0, len);
+                }
+                out.close();
+                in.close();
+            }
+        }catch (IOException e) {
+          e.printStackTrace();
+        }
+
+    }
+
 }
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java b/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java
index bf8a3b3..404d101 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java
@@ -165,7 +165,8 @@
             if (mDialogStrings != null)
                 os.write(mDialogStrings.toString().getBytes());
             mDialogStrings = null;
-            os.write(webkitData.getBytes());
+            if (webkitData != null)
+                os.write(webkitData.getBytes());
             os.flush();
             os.close();
         } catch (IOException ex) {