Commit 8869b1d8 authored by Shannon Stork's avatar Shannon Stork

Started power monitor with app launch instead of service creation

parent c6209464
package org.briarproject.snooze;
import android.app.Application;
import android.os.PowerManager;
public class SnoozeApplication extends Application {
private volatile Logger log = null;
private SleepMonitor monitor = null;
private PowerManager pm;
@Override
public void onCreate() {
super.onCreate();
log = new Logger(this, getString(R.string.app_name));
log.log("Application created");
monitor = new SleepMonitor(getApplicationContext(), pm);
monitor.start();
log.log("Sleep monitor created");
}
Logger getLogger() {
......
......@@ -46,7 +46,6 @@ public class SnoozeService extends Service {
private WifiManager.WifiLock wifiLock = null;
private NetworkClient networkClient = null;
private Alarm alarm = null;
private SleepMonitor monitor = null;
private int alarmIntervalMs, keepaliveIntervalMs, keepaliveBytes, port;
private String host;
private PowerManager pm;
......@@ -85,10 +84,6 @@ public class SnoozeService extends Service {
else if (!newWakeLock && wakeLock != null) releaseWakeLock();
if (newWifiLock && wifiLock == null) acquireWifiLock();
else if (!newWifiLock && wifiLock != null) releaseWifiLock();
if (monitor == null) {
monitor = new SleepMonitor(getApplicationContext(), pm);
monitor.start();
}
startNetworkThread();
setAlarm(newAlarmType);
} else if (ACTION_STOP.equals(i.getAction())) {
......@@ -116,7 +111,6 @@ public class SnoozeService extends Service {
if (foreground) stopForegroundService();
unregisterReceiver(receiver);
if (wakeLock != null) releaseWakeLock();
if (monitor != null) monitor.stopMonitoring();
}
@Override
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment