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 int mNumDnsEntries;
|
||||||
|
|
||||||
private boolean mTestMode;
|
private boolean mTestMode;
|
||||||
private static ConnectivityService sServiceInstance;
|
private static volatile ConnectivityService sServiceInstance;
|
||||||
|
|
||||||
private Handler mHandler;
|
private Handler mHandler;
|
||||||
|
|
||||||
@@ -174,11 +174,10 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
Looper.loop();
|
Looper.loop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConnectivityService getServiceInstance(Context context) {
|
public static synchronized ConnectivityService getServiceInstance(Context context) {
|
||||||
ConnectivityThread thread = new ConnectivityThread(context);
|
if (sServiceInstance == null) {
|
||||||
thread.start();
|
ConnectivityThread thread = new ConnectivityThread(context);
|
||||||
|
thread.start();
|
||||||
synchronized (thread) {
|
|
||||||
while (sServiceInstance == null) {
|
while (sServiceInstance == null) {
|
||||||
try {
|
try {
|
||||||
// Wait until sServiceInstance has been initialized.
|
// Wait until sServiceInstance has been initialized.
|
||||||
|
|||||||
Reference in New Issue
Block a user