Merge changes from topic "cp-networkscan-optimize" into rvc-dev am: 6c8486c771
Change-Id: I12bbf890a9b9b372cad6a9bd8625c24616055121
This commit is contained in:
@@ -260,24 +260,6 @@ public class RadioAccessFamily implements Parcelable {
|
|||||||
return raf;
|
return raf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the highest capability of the RadioAccessFamily (4G > 3G > 2G).
|
|
||||||
* @param raf The RadioAccessFamily that we wish to filter
|
|
||||||
* @return The highest radio capability
|
|
||||||
*/
|
|
||||||
public static int getHighestRafCapability(int raf) {
|
|
||||||
if ((LTE & raf) > 0) {
|
|
||||||
return TelephonyManager.NETWORK_CLASS_4_G;
|
|
||||||
}
|
|
||||||
if ((EVDO|HS|WCDMA & raf) > 0) {
|
|
||||||
return TelephonyManager.NETWORK_CLASS_3_G;
|
|
||||||
}
|
|
||||||
if((GSM|CDMA & raf) > 0) {
|
|
||||||
return TelephonyManager.NETWORK_CLASS_2_G;
|
|
||||||
}
|
|
||||||
return TelephonyManager.NETWORK_CLASS_UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
|
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
|
||||||
@PrefNetworkMode
|
@PrefNetworkMode
|
||||||
public static int getNetworkTypeFromRaf(int raf) {
|
public static int getNetworkTypeFromRaf(int raf) {
|
||||||
@@ -395,4 +377,34 @@ public class RadioAccessFamily implements Parcelable {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compare two sets of network types to see which is more capable.
|
||||||
|
*
|
||||||
|
* This algorithm first tries to see see if a set has a strict superset of RAT support for
|
||||||
|
* each generation, from newest to oldest; if that results in a tie, then it returns the set
|
||||||
|
* that supports the most RAT types.
|
||||||
|
*/
|
||||||
|
public static int compare(long networkTypeBitmaskL, long networkTypeBitmaskR) {
|
||||||
|
final long[] prioritizedNetworkClassBitmasks = new long[] {
|
||||||
|
TelephonyManager.NETWORK_CLASS_BITMASK_5G,
|
||||||
|
TelephonyManager.NETWORK_CLASS_BITMASK_4G,
|
||||||
|
TelephonyManager.NETWORK_CLASS_BITMASK_3G,
|
||||||
|
TelephonyManager.NETWORK_CLASS_BITMASK_2G,
|
||||||
|
};
|
||||||
|
|
||||||
|
long lhsUnique = networkTypeBitmaskL & ~networkTypeBitmaskR;
|
||||||
|
long rhsUnique = networkTypeBitmaskR & ~networkTypeBitmaskL;
|
||||||
|
|
||||||
|
// See if one has a strict super-set of capabilities, generation by generation.
|
||||||
|
for (long classBitmask : prioritizedNetworkClassBitmasks) {
|
||||||
|
int result = 0;
|
||||||
|
if ((lhsUnique & classBitmask) != 0) ++result;
|
||||||
|
if ((rhsUnique & classBitmask) != 0) --result;
|
||||||
|
if (result != 0) return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Without a clear winner, return the one that supports the most types.
|
||||||
|
return Long.bitCount(networkTypeBitmaskL) - Long.bitCount(networkTypeBitmaskR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3074,64 +3074,6 @@ public class TelephonyManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Network Class Definitions.
|
|
||||||
* Do not change this order, it is used for sorting during emergency calling in
|
|
||||||
* {@link TelephonyConnectionService#getFirstPhoneForEmergencyCall()}. Any newer technologies
|
|
||||||
* should be added after the current definitions.
|
|
||||||
*/
|
|
||||||
/** Unknown network class. {@hide} */
|
|
||||||
public static final int NETWORK_CLASS_UNKNOWN = 0;
|
|
||||||
/** Class of broadly defined "2G" networks. {@hide} */
|
|
||||||
@UnsupportedAppUsage
|
|
||||||
public static final int NETWORK_CLASS_2_G = 1;
|
|
||||||
/** Class of broadly defined "3G" networks. {@hide} */
|
|
||||||
@UnsupportedAppUsage
|
|
||||||
public static final int NETWORK_CLASS_3_G = 2;
|
|
||||||
/** Class of broadly defined "4G" networks. {@hide} */
|
|
||||||
@UnsupportedAppUsage
|
|
||||||
public static final int NETWORK_CLASS_4_G = 3;
|
|
||||||
/** Class of broadly defined "5G" networks. {@hide} */
|
|
||||||
public static final int NETWORK_CLASS_5_G = 4;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return general class of network type, such as "3G" or "4G". In cases
|
|
||||||
* where classification is contentious, this method is conservative.
|
|
||||||
*
|
|
||||||
* @hide
|
|
||||||
*/
|
|
||||||
@UnsupportedAppUsage
|
|
||||||
public static int getNetworkClass(int networkType) {
|
|
||||||
switch (networkType) {
|
|
||||||
case NETWORK_TYPE_GPRS:
|
|
||||||
case NETWORK_TYPE_GSM:
|
|
||||||
case NETWORK_TYPE_EDGE:
|
|
||||||
case NETWORK_TYPE_CDMA:
|
|
||||||
case NETWORK_TYPE_1xRTT:
|
|
||||||
case NETWORK_TYPE_IDEN:
|
|
||||||
return NETWORK_CLASS_2_G;
|
|
||||||
case NETWORK_TYPE_UMTS:
|
|
||||||
case NETWORK_TYPE_EVDO_0:
|
|
||||||
case NETWORK_TYPE_EVDO_A:
|
|
||||||
case NETWORK_TYPE_HSDPA:
|
|
||||||
case NETWORK_TYPE_HSUPA:
|
|
||||||
case NETWORK_TYPE_HSPA:
|
|
||||||
case NETWORK_TYPE_EVDO_B:
|
|
||||||
case NETWORK_TYPE_EHRPD:
|
|
||||||
case NETWORK_TYPE_HSPAP:
|
|
||||||
case NETWORK_TYPE_TD_SCDMA:
|
|
||||||
return NETWORK_CLASS_3_G;
|
|
||||||
case NETWORK_TYPE_LTE:
|
|
||||||
case NETWORK_TYPE_IWLAN:
|
|
||||||
case NETWORK_TYPE_LTE_CA:
|
|
||||||
return NETWORK_CLASS_4_G;
|
|
||||||
case NETWORK_TYPE_NR:
|
|
||||||
return NETWORK_CLASS_5_G;
|
|
||||||
default:
|
|
||||||
return NETWORK_CLASS_UNKNOWN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a string representation of the radio technology (network type)
|
* Returns a string representation of the radio technology (network type)
|
||||||
* currently in use on the device.
|
* currently in use on the device.
|
||||||
|
|||||||
Reference in New Issue
Block a user