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

Commit 4967f98b authored by Jack Yu's avatar Jack Yu
Browse files

Added flag to enable subscription manager service through adb

Test: Boot up and basic phone testing
Test: adb root && adb shell device_config put telephony enable_subscription_manager_service true
      && adb shell device_config set_sync_disabled_for_tests persistent && sleep 3 && adb reboot
Fix: 266896752
Change-Id: Ib3b18b9a052de4d9f78e432f42b83d099f1b42a2
parent e647afa4
Loading
Loading
Loading
Loading
+23 −6
Original line number Original line Diff line number Diff line
@@ -160,6 +160,10 @@ public class SubscriptionManager {
    private static final String CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_PROPERTY =
    private static final String CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_PROPERTY =
            "cache_key.telephony.subscription_manager_service";
            "cache_key.telephony.subscription_manager_service";


    /** The temporarily cache key to indicate whether subscription manager service is enabled. */
    private static final String CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_ENABLED_PROPERTY =
            "cache_key.telephony.subscription_manager_service_enabled";

    /** @hide */
    /** @hide */
    public static final String GET_SIM_SPECIFIC_SETTINGS_METHOD_NAME = "getSimSpecificSettings";
    public static final String GET_SIM_SPECIFIC_SETTINGS_METHOD_NAME = "getSimSpecificSettings";


@@ -340,6 +344,12 @@ public class SubscriptionManager {
                    CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_PROPERTY,
                    CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_PROPERTY,
                    INVALID_PHONE_INDEX);
                    INVALID_PHONE_INDEX);


    //TODO: Removed before U AOSP public release.
    private static VoidPropertyInvalidatedCache<Boolean> sIsSubscriptionManagerServiceEnabled =
            new VoidPropertyInvalidatedCache<>(ISub::isSubscriptionManagerServiceEnabled,
                    CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_ENABLED_PROPERTY,
                    false);

    /**
    /**
     * Generates a content {@link Uri} used to receive updates on simInfo change
     * Generates a content {@link Uri} used to receive updates on simInfo change
     * on the given subscriptionId
     * on the given subscriptionId
@@ -1358,8 +1368,6 @@ public class SubscriptionManager {


    private final Context mContext;
    private final Context mContext;


    private static boolean sIsSubscriptionManagerServiceEnabled = false;

    // Cache of Resource that has been created in getResourcesForSubId. Key is a Pair containing
    // Cache of Resource that has been created in getResourcesForSubId. Key is a Pair containing
    // the Context and subId.
    // the Context and subId.
    private static final Map<Pair<Context, Integer>, Resources> sResourcesCache =
    private static final Map<Pair<Context, Integer>, Resources> sResourcesCache =
@@ -1445,9 +1453,6 @@ public class SubscriptionManager {
    public SubscriptionManager(Context context) {
    public SubscriptionManager(Context context) {
        if (DBG) logd("SubscriptionManager created");
        if (DBG) logd("SubscriptionManager created");
        mContext = context;
        mContext = context;

        sIsSubscriptionManagerServiceEnabled = mContext.getResources().getBoolean(
                com.android.internal.R.bool.config_using_subscription_manager_service);
    }
    }


    /**
    /**
@@ -1456,8 +1461,9 @@ public class SubscriptionManager {
     *
     *
     * @hide
     * @hide
     */
     */
    //TODO: Removed before U AOSP public release.
    public static boolean isSubscriptionManagerServiceEnabled() {
    public static boolean isSubscriptionManagerServiceEnabled() {
        return sIsSubscriptionManagerServiceEnabled;
        return sIsSubscriptionManagerServiceEnabled.query(null);
    }
    }


    private NetworkPolicyManager getNetworkPolicyManager() {
    private NetworkPolicyManager getNetworkPolicyManager() {
@@ -3971,6 +3977,13 @@ public class SubscriptionManager {
        PropertyInvalidatedCache.invalidateCache(CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_PROPERTY);
        PropertyInvalidatedCache.invalidateCache(CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_PROPERTY);
    }
    }


    /** @hide */
    //TODO: Removed before U AOSP public release.
    public static void invalidateSubscriptionManagerServiceEnabledCaches() {
        PropertyInvalidatedCache.invalidateCache(
                CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_ENABLED_PROPERTY);
    }

    /**
    /**
     * Allows a test process to disable client-side caching operations.
     * Allows a test process to disable client-side caching operations.
     *
     *
@@ -3992,6 +4005,8 @@ public class SubscriptionManager {
        sGetSlotIndexCache.disableLocal();
        sGetSlotIndexCache.disableLocal();
        sGetSubIdCache.disableLocal();
        sGetSubIdCache.disableLocal();
        sGetPhoneIdCache.disableLocal();
        sGetPhoneIdCache.disableLocal();

        sIsSubscriptionManagerServiceEnabled.disableLocal();
    }
    }


    /**
    /**
@@ -4014,6 +4029,8 @@ public class SubscriptionManager {
        sGetSlotIndexCache.clear();
        sGetSlotIndexCache.clear();
        sGetSubIdCache.clear();
        sGetSubIdCache.clear();
        sGetPhoneIdCache.clear();
        sGetPhoneIdCache.clear();

        sIsSubscriptionManagerServiceEnabled.clear();
    }
    }


    /**
    /**
+7 −0
Original line number Original line Diff line number Diff line
@@ -356,4 +356,11 @@ interface ISub {
       * @hide
       * @hide
       */
       */
       List<SubscriptionInfo> getSubscriptionInfoListAssociatedWithUser(in UserHandle userHandle);
       List<SubscriptionInfo> getSubscriptionInfoListAssociatedWithUser(in UserHandle userHandle);

       /**
        * @return {@code true} if using SubscriptionManagerService instead of
        * SubscriptionController.
        */
       //TODO: Removed before U AOSP public release.
       boolean isSubscriptionManagerServiceEnabled();
}
}