Changed ConnectivityService#getServiceInstance so its a singleton. am: 7323ea10cd
Original change: undetermined Change-Id: Ia1e35d79c19ecf55fff6a65b18c07573e9b911e8
This commit is contained in:
@@ -105,7 +105,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
private int mNumDnsEntries;
|
||||
|
||||
private boolean mTestMode;
|
||||
private static ConnectivityService sServiceInstance;
|
||||
private static volatile ConnectivityService sServiceInstance;
|
||||
|
||||
private Handler mHandler;
|
||||
|
||||
@@ -174,11 +174,10 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
Looper.loop();
|
||||
}
|
||||
|
||||
public static ConnectivityService getServiceInstance(Context context) {
|
||||
ConnectivityThread thread = new ConnectivityThread(context);
|
||||
thread.start();
|
||||
|
||||
synchronized (thread) {
|
||||
public static synchronized ConnectivityService getServiceInstance(Context context) {
|
||||
if (sServiceInstance == null) {
|
||||
ConnectivityThread thread = new ConnectivityThread(context);
|
||||
thread.start();
|
||||
while (sServiceInstance == null) {
|
||||
try {
|
||||
// Wait until sServiceInstance has been initialized.
|
||||
|
||||
Reference in New Issue
Block a user