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

Commit 0e7fab02 authored by Amit Mahajan's avatar Amit Mahajan Committed by Gerrit Code Review
Browse files

Merge "Add vendor prefix files"

parents add216b6 cf33da23
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -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
@@ -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);
@@ -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;
@@ -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();
@@ -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(),
+7 −3
Original line number Diff line number Diff line
@@ -171,7 +171,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)) {
@@ -206,8 +208,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(
+29 −22
Original line number Diff line number Diff line
@@ -108,7 +108,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;
@@ -127,7 +127,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
@@ -237,7 +237,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);
@@ -314,15 +314,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:
@@ -375,7 +367,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) {
@@ -389,7 +381,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;
@@ -441,7 +433,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;

@@ -477,7 +484,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
@@ -660,7 +667,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;
@@ -677,7 +684,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 ");
        }
@@ -691,7 +698,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)) {
@@ -1141,7 +1148,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
@@ -1158,7 +1165,7 @@ public class SubscriptionInfoUpdater extends Handler {
        IntentBroadcaster.getInstance().broadcastStickyIntent(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);
@@ -1176,7 +1183,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
+10 −0
Original line number Diff line number Diff line
@@ -432,4 +432,14 @@ public class TelephonyComponentFactory {
            Looper looper) {
        return PhoneSwitcher.make(maxDataAttachModemCount, context, looper);
    }

    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);
    }
}
+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