Merge changes from topics "caps_refactor", "phone-cap-revert"

* changes:
  Revert "Modify PhoneCapabilities for device capabilities"
  Revert "PhoneCapability cleanup"
This commit is contained in:
Sarah Chin
2020-02-27 05:46:08 +00:00
committed by Gerrit Code Review
6 changed files with 177 additions and 584 deletions

View File

@@ -45351,32 +45351,8 @@ package android.telephony {
public final class PhoneCapability implements android.os.Parcelable { public final class PhoneCapability implements android.os.Parcelable {
method public int describeContents(); method public int describeContents();
method @NonNull public java.util.List<java.lang.Integer> getBands(int);
method @NonNull public java.util.List<java.util.List<java.lang.Long>> getConcurrentFeaturesSupport();
method @NonNull public java.util.List<java.lang.String> getLogicalModemUuids();
method public int getMaxActiveDedicatedBearers();
method public int getMaxActiveInternetData();
method public int getMaxActivePsVoice();
method public long getPsDataConnectionLingerTimeMillis();
method @NonNull public java.util.List<android.telephony.SimSlotCapability> getSimSlotCapabilities();
method public long getSupportedRats();
method public int getUeCategory(boolean, int);
method public void writeToParcel(@NonNull android.os.Parcel, int); method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.PhoneCapability> CREATOR; field @NonNull public static final android.os.Parcelable.Creator<android.telephony.PhoneCapability> CREATOR;
field public static final long MODEM_FEATURE_3GPP2_REG = 1L; // 0x1L
field public static final long MODEM_FEATURE_3GPP_REG = 2L; // 0x2L
field public static final long MODEM_FEATURE_CDMA2000_EHRPD_REG = 4L; // 0x4L
field public static final long MODEM_FEATURE_CSIM = 8192L; // 0x2000L
field public static final long MODEM_FEATURE_CS_VOICE_SESSION = 512L; // 0x200L
field public static final long MODEM_FEATURE_DEDICATED_BEARER = 2048L; // 0x800L
field public static final long MODEM_FEATURE_EUTRAN_REG = 32L; // 0x20L
field public static final long MODEM_FEATURE_EUTRA_NR_DUAL_CONNECTIVITY_REG = 128L; // 0x80L
field public static final long MODEM_FEATURE_GERAN_REG = 8L; // 0x8L
field public static final long MODEM_FEATURE_INTERACTIVE_DATA_SESSION = 1024L; // 0x400L
field public static final long MODEM_FEATURE_NETWORK_SCAN = 4096L; // 0x1000L
field public static final long MODEM_FEATURE_NGRAN_REG = 64L; // 0x40L
field public static final long MODEM_FEATURE_PS_VOICE_REG = 256L; // 0x100L
field public static final long MODEM_FEATURE_UTRAN_REG = 16L; // 0x10L
} }
public class PhoneNumberFormattingTextWatcher implements android.text.TextWatcher { public class PhoneNumberFormattingTextWatcher implements android.text.TextWatcher {
@@ -45561,18 +45537,6 @@ package android.telephony {
field public static final int INVALID = 2147483647; // 0x7fffffff field public static final int INVALID = 2147483647; // 0x7fffffff
} }
public final class SimSlotCapability implements android.os.Parcelable {
method public int describeContents();
method public int getPhysicalSlotIndex();
method public int getSlotType();
method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.SimSlotCapability> CREATOR;
field public static final int SLOT_TYPE_EUICC = 3; // 0x3
field public static final int SLOT_TYPE_IUICC = 2; // 0x2
field public static final int SLOT_TYPE_SOFT_SIM = 4; // 0x4
field public static final int SLOT_TYPE_UICC = 1; // 0x1
}
public final class SmsManager { public final class SmsManager {
method public String createAppSpecificSmsToken(android.app.PendingIntent); method public String createAppSpecificSmsToken(android.app.PendingIntent);
method @Nullable public String createAppSpecificSmsTokenWithPackageInfo(@Nullable String, @NonNull android.app.PendingIntent); method @Nullable public String createAppSpecificSmsTokenWithPackageInfo(@Nullable String, @NonNull android.app.PendingIntent);
@@ -45919,7 +45883,6 @@ package android.telephony {
method @RequiresPermission(anyOf={"android.permission.READ_PRIVILEGED_PHONE_STATE", android.Manifest.permission.READ_PRECISE_PHONE_STATE}) public int getNetworkSelectionMode(); method @RequiresPermission(anyOf={"android.permission.READ_PRIVILEGED_PHONE_STATE", android.Manifest.permission.READ_PRECISE_PHONE_STATE}) public int getNetworkSelectionMode();
method public String getNetworkSpecifier(); method public String getNetworkSpecifier();
method @Deprecated @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public int getNetworkType(); method @Deprecated @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public int getNetworkType();
method @Nullable @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public android.telephony.PhoneCapability getPhoneCapability();
method @Deprecated public int getPhoneCount(); method @Deprecated public int getPhoneCount();
method public int getPhoneType(); method public int getPhoneType();
method @RequiresPermission(anyOf={"android.permission.READ_PRIVILEGED_PHONE_STATE", android.Manifest.permission.READ_PHONE_STATE}) public int getPreferredOpportunisticDataSubscription(); method @RequiresPermission(anyOf={"android.permission.READ_PRIVILEGED_PHONE_STATE", android.Manifest.permission.READ_PHONE_STATE}) public int getPreferredOpportunisticDataSubscription();

View File

@@ -0,0 +1,109 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony;
import android.os.Parcel;
import android.os.Parcelable;
import java.util.Objects;
/**
* Information of a single logical modem indicating
* its id, supported rats and whether it supports voice or data, etc.
* @hide
*/
public class ModemInfo implements Parcelable {
public final int modemId;
public final int rat; /* bitset */
public final boolean isVoiceSupported;
public final boolean isDataSupported;
// TODO b/121394331: Clean up this class after V1_1.PhoneCapability cleanup.
public ModemInfo(int modemId) {
this(modemId, 0, true, true);
}
public ModemInfo(int modemId, int rat, boolean isVoiceSupported, boolean isDataSupported) {
this.modemId = modemId;
this.rat = rat;
this.isVoiceSupported = isVoiceSupported;
this.isDataSupported = isDataSupported;
}
public ModemInfo(Parcel in) {
modemId = in.readInt();
rat = in.readInt();
isVoiceSupported = in.readBoolean();
isDataSupported = in.readBoolean();
}
@Override
public String toString() {
return "modemId=" + modemId + " rat=" + rat + " isVoiceSupported:" + isVoiceSupported
+ " isDataSupported:" + isDataSupported;
}
@Override
public int hashCode() {
return Objects.hash(modemId, rat, isVoiceSupported, isDataSupported);
}
@Override
public boolean equals(Object o) {
if (o == null || !(o instanceof ModemInfo) || hashCode() != o.hashCode()) {
return false;
}
if (this == o) {
return true;
}
ModemInfo s = (ModemInfo) o;
return (modemId == s.modemId
&& rat == s.rat
&& isVoiceSupported == s.isVoiceSupported
&& isDataSupported == s.isDataSupported);
}
/**
* {@link Parcelable#describeContents}
*/
public @ContentsFlags int describeContents() {
return 0;
}
/**
* {@link Parcelable#writeToParcel}
*/
public void writeToParcel(Parcel dest, @WriteFlags int flags) {
dest.writeInt(modemId);
dest.writeInt(rat);
dest.writeBoolean(isVoiceSupported);
dest.writeBoolean(isDataSupported);
}
public static final @android.annotation.NonNull Parcelable.Creator<ModemInfo> CREATOR = new Parcelable.Creator() {
public ModemInfo createFromParcel(Parcel in) {
return new ModemInfo(in);
}
public ModemInfo[] newArray(int size) {
return new ModemInfo[size];
}
};
}

View File

@@ -16,20 +16,12 @@
package android.telephony; package android.telephony;
import android.annotation.LongDef;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import android.telephony.AccessNetworkConstants.AccessNetworkType;
import android.telephony.AccessNetworkConstants.RadioAccessNetworkType;
import android.telephony.TelephonyManager.NetworkTypeBitMask;
import com.android.internal.telephony.util.TelephonyUtils;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@@ -38,365 +30,68 @@ import java.util.Objects;
* are shared between those modems defined by list of modem IDs. * are shared between those modems defined by list of modem IDs.
*/ */
public final class PhoneCapability implements Parcelable { public final class PhoneCapability implements Parcelable {
/** Modem feature indicating 3GPP2 capability. */ // Hardcoded default DSDS capability.
public static final long MODEM_FEATURE_3GPP2_REG = 1 << 0;
/** Modem feature indicating 3GPP capability. */
public static final long MODEM_FEATURE_3GPP_REG = 1 << 1;
/** Modem feature indicating CDMA 2000 with EHRPD capability. */
public static final long MODEM_FEATURE_CDMA2000_EHRPD_REG = 1 << 2;
/** Modem feature indicating GSM capability. */
public static final long MODEM_FEATURE_GERAN_REG = 1 << 3;
/** Modem feature indicating UMTS capability. */
public static final long MODEM_FEATURE_UTRAN_REG = 1 << 4;
/** Modem feature indicating LTE capability. */
public static final long MODEM_FEATURE_EUTRAN_REG = 1 << 5;
/** Modem feature indicating 5G capability.*/
public static final long MODEM_FEATURE_NGRAN_REG = 1 << 6;
/** Modem feature indicating EN-DC capability. */
public static final long MODEM_FEATURE_EUTRA_NR_DUAL_CONNECTIVITY_REG = 1 << 7;
/** Modem feature indicating VoLTE capability (IMS registered). */
public static final long MODEM_FEATURE_PS_VOICE_REG = 1 << 8;
/** Modem feature indicating CS voice call capability. */
public static final long MODEM_FEATURE_CS_VOICE_SESSION = 1 << 9;
/** Modem feature indicating Internet connection capability. */
public static final long MODEM_FEATURE_INTERACTIVE_DATA_SESSION = 1 << 10;
/**
* Modem feature indicating dedicated bearer capability.
* For services that require a high level QoS (eg. VoLTE), the network can create
* a dedicated bearer with the required QoS on top of an established default bearer.
* This will provide a dedicated tunnel for one or more specific traffic types.
*/
public static final long MODEM_FEATURE_DEDICATED_BEARER = 1 << 11;
/** Modem feature indicating network scan capability. */
public static final long MODEM_FEATURE_NETWORK_SCAN = 1 << 12;
/** Modem feature indicating corresponding SIM has CDMA capability. */
public static final long MODEM_FEATURE_CSIM = 1 << 13;
/** @hide */ /** @hide */
@LongDef(flag = true, prefix = {"MODEM_FEATURE_" }, value = {
MODEM_FEATURE_3GPP2_REG,
MODEM_FEATURE_3GPP_REG,
MODEM_FEATURE_CDMA2000_EHRPD_REG,
MODEM_FEATURE_GERAN_REG,
MODEM_FEATURE_UTRAN_REG,
MODEM_FEATURE_EUTRAN_REG,
MODEM_FEATURE_NGRAN_REG,
MODEM_FEATURE_EUTRA_NR_DUAL_CONNECTIVITY_REG,
MODEM_FEATURE_PS_VOICE_REG,
MODEM_FEATURE_CS_VOICE_SESSION,
MODEM_FEATURE_INTERACTIVE_DATA_SESSION,
MODEM_FEATURE_DEDICATED_BEARER,
MODEM_FEATURE_NETWORK_SCAN,
MODEM_FEATURE_CSIM,
})
@Retention(RetentionPolicy.SOURCE)
public @interface ModemFeature {
}
/**
* Hardcoded default DSDS capability.
* @hide
*/
public static final PhoneCapability DEFAULT_DSDS_CAPABILITY; public static final PhoneCapability DEFAULT_DSDS_CAPABILITY;
/** // Hardcoded default Single SIM single standby capability.
* Hardcoded default Single SIM single standby capability. /** @hide */
* @hide
*/
public static final PhoneCapability DEFAULT_SSSS_CAPABILITY; public static final PhoneCapability DEFAULT_SSSS_CAPABILITY;
static { static {
List<List<Long>> capabilities = new ArrayList<>(); ModemInfo modemInfo1 = new ModemInfo(0, 0, true, true);
List<Long> modem1 = new ArrayList<>(); ModemInfo modemInfo2 = new ModemInfo(1, 0, true, true);
List<Long> modem2 = new ArrayList<>();
modem1.add(MODEM_FEATURE_GERAN_REG | MODEM_FEATURE_UTRAN_REG | MODEM_FEATURE_EUTRAN_REG
| MODEM_FEATURE_PS_VOICE_REG | MODEM_FEATURE_CS_VOICE_SESSION
| MODEM_FEATURE_INTERACTIVE_DATA_SESSION | MODEM_FEATURE_DEDICATED_BEARER);
modem2.add(MODEM_FEATURE_GERAN_REG | MODEM_FEATURE_UTRAN_REG | MODEM_FEATURE_EUTRAN_REG
| MODEM_FEATURE_PS_VOICE_REG | MODEM_FEATURE_INTERACTIVE_DATA_SESSION
| MODEM_FEATURE_DEDICATED_BEARER);
capabilities.add(modem1);
capabilities.add(modem2);
List<String> uuids = new ArrayList<>();
uuids.add("com.xxxx.lm0");
uuids.add("com.xxxx.lm1");
long rats = TelephonyManager.NETWORK_TYPE_BITMASK_GSM
| TelephonyManager.NETWORK_TYPE_BITMASK_GPRS
| TelephonyManager.NETWORK_TYPE_BITMASK_EDGE
| TelephonyManager.NETWORK_TYPE_BITMASK_UMTS
| TelephonyManager.NETWORK_TYPE_BITMASK_LTE;
DEFAULT_DSDS_CAPABILITY = new PhoneCapability(0, 0, 0, 0, 0, rats, null, null, null, null,
uuids, null, capabilities);
capabilities = new ArrayList<>(); List<ModemInfo> logicalModemList = new ArrayList<>();
capabilities.add(modem1); logicalModemList.add(modemInfo1);
uuids = new ArrayList<>(); logicalModemList.add(modemInfo2);
uuids.add("com.xxxx.lm0"); DEFAULT_DSDS_CAPABILITY = new PhoneCapability(1, 1, 0, logicalModemList, false);
DEFAULT_SSSS_CAPABILITY = new PhoneCapability(0, 0, 0, 0, 0, rats, null, null, null, null,
uuids, null, capabilities); logicalModemList = new ArrayList<>();
logicalModemList.add(modemInfo1);
DEFAULT_SSSS_CAPABILITY = new PhoneCapability(1, 1, 0, logicalModemList, false);
} }
/** @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;
private final int mUtranUeCategoryDl; /** @hide */
private final int mUtranUeCategoryUl; public PhoneCapability(int maxActiveVoiceCalls, int maxActiveData, int max5G,
private final int mEutranUeCategoryDl; List<ModemInfo> logicalModemList, boolean validationBeforeSwitchSupported) {
private final int mEutranUeCategoryUl; this.maxActiveVoiceCalls = maxActiveVoiceCalls;
private final long mPsDataConnectionLingerTimeMillis; this.maxActiveData = maxActiveData;
private final @NetworkTypeBitMask long mSupportedRats; this.max5G = max5G;
private final List<Integer> mGeranBands; // Make sure it's not null.
private final List<Integer> mUtranBands; this.logicalModemList = logicalModemList == null ? new ArrayList<>() : logicalModemList;
private final List<Integer> mEutranBands; this.validationBeforeSwitchSupported = validationBeforeSwitchSupported;
private final List<Integer> mNgranBands;
private final List<String> mLogicalModemUuids;
private final List<SimSlotCapability> mSimSlotCapabilities;
private final @ModemFeature List<List<Long>> mConcurrentFeaturesSupport;
/**
* Default constructor to create a PhoneCapability object.
* @param utranUeCategoryDl 3GPP UE category for UTRAN downlink.
* @param utranUeCategoryUl 3GPP UE category for UTRAN uplink.
* @param eutranUeCategoryDl 3GPP UE category for EUTRAN downlink.
* @param eutranUeCategoryUl 3GPP UE category for EUTRAN uplink.
* @param psDataConnectionLingerTimeMillis length of the grace period to allow a smooth
* "handover" between data connections.
* @param supportedRats all radio access technologies this phone is capable of supporting.
* @param geranBands list of supported {@link AccessNetworkConstants.GeranBand}.
* @param utranBands list of supported {@link AccessNetworkConstants.UtranBand}.
* @param eutranBands list of supported {@link AccessNetworkConstants.EutranBand}.
* @param ngranBands list of supported {@link AccessNetworkConstants.NgranBands}.
* @param logicalModemUuids list of logical modem UUIDs, typically of the form
* "com.xxxx.lmX", where X is the logical modem ID.
* @param simSlotCapabilities list of {@link SimSlotCapability} for the device
* @param concurrentFeaturesSupport list of list of concurrently supportable modem feature sets.
* @hide
*/
public PhoneCapability(int utranUeCategoryDl, int utranUeCategoryUl, int eutranUeCategoryDl,
int eutranUeCategoryUl, long psDataConnectionLingerTimeMillis,
@NetworkTypeBitMask long supportedRats, @Nullable List<Integer> geranBands,
@Nullable List<Integer> utranBands, @Nullable List<Integer> eutranBands,
@Nullable List<Integer> ngranBands, @Nullable List<String> logicalModemUuids,
@Nullable List<SimSlotCapability> simSlotCapabilities,
@Nullable @ModemFeature List<List<Long>> concurrentFeaturesSupport) {
this.mUtranUeCategoryDl = utranUeCategoryDl;
this.mUtranUeCategoryUl = utranUeCategoryUl;
this.mEutranUeCategoryDl = eutranUeCategoryDl;
this.mEutranUeCategoryUl = eutranUeCategoryUl;
this.mPsDataConnectionLingerTimeMillis = psDataConnectionLingerTimeMillis;
this.mSupportedRats = supportedRats;
this.mGeranBands = TelephonyUtils.emptyIfNull(geranBands);
this.mUtranBands = TelephonyUtils.emptyIfNull(utranBands);
this.mEutranBands = TelephonyUtils.emptyIfNull(eutranBands);
this.mNgranBands = TelephonyUtils.emptyIfNull(ngranBands);
this.mLogicalModemUuids = TelephonyUtils.emptyIfNull(logicalModemUuids);
this.mSimSlotCapabilities = TelephonyUtils.emptyIfNull(simSlotCapabilities);
this.mConcurrentFeaturesSupport = TelephonyUtils.emptyIfNull(concurrentFeaturesSupport);
}
private PhoneCapability(Parcel in) {
mUtranUeCategoryDl = in.readInt();
mUtranUeCategoryUl = in.readInt();
mEutranUeCategoryDl = in.readInt();
mEutranUeCategoryUl = in.readInt();
mPsDataConnectionLingerTimeMillis = in.readLong();
mSupportedRats = in.readLong();
mGeranBands = new ArrayList<>();
in.readList(mGeranBands, Integer.class.getClassLoader());
mUtranBands = new ArrayList<>();
in.readList(mUtranBands, Integer.class.getClassLoader());
mEutranBands = new ArrayList<>();
in.readList(mEutranBands, Integer.class.getClassLoader());
mNgranBands = new ArrayList<>();
in.readList(mNgranBands, Integer.class.getClassLoader());
mLogicalModemUuids = in.createStringArrayList();
mSimSlotCapabilities = in.createTypedArrayList(SimSlotCapability.CREATOR);
int length = in.readInt();
mConcurrentFeaturesSupport = new ArrayList<>();
for (int i = 0; i < length; i++) {
ArrayList<Long> feature = new ArrayList<>();
in.readList(feature, Long.class.getClassLoader());
mConcurrentFeaturesSupport.add(feature);
}
}
/**
* 3GPP UE category for a given Radio Access Network and direction.
*
* References are:
* TS 25.306 Table 4.1a EUTRAN downlink
* TS 25.306 Table 5.1a-2 EUTRAN uplink
* TS 25.306 Table 5.1a UTRAN downlink
* TS 25.306 Table 5.1g UTRAN uplink
*
* @param uplink true for uplink direction and false for downlink direction.
* @param accessNetworkType accessNetworkType, defined in {@link AccessNetworkType}.
* @return the UE category, or -1 if it is not supported.
*/
public int getUeCategory(boolean uplink, @RadioAccessNetworkType int accessNetworkType) {
if (uplink) {
switch (accessNetworkType) {
case AccessNetworkType.UTRAN: return mUtranUeCategoryUl;
case AccessNetworkType.EUTRAN: return mEutranUeCategoryUl;
default: return -1;
}
} else {
switch (accessNetworkType) {
case AccessNetworkType.UTRAN: return mUtranUeCategoryDl;
case AccessNetworkType.EUTRAN: return mEutranUeCategoryDl;
default: return -1;
}
}
}
/**
* In cellular devices that support a greater number of logical modems than
* Internet connections, some devices support a grace period to allow a smooth "handover"
* between those connections. If that feature is supported, then this API will provide
* the length of that grace period in milliseconds. If it is not supported, the default value
* for the grace period is 0.
* @return handover linger time in milliseconds, or 0 if it is not supported.
*/
public long getPsDataConnectionLingerTimeMillis() {
return mPsDataConnectionLingerTimeMillis;
}
/**
* The radio access technologies this device is capable of supporting.
* @return a bitfield of all supported network types, defined in {@link TelephonyManager}
*/
public @NetworkTypeBitMask long getSupportedRats() {
return mSupportedRats;
}
/**
* List of supported cellular bands for the given accessNetworkType.
* @param accessNetworkType accessNetworkType, defined in {@link AccessNetworkType}.
* @return a list of bands, or an empty list if the access network type is unsupported.
*/
public @NonNull List<Integer> getBands(@RadioAccessNetworkType int accessNetworkType) {
switch (accessNetworkType) {
case AccessNetworkType.GERAN: return mGeranBands;
case AccessNetworkType.UTRAN: return mUtranBands;
case AccessNetworkType.EUTRAN: return mEutranBands;
case AccessNetworkType.NGRAN: return mNgranBands;
default: return new ArrayList<>();
}
}
/**
* List of logical modem UUIDs, each typically "com.xxxx.lmX", where X is the logical modem ID.
* @return a list of modem UUIDs, one for every logical modem the device has.
*/
public @NonNull List<String> getLogicalModemUuids() {
return mLogicalModemUuids;
}
/**
* List of {@link SimSlotCapability} for the device. The order of SIMs corresponds to the
* order of modems in {@link #getLogicalModemUuids}.
* @return a list of SIM slot capabilities, one for every SIM slot the device has.
*/
public @NonNull List<SimSlotCapability> getSimSlotCapabilities() {
return mSimSlotCapabilities;
}
/**
* A List of Lists of concurrently supportable modem feature sets.
*
* Each entry in the top-level list is an independent configuration across all modems
* that describes the capabilities of the device as a whole.
*
* Each entry in the second-level list is a bitfield of ModemFeatures that describes
* the capabilities for a single modem. In the second-level list, the order of the modems
* corresponds to order of the UUIDs in {@link #getLogicalModemUuids}.
*
* For symmetric capabilities that can only be active on one modem at a time, there will be
* multiple configurations (equal to the number of modems) that shows it active on each modem.
* For asymmetric capabilities that are only available on one of the modems, all configurations
* will have that capability on just that one modem.
*
* The example below shows the concurrentFeaturesSupport for a 3-modem device with
* theoretical capabilities SYMMETRIC (available on all modems, but only one at a time) and
* ASYMMETRIC (only available on the first modem):
* {
* Configuration 1: ASYMMETRIC and SYMMETRIC on modem 1, modem 2 empty, modem 3 empty
* {(ASYMMETRIC | SYMMETRIC), (), ()},
*
* Configuration 2: ASYMMETRIC on modem 1, SYMMETRIC on modem 2, modem 3 empty
* {(ASYMMETRIC), (SYMMETRIC), ()},
*
* Configuration 3: ASYMMETRIC on modem 1, modem 2 empty, SYMMETRIC on modem 3
* {(ASYMMETRIC), (), (SYMMETRIC)}
* }
*
* @return List of all concurrently supportable modem features.
*/
public @NonNull @ModemFeature List<List<Long>> getConcurrentFeaturesSupport() {
return mConcurrentFeaturesSupport;
}
/**
* How many modems can simultaneously have PS attached.
* @return maximum number of active PS voice connections.
*/
public int getMaxActivePsVoice() {
return countFeature(MODEM_FEATURE_PS_VOICE_REG);
}
/**
* How many modems can simultaneously support active data connections.
* For DSDS, this will be 1, and for DSDA this will be 2.
* @return maximum number of active Internet data sessions.
*/
public int getMaxActiveInternetData() {
return countFeature(MODEM_FEATURE_INTERACTIVE_DATA_SESSION);
}
/**
* How many modems can simultaneously have dedicated bearer capability.
* @return maximum number of active dedicated bearers.
*/
public int getMaxActiveDedicatedBearers() {
return countFeature(MODEM_FEATURE_DEDICATED_BEARER);
}
/**
* Whether the CBRS band 48 is supported or not.
* @return true if any RadioAccessNetwork supports CBRS and false if none do.
* @hide
*/
public boolean isCbrsSupported() {
return mEutranBands.contains(AccessNetworkConstants.EutranBand.BAND_48)
|| mNgranBands.contains(AccessNetworkConstants.NgranBands.BAND_48);
}
private int countFeature(@ModemFeature long feature) {
int count = 0;
for (long featureSet : mConcurrentFeaturesSupport.get(0)) {
if ((featureSet & feature) != 0) {
count++;
}
}
return count;
} }
@Override @Override
public String toString() { public String toString() {
return "utranUeCategoryDl=" + mUtranUeCategoryDl return "maxActiveVoiceCalls=" + maxActiveVoiceCalls + " maxActiveData=" + maxActiveData
+ " utranUeCategoryUl=" + mUtranUeCategoryUl + " max5G=" + max5G + "logicalModemList:"
+ " eutranUeCategoryDl=" + mEutranUeCategoryDl + Arrays.toString(logicalModemList.toArray());
+ " eutranUeCategoryUl=" + mEutranUeCategoryUl }
+ " psDataConnectionLingerTimeMillis=" + mPsDataConnectionLingerTimeMillis
+ " supportedRats=" + mSupportedRats + " geranBands=" + mGeranBands private PhoneCapability(Parcel in) {
+ " utranBands=" + mUtranBands + " eutranBands=" + mEutranBands maxActiveVoiceCalls = in.readInt();
+ " ngranBands=" + mNgranBands + " logicalModemUuids=" + mLogicalModemUuids maxActiveData = in.readInt();
+ " simSlotCapabilities=" + mSimSlotCapabilities max5G = in.readInt();
+ " concurrentFeaturesSupport=" + mConcurrentFeaturesSupport; validationBeforeSwitchSupported = in.readBoolean();
logicalModemList = new ArrayList<>();
in.readList(logicalModemList, ModemInfo.class.getClassLoader());
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(mUtranUeCategoryDl, mUtranUeCategoryUl, mEutranUeCategoryDl, return Objects.hash(maxActiveVoiceCalls, maxActiveData, max5G, logicalModemList,
mEutranUeCategoryUl, mPsDataConnectionLingerTimeMillis, mSupportedRats, mGeranBands, validationBeforeSwitchSupported);
mUtranBands, mEutranBands, mNgranBands, mLogicalModemUuids, mSimSlotCapabilities,
mConcurrentFeaturesSupport);
} }
@Override @Override
@@ -411,19 +106,11 @@ public final class PhoneCapability implements Parcelable {
PhoneCapability s = (PhoneCapability) o; PhoneCapability s = (PhoneCapability) o;
return (mUtranUeCategoryDl == s.mUtranUeCategoryDl return (maxActiveVoiceCalls == s.maxActiveVoiceCalls
&& mUtranUeCategoryUl == s.mUtranUeCategoryUl && maxActiveData == s.maxActiveData
&& mEutranUeCategoryDl == s.mEutranUeCategoryDl && max5G == s.max5G
&& mEutranUeCategoryUl == s.mEutranUeCategoryUl && validationBeforeSwitchSupported == s.validationBeforeSwitchSupported
&& mPsDataConnectionLingerTimeMillis == s.mPsDataConnectionLingerTimeMillis && logicalModemList.equals(s.logicalModemList));
&& mSupportedRats == s.mSupportedRats
&& mGeranBands.equals(s.mGeranBands)
&& mUtranBands.equals(s.mUtranBands)
&& mEutranBands.equals(s.mEutranBands)
&& mNgranBands.equals(s.mNgranBands)
&& mLogicalModemUuids.equals(s.mLogicalModemUuids)
&& mSimSlotCapabilities.equals(s.mSimSlotCapabilities)
&& mConcurrentFeaturesSupport.equals(s.mConcurrentFeaturesSupport));
} }
/** /**
@@ -437,32 +124,20 @@ public final class PhoneCapability implements Parcelable {
* {@link Parcelable#writeToParcel} * {@link Parcelable#writeToParcel}
*/ */
public void writeToParcel(@NonNull Parcel dest, @Parcelable.WriteFlags int flags) { public void writeToParcel(@NonNull Parcel dest, @Parcelable.WriteFlags int flags) {
dest.writeInt(mUtranUeCategoryDl); dest.writeInt(maxActiveVoiceCalls);
dest.writeInt(mUtranUeCategoryUl); dest.writeInt(maxActiveData);
dest.writeInt(mEutranUeCategoryDl); dest.writeInt(max5G);
dest.writeInt(mEutranUeCategoryUl); dest.writeBoolean(validationBeforeSwitchSupported);
dest.writeLong(mPsDataConnectionLingerTimeMillis); dest.writeList(logicalModemList);
dest.writeLong(mSupportedRats);
dest.writeList(mGeranBands);
dest.writeList(mUtranBands);
dest.writeList(mEutranBands);
dest.writeList(mNgranBands);
dest.writeStringList(mLogicalModemUuids);
dest.writeTypedList(mSimSlotCapabilities);
dest.writeInt(mConcurrentFeaturesSupport.size());
for (List<Long> feature : mConcurrentFeaturesSupport) {
dest.writeList(feature);
}
} }
public static final @NonNull Parcelable.Creator<PhoneCapability> CREATOR = public static final @android.annotation.NonNull Parcelable.Creator<PhoneCapability> CREATOR = new Parcelable.Creator() {
new Parcelable.Creator() { public PhoneCapability createFromParcel(Parcel in) {
public PhoneCapability createFromParcel(Parcel in) { return new PhoneCapability(in);
return new PhoneCapability(in); }
}
public PhoneCapability[] newArray(int size) { public PhoneCapability[] newArray(int size) {
return new PhoneCapability[size]; return new PhoneCapability[size];
} }
}; };
} }

View File

@@ -1,130 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcelable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Objects;
/**
* Capabilities for a SIM Slot.
*/
public final class SimSlotCapability implements Parcelable {
/** Slot type for UICC (removable SIM). */
public static final int SLOT_TYPE_UICC = 1;
/** Slot type for iUICC/iSIM (integrated SIM). */
public static final int SLOT_TYPE_IUICC = 2;
/** Slot type for eUICC/eSIM (embedded SIM). */
public static final int SLOT_TYPE_EUICC = 3;
/** Slot type for soft SIM (no physical SIM). */
public static final int SLOT_TYPE_SOFT_SIM = 4;
/** @hide */
@IntDef(prefix = {"SLOT_TYPE_" }, value = {
SLOT_TYPE_UICC,
SLOT_TYPE_IUICC,
SLOT_TYPE_EUICC,
SLOT_TYPE_SOFT_SIM,
})
@Retention(RetentionPolicy.SOURCE)
public @interface SlotType {
}
private final int mPhysicalSlotIndex;
private final int mSlotType;
/** @hide */
public SimSlotCapability(int physicalSlotId, int slotType) {
this.mPhysicalSlotIndex = physicalSlotId;
this.mSlotType = slotType;
}
private SimSlotCapability(Parcel in) {
mPhysicalSlotIndex = in.readInt();
mSlotType = in.readInt();
}
/**
* @return physical SIM slot index
*/
public int getPhysicalSlotIndex() {
return mPhysicalSlotIndex;
}
/**
* @return type of SIM {@link SlotType}
*/
public @SlotType int getSlotType() {
return mSlotType;
}
@Override
public String toString() {
return "mPhysicalSlotIndex=" + mPhysicalSlotIndex + " slotType=" + mSlotType;
}
@Override
public int hashCode() {
return Objects.hash(mPhysicalSlotIndex, mSlotType);
}
@Override
public boolean equals(Object o) {
if (o == null || !(o instanceof SimSlotCapability) || hashCode() != o.hashCode()) {
return false;
}
if (this == o) {
return true;
}
SimSlotCapability s = (SimSlotCapability) o;
return (mPhysicalSlotIndex == s.mPhysicalSlotIndex && mSlotType == s.mSlotType);
}
/**
* {@link Parcelable#describeContents}
*/
public @ContentsFlags int describeContents() {
return 0;
}
/**
* {@link Parcelable#writeToParcel}
*/
public void writeToParcel(@NonNull Parcel dest, @WriteFlags int flags) {
dest.writeInt(mPhysicalSlotIndex);
dest.writeInt(mSlotType);
}
public static final @NonNull Parcelable.Creator<SimSlotCapability> CREATOR =
new Parcelable.Creator() {
public SimSlotCapability createFromParcel(Parcel in) {
return new SimSlotCapability(in);
}
public SimSlotCapability[] newArray(int size) {
return new SimSlotCapability[size];
}
};
}

View File

@@ -1722,24 +1722,6 @@ public class TelephonyManager {
// //
// //
/**
* Returns the {@link PhoneCapability} for the device or null if it is not available.
* <p>
* Requires Permission: READ_PHONE_STATE or that the calling app has
* carrier privileges (see {@link #hasCarrierPrivileges}).
*/
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
@Nullable
public PhoneCapability getPhoneCapability() {
try {
ITelephony telephony = getITelephony();
return telephony == null ? null :
telephony.getPhoneCapability(getSubId(), getOpPackageName(), getFeatureId());
} catch (RemoteException ex) {
return null;
}
}
/** /**
* Returns the software version number for the device, for example, * Returns the software version number for the device, for example,
* the IMEI/SV for GSM phones. Return null if the software version is * the IMEI/SV for GSM phones. Return null if the software version is

View File

@@ -39,7 +39,6 @@ import android.telephony.ICellInfoCallback;
import android.telephony.ModemActivityInfo; import android.telephony.ModemActivityInfo;
import android.telephony.NeighboringCellInfo; import android.telephony.NeighboringCellInfo;
import android.telephony.NetworkScanRequest; import android.telephony.NetworkScanRequest;
import android.telephony.PhoneCapability;
import android.telephony.PhoneNumberRange; import android.telephony.PhoneNumberRange;
import android.telephony.RadioAccessFamily; import android.telephony.RadioAccessFamily;
import android.telephony.ServiceState; import android.telephony.ServiceState;
@@ -1895,17 +1894,12 @@ interface ITelephony {
/** /**
* Return the network selection mode on the subscription with id {@code subId}. * Return the network selection mode on the subscription with id {@code subId}.
*/ */
int getNetworkSelectionMode(int subId); int getNetworkSelectionMode(int subId);
/** /**
* Return the PhoneCapability for the device.
*/
PhoneCapability getPhoneCapability(int subId, String callingPackage, String callingFeatureId);
/**
* Return true if the device is in emergency sms mode, false otherwise. * Return true if the device is in emergency sms mode, false otherwise.
*/ */
boolean isInEmergencySmsMode(); boolean isInEmergencySmsMode();
/** /**
* Return the modem radio power state for slot index. * Return the modem radio power state for slot index.