Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 88957ef8 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Add timeout if we dont get onEnterAnimationComplete

Window manager doesn't send us onEnterAnimationComplete in the case
where there are two activites starting at the same time and the
screen orientation is changing. Add a timeout to work around this
until we have a proper fix.

Bug: 23849216
Change-Id: I4be7787d1bc13f8cb0ffd892010c4b5c0142c783
parent 74a2283d
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.settings;
import android.app.Fragment;
import android.app.KeyguardManager;
import android.os.Bundle;
import android.os.Handler;
import android.view.MenuItem;
import android.view.WindowManager;

@@ -28,6 +29,7 @@ public abstract class ConfirmDeviceCredentialBaseActivity extends SettingsActivi
    private boolean mDark;
    private boolean mEnterAnimationPending;
    private boolean mFirstTimeVisible = true;
    private final Handler mHandler = new Handler();

    @Override
    protected void onCreate(Bundle savedState) {
@@ -67,6 +69,7 @@ public abstract class ConfirmDeviceCredentialBaseActivity extends SettingsActivi
            mFirstTimeVisible = false;
            prepareEnterAnimation();
            mEnterAnimationPending = true;
            mHandler.postDelayed(mEnterAnimationCompleteTimeoutRunnable, 1000);
        }
    }

@@ -82,6 +85,7 @@ public abstract class ConfirmDeviceCredentialBaseActivity extends SettingsActivi
    public void onEnterAnimationComplete() {
        super.onEnterAnimationComplete();
        if (mEnterAnimationPending) {
            mHandler.removeCallbacks(mEnterAnimationCompleteTimeoutRunnable);
            startEnterAnimation();
            mEnterAnimationPending = false;
        }
@@ -94,4 +98,15 @@ public abstract class ConfirmDeviceCredentialBaseActivity extends SettingsActivi
    public void startEnterAnimation() {
        getFragment().startEnterAnimation();
    }

    /**
     * Workaround for a bug in window manager which results that onEnterAnimationComplete doesn't
     * get called in all cases.
     */
    private final Runnable mEnterAnimationCompleteTimeoutRunnable = new Runnable() {
        @Override
        public void run() {
            onEnterAnimationComplete();
        }
    };
}