2 * Copyright (C) 2016 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.
19 import android.os.HandlerThread;
20 import android.os.Looper;
23 * Shared singleton connectivity thread for the system. This is a thread for
24 * connectivity operations such as AsyncChannel connections to system services.
25 * Various connectivity manager objects can use this singleton as a common
26 * resource for their handlers instead of creating separate threads of their own.
29 public final class ConnectivityThread extends HandlerThread {
30 private static ConnectivityThread sInstance;
32 private ConnectivityThread() {
33 super("ConnectivityThread");
36 private static synchronized ConnectivityThread getInstance() {
37 if (sInstance == null) {
38 sInstance = new ConnectivityThread();
44 public static ConnectivityThread get() {
48 public static Looper getInstanceLooper() {
49 return getInstance().getLooper();