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

Commit 87868f48 authored by Ling Ma's avatar Ling Ma Committed by Android (Google) Code Review
Browse files

Merge "Read auto data switch config from res" into udc-dev

parents 3a84cc40 4390b135
Loading
Loading
Loading
Loading
+7 −29
Original line number Diff line number Diff line
@@ -72,12 +72,6 @@ public class DataConfigManager extends Handler {
    /** The default timeout in ms for data network stuck in a transit state. */
    private static final int DEFAULT_NETWORK_TRANSIT_STATE_TIMEOUT_MS = 300000;

    /** Default time threshold in ms to define a internet connection status to be stable. */
    public static int DEFAULT_AUTO_DATA_SWITCH_STABILITY_TIME_MS = 10000;

    /** The max number of retries when a pre-switching validation fails. */
    public static int DEFAULT_AUTO_DATA_SWITCH_MAX_RETRY = 7;

    /** Event for carrier config changed. */
    private static final int EVENT_CARRIER_CONFIG_CHANGED = 1;

@@ -268,18 +262,6 @@ public class DataConfigManager extends Handler {
     */
    private boolean mIsApnConfigAnomalyReportEnabled;

    /**
     * Time threshold in ms to define a internet connection status to be stable(e.g. out of service,
     * in service, wifi is the default active network.etc), while -1 indicates auto switch feature
     * disabled.
     */
    private long mAutoDataSwitchAvailabilityStabilityTimeThreshold;

    /**
     * The maximum number of retries when a pre-switching validation fails.
     */
    private int mAutoDataSwitchValidationMaxRetry;

    private @NonNull final Phone mPhone;
    private @NonNull final String mLogTag;

@@ -440,12 +422,6 @@ public class DataConfigManager extends Handler {
                KEY_ANOMALY_NETWORK_HANDOVER_TIMEOUT, DEFAULT_NETWORK_TRANSIT_STATE_TIMEOUT_MS);
        mIsApnConfigAnomalyReportEnabled = properties.getBoolean(
                KEY_ANOMALY_APN_CONFIG_ENABLED, false);
        mAutoDataSwitchAvailabilityStabilityTimeThreshold = properties.getInt(
                KEY_AUTO_DATA_SWITCH_AVAILABILITY_STABILITY_TIME_THRESHOLD,
                DEFAULT_AUTO_DATA_SWITCH_STABILITY_TIME_MS);
        mAutoDataSwitchValidationMaxRetry = properties.getInt(
                KEY_AUTO_DATA_SWITCH_VALIDATION_MAX_RETRY,
                DEFAULT_AUTO_DATA_SWITCH_MAX_RETRY);
    }

    /**
@@ -957,7 +933,8 @@ public class DataConfigManager extends Handler {
     * @return The maximum number of retries when a validation for switching failed.
     */
    public int getAutoDataSwitchValidationMaxRetry() {
        return mAutoDataSwitchValidationMaxRetry;
        return mResources.getInteger(com.android.internal.R.integer
                .auto_data_switch_validation_max_retry);
    }

    /**
@@ -966,7 +943,8 @@ public class DataConfigManager extends Handler {
     * auto switch feature disabled.
     */
    public long getAutoDataSwitchAvailabilityStabilityTimeThreshold() {
        return mAutoDataSwitchAvailabilityStabilityTimeThreshold;
        return mResources.getInteger(com.android.internal.R.integer
                .auto_data_switch_availability_stability_time_threshold_millis);
    }

    /**
@@ -1349,9 +1327,9 @@ public class DataConfigManager extends Handler {
        pw.println("mNetworkDisconnectingTimeout=" + mNetworkDisconnectingTimeout);
        pw.println("mNetworkHandoverTimeout=" + mNetworkHandoverTimeout);
        pw.println("mIsApnConfigAnomalyReportEnabled=" + mIsApnConfigAnomalyReportEnabled);
        pw.println("mAutoDataSwitchAvailabilityStabilityTimeThreshold="
                + mAutoDataSwitchAvailabilityStabilityTimeThreshold);
        pw.println("mAutoDataSwitchValidationMaxRetry=" + mAutoDataSwitchValidationMaxRetry);
        pw.println("getAutoDataSwitchAvailabilityStabilityTimeThreshold="
                + getAutoDataSwitchAvailabilityStabilityTimeThreshold());
        pw.println("getAutoDataSwitchValidationMaxRetry=" + getAutoDataSwitchValidationMaxRetry());
        pw.println("Metered APN types=" + mMeteredApnTypes.stream()
                .map(ApnSetting::getApnTypeString).collect(Collectors.joining(",")));
        pw.println("Roaming metered APN types=" + mRoamingMeteredApnTypes.stream()
+6 −22
Original line number Diff line number Diff line
@@ -295,11 +295,6 @@ public class PhoneSwitcher extends Handler {
    /** Data config manager callback for updating device config. **/
    private final DataConfigManager.DataConfigManagerCallback mDataConfigManagerCallback =
            new DataConfigManager.DataConfigManagerCallback(this::post) {
        @Override
        public void onDeviceConfigChanged() {
            log("onDeviceConfigChanged");
            PhoneSwitcher.this.updateDeviceConfig();
        }

        @Override
        public void onCarrierConfigChanged() {
@@ -383,8 +378,7 @@ public class PhoneSwitcher extends Handler {
    /**
     * The maximum number of retries when a validation for switching failed.
     */
    private int mAutoDataSwitchValidationMaxRetry =
            DataConfigManager.DEFAULT_AUTO_DATA_SWITCH_MAX_RETRY;
    private int mAutoDataSwitchValidationMaxRetry;

    /** Data settings manager callback. Key is the phone id. */
    private final @NonNull Map<Integer, DataSettingsManagerCallback> mDataSettingsManagerCallbacks =
@@ -937,25 +931,26 @@ public class PhoneSwitcher extends Handler {
    }

    /**
     * Register for device config change on the primary data phone.
     * Register for config change on the primary data phone.
     */
    private void registerConfigChange() {
        Phone phone = getPhoneBySubId(mPrimaryDataSubId);
        if (phone != null) {
            DataConfigManager dataConfig = phone.getDataNetworkController().getDataConfigManager();
            dataConfig.registerCallback(mDataConfigManagerCallback);
            updateDeviceConfig();
            updateCarrierConfig();
            sendEmptyMessage(EVENT_EVALUATE_AUTO_SWITCH);
        }
    }

    /**
     * Update device config.
     * Update carrier config.
     */
    private void updateDeviceConfig() {
    private void updateCarrierConfig() {
        Phone phone = getPhoneBySubId(mPrimaryDataSubId);
        if (phone != null) {
            DataConfigManager dataConfig = phone.getDataNetworkController().getDataConfigManager();
            mRequirePingTestBeforeDataSwitch = dataConfig.requirePingTestBeforeDataSwitch();
            mAutoDataSwitchAvailabilityStabilityTimeThreshold =
                    dataConfig.getAutoDataSwitchAvailabilityStabilityTimeThreshold();
            mAutoDataSwitchValidationMaxRetry =
@@ -963,17 +958,6 @@ public class PhoneSwitcher extends Handler {
        }
    }

    /**
     * Update carrier config.
     */
    private void updateCarrierConfig() {
        Phone phone = getPhoneBySubId(mPrimaryDataSubId);
        if (phone != null) {
            DataConfigManager dataConfig = phone.getDataNetworkController().getDataConfigManager();
            mRequirePingTestBeforeDataSwitch = dataConfig.requirePingTestBeforeDataSwitch();
        }
    }

    private synchronized void onMultiSimConfigChanged(int activeModemCount) {
        // No change.
        if (mActiveModemCount == activeModemCount) return;