Changed ConnectivityService#getServiceInstance so its a singleton.
Change-Id: I27b5688a50917b01fb2fcd1c124da77ccae226b5
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) {
|
||||
public static synchronized ConnectivityService getServiceInstance(Context context) {
|
||||
if (sServiceInstance == null) {
|
||||
ConnectivityThread thread = new ConnectivityThread(context);
|
||||
thread.start();
|
||||
|
||||
synchronized (thread) {
|
||||
while (sServiceInstance == null) {
|
||||
try {
|
||||
// Wait until sServiceInstance has been initialized.
|
||||
|
||||
Reference in New Issue
Block a user