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

Commit 7abd1af2 authored by Ling Ma's avatar Ling Ma Committed by Automerger Merge Worker
Browse files

Add auto_data_switch_availability_stability_time_threshold to control auto...

Add auto_data_switch_availability_stability_time_threshold to control auto data switch am: 42505a8d

Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/2377339



Change-Id: I2f9909314bb6fe72df02ca1eb9c47ad0ea38c718
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents c1d1cfb3 42505a8d
Loading
Loading
Loading
Loading
+40 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ import android.os.PersistableBundle;
import android.os.Registrant;
import android.os.RegistrantList;
import android.os.RemoteException;
import android.provider.DeviceConfig;
import android.telephony.CarrierConfigManager;
import android.telephony.PhoneCapability;
import android.telephony.PhoneStateListener;
@@ -65,6 +66,7 @@ import android.telephony.ims.ImsReasonInfo;
import android.telephony.ims.ImsRegistrationAttributes;
import android.telephony.ims.RegistrationManager;
import android.telephony.ims.stub.ImsRegistrationImplBase;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.LocalLog;

@@ -109,6 +111,9 @@ import java.util.concurrent.CompletableFuture;
 */
public class PhoneSwitcher extends Handler {
    private static final String LOG_TAG = "PhoneSwitcher";
    /** DeviceConfig key of the time threshold in ms for defining a network status to be stable. **/
    private static final String KEY_AUTO_DATA_SWITCH_AVAILABILITY_STABILITY_TIME_THRESHOLD =
            "auto_data_switch_availability_stability_time_threshold";
    protected static final boolean VDBG = false;

    private static final int DEFAULT_NETWORK_CHANGE_TIMEOUT_MS = 5000;
@@ -294,6 +299,7 @@ public class PhoneSwitcher extends Handler {
    private static final int EVENT_PROCESS_SIM_STATE_CHANGE       = 119;
    @VisibleForTesting
    public static final int EVENT_IMS_RADIO_TECH_CHANGED          = 120;
    public static final int EVENT_DEVICE_CONFIG_CHANGED           = 121;

    // List of events triggers re-evaluations
    private static final String EVALUATION_REASON_RADIO_ON = "EVENT_RADIO_ON";
@@ -320,6 +326,13 @@ public class PhoneSwitcher extends Handler {

    private List<Set<CommandException.Error>> mCurrentDdsSwitchFailure;

    /**
     * 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 = -1;

    /** Data settings manager callback. Key is the phone id. */
    private final @NonNull Map<Integer, DataSettingsManagerCallback> mDataSettingsManagerCallbacks =
            new ArrayMap<>();
@@ -569,6 +582,17 @@ public class PhoneSwitcher extends Handler {
        // we want to see all requests
        networkFactory.registerIgnoringScore();

        // Register for device config update
        DeviceConfig.addOnPropertiesChangedListener(
                DeviceConfig.NAMESPACE_TELEPHONY, this::post,
                properties -> {
                    if (TextUtils.equals(DeviceConfig.NAMESPACE_TELEPHONY,
                            properties.getNamespace())) {
                        sendEmptyMessage(EVENT_DEVICE_CONFIG_CHANGED);
                    }
                });
        updateDeviceConfig();

        updateHalCommandToUse();

        log("PhoneSwitcher started");
@@ -840,7 +864,21 @@ public class PhoneSwitcher extends Handler {
                }
                break;
            }
            case EVENT_DEVICE_CONFIG_CHANGED: {
                updateDeviceConfig();
                break;
            }
        }
    }

    /** Update local properties from {@link DeviceConfig} */
    private void updateDeviceConfig() {
        DeviceConfig.Properties properties = //read all telephony properties
                DeviceConfig.getProperties(DeviceConfig.NAMESPACE_TELEPHONY);

        mAutoDataSwitchAvailabilityStabilityTimeThreshold = properties.getInt(
                KEY_AUTO_DATA_SWITCH_AVAILABILITY_STABILITY_TIME_THRESHOLD, -1);

    }

    private synchronized void onMultiSimConfigChanged(int activeModemCount) {
@@ -1701,6 +1739,8 @@ public class PhoneSwitcher extends Handler {
        pw.println("mActiveModemCount=" + mActiveModemCount);
        pw.println("mPhoneIdInVoiceCall=" + mPhoneIdInVoiceCall);
        pw.println("mCurrentDdsSwitchFailure=" + mCurrentDdsSwitchFailure);
        pw.println("mAutoDataSwitchAvailabilityStabilityTimeThreshold="
                + mAutoDataSwitchAvailabilityStabilityTimeThreshold);
        pw.println("Local logs:");
        pw.increaseIndent();
        mLocalLog.dump(fd, pw, args);