1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-30 05:02:26 -05:00

Move TracingPowerManager into mail package

This commit is contained in:
Jan Berkel 2014-12-20 00:48:02 +01:00 committed by cketti
parent 9e7721ca62
commit 6a24aca343
11 changed files with 37 additions and 33 deletions

View File

@ -51,8 +51,8 @@ import com.fsck.k9.activity.setup.Prefs;
import com.fsck.k9.controller.MessagingController;
import com.fsck.k9.controller.MessagingListener;
import com.fsck.k9.helper.SizeFormatter;
import com.fsck.k9.helper.power.TracingPowerManager;
import com.fsck.k9.helper.power.TracingPowerManager.TracingWakeLock;
import com.fsck.k9.mail.power.TracingPowerManager;
import com.fsck.k9.mail.power.TracingPowerManager.TracingWakeLock;
import com.fsck.k9.mail.Folder;
import com.fsck.k9.mail.Message;
import com.fsck.k9.mailstore.LocalFolder;

View File

@ -61,8 +61,8 @@ import com.fsck.k9.activity.setup.AccountSetupOutgoing;
import com.fsck.k9.cache.EmailProviderCache;
import com.fsck.k9.helper.Contacts;
import com.fsck.k9.helper.MessageHelper;
import com.fsck.k9.helper.power.TracingPowerManager;
import com.fsck.k9.helper.power.TracingPowerManager.TracingWakeLock;
import com.fsck.k9.mail.power.TracingPowerManager;
import com.fsck.k9.mail.power.TracingPowerManager.TracingWakeLock;
import com.fsck.k9.mail.Address;
import com.fsck.k9.mail.FetchProfile;
import com.fsck.k9.mail.Flag;

View File

@ -5,7 +5,7 @@ import android.util.Log;
import com.fsck.k9.Account;
import com.fsck.k9.K9;
import com.fsck.k9.helper.power.TracingPowerManager.TracingWakeLock;
import com.fsck.k9.mail.power.TracingPowerManager.TracingWakeLock;
import com.fsck.k9.mail.Folder;
import com.fsck.k9.mail.Message;

View File

@ -2,7 +2,7 @@ package com.fsck.k9.mail;
import java.util.List;
import com.fsck.k9.helper.power.TracingPowerManager.TracingWakeLock;
import com.fsck.k9.mail.power.TracingPowerManager.TracingWakeLock;
import android.content.Context;

View File

