resolve merge conflicts of ac55c2b2e4 to stage-aosp-master

Test: I solemnly swear I tested this conflict resolution.
Change-Id: Iec10dceacb406a31e6e89d798872a1befd124d2f
diff --git a/tests/tests/graphics/src/android/graphics/drawable/cts/AnimationDrawableTest.java b/tests/tests/graphics/src/android/graphics/drawable/cts/AnimationDrawableTest.java
index 7b3cab9..eb27cf2 100644
--- a/tests/tests/graphics/src/android/graphics/drawable/cts/AnimationDrawableTest.java
+++ b/tests/tests/graphics/src/android/graphics/drawable/cts/AnimationDrawableTest.java
@@ -41,6 +41,7 @@
 
 import com.android.compatibility.common.util.PollingCheck;
 
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -64,6 +65,7 @@
 
     private AnimationDrawable mAnimationDrawable;
     private Resources mResources;
+    private boolean mInitialOneShotValue;
 
     @Rule
     public ActivityTestRule<ImageViewCtsActivity> mActivityRule =
@@ -75,9 +77,23 @@
         final Activity activity = mActivityRule.getActivity();
         mResources = activity.getResources();
 
-        ImageView imageView = (ImageView) activity.findViewById(R.id.imageview);
-        imageView.setBackgroundResource(R.drawable.animationdrawable);
-        mAnimationDrawable = (AnimationDrawable) imageView.getBackground();
+        try {
+            mActivityRule.runOnUiThread(new Runnable() {
+                public void run() {
+                    ImageView imageView = (ImageView) activity.findViewById(R.id.imageview);
+                    imageView.setBackgroundResource(R.drawable.animationdrawable);
+                    mAnimationDrawable = (AnimationDrawable) imageView.getBackground();
+                    mInitialOneShotValue = mAnimationDrawable.isOneShot();
+                }
+            });
+        } catch (Throwable t) {
+            throw new Exception(t);
+        }
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        mAnimationDrawable.setOneShot(mInitialOneShotValue);
     }
 
     @Test