| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.net; | 5 package org.chromium.net; |
| 6 | 6 |
| 7 import android.content.BroadcastReceiver; | 7 import android.content.BroadcastReceiver; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.content.Intent; | 9 import android.content.Intent; |
| 10 import android.content.IntentFilter; | 10 import android.content.IntentFilter; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 @Override | 123 @Override |
| 124 public void onReceive(Context context, Intent intent) { | 124 public void onReceive(Context context, Intent intent) { |
| 125 boolean noConnection = | 125 boolean noConnection = |
| 126 intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY
, false); | 126 intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY
, false); |
| 127 int newConnectionType = noConnection ? | 127 int newConnectionType = noConnection ? |
| 128 NetworkChangeNotifier.CONNECTION_NONE : currentConnectionType(co
ntext); | 128 NetworkChangeNotifier.CONNECTION_NONE : currentConnectionType(co
ntext); |
| 129 | 129 |
| 130 if (newConnectionType != mConnectionType) { | 130 if (newConnectionType != mConnectionType) { |
| 131 mConnectionType = newConnectionType; | 131 mConnectionType = newConnectionType; |
| 132 Log.d(TAG, "Network connectivity changed, type is: " + mConnectionTy
pe); | 132 Log.d(TAG, "Network connectivity changed, type is: " + mConnectionTy
pe); |
| 133 mOwner.notifyNativeObservers(); | 133 mOwner.notifyObserversOfConnectionTypeChange(); |
| 134 } | 134 } |
| 135 } | 135 } |
| 136 | 136 |
| 137 // AcitivityStatus.Listener | 137 // AcitivityStatus.Listener |
| 138 @Override | 138 @Override |
| 139 public void onActivityStatusChanged(boolean isPaused) { | 139 public void onActivityStatusChanged(boolean isPaused) { |
| 140 if (isPaused) { | 140 if (isPaused) { |
| 141 unregisterReceiver(); | 141 unregisterReceiver(); |
| 142 } else { | 142 } else { |
| 143 registerReceiver(); | 143 registerReceiver(); |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 | 146 |
| 147 private static class NetworkConnectivityIntentFilter extends IntentFilter { | 147 private static class NetworkConnectivityIntentFilter extends IntentFilter { |
| 148 NetworkConnectivityIntentFilter() { | 148 NetworkConnectivityIntentFilter() { |
| 149 addAction(ConnectivityManager.CONNECTIVITY_ACTION); | 149 addAction(ConnectivityManager.CONNECTIVITY_ACTION); |
| 150 } | 150 } |
| 151 } | 151 } |
| 152 } | 152 } |
| OLD | NEW |