Add getPhoneCapability function in TelephonyManager
- Add a resource for Device's Nr information. - Expose below as systemApi - getDeviceNrCapabilityBitmask() - getMaxActiveInternetData() - getMaxActivePacketSwitchedVoiceCalls() Bug: 175711587 Test: atest TelephonyManager#testGetPhoneCapability atest PhoneCapabilityTest atest PhoneConfigurationManagerTest atest CellularNetworkValidatorTest atest PhoneSwitcherTest atest TelephonyRegistryTest atest PhoneCapabilityTest Change-Id: Ide25344787c15b3a57a9e6621766ad02a906f12e
This commit is contained in:
@@ -41171,12 +41171,6 @@ package android.telephony {
|
||||
field public static final int SCAN_TYPE_PERIODIC = 1; // 0x1
|
||||
}
|
||||
|
||||
public final class PhoneCapability implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
||||
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.PhoneCapability> CREATOR;
|
||||
}
|
||||
|
||||
public class PhoneNumberFormattingTextWatcher implements android.text.TextWatcher {
|
||||
ctor public PhoneNumberFormattingTextWatcher();
|
||||
ctor public PhoneNumberFormattingTextWatcher(String);
|
||||
@@ -41353,10 +41347,6 @@ package android.telephony {
|
||||
method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public void onMessageWaitingIndicatorChanged(boolean);
|
||||
}
|
||||
|
||||
public static interface PhoneStateListener.PhoneCapabilityChangedListener {
|
||||
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void onPhoneCapabilityChanged(@NonNull android.telephony.PhoneCapability);
|
||||
}
|
||||
|
||||
public static interface PhoneStateListener.PreciseDataConnectionStateChangedListener {
|
||||
method @RequiresPermission(android.Manifest.permission.READ_PRECISE_PHONE_STATE) public void onPreciseDataConnectionStateChanged(@NonNull android.telephony.PreciseDataConnectionState);
|
||||
}
|
||||
|
||||
@@ -10964,6 +10964,18 @@ package android.telephony {
|
||||
field public static final int REASON_UNSPECIFIED = 0; // 0x0
|
||||
}
|
||||
|
||||
public final class PhoneCapability implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method public int getDeviceNrCapabilityBitmask();
|
||||
method @IntRange(from=1) public int getMaxActiveInternetData();
|
||||
method @IntRange(from=1) public int getMaxActivePacketSwitchedVoiceCalls();
|
||||
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
||||
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.PhoneCapability> CREATOR;
|
||||
field public static final int DEVICE_NR_CAPABILITY_NONE = 0; // 0x0
|
||||
field public static final int DEVICE_NR_CAPABILITY_NSA = 1; // 0x1
|
||||
field public static final int DEVICE_NR_CAPABILITY_SA = 2; // 0x2
|
||||
}
|
||||
|
||||
public final class PhoneNumberRange implements android.os.Parcelable {
|
||||
ctor public PhoneNumberRange(@NonNull String, @NonNull String, @NonNull String, @NonNull String);
|
||||
method public int describeContents();
|
||||
@@ -11052,6 +11064,10 @@ package android.telephony {
|
||||
method @RequiresPermission(android.Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION) public void onOutgoingEmergencySms(@NonNull android.telephony.emergency.EmergencyNumber, int);
|
||||
}
|
||||
|
||||
public static interface PhoneStateListener.PhoneCapabilityChangedListener {
|
||||
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void onPhoneCapabilityChanged(@NonNull android.telephony.PhoneCapability);
|
||||
}
|
||||
|
||||
public static interface PhoneStateListener.PhysicalChannelConfigChangedListener {
|
||||
method @RequiresPermission(android.Manifest.permission.READ_PRECISE_PHONE_STATE) public void onPhysicalChannelConfigChanged(@NonNull java.util.List<android.telephony.PhysicalChannelConfig>);
|
||||
}
|
||||
@@ -11476,6 +11492,7 @@ package android.telephony {
|
||||
method public int getMaxNumberOfSimultaneouslyActiveSims();
|
||||
method public static long getMaxNumberVerificationTimeoutMillis();
|
||||
method @NonNull @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String[] getMergedImsisFromGroup();
|
||||
method @NonNull @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public android.telephony.PhoneCapability getPhoneCapability();
|
||||
method @Deprecated @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public long getPreferredNetworkTypeBitmask();
|
||||
method @RequiresPermission(anyOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE}) public int getRadioPowerState();
|
||||
method public int getSimApplicationState();
|
||||
|
||||
@@ -1698,8 +1698,9 @@ public class PhoneStateListener {
|
||||
|
||||
/**
|
||||
* Interface for phone capability listener.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public interface PhoneCapabilityChangedListener {
|
||||
/**
|
||||
* Callback invoked when phone capability changes.
|
||||
|
||||
@@ -4631,4 +4631,9 @@
|
||||
dreaming. This allows the AoD to rotate on devices without a wake device_orientation
|
||||
sensor. Note that this flag should only be enabled for development/testing use. -->
|
||||
<bool name="config_forceOrientationListenerEnabledWhileDreaming">false</bool>
|
||||
|
||||
<!-- Whether the device enable the standalone (SA) mode of 5G NR.-->
|
||||
<bool name="config_telephony5gStandalone">false</bool>
|
||||
<!-- Whether the device enable the non-standalone (NSA) mode of 5G NR.-->
|
||||
<bool name="config_telephony5gNonStandalone">false</bool>
|
||||
</resources>
|
||||
|
||||
@@ -4159,4 +4159,7 @@
|
||||
<java-symbol type="string" name="sensor_privacy_start_use_camera_notification_content" />
|
||||
<java-symbol type="string" name="sensor_privacy_start_use_dialog_turn_on_button" />
|
||||
<java-symbol type="string" name="sensor_privacy_notification_channel_label" />
|
||||
|
||||
<java-symbol type="bool" name="config_telephony5gStandalone" />
|
||||
<java-symbol type="bool" name="config_telephony5gNonStandalone" />
|
||||
</resources>
|
||||
|
||||
@@ -16,19 +16,26 @@
|
||||
|
||||
package android.telephony;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
import android.annotation.IntRange;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.SystemApi;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Define capability of a modem group. That is, the capabilities
|
||||
* are shared between those modems defined by list of modem IDs.
|
||||
* Phone capability which describes the data connection capability of modem.
|
||||
* It's used to evaluate possible phone config change, for example from single
|
||||
* SIM device to multi-SIM device.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public final class PhoneCapability implements Parcelable {
|
||||
// Hardcoded default DSDS capability.
|
||||
/** @hide */
|
||||
@@ -37,6 +44,38 @@ public final class PhoneCapability implements Parcelable {
|
||||
/** @hide */
|
||||
public static final PhoneCapability DEFAULT_SSSS_CAPABILITY;
|
||||
|
||||
/** @hide */
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef(prefix = { "DEVICE_NR_CAPABILITY_" }, value = {
|
||||
DEVICE_NR_CAPABILITY_NONE,
|
||||
DEVICE_NR_CAPABILITY_NSA,
|
||||
DEVICE_NR_CAPABILITY_SA,
|
||||
})
|
||||
public @interface DeviceNrCapability {}
|
||||
|
||||
/**
|
||||
* Indicates DEVICE_NR_CAPABILITY_NONE determine that the device does not enable 5G NR.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public static final int DEVICE_NR_CAPABILITY_NONE = 0;
|
||||
|
||||
/**
|
||||
* Indicates DEVICE_NR_CAPABILITY_NSA determine that the device enable the non-standalone
|
||||
* (NSA) mode of 5G NR.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public static final int DEVICE_NR_CAPABILITY_NSA = 1 << 0;
|
||||
|
||||
/**
|
||||
* Indicates DEVICE_NR_CAPABILITY_SA determine that the device enable the standalone (SA)
|
||||
* mode of 5G NR.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public static final int DEVICE_NR_CAPABILITY_SA = 1 << 1;
|
||||
|
||||
static {
|
||||
ModemInfo modemInfo1 = new ModemInfo(0, 0, true, true);
|
||||
ModemInfo modemInfo2 = new ModemInfo(1, 0, true, true);
|
||||
@@ -44,55 +83,85 @@ public final class PhoneCapability implements Parcelable {
|
||||
List<ModemInfo> logicalModemList = new ArrayList<>();
|
||||
logicalModemList.add(modemInfo1);
|
||||
logicalModemList.add(modemInfo2);
|
||||
DEFAULT_DSDS_CAPABILITY = new PhoneCapability(1, 1, 0, logicalModemList, false);
|
||||
DEFAULT_DSDS_CAPABILITY = new PhoneCapability(1, 1, logicalModemList, false,
|
||||
DEVICE_NR_CAPABILITY_NONE);
|
||||
|
||||
logicalModemList = new ArrayList<>();
|
||||
logicalModemList.add(modemInfo1);
|
||||
DEFAULT_SSSS_CAPABILITY = new PhoneCapability(1, 1, 0, logicalModemList, false);
|
||||
DEFAULT_SSSS_CAPABILITY = new PhoneCapability(1, 1, logicalModemList, false,
|
||||
DEVICE_NR_CAPABILITY_NONE);
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public final int maxActiveVoiceCalls;
|
||||
/** @hide */
|
||||
public final int maxActiveData;
|
||||
/** @hide */
|
||||
public final int max5G;
|
||||
/** @hide */
|
||||
public final boolean validationBeforeSwitchSupported;
|
||||
/** @hide */
|
||||
public final List<ModemInfo> logicalModemList;
|
||||
/**
|
||||
* MaxActivePsVoice defines the maximum number of active voice calls. For a dual sim dual
|
||||
* standby (DSDS) modem it would be one, but for a dual sim dual active modem it would be 2.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
private final int mMaxActivePsVoice;
|
||||
|
||||
/**
|
||||
* MaxActiveInternetData defines how many logical modems can have
|
||||
* PS attached simultaneously. For example, for L+L modem it
|
||||
* should be 2.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
private final int mMaxActiveInternetData;
|
||||
|
||||
/**
|
||||
* Whether modem supports both internet PDN up so
|
||||
* that we can do ping test before tearing down the
|
||||
* other one.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
private final boolean mNetworkValidationBeforeSwitchSupported;
|
||||
|
||||
/** @hide */
|
||||
public PhoneCapability(int maxActiveVoiceCalls, int maxActiveData, int max5G,
|
||||
List<ModemInfo> logicalModemList, boolean validationBeforeSwitchSupported) {
|
||||
this.maxActiveVoiceCalls = maxActiveVoiceCalls;
|
||||
this.maxActiveData = maxActiveData;
|
||||
this.max5G = max5G;
|
||||
private final List<ModemInfo> mLogicalModemList;
|
||||
|
||||
/**
|
||||
* List of logical modem information.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
private final int mDeviceNrCapability;
|
||||
|
||||
/** @hide */
|
||||
public PhoneCapability(int maxActivePsVoice, int maxActiveInternetData,
|
||||
List<ModemInfo> logicalModemList, boolean networkValidationBeforeSwitchSupported,
|
||||
int deviceNrCapability) {
|
||||
this.mMaxActivePsVoice = maxActivePsVoice;
|
||||
this.mMaxActiveInternetData = maxActiveInternetData;
|
||||
// Make sure it's not null.
|
||||
this.logicalModemList = logicalModemList == null ? new ArrayList<>() : logicalModemList;
|
||||
this.validationBeforeSwitchSupported = validationBeforeSwitchSupported;
|
||||
this.mLogicalModemList = logicalModemList == null ? new ArrayList<>() : logicalModemList;
|
||||
this.mNetworkValidationBeforeSwitchSupported = networkValidationBeforeSwitchSupported;
|
||||
this.mDeviceNrCapability = deviceNrCapability;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "maxActiveVoiceCalls=" + maxActiveVoiceCalls + " maxActiveData=" + maxActiveData
|
||||
+ " max5G=" + max5G + "logicalModemList:"
|
||||
+ Arrays.toString(logicalModemList.toArray());
|
||||
return "mMaxActivePsVoice=" + mMaxActivePsVoice
|
||||
+ " mMaxActiveInternetData=" + mMaxActiveInternetData
|
||||
+ " mNetworkValidationBeforeSwitchSupported="
|
||||
+ mNetworkValidationBeforeSwitchSupported
|
||||
+ " mDeviceNrCapability " + mDeviceNrCapability;
|
||||
}
|
||||
|
||||
private PhoneCapability(Parcel in) {
|
||||
maxActiveVoiceCalls = in.readInt();
|
||||
maxActiveData = in.readInt();
|
||||
max5G = in.readInt();
|
||||
validationBeforeSwitchSupported = in.readBoolean();
|
||||
logicalModemList = new ArrayList<>();
|
||||
in.readList(logicalModemList, ModemInfo.class.getClassLoader());
|
||||
mMaxActivePsVoice = in.readInt();
|
||||
mMaxActiveInternetData = in.readInt();
|
||||
mNetworkValidationBeforeSwitchSupported = in.readBoolean();
|
||||
mLogicalModemList = new ArrayList<>();
|
||||
in.readList(mLogicalModemList, ModemInfo.class.getClassLoader());
|
||||
mDeviceNrCapability = in.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(maxActiveVoiceCalls, maxActiveData, max5G, logicalModemList,
|
||||
validationBeforeSwitchSupported);
|
||||
return Objects.hash(mMaxActivePsVoice, mMaxActiveInternetData, mLogicalModemList,
|
||||
mNetworkValidationBeforeSwitchSupported, mDeviceNrCapability);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -107,11 +176,12 @@ public final class PhoneCapability implements Parcelable {
|
||||
|
||||
PhoneCapability s = (PhoneCapability) o;
|
||||
|
||||
return (maxActiveVoiceCalls == s.maxActiveVoiceCalls
|
||||
&& maxActiveData == s.maxActiveData
|
||||
&& max5G == s.max5G
|
||||
&& validationBeforeSwitchSupported == s.validationBeforeSwitchSupported
|
||||
&& logicalModemList.equals(s.logicalModemList));
|
||||
return (mMaxActivePsVoice == s.mMaxActivePsVoice
|
||||
&& mMaxActiveInternetData == s.mMaxActiveInternetData
|
||||
&& mNetworkValidationBeforeSwitchSupported
|
||||
== s.mNetworkValidationBeforeSwitchSupported
|
||||
&& mLogicalModemList.equals(s.mLogicalModemList)
|
||||
&& mDeviceNrCapability == s.mDeviceNrCapability);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,14 +195,15 @@ public final class PhoneCapability implements Parcelable {
|
||||
* {@link Parcelable#writeToParcel}
|
||||
*/
|
||||
public void writeToParcel(@NonNull Parcel dest, @Parcelable.WriteFlags int flags) {
|
||||
dest.writeInt(maxActiveVoiceCalls);
|
||||
dest.writeInt(maxActiveData);
|
||||
dest.writeInt(max5G);
|
||||
dest.writeBoolean(validationBeforeSwitchSupported);
|
||||
dest.writeList(logicalModemList);
|
||||
dest.writeInt(mMaxActivePsVoice);
|
||||
dest.writeInt(mMaxActiveInternetData);
|
||||
dest.writeBoolean(mNetworkValidationBeforeSwitchSupported);
|
||||
dest.writeList(mLogicalModemList);
|
||||
dest.writeInt(mDeviceNrCapability);
|
||||
}
|
||||
|
||||
public static final @android.annotation.NonNull Parcelable.Creator<PhoneCapability> CREATOR = new Parcelable.Creator() {
|
||||
public static final @android.annotation.NonNull Parcelable.Creator<PhoneCapability> CREATOR =
|
||||
new Parcelable.Creator() {
|
||||
public PhoneCapability createFromParcel(Parcel in) {
|
||||
return new PhoneCapability(in);
|
||||
}
|
||||
@@ -141,4 +212,55 @@ public final class PhoneCapability implements Parcelable {
|
||||
return new PhoneCapability[size];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @return the maximum number of active packet-switched calls. For a dual
|
||||
* sim dual standby (DSDS) modem it would be one, but for a dual sim dual active modem it
|
||||
* would be 2.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public @IntRange(from = 1) int getMaxActivePacketSwitchedVoiceCalls() {
|
||||
return mMaxActivePsVoice;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MaxActiveInternetData defines how many logical modems can have PS attached
|
||||
* simultaneously.
|
||||
* For example, for L+L modem it should be 2.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public @IntRange(from = 1) int getMaxActiveInternetData() {
|
||||
return mMaxActiveInternetData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Check whether the Citizens Broadband Radio Service(CBRS) network validation before
|
||||
* CBRS switch is supported or not.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public boolean isNetworkValidationBeforeSwitchSupported() {
|
||||
return mNetworkValidationBeforeSwitchSupported;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The list of logical modem information.
|
||||
* @hide
|
||||
*/
|
||||
public List<ModemInfo> getLogicalModemList() {
|
||||
return mLogicalModemList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the device's NR capability.
|
||||
*
|
||||
* @return {@link DeviceNrCapability} the device's NR capability.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public @DeviceNrCapability int getDeviceNrCapabilityBitmask() {
|
||||
return mDeviceNrCapability;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15322,4 +15322,32 @@ public class TelephonyManager {
|
||||
Log.e(TAG, "Error calling ITelephony#clearSignalStrengthUpdateRequest", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current phone capability.
|
||||
*
|
||||
* @return the PhoneCapability which describes the data connection capability of modem.
|
||||
* It's used to evaluate possible phone config change, for example from single
|
||||
* SIM device to multi-SIM device.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
|
||||
public @NonNull PhoneCapability getPhoneCapability() {
|
||||
try {
|
||||
ITelephony telephony = getITelephony();
|
||||
if (telephony != null) {
|
||||
return telephony.getPhoneCapability();
|
||||
} else {
|
||||
throw new IllegalStateException("telephony service is null.");
|
||||
}
|
||||
} catch (RemoteException ex) {
|
||||
ex.rethrowAsRuntimeException();
|
||||
}
|
||||
if (getActiveModemCount() > 1) {
|
||||
return PhoneCapability.DEFAULT_DSDS_CAPABILITY;
|
||||
} else {
|
||||
return PhoneCapability.DEFAULT_SSSS_CAPABILITY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ import android.telephony.ICellInfoCallback;
|
||||
import android.telephony.ModemActivityInfo;
|
||||
import android.telephony.NeighboringCellInfo;
|
||||
import android.telephony.NetworkScanRequest;
|
||||
import android.telephony.PhoneCapability;
|
||||
import android.telephony.PhoneNumberRange;
|
||||
import android.telephony.RadioAccessFamily;
|
||||
import android.telephony.RadioAccessSpecifier;
|
||||
@@ -2356,4 +2357,9 @@ interface ITelephony {
|
||||
*/
|
||||
void clearSignalStrengthUpdateRequest(int subId, in SignalStrengthUpdateRequest request,
|
||||
String callingPackage);
|
||||
|
||||
/**
|
||||
* Gets the current phone capability.
|
||||
*/
|
||||
PhoneCapability getPhoneCapability();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user