blob: c86042b234605495f0888bfa11edd8fc760235ed [file] [log] [blame]
Jorim Jaggied7993b2017-03-28 18:50:01 +01001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License
15 */
16
17package com.android.server;
18
19import static android.os.Process.THREAD_PRIORITY_DISPLAY;
20
21import android.os.Handler;
22import android.os.Trace;
23
24/**
Jorim Jaggi21c39a72017-10-20 15:47:51 +020025 * Thread for handling all legacy window animations, or anything that's directly impacting
26 * animations like starting windows or traversals.
Jorim Jaggied7993b2017-03-28 18:50:01 +010027 */
28public final class AnimationThread extends ServiceThread {
29 private static AnimationThread sInstance;
30 private static Handler sHandler;
31
32 private AnimationThread() {
33 super("android.anim", THREAD_PRIORITY_DISPLAY, false /*allowIo*/);
34 }
35
36 private static void ensureThreadLocked() {
37 if (sInstance == null) {
38 sInstance = new AnimationThread();
39 sInstance.start();
40 sInstance.getLooper().setTraceTag(Trace.TRACE_TAG_WINDOW_MANAGER);
41 sHandler = new Handler(sInstance.getLooper());
42 }
43 }
44
45 public static AnimationThread get() {
46 synchronized (AnimationThread.class) {
47 ensureThreadLocked();
48 return sInstance;
49 }
50 }
51
52 public static Handler getHandler() {
53 synchronized (AnimationThread.class) {
54 ensureThreadLocked();
55 return sHandler;
56 }
57 }
58}