diff options
author | Chet Haase <chet@google.com> | 2013-10-02 09:44:11 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-10-02 09:44:11 -0700 |
commit | c2baf840d34bd78505c9fa7a32734506e67d8628 (patch) | |
tree | c14fb77e24e821da2c0c2450e028f0c55ce9cee1 | |
parent | 15ef4b4127fd80cbebf4881e14a5594713a42ea9 (diff) | |
parent | 5e0582e5f16eccc96ee0da0fb507722180778d00 (diff) | |
download | frameworks_base-c2baf840d34bd78505c9fa7a32734506e67d8628.zip frameworks_base-c2baf840d34bd78505c9fa7a32734506e67d8628.tar.gz frameworks_base-c2baf840d34bd78505c9fa7a32734506e67d8628.tar.bz2 |
am 5e0582e5: am 0d5a9fde: am 6e4ee9d5: Merge "Make onClickHandler in KeyguardHostView a weak reference" into klp-dev
* commit '5e0582e5f16eccc96ee0da0fb507722180778d00':
Make onClickHandler in KeyguardHostView a weak reference
-rw-r--r-- | packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java | 46 |
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 { |