Reconcile with jb-mr2-zeroday-release - do not merge

Change-Id: Id19d096814424b1c1253d633f9bc0e18d53dc360
diff --git a/Android.mk b/Android.mk
index c8b81dc..0663e85 100644
--- a/Android.mk
+++ b/Android.mk
@@ -1,7 +1,7 @@
 LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
 
-LOCAL_JAVA_LIBRARIES := bouncycastle telephony-common
+LOCAL_JAVA_LIBRARIES := bouncycastle conscrypt telephony-common
 LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4 android-support-v13 jsr305
 
 LOCAL_MODULE_TAGS := optional
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 67aa7ee..7025a9c 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -262,7 +262,8 @@
         <activity android:name="ApnSettings"
                 android:label="@string/apn_settings"
                 android:configChanges="orientation|keyboardHidden|screenSize"
-                android:launchMode="singleTask">
+                android:launchMode="singleTask"
+                android:parentActivityName="Settings$WirelessSettingsActivity">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <action android:name="android.settings.APN_SETTINGS" />
diff --git a/src/com/android/settings/TrustedCredentialsSettings.java b/src/com/android/settings/TrustedCredentialsSettings.java
index 687663a..cdfe7cd 100644
--- a/src/com/android/settings/TrustedCredentialsSettings.java
+++ b/src/com/android/settings/TrustedCredentialsSettings.java
@@ -45,7 +45,8 @@
 import java.util.Collections;
 import java.util.List;
 import java.util.Set;
-import org.apache.harmony.xnet.provider.jsse.TrustedCertificateStore;
+
+import com.android.org.conscrypt.TrustedCertificateStore;
 
 public class TrustedCredentialsSettings extends Fragment {
 
diff --git a/src/com/android/settings/accounts/AccountSyncSettings.java b/src/com/android/settings/accounts/AccountSyncSettings.java
index 64c4d4a..c14dbbe 100644
--- a/src/com/android/settings/accounts/AccountSyncSettings.java
+++ b/src/com/android/settings/accounts/AccountSyncSettings.java
@@ -115,7 +115,8 @@
                                 } catch (AuthenticatorException e) {
                                     // handled below
                                 }
-                                if (failed) {
+                                if (failed && getActivity() != null &&
+                                        !getActivity().isFinishing()) {
                                     showDialog(FAILED_REMOVAL_DIALOG);
                                 } else {
                                     finish();