Changed ConnectivityService#getServiceInstance so its a singleton. am: 7323ea10cd
Original change: undetermined Change-Id: I6b654c61c23711531033d9d820eeb76383849cf6
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