Loading core/java/android/app/Activity.java +6 −0 Original line number Diff line number Diff line Loading @@ -924,6 +924,9 @@ public class Activity extends ContextThemeWrapper private AutofillPopupWindow mAutofillPopupWindow; /** @hide */ boolean mEnterAnimationComplete; private static native String getDlWarning(); /** Return the intent that started this activity. */ Loading Loading @@ -2328,6 +2331,7 @@ public class Activity extends ContextThemeWrapper } notifyContentCaptureManagerIfNeeded(CONTENT_CAPTURE_STOP); } mEnterAnimationComplete = false; } /** Loading Loading @@ -7085,6 +7089,8 @@ public class Activity extends ContextThemeWrapper * @hide */ public void dispatchEnterAnimationComplete() { mEnterAnimationComplete = true; mInstrumentation.onEnterAnimationComplete(); onEnterAnimationComplete(); if (getWindow() != null && getWindow().getDecorView() != null) { getWindow().getDecorView().getViewTreeObserver().dispatchOnEnterAnimationComplete(); Loading core/java/android/app/Instrumentation.java +27 −0 Original line number Diff line number Diff line Loading @@ -110,6 +110,7 @@ public class Instrumentation { private PerformanceCollector mPerformanceCollector; private Bundle mPerfMetrics = new Bundle(); private UiAutomation mUiAutomation; private final Object mAnimationCompleteLock = new Object(); public Instrumentation() { } Loading Loading @@ -397,6 +398,31 @@ public class Instrumentation { idler.waitForIdle(); } private void waitForEnterAnimationComplete(Activity activity) { synchronized (mAnimationCompleteLock) { long timeout = 5000; try { // We need to check that this specified Activity completed the animation, not just // any Activity. If it was another Activity, then decrease the timeout by how long // it's already waited and wait for the thread to wakeup again. while (timeout > 0 && !activity.mEnterAnimationComplete) { long startTime = System.currentTimeMillis(); mAnimationCompleteLock.wait(timeout); long totalTime = System.currentTimeMillis() - startTime; timeout -= totalTime; } } catch (InterruptedException e) { } } } /** @hide */ public void onEnterAnimationComplete() { synchronized (mAnimationCompleteLock) { mAnimationCompleteLock.notifyAll(); } } /** * Execute a call on the application's main thread, blocking until it is * complete. Useful for doing things that are not thread-safe, such as Loading Loading @@ -499,6 +525,7 @@ public class Instrumentation { } } while (mWaitingActivities.contains(aw)); waitForEnterAnimationComplete(aw.activity); return aw.activity; } } Loading Loading
core/java/android/app/Activity.java +6 −0 Original line number Diff line number Diff line Loading @@ -924,6 +924,9 @@ public class Activity extends ContextThemeWrapper private AutofillPopupWindow mAutofillPopupWindow; /** @hide */ boolean mEnterAnimationComplete; private static native String getDlWarning(); /** Return the intent that started this activity. */ Loading Loading @@ -2328,6 +2331,7 @@ public class Activity extends ContextThemeWrapper } notifyContentCaptureManagerIfNeeded(CONTENT_CAPTURE_STOP); } mEnterAnimationComplete = false; } /** Loading Loading @@ -7085,6 +7089,8 @@ public class Activity extends ContextThemeWrapper * @hide */ public void dispatchEnterAnimationComplete() { mEnterAnimationComplete = true; mInstrumentation.onEnterAnimationComplete(); onEnterAnimationComplete(); if (getWindow() != null && getWindow().getDecorView() != null) { getWindow().getDecorView().getViewTreeObserver().dispatchOnEnterAnimationComplete(); Loading
core/java/android/app/Instrumentation.java +27 −0 Original line number Diff line number Diff line Loading @@ -110,6 +110,7 @@ public class Instrumentation { private PerformanceCollector mPerformanceCollector; private Bundle mPerfMetrics = new Bundle(); private UiAutomation mUiAutomation; private final Object mAnimationCompleteLock = new Object(); public Instrumentation() { } Loading Loading @@ -397,6 +398,31 @@ public class Instrumentation { idler.waitForIdle(); } private void waitForEnterAnimationComplete(Activity activity) { synchronized (mAnimationCompleteLock) { long timeout = 5000; try { // We need to check that this specified Activity completed the animation, not just // any Activity. If it was another Activity, then decrease the timeout by how long // it's already waited and wait for the thread to wakeup again. while (timeout > 0 && !activity.mEnterAnimationComplete) { long startTime = System.currentTimeMillis(); mAnimationCompleteLock.wait(timeout); long totalTime = System.currentTimeMillis() - startTime; timeout -= totalTime; } } catch (InterruptedException e) { } } } /** @hide */ public void onEnterAnimationComplete() { synchronized (mAnimationCompleteLock) { mAnimationCompleteLock.notifyAll(); } } /** * Execute a call on the application's main thread, blocking until it is * complete. Useful for doing things that are not thread-safe, such as Loading Loading @@ -499,6 +525,7 @@ public class Instrumentation { } } while (mWaitingActivities.contains(aw)); waitForEnterAnimationComplete(aw.activity); return aw.activity; } } Loading