diff options
| author | Android (Google) Code Review <android-gerrit@google.com> | 2009-08-14 18:41:56 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2009-08-14 18:41:56 -0700 |
| commit | 82726f045de91b899502a54ca76d234c43a1ba4b (patch) | |
| tree | 5531f2e91f7e7b52c66e9a9672a23943fce67cdd | |
| parent | c650bf583dbed8701da9a49b9dbd9023768f0df8 (diff) | |
| parent | 0f79b54c3a0b4141b1da38fa301571a89e165632 (diff) | |
| download | frameworks_base-82726f045de91b899502a54ca76d234c43a1ba4b.zip frameworks_base-82726f045de91b899502a54ca76d234c43a1ba4b.tar.gz frameworks_base-82726f045de91b899502a54ca76d234c43a1ba4b.tar.bz2 | |
Merge change 21298 into eclair
* changes:
ConnectivityService: Do not send broadcasts until the system is ready.
| -rw-r--r-- | services/java/com/android/server/ConnectivityService.java | 35 | ||||
| -rw-r--r-- | services/java/com/android/server/SystemServer.java | 8 |
2 files changed, 37 insertions, 6 deletions
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java index 1c60058..72a1192 100644 --- a/services/java/com/android/server/ConnectivityService.java +++ b/services/java/com/android/server/ConnectivityService.java @@ -100,6 +100,9 @@ public class ConnectivityService extends IConnectivityManager.Stub { // a process dies private List mFeatureUsers; + private boolean mSystemReady; + private ArrayList<Intent> mDeferredBroadcasts; + private class NetworkAttributes { /** * Class for holding settings read from resources. @@ -820,7 +823,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { (newNet == null || !newNet.isAvailable() ? "" : " other=" + newNet.getNetworkInfo().getTypeName())); - mContext.sendStickyBroadcast(intent); + sendStickyBroadcast(intent); /* * If the failover network is already connected, then immediately send * out a followup broadcast indicating successful failover @@ -843,7 +846,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { intent.putExtra(ConnectivityManager.EXTRA_EXTRA_INFO, info.getExtraInfo()); } - mContext.sendStickyBroadcast(intent); + sendStickyBroadcast(intent); } /** @@ -882,7 +885,33 @@ public class ConnectivityService extends IConnectivityManager.Stub { intent.putExtra(ConnectivityManager.EXTRA_IS_FAILOVER, true); info.setFailover(false); } - mContext.sendStickyBroadcast(intent); + sendStickyBroadcast(intent); + } + + private void sendStickyBroadcast(Intent intent) { + synchronized(this) { + if (mSystemReady) { + mContext.sendStickyBroadcast(intent); + } else { + if (mDeferredBroadcasts == null) { + mDeferredBroadcasts = new ArrayList<Intent>(); + } + mDeferredBroadcasts.add(intent); + } + } + } + + void systemReady() { + synchronized(this) { + mSystemReady = true; + if (mDeferredBroadcasts != null) { + int count = mDeferredBroadcasts.size(); + for (int i = 0; i < count; i++) { + mContext.sendStickyBroadcast(mDeferredBroadcasts.get(i)); + } + mDeferredBroadcasts = null; + } + } } private void handleConnect(NetworkInfo info) { diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index ad8e892..38bf63a 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -85,6 +85,7 @@ class ServerThread extends Thread { HardwareService hardware = null; PowerManagerService power = null; BatteryService battery = null; + ConnectivityService connectivity = null; IPackageManager pm = null; Context context = null; WindowManagerService wm = null; @@ -231,8 +232,8 @@ class ServerThread extends Thread { try { Log.i(TAG, "Starting Connectivity Service."); - ServiceManager.addService(Context.CONNECTIVITY_SERVICE, - ConnectivityService.getInstance(context)); + connectivity = ConnectivityService.getInstance(context); + ServiceManager.addService(Context.CONNECTIVITY_SERVICE, connectivity); } catch (Throwable e) { Log.e(TAG, "Failure starting Connectivity Service", e); } @@ -384,7 +385,8 @@ class ServerThread extends Thread { } if (wallpaper != null) wallpaper.systemReady(); - battery.systemReady(); + if (battery != null) battery.systemReady(); + if (connectivity != null) connectivity.systemReady(); Watchdog.getInstance().start(); Looper.loop(); |
