Merge "Merge 2024-06 Release (ab/AP2A.240605.024) to aosp-main-future" into aosp-main-future
diff --git a/src/com/android/phone/CarrierConfigLoader.java b/src/com/android/phone/CarrierConfigLoader.java
index 9b71919..47fd96e 100644
--- a/src/com/android/phone/CarrierConfigLoader.java
+++ b/src/com/android/phone/CarrierConfigLoader.java
@@ -47,6 +47,7 @@
import android.os.Process;
import android.os.RemoteException;
import android.os.ResultReceiver;
+import android.os.SystemProperties;
import android.os.UserHandle;
import android.preference.PreferenceManager;
import android.service.carrier.CarrierIdentifier;
@@ -698,6 +699,7 @@
@NonNull private final FeatureFlags mFeatureFlags;
@NonNull private final PackageManager mPackageManager;
+ private final int mVendorApiLevel;
/**
* Constructs a CarrierConfigLoader, registers it as a service, and registers a broadcast
@@ -736,6 +738,8 @@
}
mFeatureFlags = featureFlags;
mPackageManager = context.getPackageManager();
+ mVendorApiLevel = SystemProperties.getInt(
+ "ro.vendor.api_level", Build.VERSION.DEVICE_INITIAL_SDK_INT);
logd("CarrierConfigLoader has started");
PhoneConfigurationManager.registerForMultiSimConfigChange(
@@ -1884,7 +1888,11 @@
if (!mFeatureFlags.enforceTelephonyFeatureMappingForPublicApis()
|| !CompatChanges.isChangeEnabled(ENABLE_FEATURE_MAPPING, callingPackage,
- Binder.getCallingUserHandle())) {
+ Binder.getCallingUserHandle())
+ || mVendorApiLevel < Build.VERSION_CODES.VANILLA_ICE_CREAM) {
+ // Skip to check associated telephony feature,
+ // if compatibility change is not enabled for the current process or
+ // the SDK version of vendor partition is less than Android V.
return;
}
diff --git a/src/com/android/phone/ImsRcsController.java b/src/com/android/phone/ImsRcsController.java
index a778f6a..766d719 100644
--- a/src/com/android/phone/ImsRcsController.java
+++ b/src/com/android/phone/ImsRcsController.java
@@ -32,6 +32,7 @@
import android.os.Build;
import android.os.RemoteException;
import android.os.ServiceSpecificException;
+import android.os.SystemProperties;
import android.os.UserHandle;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyFrameworkInitializer;
@@ -85,6 +86,7 @@
private PackageManager mPackageManager;
// set by shell cmd phone src set-device-enabled true/false
private Boolean mSingleRegistrationOverride;
+ private final int mVendorApiLevel;
/**
* For apps targeting Android T and above, support the publishing state on APIs, such as
@@ -119,6 +121,8 @@
TelephonyFrameworkInitializer
.getTelephonyServiceManager().getTelephonyImsServiceRegisterer().register(this);
mImsResolver = ImsResolver.getInstance();
+ mVendorApiLevel = SystemProperties.getInt(
+ "ro.vendor.api_level", Build.VERSION.DEVICE_INITIAL_SDK_INT);
}
/**
@@ -1000,7 +1004,11 @@
if (!mFeatureFlags.enforceTelephonyFeatureMappingForPublicApis()
|| !CompatChanges.isChangeEnabled(ENABLE_FEATURE_MAPPING, callingPackage,
- Binder.getCallingUserHandle())) {
+ Binder.getCallingUserHandle())
+ || mVendorApiLevel < Build.VERSION_CODES.VANILLA_ICE_CREAM) {
+ // Skip to check associated telephony feature,
+ // if compatibility change is not enabled for the current process or
+ // the SDK version of vendor partition is less than Android V.
return;
}
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index e18818c..3919d40 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -76,6 +76,7 @@
import android.os.ResultReceiver;
import android.os.ServiceSpecificException;
import android.os.SystemClock;
+import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
import android.os.WorkSource;
@@ -434,6 +435,7 @@
private final PhoneConfigurationManager mPhoneConfigurationManager;
private final RadioInterfaceCapabilityController mRadioInterfaceCapabilities;
private PackageManager mPackageManager;
+ private final int mVendorApiLevel;
/** User Activity */
private final AtomicBoolean mNotifyUserActivity;
@@ -2476,6 +2478,9 @@
mPackageManager = app.getPackageManager();
mSatelliteAccessController = SatelliteAccessController.getOrCreateInstance(
getDefaultPhone().getContext(), featureFlags);
+ mVendorApiLevel = SystemProperties.getInt(
+ "ro.vendor.api_level", Build.VERSION.DEVICE_INITIAL_SDK_INT);
+
PropertyInvalidatedCache.invalidateCache(TelephonyManager.CACHE_KEY_PHONE_ACCOUNT_TO_SUBID);
publish();
CarrierAllowListInfo.loadInstance(mApp);
@@ -14038,7 +14043,11 @@
if (!mFeatureFlags.enforceTelephonyFeatureMappingForPublicApis()
|| !CompatChanges.isChangeEnabled(ENABLE_FEATURE_MAPPING, callingPackage,
- Binder.getCallingUserHandle())) {
+ Binder.getCallingUserHandle())
+ || mVendorApiLevel < Build.VERSION_CODES.VANILLA_ICE_CREAM) {
+ // Skip to check associated telephony feature,
+ // if compatibility change is not enabled for the current process or
+ // the SDK version of vendor partition is less than Android V.
return;
}
diff --git a/src/com/android/phone/security/SafetySourceReceiver.java b/src/com/android/phone/security/SafetySourceReceiver.java
index d2be1a1..76f8e72 100644
--- a/src/com/android/phone/security/SafetySourceReceiver.java
+++ b/src/com/android/phone/security/SafetySourceReceiver.java
@@ -28,8 +28,10 @@
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.flags.Flags;
import com.android.phone.PhoneGlobals;
+import com.android.telephony.Rlog;
public class SafetySourceReceiver extends BroadcastReceiver {
+ private static final String TAG = "TelephonySafetySourceReceiver";
@Override
public void onReceive(Context context, Intent intent) {
@@ -72,6 +74,11 @@
@VisibleForTesting
public Phone getDefaultPhone() {
- return PhoneGlobals.getPhone();
+ try {
+ return PhoneGlobals.getPhone();
+ } catch (IllegalStateException e) {
+ Rlog.i(TAG, "Unable to get phone. Skipping safety source refresh: " + e.getMessage());
+ }
+ return null;
}
}
diff --git a/tests/src/com/android/phone/CarrierConfigLoaderTest.java b/tests/src/com/android/phone/CarrierConfigLoaderTest.java
index f4197d9..bda2313 100644
--- a/tests/src/com/android/phone/CarrierConfigLoaderTest.java
+++ b/tests/src/com/android/phone/CarrierConfigLoaderTest.java
@@ -429,11 +429,16 @@
@Test
@EnableCompatChanges({TelephonyManager.ENABLE_FEATURE_MAPPING})
- public void testGetConfigForSubIdWithFeature_withTelephonyFeatureMapping() {
+ public void testGetConfigForSubIdWithFeature_withTelephonyFeatureMapping() throws Exception {
doNothing().when(mContext).enforcePermission(
eq(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE),
anyInt(), anyInt(), anyString());
+ // Replace field to set SDK version of vendor partition to Android V
+ int vendorApiLevel = Build.VERSION_CODES.VANILLA_ICE_CREAM;
+ replaceInstance(CarrierConfigLoader.class, "mVendorApiLevel", mCarrierConfigLoader,
+ vendorApiLevel);
+
doReturn(true).when(mFeatureFlags).enforceTelephonyFeatureMappingForPublicApis();
doReturn(false).when(mPackageManager).hasSystemFeature(
eq(PackageManager.FEATURE_TELEPHONY_SUBSCRIPTION));
diff --git a/tests/src/com/android/phone/PhoneInterfaceManagerTest.java b/tests/src/com/android/phone/PhoneInterfaceManagerTest.java
index 2d338f2..04fce84 100644
--- a/tests/src/com/android/phone/PhoneInterfaceManagerTest.java
+++ b/tests/src/com/android/phone/PhoneInterfaceManagerTest.java
@@ -37,6 +37,7 @@
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Resources;
+import android.os.Build;
import android.permission.flags.Flags;
import android.platform.test.flag.junit.SetFlagsRule;
import android.telephony.RadioAccessFamily;
@@ -507,6 +508,11 @@
@Test
@EnableCompatChanges({TelephonyManager.ENABLE_FEATURE_MAPPING})
public void testWithoutTelephonyFeatureAndCompatChanges() throws Exception {
+ // Replace field to set SDK version of vendor partition to Android V
+ int vendorApiLevel = Build.VERSION_CODES.VANILLA_ICE_CREAM;
+ replaceInstance(PhoneInterfaceManager.class, "mVendorApiLevel", mPhoneInterfaceManager,
+ vendorApiLevel);
+
// telephony features is not defined, expect UnsupportedOperationException.
doReturn(false).when(mPackageManager).hasSystemFeature(
PackageManager.FEATURE_TELEPHONY_CALLING);