Merge "[Settings] Add ImsQueryProvisioningStat for VT"
This commit is contained in:
@@ -16,6 +16,10 @@
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
@@ -23,8 +27,38 @@ import androidx.annotation.VisibleForTesting;
|
||||
*/
|
||||
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
|
||||
ImsQuery isTtyOnVolteEnabled(int 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.telecom.TelecomManager;
|
||||
import android.telephony.AccessNetworkConstants;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.ims.feature.MmTelFeature;
|
||||
import android.telephony.ims.stub.ImsRegistrationImplBase;
|
||||
|
||||
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 Volte status
|
||||
@@ -41,10 +44,52 @@ public class VolteQueryImsState extends ImsQueryController {
|
||||
* @param subId subscription's id
|
||||
*/
|
||||
public VolteQueryImsState(Context context, int subId) {
|
||||
super(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
|
||||
ImsRegistrationImplBase.REGISTRATION_TECH_LTE,
|
||||
AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
|
||||
mContext = context;
|
||||
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
|
||||
*
|
||||
@@ -74,8 +119,6 @@ public class VolteQueryImsState extends ImsQueryController {
|
||||
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
|
||||
return false;
|
||||
}
|
||||
ImsManager imsManager = ImsManager.getInstance(mContext, SubscriptionUtil.getPhoneId(
|
||||
mContext, mSubId));
|
||||
return imsManager.isEnhanced4gLteModeSettingEnabledByUser();
|
||||
return isEnabledByUser(mSubId).query();
|
||||
}
|
||||
}
|
||||
|
@@ -18,10 +18,17 @@ package com.android.settings.network.ims;
|
||||
|
||||
import android.content.Context;
|
||||
import android.telecom.TelecomManager;
|
||||
import android.telephony.AccessNetworkConstants;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.ims.feature.MmTelFeature;
|
||||
import android.telephony.ims.stub.ImsRegistrationImplBase;
|
||||
|
||||
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
|
||||
*/
|
||||
@@ -37,6 +44,9 @@ public class VtQueryImsState extends ImsQueryController {
|
||||
* @param subId subscription's id
|
||||
*/
|
||||
public VtQueryImsState(Context context, int subId) {
|
||||
super(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO,
|
||||
ImsRegistrationImplBase.REGISTRATION_TECH_LTE,
|
||||
AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
|
||||
mContext = context;
|
||||
mSubId = subId;
|
||||
}
|
||||
@@ -49,6 +59,28 @@ public class VtQueryImsState extends ImsQueryController {
|
||||
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
|
||||
*
|
||||
|
@@ -37,6 +37,7 @@ public class WifiCallingQueryImsState extends ImsQueryController {
|
||||
* @param subId subscription's id
|
||||
*/
|
||||
public WifiCallingQueryImsState(Context context, int subId) {
|
||||
super();
|
||||
mContext = context;
|
||||
mSubId = subId;
|
||||
}
|
||||
|
@@ -23,9 +23,6 @@ import android.telephony.PhoneStateListener;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
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 androidx.annotation.VisibleForTesting;
|
||||
@@ -33,9 +30,7 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.android.ims.ImsManager;
|
||||
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.VtQueryImsState;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
@@ -54,8 +49,6 @@ public class VideoCallingPreferenceController extends TelephonyTogglePreferenceC
|
||||
|
||||
private Preference mPreference;
|
||||
private CarrierConfigManager mCarrierConfigManager;
|
||||
@VisibleForTesting
|
||||
ImsManager mImsManager;
|
||||
private PhoneCallStateListener mPhoneStateListener;
|
||||
@VisibleForTesting
|
||||
Integer mCallState;
|
||||
@@ -101,7 +94,7 @@ public class VideoCallingPreferenceController extends TelephonyTogglePreferenceC
|
||||
return;
|
||||
}
|
||||
final SwitchPreference switchPreference = (SwitchPreference) preference;
|
||||
final boolean videoCallEnabled = isVideoCallEnabled(mSubId, mImsManager);
|
||||
final boolean videoCallEnabled = isVideoCallEnabled(mSubId);
|
||||
switchPreference.setVisible(videoCallEnabled);
|
||||
if (videoCallEnabled) {
|
||||
final boolean videoCallEditable = queryVoLteState(mSubId).isEnabledByUser()
|
||||
@@ -138,53 +131,29 @@ public class VideoCallingPreferenceController extends TelephonyTogglePreferenceC
|
||||
|
||||
public VideoCallingPreferenceController init(int subId) {
|
||||
mSubId = subId;
|
||||
if (SubscriptionManager.isValidSubscriptionId(mSubId)) {
|
||||
mImsManager = ImsManager.getInstance(mContext,
|
||||
SubscriptionUtil.getPhoneId(mContext, mSubId));
|
||||
}
|
||||
|
||||
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
|
||||
ProvisioningManager getProvisioningManager(int subId) {
|
||||
return ProvisioningManager.createForSubscriptionId(subId);
|
||||
boolean isVideoCallEnabled(int 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);
|
||||
TelephonyManager telephonyManager = mContext.getSystemService(TelephonyManager.class);
|
||||
if (SubscriptionManager.isValidSubscriptionId(subId)) {
|
||||
telephonyManager = telephonyManager.createForSubscriptionId(subId);
|
||||
if (carrierConfig == null) {
|
||||
return false;
|
||||
}
|
||||
return carrierConfig != null && imsManager != null
|
||||
&& imsManager.isVtEnabledByPlatform()
|
||||
&& isVtProvisionedOnDevice(subId)
|
||||
&& MobileNetworkUtils.isImsServiceStateReady(imsManager)
|
||||
&& (carrierConfig.getBoolean(
|
||||
|
||||
if (!carrierConfig.getBoolean(
|
||||
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
|
||||
|
@@ -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.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.eq;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
||||
import android.content.Context;
|
||||
@@ -29,14 +28,13 @@ import android.telephony.CarrierConfigManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.telephony.ims.ProvisioningManager;
|
||||
import android.telephony.ims.feature.ImsFeature;
|
||||
import android.telephony.ims.feature.MmTelFeature;
|
||||
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
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.VtQueryImsState;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -61,7 +59,7 @@ public class VideoCallingPreferenceControllerTest {
|
||||
@Mock
|
||||
private PreferenceScreen mPreferenceScreen;
|
||||
|
||||
private VtQueryImsState mQueryImsState;
|
||||
private MockVtQueryImsState mQueryImsState;
|
||||
private VolteQueryImsState mQueryVoLteState;
|
||||
|
||||
private VideoCallingPreferenceController mController;
|
||||
@@ -74,7 +72,6 @@ public class VideoCallingPreferenceControllerTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
doReturn(mTelephonyManager).when(mContext).getSystemService(Context.TELEPHONY_SERVICE);
|
||||
doReturn(mTelephonyManager).when(mContext).getSystemService(TelephonyManager.class);
|
||||
doReturn(mCarrierConfigManager).when(mContext)
|
||||
.getSystemService(CarrierConfigManager.class);
|
||||
@@ -85,29 +82,22 @@ public class VideoCallingPreferenceControllerTest {
|
||||
CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS, true);
|
||||
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(mImsManager).when(mQueryImsState).getImsManager(anyInt());
|
||||
|
||||
mQueryVoLteState = spy(new VolteQueryImsState(mContext, SUB_ID));
|
||||
doReturn(true).when(mQueryVoLteState).isEnabledByUser();
|
||||
|
||||
mPreference = new SwitchPreference(mContext);
|
||||
mController = spy(new VideoCallingPreferenceController(mContext, "wifi_calling") {
|
||||
@Override
|
||||
ProvisioningManager getProvisioningManager(int subId) {
|
||||
return mProvisioningManager;
|
||||
}
|
||||
});
|
||||
mController = spy(new VideoCallingPreferenceController(mContext, "wifi_calling"));
|
||||
mController.init(SUB_ID);
|
||||
mController.mImsManager = mImsManager;
|
||||
doReturn(mQueryImsState).when(mController).queryImsState(anyInt());
|
||||
doReturn(mQueryVoLteState).when(mController).queryVoLteState(anyInt());
|
||||
mPreference.setKey(mController.getPreferenceKey());
|
||||
|
||||
doReturn(true).when(mImsManager).isVtEnabledByPlatform();
|
||||
doReturn(true).when(mProvisioningManager)
|
||||
.getProvisioningStatusForCapability(
|
||||
eq(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO), anyInt());
|
||||
mQueryImsState.setIsProvisionedOnDevice(true);
|
||||
doReturn(ImsFeature.STATE_READY).when(mImsManager).getImsServiceState();
|
||||
doReturn(true).when(mTelephonyManager).isDataEnabled();
|
||||
|
||||
@@ -116,14 +106,15 @@ public class VideoCallingPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void isVideoCallEnabled_allFlagsOn_returnTrue() {
|
||||
assertThat(mController.isVideoCallEnabled(SUB_ID, mImsManager)).isTrue();
|
||||
assertThat(mController.isVideoCallEnabled(SUB_ID)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isVideoCallEnabled_disabledByPlatform_returnFalse() {
|
||||
mQueryImsState.setIsProvisionedOnDevice(false);
|
||||
doReturn(false).when(mImsManager).isVtEnabledByPlatform();
|
||||
|
||||
assertThat(mController.isVideoCallEnabled(SUB_ID, mImsManager)).isFalse();
|
||||
assertThat(mController.isVideoCallEnabled(SUB_ID)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -132,7 +123,7 @@ public class VideoCallingPreferenceControllerTest {
|
||||
CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS, false);
|
||||
doReturn(false).when(mTelephonyManager).isDataEnabled();
|
||||
|
||||
assertThat(mController.isVideoCallEnabled(SUB_ID, mImsManager)).isFalse();
|
||||
assertThat(mController.isVideoCallEnabled(SUB_ID)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user