Merge "Duplicate buildPhoneAccountConfigureIntent"
diff --git a/src/com/android/phone/MobileNetworkSettings.java b/src/com/android/phone/MobileNetworkSettings.java
index f65250d..1f394f0 100644
--- a/src/com/android/phone/MobileNetworkSettings.java
+++ b/src/com/android/phone/MobileNetworkSettings.java
@@ -77,7 +77,6 @@
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.TelephonyIntents;
-import com.android.phone.settings.PhoneAccountSettingsFragment;
import com.android.settingslib.RestrictedLockUtils;
import java.util.ArrayList;
@@ -108,6 +107,9 @@
private static final String KEY_ENABLE_ESIM_UI_BY_DEFAULT =
"esim.enable_esim_system_ui_by_default";
+ private static final String LEGACY_ACTION_CONFIGURE_PHONE_ACCOUNT =
+ "android.telecom.action.CONNECTION_SERVICE_CONFIGURE";
+
private enum TabState {
NO_TABS, UPDATE, DO_NOTHING
}
@@ -171,8 +173,8 @@
boolean isWifiCallingEnabled;
if (simCallManager != null) {
- Intent intent = PhoneAccountSettingsFragment
- .buildPhoneAccountConfigureIntent(context, simCallManager);
+ Intent intent = MobileNetworkSettings.buildPhoneAccountConfigureIntent(
+ context, simCallManager);
PackageManager pm = context.getPackageManager();
isWifiCallingEnabled = intent != null
&& !pm.queryIntentActivities(intent, 0 /* flags */).isEmpty();
@@ -291,6 +293,47 @@
return isImsServiceStateReady;
}
+
+ private static Intent buildPhoneAccountConfigureIntent(
+ Context context, PhoneAccountHandle accountHandle) {
+ Intent intent = buildConfigureIntent(
+ context, accountHandle, TelecomManager.ACTION_CONFIGURE_PHONE_ACCOUNT);
+
+ if (intent == null) {
+ // If the new configuration didn't work, try the old configuration intent.
+ intent = buildConfigureIntent(
+ context, accountHandle, LEGACY_ACTION_CONFIGURE_PHONE_ACCOUNT);
+ if (intent != null) {
+ Log.w(MobileNetworkFragment.LOG_TAG,
+ "Phone account using old configuration intent: " + accountHandle);
+ }
+ }
+ return intent;
+ }
+
+ private static Intent buildConfigureIntent(
+ Context context, PhoneAccountHandle accountHandle, String actionStr) {
+ if (accountHandle == null || accountHandle.getComponentName() == null
+ || TextUtils.isEmpty(accountHandle.getComponentName().getPackageName())) {
+ return null;
+ }
+
+ // Build the settings intent.
+ Intent intent = new Intent(actionStr);
+ intent.setPackage(accountHandle.getComponentName().getPackageName());
+ intent.addCategory(Intent.CATEGORY_DEFAULT);
+ intent.putExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, accountHandle);
+
+ // Check to see that the phone account package can handle the setting intent.
+ PackageManager pm = context.getPackageManager();
+ List<ResolveInfo> resolutions = pm.queryIntentActivities(intent, 0);
+ if (resolutions.size() == 0) {
+ intent = null; // set no intent if the package cannot handle it.
+ }
+
+ return intent;
+ }
+
public static class MobileNetworkFragment extends PreferenceFragment implements
Preference.OnPreferenceChangeListener, RoamingDialogFragment.RoamingDialogListener {
@@ -1868,7 +1911,7 @@
TelecomManager.from(getContext()).getSimCallManager();
if (simCallManager != null) {
- Intent intent = PhoneAccountSettingsFragment.buildPhoneAccountConfigureIntent(
+ Intent intent = MobileNetworkSettings.buildPhoneAccountConfigureIntent(
getContext(), simCallManager);
PackageManager pm = getContext().getPackageManager();
List<ResolveInfo> resolutions = pm.queryIntentActivities(intent, 0);