зеркало из https://github.com/mozilla/gecko-dev.git
Bug 744850. Only set isRegistered if registering succeeded. r=mfinkle
--HG-- extra : rebase_source : 3e921849ea2effe2efa500dac365e4818afda206
This commit is contained in:
Родитель
4e918cf174
Коммит
cea5f91c2e
|
@ -43,8 +43,11 @@ public class GeckoBatteryManager
|
|||
if (!isRegistered) {
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(Intent.ACTION_BATTERY_CHANGED);
|
||||
activity.registerReceiver(this, filter);
|
||||
isRegistered = true;
|
||||
|
||||
// registerReciever can return null if registering fails
|
||||
isRegistered = activity.registerReceiver(this, filter) != null;
|
||||
if (!isRegistered)
|
||||
Log.e(LOGTAG, "Registering receiver failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ public class GeckoConnectivityReceiver extends BroadcastReceiver {
|
|||
private static final String LINK_DATA_DOWN = "down";
|
||||
private static final String LINK_DATA_UNKNOWN = "unknown";
|
||||
|
||||
private static final String LOGTAG = "GeckoConnectivityReciever";
|
||||
|
||||
private IntentFilter mFilter;
|
||||
|
||||
private static boolean isRegistered = false;
|
||||
|
@ -50,8 +52,10 @@ public class GeckoConnectivityReceiver extends BroadcastReceiver {
|
|||
|
||||
public void registerFor(Activity activity) {
|
||||
if (!isRegistered) {
|
||||
activity.registerReceiver(this, mFilter);
|
||||
isRegistered = true;
|
||||
// registerReciever will return null if registering throws a RemoteException
|
||||
isRegistered = activity.registerReceiver(this, mFilter) != null;
|
||||
if (!isRegistered)
|
||||
Log.e(LOGTAG, "Registering receiver failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче