summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorChet Haase <chet@google.com>2013-10-01 15:34:22 -0700
committerChet Haase <chet@google.com>2013-10-01 16:37:17 -0700
commit7fc27ea451dac0c89c8c4e6b80182ed1a7620a87 (patch)
tree5a532d2875d74389cbc0cb491dbd297950c4f408 /packages
parent607463788abd6168fa5f0133cf225600833268ae (diff)
downloadframeworks_base-7fc27ea451dac0c89c8c4e6b80182ed1a7620a87.zip
frameworks_base-7fc27ea451dac0c89c8c4e6b80182ed1a7620a87.tar.gz
frameworks_base-7fc27ea451dac0c89c8c4e6b80182ed1a7620a87.tar.bz2
Make onClickHandler in KeyguardHostView a weak reference
The strong reference OnClickHandler caused bitmaps in keyguard to be referenced when keyguard was not visible. This change makes the click handler a static class with a weak reference to the hostView instance, allowing those bitmaps to get collected and shaving ~845k off of the heap size when the keyguard isn't showing. Issue #10918599 SystemUI should have a round of Svelting Change-Id: I69de8659ac14c1a4723d082dd3cd394d8b6097f1
Diffstat (limited to 'packages')
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java46
1 files changed, 32 insertions, 14 deletions
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java
index 10ffcce..bc8c866 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java
@@ -57,6 +57,7 @@ import android.view.WindowManager;
import android.widget.RemoteViews.OnClickHandler;
import java.io.File;
+import java.lang.ref.WeakReference;
import java.util.List;
public class KeyguardHostView extends KeyguardViewBase {
@@ -124,6 +125,8 @@ public class KeyguardHostView extends KeyguardViewBase {
private final Rect mInsets = new Rect();
+ private MyOnClickHandler mOnClickHandler = new MyOnClickHandler(this);
+
/*package*/ interface UserSwitcherCallback {
void hideSecurityView(int duration);
void showSecurityView();
@@ -812,24 +815,39 @@ public class KeyguardHostView extends KeyguardViewBase {
}
}
- private OnClickHandler mOnClickHandler = new OnClickHandler() {
+ private static class MyOnClickHandler extends OnClickHandler {
+
+ // weak reference to the hostView to avoid keeping a live reference
+ // due to Binder GC linkages to AppWidgetHost. By the same token,
+ // this click handler should not keep references to any large
+ // objects.
+ WeakReference<KeyguardHostView> mThis;
+
+ MyOnClickHandler(KeyguardHostView hostView) {
+ mThis = new WeakReference<KeyguardHostView>(hostView);
+ }
+
@Override
public boolean onClickHandler(final View view,
final android.app.PendingIntent pendingIntent,
final Intent fillInIntent) {
+ KeyguardHostView hostView = mThis.get();
+ if (hostView == null) {
+ return false;
+ }
if (pendingIntent.isActivity()) {
- setOnDismissAction(new OnDismissAction() {
+ hostView.setOnDismissAction(new OnDismissAction() {
public boolean onDismiss() {
try {
- // TODO: Unregister this handler if PendingIntent.FLAG_ONE_SHOT?
- Context context = view.getContext();
- ActivityOptions opts = ActivityOptions.makeScaleUpAnimation(view,
- 0, 0,
- view.getMeasuredWidth(), view.getMeasuredHeight());
- context.startIntentSender(
- pendingIntent.getIntentSender(), fillInIntent,
- Intent.FLAG_ACTIVITY_NEW_TASK,
- Intent.FLAG_ACTIVITY_NEW_TASK, 0, opts.toBundle());
+ // TODO: Unregister this handler if PendingIntent.FLAG_ONE_SHOT?
+ Context context = view.getContext();
+ ActivityOptions opts = ActivityOptions.makeScaleUpAnimation(view,
+ 0, 0,
+ view.getMeasuredWidth(), view.getMeasuredHeight());
+ context.startIntentSender(
+ pendingIntent.getIntentSender(), fillInIntent,
+ Intent.FLAG_ACTIVITY_NEW_TASK,
+ Intent.FLAG_ACTIVITY_NEW_TASK, 0, opts.toBundle());
} catch (IntentSender.SendIntentException e) {
android.util.Log.e(TAG, "Cannot send pending intent: ", e);
} catch (Exception e) {
@@ -840,10 +858,10 @@ public class KeyguardHostView extends KeyguardViewBase {
}
});
- if (mViewStateManager.isChallengeShowing()) {
- mViewStateManager.showBouncer(true);
+ if (hostView.mViewStateManager.isChallengeShowing()) {
+ hostView.mViewStateManager.showBouncer(true);
} else {
- mCallback.dismiss(false);
+ hostView.mCallback.dismiss(false);
}
return true;
} else {