summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2014-07-30 22:48:31 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-07-29 21:36:00 +0000
commitbc8f0c99b16449249e6c1d6405ba89657064ba6b (patch)
treef1987e9534db3aad53ce74ce64cdf6c0a988ab20
parentab0e6ea8da5b3fd0b153315f28af83e1e339b9db (diff)
parente89ee6f3c48374bfdea5450d6311763bc061885f (diff)
downloadpackages_apps_InCallUI-bc8f0c99b16449249e6c1d6405ba89657064ba6b.tar.gz
packages_apps_InCallUI-bc8f0c99b16449249e6c1d6405ba89657064ba6b.tar.bz2
packages_apps_InCallUI-bc8f0c99b16449249e6c1d6405ba89657064ba6b.zip
Merge "Fix activity leaks in InCallUI" into lmp-dev
-rw-r--r--src/com/android/incallui/CallCardPresenter.java74
-rw-r--r--src/com/android/incallui/ContactInfoCache.java2
2 files changed, 52 insertions, 24 deletions
diff --git a/src/com/android/incallui/CallCardPresenter.java b/src/com/android/incallui/CallCardPresenter.java
index 7018db9d..bb6edfb7 100644
--- a/src/com/android/incallui/CallCardPresenter.java
+++ b/src/com/android/incallui/CallCardPresenter.java
@@ -41,6 +41,9 @@ import com.android.incallui.InCallPresenter.InCallEventListener;
import com.android.incallui.InCallPresenter.InCallState;
import com.android.incallui.InCallPresenter.InCallStateListener;
import com.android.incallui.InCallPresenter.IncomingCallListener;
+
+import java.lang.ref.WeakReference;
+
import com.google.common.base.Preconditions;
/**
@@ -63,6 +66,33 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
private Context mContext;
private TelecommManager mTelecommManager;
+ public static class ContactLookupCallback implements ContactInfoCacheCallback {
+ private final WeakReference<CallCardPresenter> mCallCardPresenter;
+ private final boolean mIsPrimary;
+
+ public ContactLookupCallback(CallCardPresenter callCardPresenter, boolean isPrimary) {
+ mCallCardPresenter = new WeakReference<CallCardPresenter>(callCardPresenter);
+ mIsPrimary = isPrimary;
+ }
+
+ @Override
+ public void onContactInfoComplete(String callId, ContactCacheEntry entry) {
+ CallCardPresenter presenter = mCallCardPresenter.get();
+ if (presenter != null) {
+ presenter.onContactInfoComplete(callId, entry, mIsPrimary);
+ }
+ }
+
+ @Override
+ public void onImageLoadComplete(String callId, ContactCacheEntry entry) {
+ CallCardPresenter presenter = mCallCardPresenter.get();
+ if (presenter != null) {
+ presenter.onImageLoadComplete(callId, entry);
+ }
+ }
+
+ }
+
public CallCardPresenter() {
// create the call timer
mCallTimer = new CallTimer(new Runnable() {
@@ -347,30 +377,28 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
boolean isIncoming) {
final ContactInfoCache cache = ContactInfoCache.getInstance(mContext);
- cache.findInfo(call, isIncoming, new ContactInfoCacheCallback() {
- @Override
- public void onContactInfoComplete(String callId, ContactCacheEntry entry) {
- updateContactEntry(entry, isPrimary, false);
- if (entry.name != null) {
- Log.d(TAG, "Contact found: " + entry);
- }
- if (entry.contactUri != null) {
- CallerInfoUtils.sendViewNotification(mContext, entry.contactUri);
- }
- }
+ cache.findInfo(call, isIncoming, new ContactLookupCallback(this, isPrimary));
+ }
- @Override
- public void onImageLoadComplete(String callId, ContactCacheEntry entry) {
- if (getUi() == null) {
- return;
- }
- if (entry.photo != null) {
- if (mPrimary != null && callId.equals(mPrimary.getId())) {
- getUi().setPrimaryImage(entry.photo);
- }
- }
- }
- });
+ private void onContactInfoComplete(String callId, ContactCacheEntry entry, boolean isPrimary) {
+ updateContactEntry(entry, isPrimary, false);
+ if (entry.name != null) {
+ Log.d(TAG, "Contact found: " + entry);
+ }
+ if (entry.contactUri != null) {
+ CallerInfoUtils.sendViewNotification(mContext, entry.contactUri);
+ }
+ }
+
+ private void onImageLoadComplete(String callId, ContactCacheEntry entry) {
+ if (getUi() == null) {
+ return;
+ }
+ if (entry.photo != null) {
+ if (mPrimary != null && callId.equals(mPrimary.getId())) {
+ getUi().setPrimaryImage(entry.photo);
+ }
+ }
}
private static boolean isConference(Call call) {
diff --git a/src/com/android/incallui/ContactInfoCache.java b/src/com/android/incallui/ContactInfoCache.java
index ba1dca70..d02c8c83 100644
--- a/src/com/android/incallui/ContactInfoCache.java
+++ b/src/com/android/incallui/ContactInfoCache.java
@@ -59,7 +59,7 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete
public static synchronized ContactInfoCache getInstance(Context mContext) {
if (sCache == null) {
- sCache = new ContactInfoCache(mContext);
+ sCache = new ContactInfoCache(mContext.getApplicationContext());
}
return sCache;
}