Changed ConnectivityService#getServiceInstance so its a singleton.
Change-Id: I27b5688a50917b01fb2fcd1c124da77ccae226b5
This commit is contained in:
parent
e55ada7892
commit
7323ea10cd
1 changed files with 5 additions and 6 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue