Loading src/java/com/android/internal/telephony/MultiSimSettingController.java +7 −7 Original line number Diff line number Diff line Loading @@ -109,13 +109,13 @@ public class MultiSimSettingController extends Handler { // Subscription information is initially loaded. private static final int PRIMARY_SUB_INITIALIZED = 6; private final Context mContext; private final SubscriptionController mSubController; protected final Context mContext; protected final SubscriptionController mSubController; // Keep a record of active primary (non-opportunistic) subscription list. @NonNull private List<Integer> mPrimarySubList = new ArrayList<>(); /** The singleton instance. */ private static MultiSimSettingController sInstance = null; protected static MultiSimSettingController sInstance = null; // This will be set true when handling EVENT_ALL_SUBSCRIPTIONS_LOADED. The reason of keeping // a local variable instead of calling SubscriptionInfoUpdater#isSubInfoInitialized is, there Loading Loading @@ -288,7 +288,7 @@ public class MultiSimSettingController extends Handler { * If user is enabling a non-default non-opportunistic subscription, make it default * data subscription. */ private void onUserDataEnabled(int subId, boolean enable) { protected void onUserDataEnabled(int subId, boolean enable) { if (DBG) log("onUserDataEnabled"); // Make sure MOBILE_DATA of subscriptions in same group are synced. setUserDataEnabledForGroup(subId, enable); Loading Loading @@ -483,7 +483,7 @@ public class MultiSimSettingController extends Handler { * 4) If non above is met, clear the default value to INVALID. * */ private void updateDefaults() { protected void updateDefaults() { if (DBG) log("updateDefaults"); if (!isReadyToReevaluate()) return; Loading Loading @@ -687,7 +687,7 @@ public class MultiSimSettingController extends Handler { || change == PRIMARY_SUB_SWAPPED); } private void disableDataForNonDefaultNonOpportunisticSubscriptions() { protected void disableDataForNonDefaultNonOpportunisticSubscriptions() { if (!isReadyToReevaluate()) return; int defaultDataSub = mSubController.getDefaultDataSubId(); Loading Loading @@ -718,7 +718,7 @@ public class MultiSimSettingController extends Handler { * Make sure MOBILE_DATA of subscriptions in the same group with the subId * are synced. */ private void setUserDataEnabledForGroup(int subId, boolean enable) { protected void setUserDataEnabledForGroup(int subId, boolean enable) { log("setUserDataEnabledForGroup subId " + subId + " enable " + enable); List<SubscriptionInfo> infoList = mSubController.getSubscriptionsInGroup( mSubController.getGroupUuid(subId), mContext.getOpPackageName(), Loading src/java/com/android/internal/telephony/PhoneFactory.java +7 −3 Original line number Diff line number Diff line Loading @@ -180,7 +180,9 @@ public class PhoneFactory { Rlog.i(LOG_TAG, "Creating SubscriptionController"); TelephonyComponentFactory.getInstance().inject(SubscriptionController.class. getName()).initSubscriptionController(context); MultiSimSettingController.init(context, SubscriptionController.getInstance()); TelephonyComponentFactory.getInstance().inject(MultiSimSettingController.class. getName()).initMultiSimSettingController(context, SubscriptionController.getInstance()); if (context.getPackageManager().hasSystemFeature( PackageManager.FEATURE_TELEPHONY_EUICC)) { Loading Loading @@ -215,8 +217,10 @@ public class PhoneFactory { Rlog.i(LOG_TAG, "Creating SubInfoRecordUpdater "); HandlerThread pfhandlerThread = new HandlerThread("PhoneFactoryHandlerThread"); pfhandlerThread.start(); sSubInfoRecordUpdater = new SubscriptionInfoUpdater( pfhandlerThread.getLooper(), context, sCommandsInterfaces); sSubInfoRecordUpdater = TelephonyComponentFactory.getInstance().inject( SubscriptionInfoUpdater.class.getName()). makeSubscriptionInfoUpdater(pfhandlerThread. getLooper(), context, sCommandsInterfaces); // Only bring up IMS if the device supports having an IMS stack. if (context.getPackageManager().hasSystemFeature( Loading src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java +29 −22 Original line number Diff line number Diff line Loading @@ -106,7 +106,7 @@ public class SubscriptionInfoUpdater extends Handler { private static Context sContext = null; @UnsupportedAppUsage private static String[] sIccId = new String[SUPPORTED_MODEM_COUNT]; protected static String[] sIccId = new String[SUPPORTED_MODEM_COUNT]; private static int[] sSimCardState = new int[SUPPORTED_MODEM_COUNT]; private static int[] sSimApplicationState = new int[SUPPORTED_MODEM_COUNT]; private static boolean sIsSubInfoInitialized = false; Loading @@ -123,7 +123,7 @@ public class SubscriptionInfoUpdater extends Handler { * Runnable with a boolean parameter. This is used in * updateEmbeddedSubscriptions(List<Integer> cardIds, @Nullable UpdateEmbeddedSubsCallback). */ private interface UpdateEmbeddedSubsCallback { protected interface UpdateEmbeddedSubsCallback { /** * Callback of the Runnable. * @param hasChanges Whether there is any subscription info change. If yes, we need to Loading Loading @@ -216,7 +216,7 @@ public class SubscriptionInfoUpdater extends Handler { } @UnsupportedAppUsage private boolean isAllIccIdQueryDone() { protected boolean isAllIccIdQueryDone() { for (int i = 0; i < TelephonyManager.getDefault().getActiveModemCount(); i++) { UiccSlot slot = UiccController.getInstance().getUiccSlotForPhone(i); int slotId = UiccController.getInstance().getSlotIdFromPhoneId(i); Loading Loading @@ -293,15 +293,7 @@ public class SubscriptionInfoUpdater extends Handler { break; case EVENT_SIM_READY: cardIds.add(getCardIdFromPhoneId(msg.arg1)); updateEmbeddedSubscriptions(cardIds, (hasChanges) -> { if (hasChanges) { SubscriptionController.getInstance().notifySubscriptionInfoChanged(); } }); broadcastSimStateChanged(msg.arg1, IccCardConstants.INTENT_VALUE_ICC_READY, null); broadcastSimCardStateChanged(msg.arg1, TelephonyManager.SIM_STATE_PRESENT); broadcastSimApplicationStateChanged(msg.arg1, TelephonyManager.SIM_STATE_NOT_READY); handleSimReady(msg.arg1); break; case EVENT_SIM_IMSI: Loading Loading @@ -354,7 +346,7 @@ public class SubscriptionInfoUpdater extends Handler { } } private int getCardIdFromPhoneId(int phoneId) { protected int getCardIdFromPhoneId(int phoneId) { UiccController uiccController = UiccController.getInstance(); UiccCard card = uiccController.getUiccCardForPhone(phoneId); if (card != null) { Loading @@ -368,7 +360,7 @@ public class SubscriptionInfoUpdater extends Handler { EVENT_REFRESH_EMBEDDED_SUBSCRIPTIONS, cardId, 0 /* arg2 */, callback)); } private void handleSimLocked(int phoneId, String reason) { protected void handleSimLocked(int phoneId, String reason) { if (sIccId[phoneId] != null && sIccId[phoneId].equals(ICCID_STRING_FOR_NO_SIM)) { logd("SIM" + (phoneId + 1) + " hot plug in"); sIccId[phoneId] = null; Loading Loading @@ -415,7 +407,22 @@ public class SubscriptionInfoUpdater extends Handler { } } private void handleSimNotReady(int phoneId) { protected void handleSimReady(int phoneId) { List<Integer> cardIds = new ArrayList<>(); cardIds.add(getCardIdFromPhoneId(phoneId)); updateEmbeddedSubscriptions(cardIds, (hasChanges) -> { if (hasChanges) { SubscriptionController.getInstance().notifySubscriptionInfoChanged(); } }); broadcastSimStateChanged(phoneId, IccCardConstants.INTENT_VALUE_ICC_READY, null); broadcastSimCardStateChanged(phoneId, TelephonyManager.SIM_STATE_PRESENT); broadcastSimApplicationStateChanged(phoneId, TelephonyManager.SIM_STATE_NOT_READY); } protected void handleSimNotReady(int phoneId) { logd("handleSimNotReady: phoneId: " + phoneId); boolean isFinalState = false; Loading Loading @@ -451,7 +458,7 @@ public class SubscriptionInfoUpdater extends Handler { return info != null && !info.areUiccApplicationsEnabled(); } private void handleSimLoaded(int phoneId) { protected void handleSimLoaded(int phoneId) { logd("handleSimLoaded: phoneId: " + phoneId); // The SIM should be loaded at this state, but it is possible in cases such as SIM being Loading Loading @@ -633,7 +640,7 @@ public class SubscriptionInfoUpdater extends Handler { updateSubscriptionInfoByIccId(phoneId, true /* updateEmbeddedSubs */); } private void handleSimAbsent(int phoneId) { protected void handleSimAbsent(int phoneId) { if (!SubscriptionManager.isValidPhoneId(phoneId)) { logd("handleSimAbsent on invalid phoneId"); return; Loading @@ -650,7 +657,7 @@ public class SubscriptionInfoUpdater extends Handler { updateCarrierServices(phoneId, IccCardConstants.INTENT_VALUE_ICC_ABSENT); } private void handleSimError(int phoneId) { protected void handleSimError(int phoneId) { if (sIccId[phoneId] != null && !sIccId[phoneId].equals(ICCID_STRING_FOR_NO_SIM)) { logd("SIM" + (phoneId + 1) + " Error "); } Loading @@ -664,7 +671,7 @@ public class SubscriptionInfoUpdater extends Handler { updateCarrierServices(phoneId, IccCardConstants.INTENT_VALUE_ICC_CARD_IO_ERROR); } private synchronized void updateSubscriptionInfoByIccId(int phoneId, protected synchronized void updateSubscriptionInfoByIccId(int phoneId, boolean updateEmbeddedSubs) { logd("updateSubscriptionInfoByIccId:+ Start - phoneId: " + phoneId); if (!SubscriptionManager.isValidPhoneId(phoneId)) { Loading Loading @@ -1114,7 +1121,7 @@ public class SubscriptionInfoUpdater extends Handler { } @UnsupportedAppUsage private void broadcastSimStateChanged(int phoneId, String state, String reason) { protected void broadcastSimStateChanged(int phoneId, String state, String reason) { Intent i = new Intent(TelephonyIntents.ACTION_SIM_STATE_CHANGED); // TODO - we'd like this intent to have a single snapshot of all sim state, // but until then this should not use REPLACE_PENDING or we may lose Loading @@ -1131,7 +1138,7 @@ public class SubscriptionInfoUpdater extends Handler { IntentBroadcaster.getInstance().broadcastStickyIntent(sContext, i, phoneId); } private void broadcastSimCardStateChanged(int phoneId, int state) { protected void broadcastSimCardStateChanged(int phoneId, int state) { if (state != sSimCardState[phoneId]) { sSimCardState[phoneId] = state; Intent i = new Intent(TelephonyManager.ACTION_SIM_CARD_STATE_CHANGED); Loading @@ -1149,7 +1156,7 @@ public class SubscriptionInfoUpdater extends Handler { } } private void broadcastSimApplicationStateChanged(int phoneId, int state) { protected void broadcastSimApplicationStateChanged(int phoneId, int state) { // Broadcast if the state has changed, except if old state was UNKNOWN and new is NOT_READY, // because that's the initial state and a broadcast should be sent only on a transition // after SIM is PRESENT. The only exception is eSIM boot profile, where NOT_READY is the Loading src/java/com/android/internal/telephony/TelephonyComponentFactory.java +10 −0 Original line number Diff line number Diff line Loading @@ -433,4 +433,14 @@ public class TelephonyComponentFactory { public DisplayInfoController makeDisplayInfoController(Phone phone) { return new DisplayInfoController(phone); } public MultiSimSettingController initMultiSimSettingController(Context c, SubscriptionController sc) { return MultiSimSettingController.init(c, sc); } public SubscriptionInfoUpdater makeSubscriptionInfoUpdater(Looper looper, Context context, CommandsInterface[] ci) { return new SubscriptionInfoUpdater(looper, context, ci); } } src/java/com/android/internal/telephony/vendor/VendorMultiSimSettingController.java 0 → 100644 +112 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.telephony.vendor; import android.content.Context; import android.provider.Settings; import android.provider.Settings.SettingNotFoundException; import android.telephony.SubscriptionInfo; import android.util.Log; import com.android.internal.telephony.GlobalSettingsHelper; import com.android.internal.telephony.MultiSimSettingController; import com.android.internal.telephony.SubscriptionController; import com.android.internal.telephony.Phone; import com.android.internal.telephony.PhoneFactory; import java.util.List; import java.util.stream.Collectors; /* * Extending VendorMultiSimSettingController to override default * behavior for mobile data */ public class VendorMultiSimSettingController extends MultiSimSettingController { private static final String LOG_TAG = "VendorMultiSimSettingController"; public static MultiSimSettingController init(Context context, SubscriptionController sc) { synchronized (VendorMultiSimSettingController.class) { if (sInstance == null) { sInstance = new VendorMultiSimSettingController(context, SubscriptionController.getInstance()); } else { Log.wtf(LOG_TAG, "init() called multiple times! sInstance = " + sInstance); } } return sInstance; } private VendorMultiSimSettingController(Context context, SubscriptionController sc) { super(context, sc); } public static VendorMultiSimSettingController getInstance() { return (VendorMultiSimSettingController)sInstance; } @Override protected void disableDataForNonDefaultNonOpportunisticSubscriptions() { log("disableDataForNonDefaultNonOpportunisticSubscriptions - do nothing"); } protected synchronized void onUserDataEnabled(int subId, boolean enable) { log("onUserDataEnabled"); // Make sure MOBILE_DATA of subscriptions in same group are synced. setUserDataEnabledForGroup(subId, enable); } /** * Make sure MOBILE_DATA of subscriptions in the same group with the subId * are synced. */ @Override protected synchronized void setUserDataEnabledForGroup(int subId, boolean enable) { log("setUserDataEnabledForGroup subId " + subId + " enable " + enable); List<SubscriptionInfo> infoList = mSubController.getSubscriptionsInGroup( mSubController.getGroupUuid(subId), mContext.getOpPackageName(), null); if (infoList == null) return; for (SubscriptionInfo info : infoList) { int currentSubId = info.getSubscriptionId(); if (currentSubId == subId) continue; // TODO: simplify when setUserDataEnabled becomes singleton if (mSubController.isActiveSubId(currentSubId)) { // For active subscription, call setUserDataEnabled through DataEnabledSettings. Phone phone = PhoneFactory.getPhone(mSubController.getPhoneId(currentSubId)); if (phone != null) { phone.getDataEnabledSettings().setUserDataEnabled(enable); } } else { // For inactive subscription, directly write into global settings. GlobalSettingsHelper.setBoolean( mContext, Settings.Global.MOBILE_DATA, currentSubId, enable); } } } @Override protected void updateDefaults() { log("updateDefaults"); } protected void log(String msg) { Log.d(LOG_TAG, msg); } } Loading
src/java/com/android/internal/telephony/MultiSimSettingController.java +7 −7 Original line number Diff line number Diff line Loading @@ -109,13 +109,13 @@ public class MultiSimSettingController extends Handler { // Subscription information is initially loaded. private static final int PRIMARY_SUB_INITIALIZED = 6; private final Context mContext; private final SubscriptionController mSubController; protected final Context mContext; protected final SubscriptionController mSubController; // Keep a record of active primary (non-opportunistic) subscription list. @NonNull private List<Integer> mPrimarySubList = new ArrayList<>(); /** The singleton instance. */ private static MultiSimSettingController sInstance = null; protected static MultiSimSettingController sInstance = null; // This will be set true when handling EVENT_ALL_SUBSCRIPTIONS_LOADED. The reason of keeping // a local variable instead of calling SubscriptionInfoUpdater#isSubInfoInitialized is, there Loading Loading @@ -288,7 +288,7 @@ public class MultiSimSettingController extends Handler { * If user is enabling a non-default non-opportunistic subscription, make it default * data subscription. */ private void onUserDataEnabled(int subId, boolean enable) { protected void onUserDataEnabled(int subId, boolean enable) { if (DBG) log("onUserDataEnabled"); // Make sure MOBILE_DATA of subscriptions in same group are synced. setUserDataEnabledForGroup(subId, enable); Loading Loading @@ -483,7 +483,7 @@ public class MultiSimSettingController extends Handler { * 4) If non above is met, clear the default value to INVALID. * */ private void updateDefaults() { protected void updateDefaults() { if (DBG) log("updateDefaults"); if (!isReadyToReevaluate()) return; Loading Loading @@ -687,7 +687,7 @@ public class MultiSimSettingController extends Handler { || change == PRIMARY_SUB_SWAPPED); } private void disableDataForNonDefaultNonOpportunisticSubscriptions() { protected void disableDataForNonDefaultNonOpportunisticSubscriptions() { if (!isReadyToReevaluate()) return; int defaultDataSub = mSubController.getDefaultDataSubId(); Loading Loading @@ -718,7 +718,7 @@ public class MultiSimSettingController extends Handler { * Make sure MOBILE_DATA of subscriptions in the same group with the subId * are synced. */ private void setUserDataEnabledForGroup(int subId, boolean enable) { protected void setUserDataEnabledForGroup(int subId, boolean enable) { log("setUserDataEnabledForGroup subId " + subId + " enable " + enable); List<SubscriptionInfo> infoList = mSubController.getSubscriptionsInGroup( mSubController.getGroupUuid(subId), mContext.getOpPackageName(), Loading
src/java/com/android/internal/telephony/PhoneFactory.java +7 −3 Original line number Diff line number Diff line Loading @@ -180,7 +180,9 @@ public class PhoneFactory { Rlog.i(LOG_TAG, "Creating SubscriptionController"); TelephonyComponentFactory.getInstance().inject(SubscriptionController.class. getName()).initSubscriptionController(context); MultiSimSettingController.init(context, SubscriptionController.getInstance()); TelephonyComponentFactory.getInstance().inject(MultiSimSettingController.class. getName()).initMultiSimSettingController(context, SubscriptionController.getInstance()); if (context.getPackageManager().hasSystemFeature( PackageManager.FEATURE_TELEPHONY_EUICC)) { Loading Loading @@ -215,8 +217,10 @@ public class PhoneFactory { Rlog.i(LOG_TAG, "Creating SubInfoRecordUpdater "); HandlerThread pfhandlerThread = new HandlerThread("PhoneFactoryHandlerThread"); pfhandlerThread.start(); sSubInfoRecordUpdater = new SubscriptionInfoUpdater( pfhandlerThread.getLooper(), context, sCommandsInterfaces); sSubInfoRecordUpdater = TelephonyComponentFactory.getInstance().inject( SubscriptionInfoUpdater.class.getName()). makeSubscriptionInfoUpdater(pfhandlerThread. getLooper(), context, sCommandsInterfaces); // Only bring up IMS if the device supports having an IMS stack. if (context.getPackageManager().hasSystemFeature( Loading
src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java +29 −22 Original line number Diff line number Diff line Loading @@ -106,7 +106,7 @@ public class SubscriptionInfoUpdater extends Handler { private static Context sContext = null; @UnsupportedAppUsage private static String[] sIccId = new String[SUPPORTED_MODEM_COUNT]; protected static String[] sIccId = new String[SUPPORTED_MODEM_COUNT]; private static int[] sSimCardState = new int[SUPPORTED_MODEM_COUNT]; private static int[] sSimApplicationState = new int[SUPPORTED_MODEM_COUNT]; private static boolean sIsSubInfoInitialized = false; Loading @@ -123,7 +123,7 @@ public class SubscriptionInfoUpdater extends Handler { * Runnable with a boolean parameter. This is used in * updateEmbeddedSubscriptions(List<Integer> cardIds, @Nullable UpdateEmbeddedSubsCallback). */ private interface UpdateEmbeddedSubsCallback { protected interface UpdateEmbeddedSubsCallback { /** * Callback of the Runnable. * @param hasChanges Whether there is any subscription info change. If yes, we need to Loading Loading @@ -216,7 +216,7 @@ public class SubscriptionInfoUpdater extends Handler { } @UnsupportedAppUsage private boolean isAllIccIdQueryDone() { protected boolean isAllIccIdQueryDone() { for (int i = 0; i < TelephonyManager.getDefault().getActiveModemCount(); i++) { UiccSlot slot = UiccController.getInstance().getUiccSlotForPhone(i); int slotId = UiccController.getInstance().getSlotIdFromPhoneId(i); Loading Loading @@ -293,15 +293,7 @@ public class SubscriptionInfoUpdater extends Handler { break; case EVENT_SIM_READY: cardIds.add(getCardIdFromPhoneId(msg.arg1)); updateEmbeddedSubscriptions(cardIds, (hasChanges) -> { if (hasChanges) { SubscriptionController.getInstance().notifySubscriptionInfoChanged(); } }); broadcastSimStateChanged(msg.arg1, IccCardConstants.INTENT_VALUE_ICC_READY, null); broadcastSimCardStateChanged(msg.arg1, TelephonyManager.SIM_STATE_PRESENT); broadcastSimApplicationStateChanged(msg.arg1, TelephonyManager.SIM_STATE_NOT_READY); handleSimReady(msg.arg1); break; case EVENT_SIM_IMSI: Loading Loading @@ -354,7 +346,7 @@ public class SubscriptionInfoUpdater extends Handler { } } private int getCardIdFromPhoneId(int phoneId) { protected int getCardIdFromPhoneId(int phoneId) { UiccController uiccController = UiccController.getInstance(); UiccCard card = uiccController.getUiccCardForPhone(phoneId); if (card != null) { Loading @@ -368,7 +360,7 @@ public class SubscriptionInfoUpdater extends Handler { EVENT_REFRESH_EMBEDDED_SUBSCRIPTIONS, cardId, 0 /* arg2 */, callback)); } private void handleSimLocked(int phoneId, String reason) { protected void handleSimLocked(int phoneId, String reason) { if (sIccId[phoneId] != null && sIccId[phoneId].equals(ICCID_STRING_FOR_NO_SIM)) { logd("SIM" + (phoneId + 1) + " hot plug in"); sIccId[phoneId] = null; Loading Loading @@ -415,7 +407,22 @@ public class SubscriptionInfoUpdater extends Handler { } } private void handleSimNotReady(int phoneId) { protected void handleSimReady(int phoneId) { List<Integer> cardIds = new ArrayList<>(); cardIds.add(getCardIdFromPhoneId(phoneId)); updateEmbeddedSubscriptions(cardIds, (hasChanges) -> { if (hasChanges) { SubscriptionController.getInstance().notifySubscriptionInfoChanged(); } }); broadcastSimStateChanged(phoneId, IccCardConstants.INTENT_VALUE_ICC_READY, null); broadcastSimCardStateChanged(phoneId, TelephonyManager.SIM_STATE_PRESENT); broadcastSimApplicationStateChanged(phoneId, TelephonyManager.SIM_STATE_NOT_READY); } protected void handleSimNotReady(int phoneId) { logd("handleSimNotReady: phoneId: " + phoneId); boolean isFinalState = false; Loading Loading @@ -451,7 +458,7 @@ public class SubscriptionInfoUpdater extends Handler { return info != null && !info.areUiccApplicationsEnabled(); } private void handleSimLoaded(int phoneId) { protected void handleSimLoaded(int phoneId) { logd("handleSimLoaded: phoneId: " + phoneId); // The SIM should be loaded at this state, but it is possible in cases such as SIM being Loading Loading @@ -633,7 +640,7 @@ public class SubscriptionInfoUpdater extends Handler { updateSubscriptionInfoByIccId(phoneId, true /* updateEmbeddedSubs */); } private void handleSimAbsent(int phoneId) { protected void handleSimAbsent(int phoneId) { if (!SubscriptionManager.isValidPhoneId(phoneId)) { logd("handleSimAbsent on invalid phoneId"); return; Loading @@ -650,7 +657,7 @@ public class SubscriptionInfoUpdater extends Handler { updateCarrierServices(phoneId, IccCardConstants.INTENT_VALUE_ICC_ABSENT); } private void handleSimError(int phoneId) { protected void handleSimError(int phoneId) { if (sIccId[phoneId] != null && !sIccId[phoneId].equals(ICCID_STRING_FOR_NO_SIM)) { logd("SIM" + (phoneId + 1) + " Error "); } Loading @@ -664,7 +671,7 @@ public class SubscriptionInfoUpdater extends Handler { updateCarrierServices(phoneId, IccCardConstants.INTENT_VALUE_ICC_CARD_IO_ERROR); } private synchronized void updateSubscriptionInfoByIccId(int phoneId, protected synchronized void updateSubscriptionInfoByIccId(int phoneId, boolean updateEmbeddedSubs) { logd("updateSubscriptionInfoByIccId:+ Start - phoneId: " + phoneId); if (!SubscriptionManager.isValidPhoneId(phoneId)) { Loading Loading @@ -1114,7 +1121,7 @@ public class SubscriptionInfoUpdater extends Handler { } @UnsupportedAppUsage private void broadcastSimStateChanged(int phoneId, String state, String reason) { protected void broadcastSimStateChanged(int phoneId, String state, String reason) { Intent i = new Intent(TelephonyIntents.ACTION_SIM_STATE_CHANGED); // TODO - we'd like this intent to have a single snapshot of all sim state, // but until then this should not use REPLACE_PENDING or we may lose Loading @@ -1131,7 +1138,7 @@ public class SubscriptionInfoUpdater extends Handler { IntentBroadcaster.getInstance().broadcastStickyIntent(sContext, i, phoneId); } private void broadcastSimCardStateChanged(int phoneId, int state) { protected void broadcastSimCardStateChanged(int phoneId, int state) { if (state != sSimCardState[phoneId]) { sSimCardState[phoneId] = state; Intent i = new Intent(TelephonyManager.ACTION_SIM_CARD_STATE_CHANGED); Loading @@ -1149,7 +1156,7 @@ public class SubscriptionInfoUpdater extends Handler { } } private void broadcastSimApplicationStateChanged(int phoneId, int state) { protected void broadcastSimApplicationStateChanged(int phoneId, int state) { // Broadcast if the state has changed, except if old state was UNKNOWN and new is NOT_READY, // because that's the initial state and a broadcast should be sent only on a transition // after SIM is PRESENT. The only exception is eSIM boot profile, where NOT_READY is the Loading
src/java/com/android/internal/telephony/TelephonyComponentFactory.java +10 −0 Original line number Diff line number Diff line Loading @@ -433,4 +433,14 @@ public class TelephonyComponentFactory { public DisplayInfoController makeDisplayInfoController(Phone phone) { return new DisplayInfoController(phone); } public MultiSimSettingController initMultiSimSettingController(Context c, SubscriptionController sc) { return MultiSimSettingController.init(c, sc); } public SubscriptionInfoUpdater makeSubscriptionInfoUpdater(Looper looper, Context context, CommandsInterface[] ci) { return new SubscriptionInfoUpdater(looper, context, ci); } }
src/java/com/android/internal/telephony/vendor/VendorMultiSimSettingController.java 0 → 100644 +112 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.telephony.vendor; import android.content.Context; import android.provider.Settings; import android.provider.Settings.SettingNotFoundException; import android.telephony.SubscriptionInfo; import android.util.Log; import com.android.internal.telephony.GlobalSettingsHelper; import com.android.internal.telephony.MultiSimSettingController; import com.android.internal.telephony.SubscriptionController; import com.android.internal.telephony.Phone; import com.android.internal.telephony.PhoneFactory; import java.util.List; import java.util.stream.Collectors; /* * Extending VendorMultiSimSettingController to override default * behavior for mobile data */ public class VendorMultiSimSettingController extends MultiSimSettingController { private static final String LOG_TAG = "VendorMultiSimSettingController"; public static MultiSimSettingController init(Context context, SubscriptionController sc) { synchronized (VendorMultiSimSettingController.class) { if (sInstance == null) { sInstance = new VendorMultiSimSettingController(context, SubscriptionController.getInstance()); } else { Log.wtf(LOG_TAG, "init() called multiple times! sInstance = " + sInstance); } } return sInstance; } private VendorMultiSimSettingController(Context context, SubscriptionController sc) { super(context, sc); } public static VendorMultiSimSettingController getInstance() { return (VendorMultiSimSettingController)sInstance; } @Override protected void disableDataForNonDefaultNonOpportunisticSubscriptions() { log("disableDataForNonDefaultNonOpportunisticSubscriptions - do nothing"); } protected synchronized void onUserDataEnabled(int subId, boolean enable) { log("onUserDataEnabled"); // Make sure MOBILE_DATA of subscriptions in same group are synced. setUserDataEnabledForGroup(subId, enable); } /** * Make sure MOBILE_DATA of subscriptions in the same group with the subId * are synced. */ @Override protected synchronized void setUserDataEnabledForGroup(int subId, boolean enable) { log("setUserDataEnabledForGroup subId " + subId + " enable " + enable); List<SubscriptionInfo> infoList = mSubController.getSubscriptionsInGroup( mSubController.getGroupUuid(subId), mContext.getOpPackageName(), null); if (infoList == null) return; for (SubscriptionInfo info : infoList) { int currentSubId = info.getSubscriptionId(); if (currentSubId == subId) continue; // TODO: simplify when setUserDataEnabled becomes singleton if (mSubController.isActiveSubId(currentSubId)) { // For active subscription, call setUserDataEnabled through DataEnabledSettings. Phone phone = PhoneFactory.getPhone(mSubController.getPhoneId(currentSubId)); if (phone != null) { phone.getDataEnabledSettings().setUserDataEnabled(enable); } } else { // For inactive subscription, directly write into global settings. GlobalSettingsHelper.setBoolean( mContext, Settings.Global.MOBILE_DATA, currentSubId, enable); } } } @Override protected void updateDefaults() { log("updateDefaults"); } protected void log(String msg) { Log.d(LOG_TAG, msg); } }