summaryrefslogtreecommitdiffstats
path: root/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java
diff options
context:
space:
mode:
authorJohn Spurlock <jspurlock@google.com>2013-10-30 19:40:48 -0400
committerJohn Spurlock <jspurlock@google.com>2013-10-31 10:49:50 -0400
commit385a63d56a1f5afdf064539d033da999b748289a (patch)
tree80f343a34012745968f97d21ea3a055241e35a29 /packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java
parenta223d1933ba69fbf454cf17e93ab62bd13fa9293 (diff)
downloadframeworks_base-385a63d56a1f5afdf064539d033da999b748289a.zip
frameworks_base-385a63d56a1f5afdf064539d033da999b748289a.tar.gz
frameworks_base-385a63d56a1f5afdf064539d033da999b748289a.tar.bz2
Move coalescing to callback, optimize KeyguardStatusView.
Move the recent keyguard hidden coalescing down to the callback level. The lifetime of each callback can be short, make sure they see visibility changes at least once for each change local to their lifetime. KeyguardStatusView.refresh() is called multiple times, and instances are recreated often. This results in expensive computations filling the sysui/keyguard ui queue, adding to overall sluggishness. Traceview points to DateFormat.getBestDateTimePattern as the main culprit. As of this change, refresh() will only call the expensive date pattern computations when absolutely necessary, resulting in better performance turning the screen off/on. Bug:11221659 Bug:11447043 Change-Id: I3d4105af7db608803b82d8ef0ff141e42c154257
Diffstat (limited to 'packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java')
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java
index 76f9637..c08880d 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java
@@ -19,6 +19,7 @@ import android.app.PendingIntent;
import android.app.admin.DevicePolicyManager;
import android.graphics.Bitmap;
import android.media.AudioManager;
+import android.os.SystemClock;
import android.view.WindowManagerPolicy;
import com.android.internal.telephony.IccCardConstants;
@@ -27,6 +28,11 @@ import com.android.internal.telephony.IccCardConstants;
* Callback for general information relevant to lock screen.
*/
class KeyguardUpdateMonitorCallback {
+
+ private static final long VISIBILITY_CHANGED_COLLAPSE_MS = 1000;
+ private long mVisibilityChangedCalled;
+ private boolean mShowing;
+
/**
* Called when the battery status changes, e.g. when plugged in or unplugged, charge
* level, etc. changes.
@@ -70,6 +76,15 @@ class KeyguardUpdateMonitorCallback {
*/
void onKeyguardVisibilityChanged(boolean showing) { }
+ void onKeyguardVisibilityChangedRaw(boolean showing) {
+ final long now = SystemClock.elapsedRealtime();
+ if (showing == mShowing
+ && (now - mVisibilityChangedCalled) < VISIBILITY_CHANGED_COLLAPSE_MS) return;
+ onKeyguardVisibilityChanged(showing);
+ mVisibilityChangedCalled = now;
+ mShowing = showing;
+ }
+
/**
* Called when visibility of lockscreen clock changes, such as when
* obscured by a widget.