Loading telephony/java/android/telephony/TelephonyFrameworkInitializer.java +30 −0 Original line number Diff line number Diff line Loading @@ -18,8 +18,13 @@ package android.telephony; import android.annotation.NonNull; import android.app.SystemServiceRegistry; import android.compat.Compatibility; import android.compat.annotation.ChangeId; import android.compat.annotation.EnabledSince; import android.content.Context; import android.content.pm.PackageManager; import android.os.Build; import android.os.SystemProperties; import android.os.TelephonyServiceManager; import android.telephony.euicc.EuiccCardManager; import android.telephony.euicc.EuiccManager; Loading @@ -40,6 +45,16 @@ public class TelephonyFrameworkInitializer { private TelephonyFrameworkInitializer() { } /** * Starting with {@link VANILLA_ICE_CREAM}, Telephony feature flags * (e.g. {@link PackageManager#FEATURE_TELEPHONY_SUBSCRIPTION}) are being checked before * returning managers that depend on them. If the feature is missing, * {@link Context#getSystemService} will return null. */ @ChangeId @EnabledSince(targetSdkVersion = Build.VERSION_CODES.VANILLA_ICE_CREAM) static final long ENABLE_CHECKING_TELEPHONY_FEATURES = 330583731; private static volatile TelephonyServiceManager sTelephonyServiceManager; /** Loading @@ -57,8 +72,23 @@ public class TelephonyFrameworkInitializer { sTelephonyServiceManager = Preconditions.checkNotNull(telephonyServiceManager); } // Suppressing AndroidFrameworkCompatChange because we're querying vendor // partition SDK level, not application's target SDK version (which BTW we // also check through Compatibility framework a few lines below). @SuppressWarnings("AndroidFrameworkCompatChange") private static boolean hasSystemFeature(Context context, String feature) { // Check release status of this change in behavior. if (!Flags.minimalTelephonyManagersConditionalOnFeatures()) return true; // Check SDK version of the vendor partition. final int vendorApiLevel = SystemProperties.getInt( "ro.vendor.api_level", Build.VERSION.DEVICE_INITIAL_SDK_INT); if (vendorApiLevel < Build.VERSION_CODES.VANILLA_ICE_CREAM) return true; // Check SDK version of the client app. if (!Compatibility.isChangeEnabled(ENABLE_CHECKING_TELEPHONY_FEATURES)) return true; // Finally, check if the system feature is actually present. return context.getPackageManager().hasSystemFeature(feature); } Loading Loading
telephony/java/android/telephony/TelephonyFrameworkInitializer.java +30 −0 Original line number Diff line number Diff line Loading @@ -18,8 +18,13 @@ package android.telephony; import android.annotation.NonNull; import android.app.SystemServiceRegistry; import android.compat.Compatibility; import android.compat.annotation.ChangeId; import android.compat.annotation.EnabledSince; import android.content.Context; import android.content.pm.PackageManager; import android.os.Build; import android.os.SystemProperties; import android.os.TelephonyServiceManager; import android.telephony.euicc.EuiccCardManager; import android.telephony.euicc.EuiccManager; Loading @@ -40,6 +45,16 @@ public class TelephonyFrameworkInitializer { private TelephonyFrameworkInitializer() { } /** * Starting with {@link VANILLA_ICE_CREAM}, Telephony feature flags * (e.g. {@link PackageManager#FEATURE_TELEPHONY_SUBSCRIPTION}) are being checked before * returning managers that depend on them. If the feature is missing, * {@link Context#getSystemService} will return null. */ @ChangeId @EnabledSince(targetSdkVersion = Build.VERSION_CODES.VANILLA_ICE_CREAM) static final long ENABLE_CHECKING_TELEPHONY_FEATURES = 330583731; private static volatile TelephonyServiceManager sTelephonyServiceManager; /** Loading @@ -57,8 +72,23 @@ public class TelephonyFrameworkInitializer { sTelephonyServiceManager = Preconditions.checkNotNull(telephonyServiceManager); } // Suppressing AndroidFrameworkCompatChange because we're querying vendor // partition SDK level, not application's target SDK version (which BTW we // also check through Compatibility framework a few lines below). @SuppressWarnings("AndroidFrameworkCompatChange") private static boolean hasSystemFeature(Context context, String feature) { // Check release status of this change in behavior. if (!Flags.minimalTelephonyManagersConditionalOnFeatures()) return true; // Check SDK version of the vendor partition. final int vendorApiLevel = SystemProperties.getInt( "ro.vendor.api_level", Build.VERSION.DEVICE_INITIAL_SDK_INT); if (vendorApiLevel < Build.VERSION_CODES.VANILLA_ICE_CREAM) return true; // Check SDK version of the client app. if (!Compatibility.isChangeEnabled(ENABLE_CHECKING_TELEPHONY_FEATURES)) return true; // Finally, check if the system feature is actually present. return context.getPackageManager().hasSystemFeature(feature); } Loading