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

Commit 5c2d6223 authored by Jack Yu's avatar Jack Yu Committed by Ling Ma
Browse files

Limited profiles to access only associated subscriptions

The profile can only access its associated subscriptions.
Default voice/sms subscription ids would be profile
dependent. The behavior does not change if no association
is set.

Bug: 296076674
Test: assign both SIMs to a profile + assign each to profiles to make
call and send messages

Change-Id: Ieb19ff6d917cc6b73773fae5e037237a49a0dfb7
parent b9966b72
Loading
Loading
Loading
Loading
+11 −11
Original line number Original line Diff line number Diff line
@@ -265,8 +265,8 @@ public class SubscriptionManager {
        }
        }
    }
    }


    private static VoidPropertyInvalidatedCache<Integer> sGetDefaultSubIdCache =
    private static IntegerPropertyInvalidatedCache<Integer> sGetDefaultSubIdCacheAsUser =
            new VoidPropertyInvalidatedCache<>(ISub::getDefaultSubId,
            new IntegerPropertyInvalidatedCache<>(ISub::getDefaultSubIdAsUser,
                    CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_PROPERTY,
                    CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_PROPERTY,
                    INVALID_SUBSCRIPTION_ID);
                    INVALID_SUBSCRIPTION_ID);


@@ -275,8 +275,8 @@ public class SubscriptionManager {
                    CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_PROPERTY,
                    CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_PROPERTY,
                    INVALID_SUBSCRIPTION_ID);
                    INVALID_SUBSCRIPTION_ID);


    private static VoidPropertyInvalidatedCache<Integer> sGetDefaultSmsSubIdCache =
    private static IntegerPropertyInvalidatedCache<Integer> sGetDefaultSmsSubIdCacheAsUser =
            new VoidPropertyInvalidatedCache<>(ISub::getDefaultSmsSubId,
            new IntegerPropertyInvalidatedCache<>(ISub::getDefaultSmsSubIdAsUser,
                    CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_PROPERTY,
                    CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_PROPERTY,
                    INVALID_SUBSCRIPTION_ID);
                    INVALID_SUBSCRIPTION_ID);


@@ -2309,7 +2309,7 @@ public class SubscriptionManager {
     * @return the "system" default subscription id.
     * @return the "system" default subscription id.
     */
     */
    public static int getDefaultSubscriptionId() {
    public static int getDefaultSubscriptionId() {
        return sGetDefaultSubIdCache.query(null);
        return sGetDefaultSubIdCacheAsUser.query(Process.myUserHandle().getIdentifier());
    }
    }


    /**
    /**
@@ -2325,7 +2325,7 @@ public class SubscriptionManager {
        try {
        try {
            ISub iSub = TelephonyManager.getSubscriptionService();
            ISub iSub = TelephonyManager.getSubscriptionService();
            if (iSub != null) {
            if (iSub != null) {
                subId = iSub.getDefaultVoiceSubId();
                subId = iSub.getDefaultVoiceSubIdAsUser(Process.myUserHandle().getIdentifier());
            }
            }
        } catch (RemoteException ex) {
        } catch (RemoteException ex) {
            // ignore it
            // ignore it
@@ -2397,7 +2397,7 @@ public class SubscriptionManager {
     * @return the default SMS subscription Id.
     * @return the default SMS subscription Id.
     */
     */
    public static int getDefaultSmsSubscriptionId() {
    public static int getDefaultSmsSubscriptionId() {
        return sGetDefaultSmsSubIdCache.query(null);
        return sGetDefaultSmsSubIdCacheAsUser.query(Process.myUserHandle().getIdentifier());
    }
    }


    /**
    /**
@@ -3927,10 +3927,10 @@ public class SubscriptionManager {
     * @hide
     * @hide
     */
     */
    public static void disableCaching() {
    public static void disableCaching() {
        sGetDefaultSubIdCache.disableLocal();
        sGetDefaultSubIdCacheAsUser.disableLocal();
        sGetDefaultDataSubIdCache.disableLocal();
        sGetDefaultDataSubIdCache.disableLocal();
        sGetActiveDataSubscriptionIdCache.disableLocal();
        sGetActiveDataSubscriptionIdCache.disableLocal();
        sGetDefaultSmsSubIdCache.disableLocal();
        sGetDefaultSmsSubIdCacheAsUser.disableLocal();
        sGetSlotIndexCache.disableLocal();
        sGetSlotIndexCache.disableLocal();
        sGetSubIdCache.disableLocal();
        sGetSubIdCache.disableLocal();
        sGetPhoneIdCache.disableLocal();
        sGetPhoneIdCache.disableLocal();
@@ -3941,10 +3941,10 @@ public class SubscriptionManager {
     *
     *
     * @hide */
     * @hide */
    public static void clearCaches() {
    public static void clearCaches() {
        sGetDefaultSubIdCache.clear();
        sGetDefaultSubIdCacheAsUser.clear();
        sGetDefaultDataSubIdCache.clear();
        sGetDefaultDataSubIdCache.clear();
        sGetActiveDataSubscriptionIdCache.clear();
        sGetActiveDataSubscriptionIdCache.clear();
        sGetDefaultSmsSubIdCache.clear();
        sGetDefaultSmsSubIdCacheAsUser.clear();
        sGetSlotIndexCache.clear();
        sGetSlotIndexCache.clear();
        sGetSubIdCache.clear();
        sGetSubIdCache.clear();
        sGetPhoneIdCache.clear();
        sGetPhoneIdCache.clear();
+3 −0
Original line number Original line Diff line number Diff line
@@ -239,6 +239,7 @@ interface ISub {
    int getSubId(int slotIndex);
    int getSubId(int slotIndex);


    int getDefaultSubId();
    int getDefaultSubId();
    int getDefaultSubIdAsUser(int userId);


    int getPhoneId(int subId);
    int getPhoneId(int subId);


@@ -251,10 +252,12 @@ interface ISub {
    void setDefaultDataSubId(int subId);
    void setDefaultDataSubId(int subId);


    int getDefaultVoiceSubId();
    int getDefaultVoiceSubId();
    int getDefaultVoiceSubIdAsUser(int userId);


    void setDefaultVoiceSubId(int subId);
    void setDefaultVoiceSubId(int subId);


    int getDefaultSmsSubId();
    int getDefaultSmsSubId();
    int getDefaultSmsSubIdAsUser(int userId);


    void setDefaultSmsSubId(int subId);
    void setDefaultSmsSubId(int subId);