Merge "Copy wifiCalling method from telephony to settings"
This commit is contained in:
@@ -22,6 +22,7 @@ import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.database.Cursor;
|
||||
import android.os.PersistableBundle;
|
||||
import android.os.SystemProperties;
|
||||
@@ -36,6 +37,8 @@ import android.telephony.ims.feature.ImsFeature;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.ims.ImsException;
|
||||
import com.android.ims.ImsManager;
|
||||
|
||||
@@ -54,6 +57,8 @@ public class MobileNetworkUtils {
|
||||
// the default value is false.
|
||||
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";
|
||||
|
||||
/**
|
||||
* Returns if DPC APNs are enforced.
|
||||
@@ -91,11 +96,10 @@ public class MobileNetworkUtils {
|
||||
|
||||
boolean isWifiCallingEnabled;
|
||||
if (simCallManager != null) {
|
||||
//TODO(b/114749736): build intent to query wifi calling feature
|
||||
final Intent intent = null;
|
||||
PackageManager pm = context.getPackageManager();
|
||||
isWifiCallingEnabled = intent != null
|
||||
&& !pm.queryIntentActivities(intent, 0 /* flags */).isEmpty();
|
||||
Intent intent = buildPhoneAccountConfigureIntent(
|
||||
context, simCallManager);
|
||||
|
||||
isWifiCallingEnabled = intent != null;
|
||||
} else {
|
||||
ImsManager imsMgr = ImsManager.getInstance(context, phoneId);
|
||||
isWifiCallingEnabled = imsMgr != null
|
||||
@@ -107,6 +111,43 @@ public class MobileNetworkUtils {
|
||||
return isWifiCallingEnabled;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
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);
|
||||
}
|
||||
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 boolean isImsServiceStateReady(ImsManager imsMgr) {
|
||||
boolean isImsServiceStateReady = false;
|
||||
|
||||
|
Reference in New Issue
Block a user