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

Commit ec2adbf2 authored by Jack Yu's avatar Jack Yu Committed by Gerrit Code Review
Browse files

Merge changes from topics "data_settings_manager", "tnf_migrate"

* changes:
  Migrated codes to the new package
  Hook DataSettingsManager to the new telephony data stack
parents 21258c3e e911257f
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -183,8 +183,10 @@ public class GsmCdmaCallTracker extends CallTracker {
            // Prior to phone switch to GSM, if CDMA has any emergency call
            // data will be in disabled state, after switching to GSM enable data.
            if (mIsInEmergencyCall) {
                if (!mPhone.isUsingNewDataStack()) {
                    mPhone.getDataEnabledSettings().setInternalDataEnabled(true);
                }
            }
        } else {
            mConnections = new GsmCdmaConnection[MAX_CONNECTIONS_CDMA];
            mPendingCallInEcm = false;
@@ -398,7 +400,9 @@ public class GsmCdmaCallTracker extends CallTracker {
    //CDMA
    public void setIsInEmergencyCall() {
        mIsInEmergencyCall = true;
        if (!mPhone.isUsingNewDataStack()) {
            mPhone.getDataEnabledSettings().setInternalDataEnabled(false);
        }
        mPhone.notifyEmergencyCallRegistrants(true);
        mPhone.sendEmergencyCallStateChange(true);
    }
@@ -1750,7 +1754,9 @@ public class GsmCdmaCallTracker extends CallTracker {
            }
            if (!inEcm) {
                // Re-initiate data connection
                if (!mPhone.isUsingNewDataStack()) {
                    mPhone.getDataEnabledSettings().setInternalDataEnabled(true);
                }
                mPhone.notifyEmergencyCallRegistrants(false);
            }
            mPhone.sendEmergencyCallStateChange(false);
+26 −3
Original line number Diff line number Diff line
@@ -358,6 +358,7 @@ public class GsmCdmaPhone extends Phone {
        mSST.registerForNetworkAttached(this, EVENT_REGISTERED_TO_NETWORK, null);
        mSST.registerForVoiceRegStateOrRatChanged(this, EVENT_VRS_OR_RAT_CHANGED, null);

        // TODO: Remove SettingsObserver and provisioning events when DataEnabledSettings is removed
        mSettingsObserver = new SettingsObserver(context, this);
        mSettingsObserver.observe(
                Settings.Global.getUriFor(Settings.Global.DEVICE_PROVISIONED),
@@ -2629,6 +2630,9 @@ public class GsmCdmaPhone extends Phone {

    @Override
    public boolean getDataRoamingEnabled() {
        if (isUsingNewDataStack()) {
            return getDataSettingsManager().isDataRoamingEnabled();
        }
        if (getDcTracker(AccessNetworkConstants.TRANSPORT_TYPE_WWAN) != null) {
            return getDcTracker(AccessNetworkConstants.TRANSPORT_TYPE_WWAN).getDataRoamingEnabled();
        }
@@ -2637,6 +2641,10 @@ public class GsmCdmaPhone extends Phone {

    @Override
    public void setDataRoamingEnabled(boolean enable) {
        if (isUsingNewDataStack()) {
            getDataSettingsManager().setDataRoamingEnabled(enable);
            return;
        }
        if (getDcTracker(AccessNetworkConstants.TRANSPORT_TYPE_WWAN) != null) {
            getDcTracker(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                    .setDataRoamingEnabledByUser(enable);
@@ -2691,6 +2699,10 @@ public class GsmCdmaPhone extends Phone {
     */
    @Override
    public boolean isUserDataEnabled() {
        if (isUsingNewDataStack()) {
            return getDataSettingsManager().isDataEnabledForReason(
                    TelephonyManager.DATA_ENABLED_REASON_USER);
        }
        if (mDataEnabledSettings.isProvisioning()) {
            return mDataEnabledSettings.isProvisioningDataEnabled();
        } else {
@@ -3249,14 +3261,23 @@ public class GsmCdmaPhone extends Phone {
            case EVENT_SET_CARRIER_DATA_ENABLED:
                ar = (AsyncResult) msg.obj;
                boolean enabled = (boolean) ar.result;
                if (isUsingNewDataStack()) {
                    getDataSettingsManager().setDataEnabled(
                            TelephonyManager.DATA_ENABLED_REASON_CARRIER, enabled);
                    return;
                }
                mDataEnabledSettings.setDataEnabled(TelephonyManager.DATA_ENABLED_REASON_CARRIER,
                        enabled);
                break;
            case EVENT_DEVICE_PROVISIONED_CHANGE:
                if (!isUsingNewDataStack()) {
                    mDataEnabledSettings.updateProvisionedChanged();
                }
                break;
            case EVENT_DEVICE_PROVISIONING_DATA_SETTING_CHANGE:
                if (!isUsingNewDataStack()) {
                    mDataEnabledSettings.updateProvisioningDataEnabled();
                }
                break;
            case EVENT_GET_AVAILABLE_NETWORKS_DONE:
                ar = (AsyncResult) msg.obj;
@@ -3748,7 +3769,9 @@ public class GsmCdmaPhone extends Phone {
            // send an Intent
            sendEmergencyCallbackModeChange();
            // Re-initiate data connection
            if (!isUsingNewDataStack()) {
                mDataEnabledSettings.setInternalDataEnabled(true);
            }
            notifyEmergencyCallRegistrants(false);
        }
        mIsTestingEmergencyCallbackMode = false;
+15 −5
Original line number Diff line number Diff line
@@ -790,11 +790,16 @@ public class MultiSimSettingController extends Handler {
                    && phone.isUserDataEnabled()
                    && !areSubscriptionsInSameGroup(defaultDataSub, phone.getSubId())) {
                log("setting data to false on " + phone.getSubId());
                if (phone.isUsingNewDataStack()) {
                    phone.getDataSettingsManager().setDataEnabled(
                            TelephonyManager.DATA_ENABLED_REASON_USER, false);
                } else {
                    phone.getDataEnabledSettings().setDataEnabled(
                            TelephonyManager.DATA_ENABLED_REASON_USER, false);
                }
            }
        }
    }

    private boolean areSubscriptionsInSameGroup(int subId1, int subId2) {
        if (!SubscriptionManager.isUsableSubscriptionId(subId1)
@@ -822,13 +827,18 @@ public class MultiSimSettingController extends Handler {
            int currentSubId = info.getSubscriptionId();
            // TODO: simplify when setUserDataEnabled becomes singleton
            if (mSubController.isActiveSubId(currentSubId)) {
                // For active subscription, call setUserDataEnabled through DataEnabledSettings.
                // For active subscription, call setUserDataEnabled through DataSettingsManager.
                Phone phone = PhoneFactory.getPhone(mSubController.getPhoneId(currentSubId));
                // If enable is true and it's not opportunistic subscription, we don't enable it,
                // as there can't e two
                // as there can't be two
                if (phone != null) {
                    if (phone.isUsingNewDataStack()) {
                        phone.getDataSettingsManager().setDataEnabled(
                                TelephonyManager.DATA_ENABLED_REASON_USER, enable);
                    } else {
                        phone.getDataEnabledSettings().setUserDataEnabled(enable, false);
                    }
                }
            } else {
                // For inactive subscription, directly write into global settings.
                GlobalSettingsHelper.setBoolean(
+9 −0
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.data.AccessNetworksManager;
import com.android.internal.telephony.data.DataNetworkController;
import com.android.internal.telephony.data.DataSettingsManager;
import com.android.internal.telephony.data.LinkBandwidthEstimator;
import com.android.internal.telephony.dataconnection.DataConnectionReasons;
import com.android.internal.telephony.dataconnection.DataEnabledSettings;
@@ -4889,6 +4890,14 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        return mDataNetworkController;
    }

    /**
     * @return The data settings manager
     */
    public @Nullable DataSettingsManager getDataSettingsManager() {
        if (mDataNetworkController == null) return null;
        return mDataNetworkController.getDataSettingsManager();
    }

    /**
     * Used in unit tests to set whether the AllowedNetworkTypes is loaded from Db.  Should not
     * be used otherwise.
+1 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ import android.telephony.TelephonyManager;
import android.util.LocalLog;

import com.android.internal.telephony.cdma.CdmaSubscriptionSourceManager;
import com.android.internal.telephony.dataconnection.TelephonyNetworkFactory;
import com.android.internal.telephony.data.TelephonyNetworkFactory;
import com.android.internal.telephony.euicc.EuiccCardController;
import com.android.internal.telephony.euicc.EuiccController;
import com.android.internal.telephony.imsphone.ImsPhone;
Loading