Wrap subManager creation with createForAllProfiles

Since U, a sub can be associated to a particular profile, and thus in V we enforce filtering on caller and only show the subs that are associated with the caller.
However, in some cases the caller indeed needs to see all subs regardless its association, e.g. sysUI. Therefore, a param isForAllProfile is added to indicate whether the caller intends to see all subs.

Bug: 296076674
Test: voice call + data browsing
Flag: ACONFIG com.android.internal.telephony.flags.work_profile_api_split DEVELOPMENT
Change-Id: I8bb10babd47f02df892f60da0a37a6feba5341ca
diff --git a/src/com/android/phone/SimPhonebookProvider.java b/src/com/android/phone/SimPhonebookProvider.java
index 8952865..3917d83 100644
--- a/src/com/android/phone/SimPhonebookProvider.java
+++ b/src/com/android/phone/SimPhonebookProvider.java
@@ -50,6 +50,7 @@
 
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.internal.telephony.IIccPhoneBook;
+import com.android.internal.telephony.flags.Flags;
 import com.android.internal.telephony.uicc.AdnRecord;
 import com.android.internal.telephony.uicc.IccConstants;
 
@@ -173,17 +174,21 @@
     @Override
     public boolean onCreate() {
         ContentResolver resolver = getContext().getContentResolver();
-        return onCreate(getContext().getSystemService(SubscriptionManager.class),
+
+        SubscriptionManager sm = getContext().getSystemService(SubscriptionManager.class);
+        if (sm == null) {
+            return false;
+        } else if (Flags.workProfileApiSplit()) {
+            sm = sm.createForAllUserProfiles();
+        }
+        return onCreate(sm,
                 SimPhonebookProvider::getIccPhoneBook,
                 uri -> resolver.notifyChange(uri, null));
     }
 
     @TestApi
-    boolean onCreate(SubscriptionManager subscriptionManager,
+    boolean onCreate(@NonNull SubscriptionManager subscriptionManager,
             Supplier<IIccPhoneBook> iccPhoneBookSupplier, ContentNotifier notifier) {
-        if (subscriptionManager == null) {
-            return false;
-        }
         mSubscriptionManager = subscriptionManager;
         mIccPhoneBookSupplier = iccPhoneBookSupplier;
         mContentNotifier = notifier;