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

Commit d0c81812 authored by Shuo Qian's avatar Shuo Qian
Browse files

Use changeID and Compatibility.isChangeEnabled for Mainline

Test: Treehugger
Bug: 145147528
Bug: 147600208

Change-Id: I8092f4c7d3be046da337cdcbadeed89844b3aaab
parent 10432c77
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -20,6 +20,9 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.compat.Compatibility;
import android.compat.annotation.ChangeId;
import android.compat.annotation.EnabledAfter;
import android.compat.annotation.UnsupportedAppUsage;
import android.net.LinkProperties;
import android.os.Build;
@@ -31,8 +34,6 @@ import android.telephony.Annotation.DataState;
import android.telephony.Annotation.NetworkType;
import android.telephony.data.ApnSetting;

import dalvik.system.VMRuntime;

import java.util.Objects;


@@ -133,6 +134,13 @@ public final class PreciseDataConnectionState implements Parcelable {
        mApnSetting = (ApnSetting) in.readParcelable(null);
    }

    /**
     * To check the SDK version for {@link PreciseDataConnectionState#getDataConnectionState}.
     */
    @ChangeId
    @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.R)
    private static final long GET_DATA_CONNECTION_STATE_CODE_CHANGE = 147600208L;

    /**
     * Returns the state of data connection that supported the apn types returned by
     * {@link #getDataConnectionApnTypeBitMask()}
@@ -144,7 +152,7 @@ public final class PreciseDataConnectionState implements Parcelable {
    @SystemApi
    public @DataState int getDataConnectionState() {
        if (mState == TelephonyManager.DATA_DISCONNECTING
                && VMRuntime.getRuntime().getTargetSdkVersion() < Build.VERSION_CODES.R) {
                && !Compatibility.isChangeEnabled(GET_DATA_CONNECTION_STATE_CODE_CHANGE)) {
            return TelephonyManager.DATA_CONNECTED;
        }

+16 −4
Original line number Diff line number Diff line
@@ -109,8 +109,6 @@ import com.android.internal.telephony.RILConstants;
import com.android.internal.telephony.SmsApplication;
import com.android.telephony.Rlog;

import dalvik.system.VMRuntime;

import java.io.FileInputStream;
import java.io.IOException;
import java.lang.annotation.Retention;
@@ -5410,6 +5408,13 @@ public class TelephonyManager {
     */
    public static final int DATA_DISCONNECTING = 4;

    /**
     * To check the SDK version for {@link TelephonyManager#getDataState}.
     */
    @ChangeId
    @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.R)
    private static final long GET_DATA_STATE_CODE_CHANGE = 147600208L;

    /**
     * Returns a constant indicating the current data connection state
     * (cellular).
@@ -5428,7 +5433,7 @@ public class TelephonyManager {
            int state = telephony.getDataStateForSubId(
                    getSubId(SubscriptionManager.getActiveDataSubscriptionId()));
            if (state == TelephonyManager.DATA_DISCONNECTING
                    && VMRuntime.getRuntime().getTargetSdkVersion() < Build.VERSION_CODES.R) {
                    && !Compatibility.isChangeEnabled(GET_DATA_STATE_CODE_CHANGE)) {
                return TelephonyManager.DATA_CONNECTED;
            }

@@ -5489,6 +5494,13 @@ public class TelephonyManager {
    //
    //

    /**
     * To check the SDK version for {@link TelephonyManager#listen}.
     */
    @ChangeId
    @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.Q)
    private static final long LISTEN_CODE_CHANGE = 147600208L;

    /**
     * Registers a listener object to receive notification of changes
     * in specified telephony states.
@@ -5528,7 +5540,7 @@ public class TelephonyManager {
                // subId from PhoneStateListener is deprecated Q on forward, use the subId from
                // TelephonyManager instance. keep using subId from PhoneStateListener for pre-Q.
                int subId = mSubId;
                if (VMRuntime.getRuntime().getTargetSdkVersion() >= Build.VERSION_CODES.Q) {
                if (Compatibility.isChangeEnabled(LISTEN_CODE_CHANGE)) {
                    // since mSubId in PhoneStateListener is deprecated from Q on forward, this is
                    // the only place to set mSubId and its for "informational" only.
                    //  TODO: remove this once we completely get rid of mSubId in PhoneStateListener