mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Code cleanup.
This commit is contained in:
@@ -105,6 +105,8 @@ class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
|
||||
private static final String OWNER = "__OwningControllerProcess";
|
||||
private static final int COOKIE_TIMEOUT = 3000; // Milliseconds
|
||||
private static final Pattern ONION = Pattern.compile("[a-z2-7]{16}");
|
||||
// This tag will prevent Huawei's power manager from killing us
|
||||
private static final String WAKE_LOCK_TAG = "LocationManagerService";
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(TorPlugin.class.getName());
|
||||
|
||||
@@ -161,9 +163,8 @@ class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
|
||||
ioExecutor, 1);
|
||||
PowerManager pm = (PowerManager)
|
||||
appContext.getSystemService(POWER_SERVICE);
|
||||
// This tag will prevent Huawei's power manager from killing us
|
||||
wakeLock = new RenewableWakeLock(pm, scheduler, PARTIAL_WAKE_LOCK,
|
||||
"LocationManagerService", 30, MINUTES);
|
||||
WAKE_LOCK_TAG, 30, MINUTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,16 +35,11 @@ public class RenewableWakeLock {
|
||||
this.tag = tag;
|
||||
this.duration = duration;
|
||||
this.timeUnit = timeUnit;
|
||||
renewTask = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
renew();
|
||||
}
|
||||
};
|
||||
renewTask = this::renew;
|
||||
}
|
||||
|
||||
public void acquire() {
|
||||
if (LOG.isLoggable(INFO)) LOG.info("Acquiring wake lock " + tag );
|
||||
if (LOG.isLoggable(INFO)) LOG.info("Acquiring wake lock " + tag);
|
||||
synchronized (lock) {
|
||||
if (wakeLock != null) {
|
||||
LOG.info("Already acquired");
|
||||
@@ -58,7 +53,7 @@ public class RenewableWakeLock {
|
||||
}
|
||||
|
||||
private void renew() {
|
||||
if (LOG.isLoggable(INFO)) LOG.info("Renewing wake lock " + tag );
|
||||
if (LOG.isLoggable(INFO)) LOG.info("Renewing wake lock " + tag);
|
||||
synchronized (lock) {
|
||||
if (wakeLock == null) {
|
||||
LOG.info("Already released");
|
||||
@@ -74,7 +69,7 @@ public class RenewableWakeLock {
|
||||
}
|
||||
|
||||
public void release() {
|
||||
if (LOG.isLoggable(INFO)) LOG.info("Releasing wake lock " + tag );
|
||||
if (LOG.isLoggable(INFO)) LOG.info("Releasing wake lock " + tag);
|
||||
synchronized (lock) {
|
||||
if (wakeLock == null) {
|
||||
LOG.info("Already released");
|
||||
|
||||
Reference in New Issue
Block a user