summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWink Saville <wink@google.com>2010-09-01 15:15:06 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-09-01 15:15:06 -0700
commit276e8d44a4e29c86712c3ccb60dc8dc057b209d0 (patch)
treea6efbeafc1f24e194c84ce456d1f7fba9ed115fd
parent0eb9b77eec4abb201a6c90cf543172df6473a19e (diff)
parent28961cc02f350ccd1770fb5af2f0d4c9793e4aec (diff)
downloadframeworks_base-276e8d44a4e29c86712c3ccb60dc8dc057b209d0.zip
frameworks_base-276e8d44a4e29c86712c3ccb60dc8dc057b209d0.tar.gz
frameworks_base-276e8d44a4e29c86712c3ccb60dc8dc057b209d0.tar.bz2
Merge "Changed ConnectivityService#getServiceInstance so its a singleton."
-rw-r--r--services/java/com/android/server/ConnectivityService.java11
1 files changed, 5 insertions, 6 deletions
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index 6f23805..98394d0 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -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.