fix: lag when accessibility service switch toggled

This commit is contained in:
hyb1996
2017-07-31 21:28:13 +08:00
parent 6307d3aa96
commit f51d791d98
10 changed files with 75 additions and 14 deletions

View File

@@ -150,12 +150,15 @@ public class AccessibilityService extends android.accessibilityservice.Accessibi
return false;
}
public static void waitForEnabled(long timeOut) {
public static boolean waitForEnabled(long timeOut) {
if (instance != null)
return true;
LOCK.lock();
try {
ENABLED.await(timeOut, TimeUnit.MILLISECONDS);
return ENABLED.await(timeOut, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
e.printStackTrace();
return false;
} finally {
LOCK.unlock();
}