Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 44623ac1 authored by Jack Yu's avatar Jack Yu Committed by Automerger Merge Worker
Browse files

Fixed crash during eSIM activation am: ff168096

parents b150a4d1 ff168096
Loading
Loading
Loading
Loading
+13 −8
Original line number Original line Diff line number Diff line
@@ -102,6 +102,7 @@ import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Comparator;
import java.util.List;
import java.util.List;
import java.util.Map;
import java.util.Map;
@@ -1646,8 +1647,6 @@ public class SubscriptionManagerService extends ISub.Stub {
     *
     *
     * @return Sorted list of the currently {@link SubscriptionInfo} records available on the
     * @return Sorted list of the currently {@link SubscriptionInfo} records available on the
     * device.
     * device.
     *
     * @throws SecurityException if the caller does not have required permissions.
     */
     */
    @Override
    @Override
    @NonNull
    @NonNull
@@ -1667,8 +1666,12 @@ public class SubscriptionManagerService extends ISub.Stub {
        if (!TelephonyPermissions.checkReadPhoneStateOnAnyActiveSub(mContext,
        if (!TelephonyPermissions.checkReadPhoneStateOnAnyActiveSub(mContext,
                Binder.getCallingPid(), Binder.getCallingUid(), callingPackage, callingFeatureId,
                Binder.getCallingPid(), Binder.getCallingUid(), callingPackage, callingFeatureId,
                "getAllSubInfoList")) {
                "getAllSubInfoList")) {
            throw new SecurityException("Need READ_PHONE_STATE, READ_PRIVILEGED_PHONE_STATE, or "
            // Ideally we should avoid silent failure, but since this API has already been used by
                    + "carrier privilege");
            // many apps and they do not expect the security exception, we return an empty list
            // here so it's consistent with pre-U behavior.
            loge("getActiveSubscriptionInfoList: " + callingPackage + " does not have enough "
                    + "permission. Returning empty list here.");
            return Collections.emptyList();
        }
        }


        return mSubscriptionDatabaseManager.getAllSubscriptions().stream()
        return mSubscriptionDatabaseManager.getAllSubscriptions().stream()
@@ -2270,8 +2273,6 @@ public class SubscriptionManagerService extends ISub.Stub {
     * @param callingFeatureId The feature in the package.
     * @param callingFeatureId The feature in the package.
     *
     *
     * @return The list of opportunistic subscription info that can be accessed by the callers.
     * @return The list of opportunistic subscription info that can be accessed by the callers.
     *
     * @throws SecurityException if callers do not hold the required permission.
     */
     */
    @Override
    @Override
    @NonNull
    @NonNull
@@ -2291,8 +2292,12 @@ public class SubscriptionManagerService extends ISub.Stub {
        if (!TelephonyPermissions.checkReadPhoneStateOnAnyActiveSub(mContext,
        if (!TelephonyPermissions.checkReadPhoneStateOnAnyActiveSub(mContext,
                Binder.getCallingPid(), Binder.getCallingUid(), callingPackage, callingFeatureId,
                Binder.getCallingPid(), Binder.getCallingUid(), callingPackage, callingFeatureId,
                "getOpportunisticSubscriptions")) {
                "getOpportunisticSubscriptions")) {
            throw new SecurityException("Need READ_PHONE_STATE, READ_PRIVILEGED_PHONE_STATE, or "
            // Ideally we should avoid silent failure, but since this API has already been used by
                    + "carrier privilege");
            // many apps and they do not expect the security exception, we return an empty list
            // here so it's consistent with pre-U behavior.
            loge("getOpportunisticSubscriptions: " + callingPackage + " does not have enough "
                    + "permission. Returning empty list here.");
            return Collections.emptyList();
        }
        }


        return mSubscriptionDatabaseManager.getAllSubscriptions().stream()
        return mSubscriptionDatabaseManager.getAllSubscriptions().stream()
+6 −6
Original line number Original line Diff line number Diff line
@@ -673,9 +673,9 @@ public class SubscriptionManagerServiceTest extends TelephonyTest {
        // Remove MODIFY_PHONE_STATE
        // Remove MODIFY_PHONE_STATE
        mContextFixture.removeCallingOrSelfPermission(Manifest.permission.MODIFY_PHONE_STATE);
        mContextFixture.removeCallingOrSelfPermission(Manifest.permission.MODIFY_PHONE_STATE);


        // Should fail without READ_PHONE_STATE
        // Should get an empty list without READ_PHONE_STATE.
        assertThrows(SecurityException.class, () -> mSubscriptionManagerServiceUT
        assertThat(mSubscriptionManagerServiceUT.getActiveSubscriptionInfoList(
                .getActiveSubscriptionInfoList(CALLING_PACKAGE, CALLING_FEATURE));
                CALLING_PACKAGE, CALLING_FEATURE)).isEmpty();


        // Grant READ_PHONE_STATE permission for insertion.
        // Grant READ_PHONE_STATE permission for insertion.
        mContextFixture.addCallingOrSelfPermission(Manifest.permission.READ_PHONE_STATE);
        mContextFixture.addCallingOrSelfPermission(Manifest.permission.READ_PHONE_STATE);
@@ -1078,9 +1078,9 @@ public class SubscriptionManagerServiceTest extends TelephonyTest {
        testSetOpportunistic();
        testSetOpportunistic();
        insertSubscription(FAKE_SUBSCRIPTION_INFO2);
        insertSubscription(FAKE_SUBSCRIPTION_INFO2);


        // Should fail without READ_PHONE_STATE
        // Should get an empty list without READ_PHONE_STATE.
        assertThrows(SecurityException.class, () -> mSubscriptionManagerServiceUT
        assertThat(mSubscriptionManagerServiceUT.getOpportunisticSubscriptions(
                .getOpportunisticSubscriptions(CALLING_PACKAGE, CALLING_FEATURE));
                CALLING_PACKAGE, CALLING_FEATURE)).isEmpty();


        mContextFixture.addCallingOrSelfPermission(Manifest.permission.READ_PHONE_STATE);
        mContextFixture.addCallingOrSelfPermission(Manifest.permission.READ_PHONE_STATE);