@ -1,15 +1,19 @@
package com.fsck.k9.helper.power;
package com.fsck.k9.mail.power;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.atomic.AtomicInteger;
import com.fsck.k9.K9;
import com.fsck.k9.mail.K9MailLib;
import android.content.Context;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.util.Log;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
public class TracingPowerManager {
private final static boolean TRACE = false;
public static AtomicInteger wakeLockId = new AtomicInteger(0);
@ -20,8 +24,8 @@ public class TracingPowerManager {
public static synchronized TracingPowerManager getPowerManager(Context context) {
Context appContext = context.getApplicationContext();
if (tracingPowerManager == null) {
if (K9.DEBUG) {
Log.v(K9.LOG_TAG, "Creating TracingPowerManager");
if (K9MailLib.isDebug()) {
Log.v(LOG_TAG, "Creating TracingPowerManager");
}
tracingPowerManager = new TracingPowerManager(appContext);
}
@ -50,16 +54,16 @@ public class TracingPowerManager {
tag = ntag;
wakeLock = pm.newWakeLock(flags, tag);
id = wakeLockId.getAndIncrement();
if (K9.DEBUG) {
Log.v(K9.LOG_TAG, "TracingWakeLock for tag " + tag + " / id " + id + ": Create");
if (K9MailLib.isDebug()) {
Log.v(LOG_TAG, "TracingWakeLock for tag " + tag + " / id " + id + ": Create");
}
}
public void acquire(long timeout) {
synchronized (wakeLock) {
wakeLock.acquire(timeout);
}
if (K9.DEBUG) {
Log.v(K9.LOG_TAG, "TracingWakeLock for tag " + tag + " / id " + id + " for " + timeout + " ms: acquired");
if (K9MailLib.isDebug()) {
Log.v(LOG_TAG, "TracingWakeLock for tag " + tag + " / id " + id + " for " + timeout + " ms: acquired");
}
raiseNotification();
if (startTime == null) {
@ -72,8 +76,8 @@ public class TracingPowerManager {
wakeLock.acquire();
}
raiseNotification();
if (K9.DEBUG) {
Log.w(K9.LOG_TAG, "TracingWakeLock for tag " + tag + " / id " + id + ": acquired with no timeout. K-9 Mail should not do this");
if (K9MailLib.isDebug()) {
Log.w(LOG_TAG, "TracingWakeLock for tag " + tag + " / id " + id + ": acquired with no timeout. K-9 Mail should not do this");
}
if (startTime == null) {
startTime = System.currentTimeMillis();
@ -88,12 +92,12 @@ public class TracingPowerManager {
public void release() {
if (startTime != null) {
Long endTime = System.currentTimeMillis();
if (K9.DEBUG) {
Log.v(K9.LOG_TAG, "TracingWakeLock for tag " + tag + " / id " + id + ": releasing after " + (endTime - startTime) + " ms, timeout = " + timeout + " ms");
if (K9MailLib.isDebug()) {
Log.v(LOG_TAG, "TracingWakeLock for tag " + tag + " / id " + id + ": releasing after " + (endTime - startTime) + " ms, timeout = " + timeout + " ms");
}
} else {
if (K9.DEBUG) {
Log.v(K9.LOG_TAG, "TracingWakeLock for tag " + tag + " / id " + id + ", timeout = " + timeout + " ms: releasing");
if (K9MailLib.isDebug()) {
Log.v(LOG_TAG, "TracingWakeLock for tag " + tag + " / id " + id + ", timeout = " + timeout + " ms: releasing");
}
}
cancelNotification();
@ -123,11 +127,11 @@ public class TracingPowerManager {
public void run() {
if (startTime != null) {
Long endTime = System.currentTimeMillis();
Log.i(K9.LOG_TAG, "TracingWakeLock for tag " + tag + " / id " + id + ": has been active for "
Log.i(LOG_TAG, "TracingWakeLock for tag " + tag + " / id " + id + ": has been active for "
+ (endTime - startTime) + " ms, timeout = " + timeout + " ms");
} else {
Log.i(K9.LOG_TAG, "TracingWakeLock for tag " + tag + " / id " + id + ": still active, timeout = " + timeout + " ms");
Log.i(LOG_TAG, "TracingWakeLock for tag " + tag + " / id " + id + ": still active, timeout = " + timeout + " ms");
}
}

View File

@ -37,8 +37,8 @@ import android.os.PowerManager;
import android.text.TextUtils;
import android.util.Log;
import com.fsck.k9.helper.power.TracingPowerManager;
import com.fsck.k9.helper.power.TracingPowerManager.TracingWakeLock;
import com.fsck.k9.mail.power.TracingPowerManager;
import com.fsck.k9.mail.power.TracingPowerManager.TracingWakeLock;
import com.fsck.k9.mail.AuthType;
import com.fsck.k9.mail.Body;
import com.fsck.k9.mail.ConnectionSecurity;

View File

@ -11,8 +11,8 @@ import android.os.PowerManager;
import android.util.Log;
import com.fsck.k9.K9;
import com.fsck.k9.helper.power.TracingPowerManager;
import com.fsck.k9.helper.power.TracingPowerManager.TracingWakeLock;
import com.fsck.k9.mail.power.TracingPowerManager;
import com.fsck.k9.mail.power.TracingPowerManager.TracingWakeLock;
public class CoreReceiver extends BroadcastReceiver {

View File

@ -14,8 +14,8 @@ import android.os.PowerManager;
import android.util.Log;
import com.fsck.k9.K9;
import com.fsck.k9.controller.MessagingController;
import com.fsck.k9.helper.power.TracingPowerManager;
import com.fsck.k9.helper.power.TracingPowerManager.TracingWakeLock;
import com.fsck.k9.mail.power.TracingPowerManager;
import com.fsck.k9.mail.power.TracingPowerManager.TracingWakeLock;
/**
* {@code CoreService} is the base class for all K-9 Services.

View File

@ -15,8 +15,8 @@ import com.fsck.k9.Account;
import com.fsck.k9.K9;
import com.fsck.k9.Preferences;
import com.fsck.k9.activity.UpgradeDatabases;
import com.fsck.k9.helper.power.TracingPowerManager;
import com.fsck.k9.helper.power.TracingPowerManager.TracingWakeLock;
import com.fsck.k9.mail.power.TracingPowerManager;
import com.fsck.k9.mail.power.TracingPowerManager.TracingWakeLock;
import com.fsck.k9.mailstore.UnavailableStorageException;
/**

View File

@ -8,8 +8,8 @@ import android.util.Log;
import com.fsck.k9.*;
import com.fsck.k9.controller.MessagingController;
import com.fsck.k9.controller.MessagingListener;
import com.fsck.k9.helper.power.TracingPowerManager;
import com.fsck.k9.helper.power.TracingPowerManager.TracingWakeLock;
import com.fsck.k9.mail.power.TracingPowerManager;
import com.fsck.k9.mail.power.TracingPowerManager.TracingWakeLock;
import java.util.HashMap;
import java.util.Map;

View File

@ -4,7 +4,7 @@ import android.content.Context;
import android.content.Intent;
import android.util.Log;
import com.fsck.k9.K9;
import com.fsck.k9.helper.power.TracingPowerManager.TracingWakeLock;
import com.fsck.k9.mail.power.TracingPowerManager.TracingWakeLock;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;