Merge "Use changeID and Compatibility.isChangeEnabled for Mainline" am: 1d40225791 am: f1317cc00c

Change-Id: If7f87f58d9014f36a981a767f8ab4c47e63c9442
This commit is contained in:
Automerger Merge Worker
2020-01-27 23:52:18 +00:00
2 changed files with 27 additions and 7 deletions

View File

@@ -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.Q)
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;
}

View File

@@ -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;
@@ -5108,6 +5106,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.Q)
private static final long GET_DATA_STATE_CODE_CHANGE = 147600208L;
/**
* Returns a constant indicating the current data connection state
* (cellular).
@@ -5126,7 +5131,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;
}
@@ -5178,6 +5183,13 @@ public class TelephonyManager {
//
//
/**
* To check the SDK version for {@link TelephonyManager#listen}.
*/
@ChangeId
@EnabledAfter(targetSdkVersion = Build.VERSION_CODES.P)
private static final long LISTEN_CODE_CHANGE = 147600208L;
/**
* Registers a listener object to receive notification of changes
* in specified telephony states.
@@ -5217,7 +5229,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