Don't perform entitlement checks on invalid subscription IDs
Bug: 414252282 Test: TH Flag: EXEMPT bugfix Change-Id: I9bd208cf9e59bcfad03108c85dd7bfeb10aeff56
This commit is contained in:
parent
4e4f2e6da6
commit
bf34d61b8d
2 changed files with 23 additions and 6 deletions
|
|
@ -110,6 +110,7 @@ public final class EntitlementManagerTest {
|
|||
private static final String TEST_PACKAGE_NAME = "com.android.tethering.test";
|
||||
private static final String FAILED_TETHERING_REASON = "Tethering provisioning failed.";
|
||||
private static final int RECHECK_TIMER_HOURS = 24;
|
||||
private static final int TEST_SUBID = 1;
|
||||
|
||||
@Mock private CarrierConfigManager mCarrierConfigManager;
|
||||
@Mock private Context mContext;
|
||||
|
|
@ -326,7 +327,7 @@ public final class EntitlementManagerTest {
|
|||
when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(mCarrierConfig);
|
||||
mCarrierConfig.putBoolean(CarrierConfigManager.KEY_REQUIRE_ENTITLEMENT_CHECKS_BOOL, true);
|
||||
mCarrierConfig.putBoolean(CarrierConfigManager.KEY_CARRIER_CONFIG_APPLIED_BOOL, true);
|
||||
mConfig = new FakeTetheringConfiguration(mMockContext, mLog, INVALID_SUBSCRIPTION_ID);
|
||||
mConfig = new FakeTetheringConfiguration(mMockContext, mLog, TEST_SUBID);
|
||||
}
|
||||
|
||||
private void setupCarrierConfig(boolean carrierSupported) {
|
||||
|
|
@ -349,14 +350,24 @@ public final class EntitlementManagerTest {
|
|||
setupForRequiredProvisioning();
|
||||
when(mResources.getStringArray(R.array.config_mobile_hotspot_provision_app))
|
||||
.thenReturn(null);
|
||||
mConfig = new FakeTetheringConfiguration(mMockContext, mLog, INVALID_SUBSCRIPTION_ID);
|
||||
mConfig = new FakeTetheringConfiguration(mMockContext, mLog, TEST_SUBID);
|
||||
assertFalse(mEnMgr.isTetherProvisioningRequired(mConfig));
|
||||
when(mResources.getStringArray(R.array.config_mobile_hotspot_provision_app))
|
||||
.thenReturn(new String[] {"malformedApp"});
|
||||
mConfig = new FakeTetheringConfiguration(mMockContext, mLog, INVALID_SUBSCRIPTION_ID);
|
||||
mConfig = new FakeTetheringConfiguration(mMockContext, mLog, TEST_SUBID);
|
||||
assertFalse(mEnMgr.isTetherProvisioningRequired(mConfig));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void provisioningNotRequiredAfterSwitchToInvalidSubId() {
|
||||
setupForRequiredProvisioning();
|
||||
assertTrue(mEnMgr.isTetherProvisioningRequired(mConfig));
|
||||
|
||||
final TetheringConfiguration config = new FakeTetheringConfiguration(mMockContext, mLog,
|
||||
INVALID_SUBSCRIPTION_ID);
|
||||
assertFalse(mEnMgr.isTetherProvisioningRequired(config));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRequestLastEntitlementCacheValue() throws Exception {
|
||||
// 1. Entitlement check is not required.
|
||||
|
|
@ -759,7 +770,7 @@ public final class EntitlementManagerTest {
|
|||
mEnMgr.notifyUpstream(false);
|
||||
mLooper.dispatchAll();
|
||||
setupCarrierConfig(false);
|
||||
mConfig = new FakeTetheringConfiguration(mMockContext, mLog, INVALID_SUBSCRIPTION_ID);
|
||||
mConfig = new FakeTetheringConfiguration(mMockContext, mLog, TEST_SUBID);
|
||||
mEnMgr.reevaluateSimCardProvisioning(mConfig);
|
||||
|
||||
// Turn on upstream.
|
||||
|
|
@ -799,7 +810,7 @@ public final class EntitlementManagerTest {
|
|||
setupCarrierConfig(false);
|
||||
when(mResources.getStringArray(R.array.config_mobile_hotspot_provision_app))
|
||||
.thenReturn(new String[0]);
|
||||
mConfig = new FakeTetheringConfiguration(mMockContext, mLog, INVALID_SUBSCRIPTION_ID);
|
||||
mConfig = new FakeTetheringConfiguration(mMockContext, mLog, TEST_SUBID);
|
||||
|
||||
if (SdkLevel.isAtLeastT()) {
|
||||
assertTrue(mEnMgr.isTetherProvisioningRequired(mConfig));
|
||||
|
|
|
|||
|
|
@ -294,6 +294,7 @@ public class TetheringTest {
|
|||
private static final int CELLULAR_NETID = 100;
|
||||
private static final int WIFI_NETID = 101;
|
||||
private static final int DUN_NETID = 102;
|
||||
private static final int TEST_SUBID = 1;
|
||||
|
||||
private static final int TETHER_USB_RNDIS_NCM_FUNCTIONS = 2;
|
||||
|
||||
|
|
@ -3531,6 +3532,7 @@ public class TetheringTest {
|
|||
@Test
|
||||
public void testExemptFromEntitlementCheck() throws Exception {
|
||||
initTetheringOnTestThread();
|
||||
mPhoneStateListener.onActiveDataSubscriptionIdChanged(TEST_SUBID);
|
||||
setupForRequiredProvisioning();
|
||||
final TetheringRequest wifiNotExemptRequest =
|
||||
createTetheringRequest(TETHERING_WIFI, null, null, false,
|
||||
|
|
@ -3566,6 +3568,7 @@ public class TetheringTest {
|
|||
// requests of the same type that are subject to carrier entitlement due to fuzzy-matching.
|
||||
mTetheringWithSoftApConfigEnabled = false;
|
||||
initTetheringOnTestThread();
|
||||
mPhoneStateListener.onActiveDataSubscriptionIdChanged(TEST_SUBID);
|
||||
setupForRequiredProvisioning();
|
||||
final TetheringRequest wifiExemptRequest =
|
||||
createTetheringRequest(TETHERING_WIFI, null, null, true,
|
||||
|
|
@ -3727,6 +3730,7 @@ public class TetheringTest {
|
|||
@Test
|
||||
public void testProvisioningNeededButUnavailable() throws Exception {
|
||||
initTetheringOnTestThread();
|
||||
mPhoneStateListener.onActiveDataSubscriptionIdChanged(TEST_SUBID);
|
||||
assertTrue(mTethering.isTetheringSupported());
|
||||
verify(mPackageManager, never()).getPackageInfo(PROVISIONING_APP_NAME[0], GET_ACTIVITIES);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue