Fix HoloTest instability

Bug 6948782

testHolo began failing on a device that crashed in the prior camera
tests. When the phone got a mcc, it triggered a configuration change
that caused the controlling ThemeTestActivity to restart. This in turn
caused two LayoutTestActivity instances to launch which in turn started
two threads that process the same resource bitmap and thenn call
recycle. The thread unfortunate enough not to finish early gets an error
when it tries to read a pixel from the recycled bitmap.

2 fixes:
- Don't call recycle on the resource drawable bitmap.
- Make holo test not restart on mcc and mnc changes.

Bonus:
- Move bitmap comparison into thread rather than blocking main thread.

The real fix would be to rewrite the Holo test so that it can handle
configuration changes like an ordinary app would.

Change-Id: I9cee199a0644e630944cc2976fb1982ab820a1fd
diff --git a/tests/tests/holo/AndroidManifest.xml b/tests/tests/holo/AndroidManifest.xml
index ea53a73..7eb899c 100644
--- a/tests/tests/holo/AndroidManifest.xml
+++ b/tests/tests/holo/AndroidManifest.xml
@@ -41,12 +41,12 @@
                 android:label="@string/pick_layout" />
 
         <activity android:name="android.holo.cts.ThemeTestActivity"
-                android:configChanges="keyboardHidden|orientation|screenSize"
+                android:configChanges="keyboardHidden|orientation|screenSize|mcc|mnc"
                 android:screenOrientation="nosensor"
                 android:theme="@android:style/Theme.Translucent.NoTitleBar" />
 
         <activity android:name="android.holo.cts.LayoutTestActivity"
-                android:configChanges="keyboardHidden|orientation|screenSize"
+                android:configChanges="keyboardHidden|orientation|screenSize|mcc|mnc"
                 android:screenOrientation="nosensor" />
 
         <activity android:name="android.holo.cts.BitmapDeletionActivity"
diff --git a/tests/tests/holo/src/android/holo/cts/LayoutTestActivity.java b/tests/tests/holo/src/android/holo/cts/LayoutTestActivity.java
index e88f5e1..2b6c371 100644
--- a/tests/tests/holo/src/android/holo/cts/LayoutTestActivity.java
+++ b/tests/tests/holo/src/android/holo/cts/LayoutTestActivity.java
@@ -163,8 +163,6 @@
         protected void onPreExecute() {
             mBitmap = getBitmap();
             mReferenceBitmap = BitmapAssets.getBitmap(getApplicationContext(), mBitmapName);
-            final int threshold = 2;
-            mSame = compareTo(mBitmap, mReferenceBitmap, threshold);
         }
 
         /* Compares 2 bitmaps' width, height and pixels.
@@ -213,6 +211,8 @@
         @Override
         protected String[] doInBackground(Void... devoid) {
             try {
+                final int threshold = 2;
+                mSame = compareTo(mBitmap, mReferenceBitmap, threshold);
                 if (!mSame) {
                     String[] paths = new String[2];
                     paths[0] = saveDiffBitmap(mBitmap, mReferenceBitmap);
@@ -222,9 +222,6 @@
                     return null;
                 }
             } finally {
-                mReferenceBitmap.recycle();
-                mReferenceBitmap = null;
-
                 mBitmap.recycle();
                 mBitmap = null;
             }