summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorblong <blong@codeaurora.org>2016-10-21 16:58:54 +0800
committerGerrit - the friendly Code Review server <code-review@localhost>2016-10-31 23:34:26 -0700
commitc06fca9e244508ec83a41edb80a6557a824ab045 (patch)
tree1a6339e8b2e626a081ef609e72dfc73764811a3a
parent54dc242a0bb84f997e5f9de6b2681a9d3c96d391 (diff)
downloadpackages_apps_ContactsCommon-c06fca9e244508ec83a41edb80a6557a824ab045.tar.gz
packages_apps_ContactsCommon-c06fca9e244508ec83a41edb80a6557a824ab045.tar.bz2
packages_apps_ContactsCommon-c06fca9e244508ec83a41edb80a6557a824ab045.zip
Fix ServiceConnectionLeaked during import vcard
- Service registered when activity create but not unregister when activity destroy, it will cause ServiceConnectionLeaked after rotate screen. CRs-Fixed: 1080625 Change-Id: Ia0fe990bc96fee8b448caf697a5c5aaa275a7b13
-rwxr-xr-x[-rw-r--r--]src/com/android/contacts/common/vcard/ImportVCardActivity.java20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/com/android/contacts/common/vcard/ImportVCardActivity.java b/src/com/android/contacts/common/vcard/ImportVCardActivity.java
index 9da8c0b7..eaacb600 100644..100755
--- a/src/com/android/contacts/common/vcard/ImportVCardActivity.java
+++ b/src/com/android/contacts/common/vcard/ImportVCardActivity.java
@@ -110,6 +110,8 @@ public class ImportVCardActivity extends Activity {
private Handler mHandler = new Handler();
+ private boolean mBind = false;
+
// Runs on the UI thread.
private class DialogDisplayer implements Runnable {
private final int mResId;
@@ -153,6 +155,7 @@ public class ImportVCardActivity extends Activity {
@Override
public void onServiceConnected(ComponentName name, IBinder binder) {
mService = ((VCardService.MyBinder) binder).getService();
+ mBind = true;
Log.i(LOG_TAG,
String.format("Connected to VCardService. Kick a vCard cache thread (uri: %s)",
Arrays.toString(mVCardCacheThread.getSourceUris())));
@@ -161,6 +164,7 @@ public class ImportVCardActivity extends Activity {
@Override
public void onServiceDisconnected(ComponentName name) {
+ mBind = false;
Log.i(LOG_TAG, "Disconnected from VCardService");
}
}
@@ -284,9 +288,10 @@ public class ImportVCardActivity extends Activity {
} finally {
Log.i(LOG_TAG, "Finished caching vCard.");
mWakeLock.release();
- unbindService(mConnection);
- mProgressDialogForCachingVCard.dismiss();
- mProgressDialogForCachingVCard = null;
+ if (mProgressDialogForCachingVCard != null) {
+ mProgressDialogForCachingVCard.dismiss();
+ mProgressDialogForCachingVCard = null;
+ }
finish();
}
}
@@ -766,4 +771,13 @@ public class ImportVCardActivity extends Activity {
}
});
}
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ if (mBind) {
+ unbindService(mConnection);
+ mBind = false;
+ }
+ }
}