Bug 744850. Only set isRegistered if registering succeeded. r=mfinkle

--HG--
extra : rebase_source : 3e921849ea2effe2efa500dac365e4818afda206
This commit is contained in:
Jeff Muizelaar 2012-05-29 15:35:25 -04:00
Родитель 4e918cf174
Коммит cea5f91c2e
2 изменённых файлов: 11 добавлений и 4 удалений

Просмотреть файл

@ -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");
}
}