Snap for 8712302 from 3865c72f0f0aff56ed684a4988c8ca3106d9e5f6 to tm-frc-odp-release
Change-Id: I94e7c4edf4b26f5a82849dd90662cecfe3fadd0c
diff --git a/src/java/com/android/internal/telephony/SubscriptionController.java b/src/java/com/android/internal/telephony/SubscriptionController.java
index 24a8dfb..7e762d7 100644
--- a/src/java/com/android/internal/telephony/SubscriptionController.java
+++ b/src/java/com/android/internal/telephony/SubscriptionController.java
@@ -28,9 +28,6 @@
import android.annotation.Nullable;
import android.app.AppOpsManager;
import android.app.PendingIntent;
-import android.app.compat.CompatChanges;
-import android.compat.annotation.ChangeId;
-import android.compat.annotation.EnabledSince;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.ContentResolver;
import android.content.ContentValues;
@@ -170,15 +167,6 @@
// Allows test mocks to avoid SELinux failures on invalidate calls.
private static boolean sCachingEnabled = true;
- /**
- * Apps targeting on Android T and beyond will get exception if there is no
- * {@link Manifest.permission#USE_ICC_AUTH_WITH_DEVICE_IDENTIFIER} permission
- * when calling SubscriptionManager#getSubscriptionsInGroup.
- */
- @ChangeId
- @EnabledSince(targetSdkVersion = Build.VERSION_CODES.TIRAMISU)
- public static final long REQUIRE_ICC_AUTH_DEVICE_IDENTIFIERS_FOR_GROUP_UUID = 213902861L;
-
// Each slot can have multiple subs.
private static class WatchedSlotIndexToSubIds {
private Map<Integer, ArrayList<Integer>> mSlotIndexToSubIds = new ConcurrentHashMap<>();
@@ -473,11 +461,10 @@
/**
* Returns whether the {@code callingPackage} has access to subscriber identifiers on the
* specified {@code subId} using the provided {@code message} in any resulting
- * SecurityException. {@code throwException} flag to indicate if throw exception.
+ * SecurityException.
*/
private boolean hasSubscriberIdentifierAccess(int subId, String callingPackage,
- String callingFeatureId, String message, boolean reportFailure,
- boolean throwException) {
+ String callingFeatureId, String message, boolean reportFailure) {
try {
return TelephonyPermissions.checkCallingOrSelfReadSubscriberIdentifiers(mContext, subId,
callingPackage, callingFeatureId, message, reportFailure);
@@ -485,9 +472,6 @@
// A SecurityException indicates that the calling package is targeting at least the
// minimum level that enforces identifier access restrictions and the new access
// requirements are not met.
- if (throwException) {
- throw e;
- }
return false;
}
}
@@ -3976,21 +3960,10 @@
* Get subscriptionInfo list of subscriptions that are in the same group of given subId.
* See {@link #createSubscriptionGroup(int[], String)} for more details.
*
- * Caller must have {@link android.Manifest.permission#READ_PHONE_STATE}
- * or carrier privilege permission on the subscription.
+ * Caller will either have {@link android.Manifest.permission#READ_PHONE_STATE}
+ * permission or had carrier privilege permission on the subscription.
* {@link TelephonyManager#hasCarrierPrivileges(int)}
*
- * <p>Starting with API level 33, the caller needs the additional permission
- * {@link Manifest.permission#USE_ICC_AUTH_WITH_DEVICE_IDENTIFIER}
- * to get the list of subscriptions associated with a group UUID.
- * This method can be invoked if one of the following requirements is met:
- * <ul>
- * <li>If the app has carrier privilege permission.
- * {@link TelephonyManager#hasCarrierPrivileges()}
- * <li>If the app has {@link android.Manifest.permission#READ_PHONE_STATE} and
- * {@link Manifest.permission#USE_ICC_AUTH_WITH_DEVICE_IDENTIFIER} permission.
- * </ul>
- *
* @throws SecurityException if the caller doesn't meet the requirements
* outlined above.
*
@@ -4018,29 +3991,15 @@
}
return subInfoList.stream().filter(info -> {
- int subId = info.getSubscriptionId();
- boolean permission = checkPermissionForGroupUuid(subId, callingPackage,
- callingFeatureId, Binder.getCallingUid());
if (!groupUuid.equals(info.getGroupUuid())) return false;
- return permission || info.canManageSubscription(mContext, callingPackage);
+ int subId = info.getSubscriptionId();
+ return TelephonyPermissions.checkCallingOrSelfReadPhoneState(mContext, subId,
+ callingPackage, callingFeatureId, "getSubscriptionsInGroup")
+ || info.canManageSubscription(mContext, callingPackage);
}).map(subscriptionInfo -> conditionallyRemoveIdentifiers(subscriptionInfo,
callingPackage, callingFeatureId, "getSubscriptionsInGroup"))
.collect(Collectors.toList());
- }
- private boolean checkPermissionForGroupUuid(int subId, String callingPackage,
- String callingFeatureId, int uid) {
- if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(mContext, subId,
- callingPackage, callingFeatureId, "getSubscriptionsInGroup")) {
- return false;
- }
-
- if (CompatChanges.isChangeEnabled(
- REQUIRE_ICC_AUTH_DEVICE_IDENTIFIERS_FOR_GROUP_UUID, uid)) {
- return hasSubscriberIdentifierAccess(subId, callingPackage,
- callingFeatureId, "getSubscriptionsInGroup", true, true);
- }
- return true;
}
/**
@@ -4354,7 +4313,7 @@
if (canReadPhoneState) {
canReadIdentifiers = hasSubscriberIdentifierAccess(
SubscriptionManager.INVALID_SUBSCRIPTION_ID, callingPackage,
- callingFeatureId, "getSubscriptionInfoList", false, false);
+ callingFeatureId, "getSubscriptionInfoList", false);
canReadPhoneNumber = hasPhoneNumberAccess(
SubscriptionManager.INVALID_SUBSCRIPTION_ID, callingPackage,
callingFeatureId, "getSubscriptionInfoList");
@@ -4406,7 +4365,7 @@
SubscriptionInfo result = subInfo;
int subId = subInfo.getSubscriptionId();
boolean hasIdentifierAccess = hasSubscriberIdentifierAccess(subId, callingPackage,
- callingFeatureId, message, true, false);
+ callingFeatureId, message, true);
boolean hasPhoneNumberAccess = hasPhoneNumberAccess(subId, callingPackage, callingFeatureId,
message);
return conditionallyRemoveIdentifiers(subInfo, hasIdentifierAccess, hasPhoneNumberAccess);
diff --git a/src/java/com/android/internal/telephony/data/DataNetwork.java b/src/java/com/android/internal/telephony/data/DataNetwork.java
index 85a96fc..f85bc13 100644
--- a/src/java/com/android/internal/telephony/data/DataNetwork.java
+++ b/src/java/com/android/internal/telephony/data/DataNetwork.java
@@ -231,12 +231,6 @@
/** Event for CSS indicator changed. */
private static final int EVENT_CSS_INDICATOR_CHANGED = 24;
- /** The default MTU for IPv4 network. */
- private static final int DEFAULT_MTU_V4 = 1280;
-
- /** The default MTU for IPv6 network. */
- private static final int DEFAULT_MTU_V6 = 1280;
-
/** Invalid context id. */
private static final int INVALID_CID = -1;
@@ -2220,7 +2214,7 @@
mtuV4 = mDataProfile.getApnSetting().getMtuV4();
}
if (mtuV4 <= 0) {
- mtuV4 = DEFAULT_MTU_V4;
+ mtuV4 = mDataConfigManager.getDefaultMtu();
}
}
@@ -2232,7 +2226,7 @@
mtuV6 = mDataProfile.getApnSetting().getMtuV6();
}
if (mtuV6 <= 0) {
- mtuV6 = DEFAULT_MTU_V6;
+ mtuV6 = mDataConfigManager.getDefaultMtu();
}
}
diff --git a/src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java b/src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java
index ac2398c..cc8af38 100644
--- a/src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java
+++ b/src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java
@@ -506,6 +506,8 @@
PENDING_RESUME_FOREGROUND_AFTER_FAILURE,
// Pending holding a call to dial another outgoing call
HOLDING_TO_DIAL_OUTGOING,
+ // Pending resuming the foreground call after it has completed an ongoing hold operation.
+ PENDING_RESUME_FOREGROUND_AFTER_HOLD
}
//***** Instance Variables
@@ -2068,9 +2070,15 @@
//they were switched before holding
ImsCall imsCall = mForegroundCall.getImsCall();
if (imsCall != null) {
- imsCall.resume();
- mMetrics.writeOnImsCommand(mPhone.getPhoneId(), imsCall.getSession(),
- ImsCommand.IMS_CMD_RESUME);
+ if (!imsCall.isPendingHold()) {
+ imsCall.resume();
+ mMetrics.writeOnImsCommand(mPhone.getPhoneId(), imsCall.getSession(),
+ ImsCommand.IMS_CMD_RESUME);
+ } else {
+ mHoldSwitchingState =
+ HoldSwapState.PENDING_RESUME_FOREGROUND_AFTER_HOLD;
+ logHoldSwapState("resumeForegroundCall - unhold pending; resume request again");
+ }
}
}
@@ -3449,7 +3457,12 @@
// processCallStateChange above may have caused the mBackgroundCall and
// mForegroundCall references below to change meaning. Watch out for this if you
// are reading through this code.
- if (oldState == ImsPhoneCall.State.ACTIVE) {
+ if (mHoldSwitchingState
+ == HoldSwapState.PENDING_RESUME_FOREGROUND_AFTER_HOLD) {
+ sendEmptyMessage(EVENT_RESUME_NOW_FOREGROUND_CALL);
+ mHoldSwitchingState = HoldSwapState.INACTIVE;
+ mCallExpectedToResume = null;
+ } else if (oldState == ImsPhoneCall.State.ACTIVE) {
// Note: This case comes up when we have just held a call in response to a
// switchWaitingOrHoldingAndActive. We now need to resume the background call.
if (mForegroundCall.getState() == ImsPhoneCall.State.HOLDING
@@ -3494,7 +3507,10 @@
synchronized (mSyncHold) {
ImsPhoneCall.State bgState = mBackgroundCall.getState();
- if (reasonInfo.getCode() == ImsReasonInfo.CODE_LOCAL_CALL_TERMINATED) {
+ if (mHoldSwitchingState
+ == HoldSwapState.PENDING_RESUME_FOREGROUND_AFTER_HOLD) {
+ mHoldSwitchingState = HoldSwapState.INACTIVE;
+ } else if (reasonInfo.getCode() == ImsReasonInfo.CODE_LOCAL_CALL_TERMINATED) {
// disconnected while processing hold
if (mPendingMO != null) {
dialPendingMO();
@@ -4591,6 +4607,9 @@
case HOLDING_TO_DIAL_OUTGOING:
holdSwapState = "HOLDING_TO_DIAL_OUTGOING";
break;
+ case PENDING_RESUME_FOREGROUND_AFTER_HOLD:
+ holdSwapState = "PENDING_RESUME_FOREGROUND_AFTER_HOLD";
+ break;
}
logi("holdSwapState set to " + holdSwapState + " at " + loc);
}
diff --git a/tests/telephonytests/src/com/android/internal/telephony/SubscriptionControllerTest.java b/tests/telephonytests/src/com/android/internal/telephony/SubscriptionControllerTest.java
index 14e58c7..6a4c9c2 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/SubscriptionControllerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/SubscriptionControllerTest.java
@@ -17,7 +17,6 @@
import static android.telephony.TelephonyManager.SET_OPPORTUNISTIC_SUB_REMOTE_SERVICE_EXCEPTION;
-import static com.android.internal.telephony.SubscriptionController.REQUIRE_ICC_AUTH_DEVICE_IDENTIFIERS_FOR_GROUP_UUID;
import static com.android.internal.telephony.uicc.IccCardStatus.CardState.CARDSTATE_PRESENT;
import static org.junit.Assert.assertEquals;
@@ -34,9 +33,7 @@
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.atLeast;
-import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
@@ -44,7 +41,6 @@
import static org.mockito.Mockito.when;
import android.Manifest;
-import android.compat.testing.PlatformCompatChangeRule;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Intent;
@@ -72,14 +68,9 @@
import com.android.internal.telephony.uicc.UiccController;
import com.android.internal.telephony.uicc.UiccSlot;
-import libcore.junit.util.compat.CoreCompatChangeRule.DisableCompatChanges;
-import libcore.junit.util.compat.CoreCompatChangeRule.EnableCompatChanges;
-
import org.junit.After;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.TestRule;
import org.mockito.ArgumentCaptor;
import java.util.ArrayList;
@@ -117,9 +108,6 @@
private static final String DISPLAY_NUMBER = "123456";
private static final String DISPLAY_NAME = "testing_display_name";
- @Rule
- public TestRule mCompatChangeRule = new PlatformCompatChangeRule();
-
@Before
public void setUp() throws Exception {
super.setUp(getClass().getSimpleName());
@@ -1111,7 +1099,6 @@
@Test
@SmallTest
- @EnableCompatChanges({REQUIRE_ICC_AUTH_DEVICE_IDENTIFIERS_FOR_GROUP_UUID})
public void testAddSubscriptionIntoGroupWithCarrierPrivilegePermission() throws Exception {
testInsertSim();
// Adding a second profile and mark as embedded.
@@ -1163,7 +1150,6 @@
@Test
@SmallTest
- @EnableCompatChanges({REQUIRE_ICC_AUTH_DEVICE_IDENTIFIERS_FOR_GROUP_UUID})
public void testUpdateSubscriptionGroupWithCarrierPrivilegePermission() throws Exception {
testInsertSim();
// Adding a second profile and mark as embedded.
@@ -1285,7 +1271,6 @@
@Test
@SmallTest
- @EnableCompatChanges({REQUIRE_ICC_AUTH_DEVICE_IDENTIFIERS_FOR_GROUP_UUID})
public void testSetSubscriptionGroup() throws Exception {
testInsertSim();
// Adding a second profile and mark as embedded.
@@ -1720,9 +1705,26 @@
}
@Test
- @DisableCompatChanges({REQUIRE_ICC_AUTH_DEVICE_IDENTIFIERS_FOR_GROUP_UUID})
+ public void testGetSubscriptionsInGroupWithNoPermission() throws Exception {
+ // If the calling package does not have the READ_PHONE_STATE permission or carrier
+ // privileges then getSubscriptionsInGroup should throw a SecurityException when the
+ // READ_PHONE_STATE permission check is performed.
+ ParcelUuid groupUuid = setupGetSubscriptionsInGroupTest();
+ mContextFixture.removeCallingOrSelfPermission(ContextFixture.PERMISSION_ENABLE_ALL);
+
+ try {
+ mSubscriptionControllerUT.getSubscriptionsInGroup(groupUuid, mCallingPackage,
+ mCallingFeature);
+ fail("getSubscriptionsInGroup should fail when invoked with no permissions");
+ } catch (SecurityException expected) {
+ }
+ }
+
+ @Test
public void testGetSubscriptionsInGroupWithReadPhoneState() throws Exception {
- // For backward compatibility test
+ // If the calling package only has the READ_PHONE_STATE permission then
+ // getSubscriptionsInGroup should still return the list of SubscriptionInfo objects
+ // but the ICC ID should not be available via getIccId or getCardString.
ParcelUuid groupUuid = setupGetSubscriptionsInGroupTest();
setupReadPhoneNumbersTest();
setIdentifierAccess(false);
@@ -1739,62 +1741,6 @@
}
@Test
- @EnableCompatChanges({REQUIRE_ICC_AUTH_DEVICE_IDENTIFIERS_FOR_GROUP_UUID})
- public void testGetSubscriptionsInGroupWithoutAppropriatePermission() throws Exception {
- ParcelUuid groupUuid = setupGetSubscriptionsInGroupTest();
-
- // no permission
- setNoPermission();
- try {
- mSubscriptionControllerUT.getSubscriptionsInGroup(groupUuid, mCallingPackage,
- mCallingFeature);
- fail("getSubscriptionsInGroup should fail when invoked with no permissions");
- } catch (SecurityException expected) {
- }
-
- // only has the USE_ICC_AUTH_WITH_DEVICE_IDENTIFIER permission
- setIdentifierAccess(true);
- try {
- mSubscriptionControllerUT.getSubscriptionsInGroup(groupUuid, mCallingPackage,
- mCallingFeature);
- fail("getSubscriptionsInGroup should fail when invoked with no"
- + "READ_PHONE_STATE permissions");
- } catch (SecurityException expected) {
- }
-
- // only has the READ_PHONE_STATE permission
- setIdentifierAccess(false);
- setReadPhoneState();
- try {
- mSubscriptionControllerUT.getSubscriptionsInGroup(groupUuid, mCallingPackage,
- mCallingFeature);
- fail("getSubscriptionsInGroup should fail when invoked with no "
- + "USE_ICC_AUTH_WITH_DEVICE_IDENTIFIER permissions");
- } catch (SecurityException expected) {
- }
- }
-
- @Test
- @EnableCompatChanges({REQUIRE_ICC_AUTH_DEVICE_IDENTIFIERS_FOR_GROUP_UUID})
- public void testGetSubscriptionsInGroupWithReadDeviceIdentifier() throws Exception {
- ParcelUuid groupUuid = setupGetSubscriptionsInGroupTest();
- setNoPermission();
- setCarrierPrivileges(false);
- setIdentifierAccess(true);
- setReadPhoneState();
-
- List<SubscriptionInfo> subInfoList = mSubscriptionControllerUT.getSubscriptionsInGroup(
- groupUuid, mCallingPackage, mCallingFeature);
-
- assertTrue(subInfoList.size() > 0);
- for (SubscriptionInfo info : subInfoList) {
- assertTrue(info.getIccId().length() > 0);
- assertTrue(info.getCardString().length() > 0);
- }
- }
-
- @Test
- @EnableCompatChanges({REQUIRE_ICC_AUTH_DEVICE_IDENTIFIERS_FOR_GROUP_UUID})
public void testGetSubscriptionInGroupWithPhoneNumberAccess() throws Exception {
// If the calling package meets any of the requirements for the
// LegacyPermissionManager#checkPhoneNumberAccess test then the number should be available
@@ -1812,7 +1758,6 @@
}
@Test
- @EnableCompatChanges({REQUIRE_ICC_AUTH_DEVICE_IDENTIFIERS_FOR_GROUP_UUID})
public void testGetSubscriptionsInGroupWithCarrierPrivileges() throws Exception {
// If the calling package has the READ_PRIVILEGED_PHONE_STATE permission or carrier
// privileges the ICC ID should be available in the SubscriptionInfo objects in the List.
@@ -1830,7 +1775,6 @@
}
@Test
- @EnableCompatChanges({REQUIRE_ICC_AUTH_DEVICE_IDENTIFIERS_FOR_GROUP_UUID})
public void testGetSubscriptionsInGroupWithPrivilegedPermission() throws Exception {
// If the calling package has the READ_PRIVILEGED_PHONE_STATE permission or carrier
// privileges the ICC ID should be available in the SubscriptionInfo objects in the List.
@@ -2110,14 +2054,4 @@
assertTrue(mSubscriptionControllerUT.checkPhoneIdAndIccIdMatch(0, "test2"));
assertFalse(mSubscriptionControllerUT.checkPhoneIdAndIccIdMatch(0, "test3"));
}
-
- private void setNoPermission() {
- doThrow(new SecurityException()).when(mContext)
- .enforcePermission(anyString(), anyInt(), anyInt(), anyString());
- }
-
- private void setReadPhoneState() {
- doNothing().when(mContext).enforcePermission(
- eq(android.Manifest.permission.READ_PHONE_STATE), anyInt(), anyInt(), anyString());
- }
}
diff --git a/tests/telephonytests/src/com/android/internal/telephony/data/DataNetworkTest.java b/tests/telephonytests/src/com/android/internal/telephony/data/DataNetworkTest.java
index 09371d6..f53298d 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/data/DataNetworkTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/data/DataNetworkTest.java
@@ -102,6 +102,8 @@
private static final int ADMIN_UID1 = 1234;
private static final int ADMIN_UID2 = 5678;
+ private static final int DEFAULT_MTU = 1501;
+
private static final String FAKE_IMSI = "123456789";
private DataNetwork mDataNetworkUT;
@@ -218,7 +220,6 @@
InetAddresses.parseNumericAddress("fd00:976a:c202:1d::7"),
InetAddresses.parseNumericAddress("fd00:976a:c305:1d::5")))
.setMtuV4(1234)
- .setMtuV6(5678)
.setPduSessionId(1)
.setQosBearerSessions(new ArrayList<>())
.setTrafficDescriptors(tds)
@@ -318,6 +319,7 @@
.when(mDataConfigManager).getBandwidthEstimateSource();
doReturn(true).when(mDataConfigManager).isTempNotMeteredSupportedByCarrier();
doReturn(true).when(mDataConfigManager).isImsDelayTearDownEnabled();
+ doReturn(DEFAULT_MTU).when(mDataConfigManager).getDefaultMtu();
doReturn(FAKE_IMSI).when(mPhone).getSubscriberId();
doReturn(true).when(mDataNetworkController)
.isNetworkRequestExisting(any(TelephonyNetworkRequest.class));
@@ -402,9 +404,10 @@
assertThat(lp.getRoutes().get(0).getMtu()).isEqualTo(1234);
assertThat(lp.getRoutes().get(1).getGateway()).isEqualTo(
InetAddresses.parseNumericAddress("fe80::2"));
- assertThat(lp.getRoutes().get(1).getMtu()).isEqualTo(5678);
+ // The default from carrier configs should be used if MTU is not set.
+ assertThat(lp.getRoutes().get(1).getMtu()).isEqualTo(DEFAULT_MTU);
// The higher value of v4 and v6 should be used.
- assertThat(lp.getMtu()).isEqualTo(5678);
+ assertThat(lp.getMtu()).isEqualTo(DEFAULT_MTU);
ArgumentCaptor<PreciseDataConnectionState> pdcsCaptor =
ArgumentCaptor.forClass(PreciseDataConnectionState.class);