Loading services/core/java/com/android/server/MmsServiceBroker.java +15 −1 Original line number Diff line number Diff line Loading @@ -342,7 +342,10 @@ public class MmsServiceBroker extends SystemService { // Check if user is associated with the subscription if (!TelephonyPermissions.checkSubscriptionAssociatedWithUser(mContext, subId, Binder.getCallingUserHandle())) { Binder.getCallingUserHandle()) // For inactive sub, fall through to MMS service to have it recorded in metrics. && isActiveSubId(subId)) { // Try remind user to use another profile to send. TelephonyUtils.showSwitchToManagedProfileDialogIfAppropriate(mContext, subId, Binder.getCallingUid(), callingPkg); return; Loading Loading @@ -550,6 +553,17 @@ public class MmsServiceBroker extends SystemService { } } /** @return true if the subId is active. */ private boolean isActiveSubId(int subId) { final long token = Binder.clearCallingIdentity(); try { SubscriptionManager subManager = mContext.getSystemService(SubscriptionManager.class); return subManager != null && subManager.isActiveSubscriptionId(subId); } finally { Binder.restoreCallingIdentity(token); } } private int getPhoneIdFromSubId(int subId) { SubscriptionManager subManager = (SubscriptionManager) mContext.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE); Loading telephony/common/com/android/internal/telephony/TelephonyPermissions.java +17 −7 Original line number Diff line number Diff line Loading @@ -35,6 +35,8 @@ import android.telephony.TelephonyManager; import android.util.Log; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.telephony.flags.FeatureFlags; import com.android.internal.telephony.flags.FeatureFlagsImpl; import java.util.HashMap; import java.util.HashSet; Loading @@ -46,7 +48,8 @@ public final class TelephonyPermissions { private static final String LOG_TAG = "TelephonyPermissions"; private static final boolean DBG = false; /** Feature flags */ private static final FeatureFlags sFeatureFlag = new FeatureFlagsImpl(); /** * Whether to disable the new device identifier access restrictions. */ Loading Loading @@ -854,7 +857,8 @@ public final class TelephonyPermissions { public static boolean checkSubscriptionAssociatedWithUser(@NonNull Context context, int subId, @NonNull UserHandle callerUserHandle, @NonNull String destAddr) { // Skip subscription-user association check for emergency numbers TelephonyManager tm = context.getSystemService(TelephonyManager.class); TelephonyManager tm = (TelephonyManager) context.getSystemService( Context.TELEPHONY_SERVICE); final long token = Binder.clearCallingIdentity(); try { if (tm != null && tm.isEmergencyNumber(destAddr)) { Loading @@ -876,16 +880,19 @@ public final class TelephonyPermissions { * @param context Context * @param subId subscription ID * @param callerUserHandle caller user handle * @return false if user is not associated with the subscription. * @return false if user is not associated with the subscription, or no record found of this * subscription. */ public static boolean checkSubscriptionAssociatedWithUser(@NonNull Context context, int subId, @NonNull UserHandle callerUserHandle) { if (!SubscriptionManager.isValidSubscriptionId(subId)) { // No subscription on device, return true. if (!sFeatureFlag.rejectBadSubIdInteraction() && !SubscriptionManager.isValidSubscriptionId(subId)) { // Return true for invalid sub Id. return true; } SubscriptionManager subManager = context.getSystemService(SubscriptionManager.class); SubscriptionManager subManager = (SubscriptionManager) context.getSystemService( Context.TELEPHONY_SUBSCRIPTION_SERVICE); final long token = Binder.clearCallingIdentity(); try { if ((subManager != null) && Loading @@ -894,8 +901,11 @@ public final class TelephonyPermissions { Log.e(LOG_TAG, "User[User ID:" + callerUserHandle.getIdentifier() + "] is not associated with Subscription ID:" + subId); return false; } } catch (IllegalArgumentException e) { // Found no record of this sub Id. Log.e(LOG_TAG, "Subscription[Subscription ID:" + subId + "] has no records on device"); return !sFeatureFlag.rejectBadSubIdInteraction(); } finally { Binder.restoreCallingIdentity(token); } Loading telephony/common/com/android/internal/telephony/util/TelephonyUtils.java +5 −1 Original line number Diff line number Diff line Loading @@ -274,6 +274,10 @@ public final class TelephonyUtils { SubscriptionManager subscriptionManager = context.getSystemService( SubscriptionManager.class); if (!subscriptionManager.isActiveSubscriptionId(subId)) { Log.e(LOG_TAG, "Tried to send message with an inactive subscription " + subId); return; } UserHandle associatedUserHandle = subscriptionManager.getSubscriptionUserHandle(subId); UserManager um = context.getSystemService(UserManager.class); Loading telephony/java/android/telephony/SubscriptionManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -4348,7 +4348,7 @@ public class SubscriptionManager { * {code true} if there are no subscriptions on device * else {@code false} if subscription is not associated with user. * * @throws IllegalArgumentException if subscription is invalid. * @throws IllegalArgumentException if subscription doesn't exist. * @throws SecurityException if the caller doesn't have permissions required. * * @hide Loading Loading
services/core/java/com/android/server/MmsServiceBroker.java +15 −1 Original line number Diff line number Diff line Loading @@ -342,7 +342,10 @@ public class MmsServiceBroker extends SystemService { // Check if user is associated with the subscription if (!TelephonyPermissions.checkSubscriptionAssociatedWithUser(mContext, subId, Binder.getCallingUserHandle())) { Binder.getCallingUserHandle()) // For inactive sub, fall through to MMS service to have it recorded in metrics. && isActiveSubId(subId)) { // Try remind user to use another profile to send. TelephonyUtils.showSwitchToManagedProfileDialogIfAppropriate(mContext, subId, Binder.getCallingUid(), callingPkg); return; Loading Loading @@ -550,6 +553,17 @@ public class MmsServiceBroker extends SystemService { } } /** @return true if the subId is active. */ private boolean isActiveSubId(int subId) { final long token = Binder.clearCallingIdentity(); try { SubscriptionManager subManager = mContext.getSystemService(SubscriptionManager.class); return subManager != null && subManager.isActiveSubscriptionId(subId); } finally { Binder.restoreCallingIdentity(token); } } private int getPhoneIdFromSubId(int subId) { SubscriptionManager subManager = (SubscriptionManager) mContext.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE); Loading
telephony/common/com/android/internal/telephony/TelephonyPermissions.java +17 −7 Original line number Diff line number Diff line Loading @@ -35,6 +35,8 @@ import android.telephony.TelephonyManager; import android.util.Log; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.telephony.flags.FeatureFlags; import com.android.internal.telephony.flags.FeatureFlagsImpl; import java.util.HashMap; import java.util.HashSet; Loading @@ -46,7 +48,8 @@ public final class TelephonyPermissions { private static final String LOG_TAG = "TelephonyPermissions"; private static final boolean DBG = false; /** Feature flags */ private static final FeatureFlags sFeatureFlag = new FeatureFlagsImpl(); /** * Whether to disable the new device identifier access restrictions. */ Loading Loading @@ -854,7 +857,8 @@ public final class TelephonyPermissions { public static boolean checkSubscriptionAssociatedWithUser(@NonNull Context context, int subId, @NonNull UserHandle callerUserHandle, @NonNull String destAddr) { // Skip subscription-user association check for emergency numbers TelephonyManager tm = context.getSystemService(TelephonyManager.class); TelephonyManager tm = (TelephonyManager) context.getSystemService( Context.TELEPHONY_SERVICE); final long token = Binder.clearCallingIdentity(); try { if (tm != null && tm.isEmergencyNumber(destAddr)) { Loading @@ -876,16 +880,19 @@ public final class TelephonyPermissions { * @param context Context * @param subId subscription ID * @param callerUserHandle caller user handle * @return false if user is not associated with the subscription. * @return false if user is not associated with the subscription, or no record found of this * subscription. */ public static boolean checkSubscriptionAssociatedWithUser(@NonNull Context context, int subId, @NonNull UserHandle callerUserHandle) { if (!SubscriptionManager.isValidSubscriptionId(subId)) { // No subscription on device, return true. if (!sFeatureFlag.rejectBadSubIdInteraction() && !SubscriptionManager.isValidSubscriptionId(subId)) { // Return true for invalid sub Id. return true; } SubscriptionManager subManager = context.getSystemService(SubscriptionManager.class); SubscriptionManager subManager = (SubscriptionManager) context.getSystemService( Context.TELEPHONY_SUBSCRIPTION_SERVICE); final long token = Binder.clearCallingIdentity(); try { if ((subManager != null) && Loading @@ -894,8 +901,11 @@ public final class TelephonyPermissions { Log.e(LOG_TAG, "User[User ID:" + callerUserHandle.getIdentifier() + "] is not associated with Subscription ID:" + subId); return false; } } catch (IllegalArgumentException e) { // Found no record of this sub Id. Log.e(LOG_TAG, "Subscription[Subscription ID:" + subId + "] has no records on device"); return !sFeatureFlag.rejectBadSubIdInteraction(); } finally { Binder.restoreCallingIdentity(token); } Loading
telephony/common/com/android/internal/telephony/util/TelephonyUtils.java +5 −1 Original line number Diff line number Diff line Loading @@ -274,6 +274,10 @@ public final class TelephonyUtils { SubscriptionManager subscriptionManager = context.getSystemService( SubscriptionManager.class); if (!subscriptionManager.isActiveSubscriptionId(subId)) { Log.e(LOG_TAG, "Tried to send message with an inactive subscription " + subId); return; } UserHandle associatedUserHandle = subscriptionManager.getSubscriptionUserHandle(subId); UserManager um = context.getSystemService(UserManager.class); Loading
telephony/java/android/telephony/SubscriptionManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -4348,7 +4348,7 @@ public class SubscriptionManager { * {code true} if there are no subscriptions on device * else {@code false} if subscription is not associated with user. * * @throws IllegalArgumentException if subscription is invalid. * @throws IllegalArgumentException if subscription doesn't exist. * @throws SecurityException if the caller doesn't have permissions required. * * @hide Loading