From 7539508bfc315fb3fce10d57da27762dab4d2bd4 Mon Sep 17 00:00:00 2001 From: Yu Ping Hu Date: Thu, 18 Apr 2013 10:02:06 -0700 Subject: [PATCH] Add a way to check whether we have a wakelock. Bug: 8640907 Change-Id: I886af09d20dab195a9bbd38082a02d29e8b864e7 --- .../src/com/android/emailsync/SyncManager.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/emailsync/src/com/android/emailsync/SyncManager.java b/emailsync/src/com/android/emailsync/SyncManager.java index 6ed7a7e01..67723ed2a 100644 --- a/emailsync/src/com/android/emailsync/SyncManager.java +++ b/emailsync/src/com/android/emailsync/SyncManager.java @@ -980,6 +980,12 @@ public abstract class SyncManager extends Service implements Runnable { } } + private boolean hasWakeLock(long id) { + synchronized (mWakeLocks) { + return mWakeLocks.get(id) != null; + } + } + private void acquireWakeLock(long id) { synchronized (mWakeLocks) { Long lock = mWakeLocks.get(id); @@ -1075,6 +1081,14 @@ public abstract class SyncManager extends Service implements Runnable { } } + static public boolean isHoldingWakeLock(long id) { + SyncManager ssm = INSTANCE; + if (ssm != null) { + return ssm.hasWakeLock(id); + } + return false; + } + static public void runAwake(long id) { SyncManager ssm = INSTANCE; if (ssm != null) {