Create HandlerThread for TaskFragmentAnimationRunner
TaskFragmentAnimationRunner is initialized using the looper from the caller thread. This may cause a NPE because the looper may be null if the TaskFragmentAnimationRunner is initialized from a non-main thread. This CL creates a HandlerThread for the TaskFragmentAnimationRunner so that it can be initialized from any thread. Bug: b/207662199 Test: atest CtsWindowManagerJetpackTestCases:ActivityEmbeddingLaunchTests Change-Id: Id06b03380dc6dfa9122fca293df8948b4374c966
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package androidx.window.extensions.embedding;
|
||||
|
||||
import static android.os.Process.THREAD_PRIORITY_DISPLAY;
|
||||
import static android.view.RemoteAnimationTarget.MODE_CLOSING;
|
||||
import static android.view.WindowManager.TRANSIT_OLD_ACTIVITY_CLOSE;
|
||||
import static android.view.WindowManager.TRANSIT_OLD_ACTIVITY_OPEN;
|
||||
@@ -29,7 +30,7 @@ import android.animation.Animator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.HandlerThread;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
import android.view.IRemoteAnimationFinishedCallback;
|
||||
@@ -50,10 +51,14 @@ import java.util.function.BiFunction;
|
||||
class TaskFragmentAnimationRunner extends IRemoteAnimationRunner.Stub {
|
||||
|
||||
private static final String TAG = "TaskFragAnimationRunner";
|
||||
private final Handler mHandler = new Handler(Looper.myLooper());
|
||||
private final Handler mHandler;
|
||||
private final TaskFragmentAnimationSpec mAnimationSpec;
|
||||
|
||||
TaskFragmentAnimationRunner() {
|
||||
HandlerThread animationThread = new HandlerThread(
|
||||
"androidx.window.extensions.embedding", THREAD_PRIORITY_DISPLAY);
|
||||
animationThread.start();
|
||||
mHandler = animationThread.getThreadHandler();
|
||||
mAnimationSpec = new TaskFragmentAnimationSpec(mHandler);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user