2 * Copyright (C) 2013 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.server;
19 import android.os.Handler;
22 * Shared singleton foreground thread for the system. This is a thread for
23 * operations that affect what's on the display, which needs to have a minimum
24 * of latency. This thread should pretty much only be used by the WindowManager,
25 * DisplayManager, and InputManager to perform quick operations in real time.
27 public final class DisplayThread extends ServiceThread {
28 private static DisplayThread sInstance;
29 private static Handler sHandler;
31 private DisplayThread() {
32 super("android.display", android.os.Process.THREAD_PRIORITY_DISPLAY, false /*allowIo*/);
35 private static void ensureThreadLocked() {
36 if (sInstance == null) {
37 sInstance = new DisplayThread();
39 sHandler = new Handler(sInstance.getLooper());
43 public static DisplayThread get() {
44 synchronized (DisplayThread.class) {
50 public static Handler getHandler() {
51 synchronized (DisplayThread.class) {