mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 22:29:53 +01:00
IntentFilter may not be thread-safe.
This commit is contained in:
@@ -30,9 +30,6 @@ class AndroidBatteryManager implements BatteryManager, Service {
|
|||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
getLogger(AndroidBatteryManager.class.getName());
|
getLogger(AndroidBatteryManager.class.getName());
|
||||||
|
|
||||||
private static final IntentFilter BATTERY_FILTER =
|
|
||||||
new IntentFilter(ACTION_BATTERY_CHANGED);
|
|
||||||
|
|
||||||
private final Context appContext;
|
private final Context appContext;
|
||||||
private final EventBus eventBus;
|
private final EventBus eventBus;
|
||||||
private final AtomicBoolean used = new AtomicBoolean(false);
|
private final AtomicBoolean used = new AtomicBoolean(false);
|
||||||
@@ -48,7 +45,8 @@ class AndroidBatteryManager implements BatteryManager, Service {
|
|||||||
@Override
|
@Override
|
||||||
public boolean isCharging() {
|
public boolean isCharging() {
|
||||||
// Get the sticky intent for ACTION_BATTERY_CHANGED
|
// Get the sticky intent for ACTION_BATTERY_CHANGED
|
||||||
Intent i = appContext.registerReceiver(null, BATTERY_FILTER);
|
IntentFilter filter = new IntentFilter(ACTION_BATTERY_CHANGED);
|
||||||
|
Intent i = appContext.registerReceiver(null, filter);
|
||||||
if (i == null) return false;
|
if (i == null) return false;
|
||||||
int status = i.getIntExtra(EXTRA_STATUS, -1);
|
int status = i.getIntExtra(EXTRA_STATUS, -1);
|
||||||
return status == BATTERY_STATUS_CHARGING ||
|
return status == BATTERY_STATUS_CHARGING ||
|
||||||
|
|||||||
Reference in New Issue
Block a user