Merge "[Settings] Add ImsQueryProvisioningStat for VT"
This commit is contained in:
@@ -16,6 +16,10 @@
|
|||||||
|
|
||||||
package com.android.settings.network.ims;
|
package com.android.settings.network.ims;
|
||||||
|
|
||||||
|
import android.telephony.AccessNetworkConstants;
|
||||||
|
import android.telephony.ims.feature.MmTelFeature;
|
||||||
|
import android.telephony.ims.stub.ImsRegistrationImplBase;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,8 +27,38 @@ import androidx.annotation.VisibleForTesting;
|
|||||||
*/
|
*/
|
||||||
abstract class ImsQueryController {
|
abstract class ImsQueryController {
|
||||||
|
|
||||||
|
private volatile int mCapability;
|
||||||
|
private volatile int mTech;
|
||||||
|
private volatile int mTransportType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for query IMS status
|
||||||
|
*/
|
||||||
|
ImsQueryController() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for query IMS status
|
||||||
|
*
|
||||||
|
* @param capability {@code MmTelFeature.MmTelCapabilities.MmTelCapability}
|
||||||
|
* @param tech {@code @ImsRegistrationImplBase.ImsRegistrationTech}
|
||||||
|
* @param transportType {@code @AccessNetworkConstants.TransportType}
|
||||||
|
*/
|
||||||
|
ImsQueryController(
|
||||||
|
@MmTelFeature.MmTelCapabilities.MmTelCapability int capability,
|
||||||
|
@ImsRegistrationImplBase.ImsRegistrationTech int tech,
|
||||||
|
@AccessNetworkConstants.TransportType int transportType) {
|
||||||
|
mCapability = capability;
|
||||||
|
mTech = tech;
|
||||||
|
mTransportType = transportType;
|
||||||
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
ImsQuery isTtyOnVolteEnabled(int subId) {
|
ImsQuery isTtyOnVolteEnabled(int subId) {
|
||||||
return new ImsQueryTtyOnVolteStat(subId);
|
return new ImsQueryTtyOnVolteStat(subId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
ImsQuery isProvisionedOnDevice(int subId) {
|
||||||
|
return new ImsQueryProvisioningStat(subId, mCapability, mTech);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2020 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.network.ims;
|
||||||
|
|
||||||
|
import android.telephony.ims.ImsMmTelManager;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An {@code ImsQuery} for accessing IMS user setting for enhanced 4G LTE
|
||||||
|
*/
|
||||||
|
public class ImsQueryEnhanced4gLteModeUserSetting implements ImsQuery {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param subId subscription id
|
||||||
|
*/
|
||||||
|
public ImsQueryEnhanced4gLteModeUserSetting(int subId) {
|
||||||
|
mSubId = subId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private volatile int mSubId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of interface {@code ImsQuery}
|
||||||
|
*
|
||||||
|
* @return result of query
|
||||||
|
*/
|
||||||
|
public boolean query() {
|
||||||
|
final ImsMmTelManager imsMmTelManager =
|
||||||
|
ImsMmTelManager.createForSubscriptionId(mSubId);
|
||||||
|
return imsMmTelManager.isAdvancedCallingSettingEnabled();
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2020 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.network.ims;
|
||||||
|
|
||||||
|
import android.telephony.ims.ProvisioningManager;
|
||||||
|
import android.telephony.ims.feature.MmTelFeature;
|
||||||
|
import android.telephony.ims.stub.ImsRegistrationImplBase;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An {@code ImsQuery} for accessing IMS provision stat
|
||||||
|
*/
|
||||||
|
public class ImsQueryProvisioningStat implements ImsQuery {
|
||||||
|
|
||||||
|
private volatile int mSubId;
|
||||||
|
private volatile int mCapability;
|
||||||
|
private volatile int mTech;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param subId subscription id
|
||||||
|
* @param capability {@code MmTelFeature.MmTelCapabilities.MmTelCapability}
|
||||||
|
* @param tech {@code @ImsRegistrationImplBase.ImsRegistrationTech}
|
||||||
|
*/
|
||||||
|
public ImsQueryProvisioningStat(int subId,
|
||||||
|
@MmTelFeature.MmTelCapabilities.MmTelCapability int capability,
|
||||||
|
@ImsRegistrationImplBase.ImsRegistrationTech int tech) {
|
||||||
|
mSubId = subId;
|
||||||
|
mCapability = capability;
|
||||||
|
mTech = tech;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of interface {@code ImsQuery}
|
||||||
|
*
|
||||||
|
* @return result of query
|
||||||
|
*/
|
||||||
|
public boolean query() {
|
||||||
|
final ProvisioningManager privisionManager =
|
||||||
|
ProvisioningManager.createForSubscriptionId(mSubId);
|
||||||
|
return privisionManager.getProvisioningStatusForCapability(mCapability, mTech);
|
||||||
|
}
|
||||||
|
}
|
@@ -18,13 +18,16 @@ package com.android.settings.network.ims;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.telecom.TelecomManager;
|
import android.telecom.TelecomManager;
|
||||||
|
import android.telephony.AccessNetworkConstants;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
|
import android.telephony.ims.feature.MmTelFeature;
|
||||||
|
import android.telephony.ims.stub.ImsRegistrationImplBase;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
import com.android.ims.ImsManager;
|
import com.android.ims.ImsManager;
|
||||||
import com.android.settings.network.SubscriptionUtil;
|
import com.android.settings.network.SubscriptionUtil;
|
||||||
|
import com.android.settings.network.telephony.MobileNetworkUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller class for querying Volte status
|
* Controller class for querying Volte status
|
||||||
@@ -41,10 +44,52 @@ public class VolteQueryImsState extends ImsQueryController {
|
|||||||
* @param subId subscription's id
|
* @param subId subscription's id
|
||||||
*/
|
*/
|
||||||
public VolteQueryImsState(Context context, int subId) {
|
public VolteQueryImsState(Context context, int subId) {
|
||||||
|
super(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
|
||||||
|
ImsRegistrationImplBase.REGISTRATION_TECH_LTE,
|
||||||
|
AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mSubId = subId;
|
mSubId = subId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of ImsQueryController#isEnabledByUser(int subId)
|
||||||
|
*/
|
||||||
|
@VisibleForTesting
|
||||||
|
ImsQuery isEnabledByUser(int subId) {
|
||||||
|
return new ImsQueryEnhanced4gLteModeUserSetting(subId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
ImsManager getImsManager(int subId) {
|
||||||
|
return ImsManager.getInstance(mContext,
|
||||||
|
SubscriptionUtil.getPhoneId(mContext, subId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether VoLTE has been provisioned or not on this subscription
|
||||||
|
*
|
||||||
|
* @return true when VoLTE has been enabled, otherwise false
|
||||||
|
*/
|
||||||
|
public boolean isVoLteProvisioned() {
|
||||||
|
final ImsManager imsManager = getImsManager(mSubId);
|
||||||
|
if (imsManager == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return imsManager.isVolteEnabledByPlatform()
|
||||||
|
&& isProvisionedOnDevice(mSubId).query();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether VoLTE can be perform or not on this subscription
|
||||||
|
*
|
||||||
|
* @return true when VoLTE can be performed, otherwise false
|
||||||
|
*/
|
||||||
|
public boolean isReadyToVoLte() {
|
||||||
|
return isVoLteProvisioned()
|
||||||
|
&& MobileNetworkUtils.isImsServiceStateReady(getImsManager(mSubId));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get allowance status for user to alter configuration
|
* Get allowance status for user to alter configuration
|
||||||
*
|
*
|
||||||
@@ -74,8 +119,6 @@ public class VolteQueryImsState extends ImsQueryController {
|
|||||||
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
|
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ImsManager imsManager = ImsManager.getInstance(mContext, SubscriptionUtil.getPhoneId(
|
return isEnabledByUser(mSubId).query();
|
||||||
mContext, mSubId));
|
|
||||||
return imsManager.isEnhanced4gLteModeSettingEnabledByUser();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,10 +18,17 @@ package com.android.settings.network.ims;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.telecom.TelecomManager;
|
import android.telecom.TelecomManager;
|
||||||
|
import android.telephony.AccessNetworkConstants;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
|
import android.telephony.ims.feature.MmTelFeature;
|
||||||
|
import android.telephony.ims.stub.ImsRegistrationImplBase;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
|
import com.android.ims.ImsManager;
|
||||||
|
import com.android.settings.network.SubscriptionUtil;
|
||||||
|
import com.android.settings.network.telephony.MobileNetworkUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller class for querying VT status
|
* Controller class for querying VT status
|
||||||
*/
|
*/
|
||||||
@@ -37,6 +44,9 @@ public class VtQueryImsState extends ImsQueryController {
|
|||||||
* @param subId subscription's id
|
* @param subId subscription's id
|
||||||
*/
|
*/
|
||||||
public VtQueryImsState(Context context, int subId) {
|
public VtQueryImsState(Context context, int subId) {
|
||||||
|
super(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO,
|
||||||
|
ImsRegistrationImplBase.REGISTRATION_TECH_LTE,
|
||||||
|
AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mSubId = subId;
|
mSubId = subId;
|
||||||
}
|
}
|
||||||
@@ -49,6 +59,28 @@ public class VtQueryImsState extends ImsQueryController {
|
|||||||
return new ImsQueryVtUserSetting(subId);
|
return new ImsQueryVtUserSetting(subId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
ImsManager getImsManager(int subId) {
|
||||||
|
return ImsManager.getInstance(mContext,
|
||||||
|
SubscriptionUtil.getPhoneId(mContext, subId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether Video Call can be perform or not on this subscription
|
||||||
|
*
|
||||||
|
* @return true when Video Call can be performed, otherwise false
|
||||||
|
*/
|
||||||
|
public boolean isReadyToVideoCall() {
|
||||||
|
final ImsManager imsManager = getImsManager(mSubId);
|
||||||
|
if (imsManager == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return imsManager.isVtEnabledByPlatform()
|
||||||
|
&& isProvisionedOnDevice(mSubId).query()
|
||||||
|
&& MobileNetworkUtils.isImsServiceStateReady(imsManager);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get allowance status for user to alter configuration
|
* Get allowance status for user to alter configuration
|
||||||
*
|
*
|
||||||
|
@@ -37,6 +37,7 @@ public class WifiCallingQueryImsState extends ImsQueryController {
|
|||||||
* @param subId subscription's id
|
* @param subId subscription's id
|
||||||
*/
|
*/
|
||||||
public WifiCallingQueryImsState(Context context, int subId) {
|
public WifiCallingQueryImsState(Context context, int subId) {
|
||||||
|
super();
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mSubId = subId;
|
mSubId = subId;
|
||||||
}
|
}
|
||||||
|
@@ -23,9 +23,6 @@ import android.telephony.PhoneStateListener;
|
|||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.telephony.ims.ImsMmTelManager;
|
import android.telephony.ims.ImsMmTelManager;
|
||||||
import android.telephony.ims.ProvisioningManager;
|
|
||||||
import android.telephony.ims.feature.MmTelFeature;
|
|
||||||
import android.telephony.ims.stub.ImsRegistrationImplBase;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
@@ -33,9 +30,7 @@ import androidx.preference.Preference;
|
|||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
import androidx.preference.SwitchPreference;
|
import androidx.preference.SwitchPreference;
|
||||||
|
|
||||||
import com.android.ims.ImsManager;
|
|
||||||
import com.android.settings.network.MobileDataEnabledListener;
|
import com.android.settings.network.MobileDataEnabledListener;
|
||||||
import com.android.settings.network.SubscriptionUtil;
|
|
||||||
import com.android.settings.network.ims.VolteQueryImsState;
|
import com.android.settings.network.ims.VolteQueryImsState;
|
||||||
import com.android.settings.network.ims.VtQueryImsState;
|
import com.android.settings.network.ims.VtQueryImsState;
|
||||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||||
@@ -54,8 +49,6 @@ public class VideoCallingPreferenceController extends TelephonyTogglePreferenceC
|
|||||||
|
|
||||||
private Preference mPreference;
|
private Preference mPreference;
|
||||||
private CarrierConfigManager mCarrierConfigManager;
|
private CarrierConfigManager mCarrierConfigManager;
|
||||||
@VisibleForTesting
|
|
||||||
ImsManager mImsManager;
|
|
||||||
private PhoneCallStateListener mPhoneStateListener;
|
private PhoneCallStateListener mPhoneStateListener;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
Integer mCallState;
|
Integer mCallState;
|
||||||
@@ -101,7 +94,7 @@ public class VideoCallingPreferenceController extends TelephonyTogglePreferenceC
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final SwitchPreference switchPreference = (SwitchPreference) preference;
|
final SwitchPreference switchPreference = (SwitchPreference) preference;
|
||||||
final boolean videoCallEnabled = isVideoCallEnabled(mSubId, mImsManager);
|
final boolean videoCallEnabled = isVideoCallEnabled(mSubId);
|
||||||
switchPreference.setVisible(videoCallEnabled);
|
switchPreference.setVisible(videoCallEnabled);
|
||||||
if (videoCallEnabled) {
|
if (videoCallEnabled) {
|
||||||
final boolean videoCallEditable = queryVoLteState(mSubId).isEnabledByUser()
|
final boolean videoCallEditable = queryVoLteState(mSubId).isEnabledByUser()
|
||||||
@@ -138,53 +131,29 @@ public class VideoCallingPreferenceController extends TelephonyTogglePreferenceC
|
|||||||
|
|
||||||
public VideoCallingPreferenceController init(int subId) {
|
public VideoCallingPreferenceController init(int subId) {
|
||||||
mSubId = subId;
|
mSubId = subId;
|
||||||
if (SubscriptionManager.isValidSubscriptionId(mSubId)) {
|
|
||||||
mImsManager = ImsManager.getInstance(mContext,
|
|
||||||
SubscriptionUtil.getPhoneId(mContext, mSubId));
|
|
||||||
}
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isVideoCallEnabled(int subId) {
|
|
||||||
final ImsManager imsManager = SubscriptionManager.isValidSubscriptionId(subId)
|
|
||||||
? ImsManager.getInstance(mContext, SubscriptionUtil.getPhoneId(mContext, subId))
|
|
||||||
: null;
|
|
||||||
return isVideoCallEnabled(subId, imsManager);
|
|
||||||
}
|
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
ProvisioningManager getProvisioningManager(int subId) {
|
boolean isVideoCallEnabled(int subId) {
|
||||||
return ProvisioningManager.createForSubscriptionId(subId);
|
if (!SubscriptionManager.isValidSubscriptionId(subId)) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isVtProvisionedOnDevice(int subId) {
|
|
||||||
if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final ProvisioningManager provisioningMgr = getProvisioningManager(subId);
|
|
||||||
if (provisioningMgr == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return provisioningMgr.getProvisioningStatusForCapability(
|
|
||||||
MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO,
|
|
||||||
ImsRegistrationImplBase.REGISTRATION_TECH_LTE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
boolean isVideoCallEnabled(int subId, ImsManager imsManager) {
|
|
||||||
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
|
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
|
||||||
TelephonyManager telephonyManager = mContext.getSystemService(TelephonyManager.class);
|
if (carrierConfig == null) {
|
||||||
if (SubscriptionManager.isValidSubscriptionId(subId)) {
|
return false;
|
||||||
telephonyManager = telephonyManager.createForSubscriptionId(subId);
|
|
||||||
}
|
}
|
||||||
return carrierConfig != null && imsManager != null
|
|
||||||
&& imsManager.isVtEnabledByPlatform()
|
if (!carrierConfig.getBoolean(
|
||||||
&& isVtProvisionedOnDevice(subId)
|
|
||||||
&& MobileNetworkUtils.isImsServiceStateReady(imsManager)
|
|
||||||
&& (carrierConfig.getBoolean(
|
|
||||||
CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS)
|
CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS)
|
||||||
|| telephonyManager.isDataEnabled());
|
&& (!mContext.getSystemService(TelephonyManager.class)
|
||||||
|
.createForSubscriptionId(subId).isDataEnabled())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return queryImsState(subId).isReadyToVideoCall();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2020 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.network.ims;
|
||||||
|
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
|
||||||
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
public class MockImsQueryResult {
|
||||||
|
|
||||||
|
public static class BooleanResult implements ImsQuery {
|
||||||
|
private boolean mResult;
|
||||||
|
|
||||||
|
public BooleanResult(boolean result) {
|
||||||
|
super();
|
||||||
|
mResult = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean query() {
|
||||||
|
return mResult;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2020 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.network.ims;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.android.ims.ImsManager;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controller class for mock VT status
|
||||||
|
*/
|
||||||
|
public class MockVtQueryImsState extends VtQueryImsState {
|
||||||
|
|
||||||
|
private ImsQuery mIsTtyOnVolteEnabled;
|
||||||
|
private ImsQuery mIsProvisionedOnDevice;
|
||||||
|
private ImsQuery mIsEnabledByUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param context {@code Context}
|
||||||
|
* @param subId subscription's id
|
||||||
|
*/
|
||||||
|
public MockVtQueryImsState(Context context, int subId) {
|
||||||
|
super(context, subId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImsManager getImsManager(int subId) {
|
||||||
|
return super.getImsManager(subId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsTtyOnVolteEnabled(boolean enabled) {
|
||||||
|
mIsTtyOnVolteEnabled = new MockImsQueryResult.BooleanResult(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
ImsQuery isTtyOnVolteEnabled(int subId) {
|
||||||
|
if (mIsTtyOnVolteEnabled != null) {
|
||||||
|
return mIsTtyOnVolteEnabled;
|
||||||
|
}
|
||||||
|
return super.isTtyOnVolteEnabled(subId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsProvisionedOnDevice(boolean isProvisioned) {
|
||||||
|
mIsProvisionedOnDevice = new MockImsQueryResult.BooleanResult(isProvisioned);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
ImsQuery isProvisionedOnDevice(int subId) {
|
||||||
|
if (mIsProvisionedOnDevice != null) {
|
||||||
|
return mIsProvisionedOnDevice;
|
||||||
|
}
|
||||||
|
return super.isProvisionedOnDevice(subId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsEnabledByUser(boolean enabled) {
|
||||||
|
mIsEnabledByUser = new MockImsQueryResult.BooleanResult(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
ImsQuery isEnabledByUser(int subId) {
|
||||||
|
if (mIsEnabledByUser != null) {
|
||||||
|
return mIsEnabledByUser;
|
||||||
|
}
|
||||||
|
return super.isEnabledByUser(subId);
|
||||||
|
}
|
||||||
|
}
|
@@ -20,7 +20,6 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.eq;
|
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -29,14 +28,13 @@ import android.telephony.CarrierConfigManager;
|
|||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.telephony.ims.ProvisioningManager;
|
import android.telephony.ims.ProvisioningManager;
|
||||||
import android.telephony.ims.feature.ImsFeature;
|
import android.telephony.ims.feature.ImsFeature;
|
||||||
import android.telephony.ims.feature.MmTelFeature;
|
|
||||||
|
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
import androidx.preference.SwitchPreference;
|
import androidx.preference.SwitchPreference;
|
||||||
|
|
||||||
import com.android.ims.ImsManager;
|
import com.android.ims.ImsManager;
|
||||||
|
import com.android.settings.network.ims.MockVtQueryImsState;
|
||||||
import com.android.settings.network.ims.VolteQueryImsState;
|
import com.android.settings.network.ims.VolteQueryImsState;
|
||||||
import com.android.settings.network.ims.VtQueryImsState;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -61,7 +59,7 @@ public class VideoCallingPreferenceControllerTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private PreferenceScreen mPreferenceScreen;
|
private PreferenceScreen mPreferenceScreen;
|
||||||
|
|
||||||
private VtQueryImsState mQueryImsState;
|
private MockVtQueryImsState mQueryImsState;
|
||||||
private VolteQueryImsState mQueryVoLteState;
|
private VolteQueryImsState mQueryVoLteState;
|
||||||
|
|
||||||
private VideoCallingPreferenceController mController;
|
private VideoCallingPreferenceController mController;
|
||||||
@@ -74,7 +72,6 @@ public class VideoCallingPreferenceControllerTest {
|
|||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
|
|
||||||
mContext = spy(RuntimeEnvironment.application);
|
mContext = spy(RuntimeEnvironment.application);
|
||||||
doReturn(mTelephonyManager).when(mContext).getSystemService(Context.TELEPHONY_SERVICE);
|
|
||||||
doReturn(mTelephonyManager).when(mContext).getSystemService(TelephonyManager.class);
|
doReturn(mTelephonyManager).when(mContext).getSystemService(TelephonyManager.class);
|
||||||
doReturn(mCarrierConfigManager).when(mContext)
|
doReturn(mCarrierConfigManager).when(mContext)
|
||||||
.getSystemService(CarrierConfigManager.class);
|
.getSystemService(CarrierConfigManager.class);
|
||||||
@@ -85,29 +82,22 @@ public class VideoCallingPreferenceControllerTest {
|
|||||||
CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS, true);
|
CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS, true);
|
||||||
doReturn(mCarrierConfig).when(mCarrierConfigManager).getConfigForSubId(SUB_ID);
|
doReturn(mCarrierConfig).when(mCarrierConfigManager).getConfigForSubId(SUB_ID);
|
||||||
|
|
||||||
mQueryImsState = spy(new VtQueryImsState(mContext, SUB_ID));
|
mQueryImsState = spy(new MockVtQueryImsState(mContext, SUB_ID));
|
||||||
doReturn(true).when(mQueryImsState).isEnabledByUser();
|
doReturn(true).when(mQueryImsState).isEnabledByUser();
|
||||||
|
doReturn(mImsManager).when(mQueryImsState).getImsManager(anyInt());
|
||||||
|
|
||||||
mQueryVoLteState = spy(new VolteQueryImsState(mContext, SUB_ID));
|
mQueryVoLteState = spy(new VolteQueryImsState(mContext, SUB_ID));
|
||||||
doReturn(true).when(mQueryVoLteState).isEnabledByUser();
|
doReturn(true).when(mQueryVoLteState).isEnabledByUser();
|
||||||
|
|
||||||
mPreference = new SwitchPreference(mContext);
|
mPreference = new SwitchPreference(mContext);
|
||||||
mController = spy(new VideoCallingPreferenceController(mContext, "wifi_calling") {
|
mController = spy(new VideoCallingPreferenceController(mContext, "wifi_calling"));
|
||||||
@Override
|
|
||||||
ProvisioningManager getProvisioningManager(int subId) {
|
|
||||||
return mProvisioningManager;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
mController.init(SUB_ID);
|
mController.init(SUB_ID);
|
||||||
mController.mImsManager = mImsManager;
|
|
||||||
doReturn(mQueryImsState).when(mController).queryImsState(anyInt());
|
doReturn(mQueryImsState).when(mController).queryImsState(anyInt());
|
||||||
doReturn(mQueryVoLteState).when(mController).queryVoLteState(anyInt());
|
doReturn(mQueryVoLteState).when(mController).queryVoLteState(anyInt());
|
||||||
mPreference.setKey(mController.getPreferenceKey());
|
mPreference.setKey(mController.getPreferenceKey());
|
||||||
|
|
||||||
doReturn(true).when(mImsManager).isVtEnabledByPlatform();
|
doReturn(true).when(mImsManager).isVtEnabledByPlatform();
|
||||||
doReturn(true).when(mProvisioningManager)
|
mQueryImsState.setIsProvisionedOnDevice(true);
|
||||||
.getProvisioningStatusForCapability(
|
|
||||||
eq(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO), anyInt());
|
|
||||||
doReturn(ImsFeature.STATE_READY).when(mImsManager).getImsServiceState();
|
doReturn(ImsFeature.STATE_READY).when(mImsManager).getImsServiceState();
|
||||||
doReturn(true).when(mTelephonyManager).isDataEnabled();
|
doReturn(true).when(mTelephonyManager).isDataEnabled();
|
||||||
|
|
||||||
@@ -116,14 +106,15 @@ public class VideoCallingPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isVideoCallEnabled_allFlagsOn_returnTrue() {
|
public void isVideoCallEnabled_allFlagsOn_returnTrue() {
|
||||||
assertThat(mController.isVideoCallEnabled(SUB_ID, mImsManager)).isTrue();
|
assertThat(mController.isVideoCallEnabled(SUB_ID)).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isVideoCallEnabled_disabledByPlatform_returnFalse() {
|
public void isVideoCallEnabled_disabledByPlatform_returnFalse() {
|
||||||
|
mQueryImsState.setIsProvisionedOnDevice(false);
|
||||||
doReturn(false).when(mImsManager).isVtEnabledByPlatform();
|
doReturn(false).when(mImsManager).isVtEnabledByPlatform();
|
||||||
|
|
||||||
assertThat(mController.isVideoCallEnabled(SUB_ID, mImsManager)).isFalse();
|
assertThat(mController.isVideoCallEnabled(SUB_ID)).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -132,7 +123,7 @@ public class VideoCallingPreferenceControllerTest {
|
|||||||
CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS, false);
|
CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS, false);
|
||||||
doReturn(false).when(mTelephonyManager).isDataEnabled();
|
doReturn(false).when(mTelephonyManager).isDataEnabled();
|
||||||
|
|
||||||
assertThat(mController.isVideoCallEnabled(SUB_ID, mImsManager)).isFalse();
|
assertThat(mController.isVideoCallEnabled(SUB_ID)).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user