The phone didn't reload the allowed Network Type
Reload the allowed Network after device insert SIM card. Change the behavior of notifyAllowedNetworkTypesChanged. Log print String representation of the allowed network types. Bug: 180903931 Bug: 179814490 Test: atest cts/tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java#testSetAllowedNetworkTypesForReason_moreReason atest cts/tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java#testSetAllowedNetworkTypesForReason atest android.telephony.cts.TelephonyCallbackTest Change-Id: Icfffea3c74ecf6938455d841da9d6175f6aa07de
This commit is contained in:
@@ -11488,7 +11488,7 @@ package android.telephony {
|
||||
}
|
||||
|
||||
public static interface TelephonyCallback.AllowedNetworkTypesListener {
|
||||
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void onAllowedNetworkTypesChanged(@NonNull java.util.Map<java.lang.Integer,java.lang.Long>);
|
||||
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void onAllowedNetworkTypesChanged(int, long);
|
||||
}
|
||||
|
||||
public static interface TelephonyCallback.CallAttributesListener {
|
||||
|
||||
@@ -20,7 +20,6 @@ import android.Manifest;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.RequiresPermission;
|
||||
import android.annotation.SystemApi;
|
||||
import android.compat.annotation.ChangeId;
|
||||
import android.compat.annotation.UnsupportedAppUsage;
|
||||
import android.os.Binder;
|
||||
import android.os.Build;
|
||||
@@ -1573,7 +1572,7 @@ public class PhoneStateListener {
|
||||
// default implementation empty
|
||||
}
|
||||
|
||||
public void onAllowedNetworkTypesChanged(Map allowedNetworkTypesList) {
|
||||
public void onAllowedNetworkTypesChanged(int reason, long allowedNetworkType) {
|
||||
// default implementation empty
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import android.annotation.Nullable;
|
||||
import android.annotation.RequiresPermission;
|
||||
import android.annotation.SystemApi;
|
||||
import android.compat.annotation.ChangeId;
|
||||
import android.compat.annotation.UnsupportedAppUsage;
|
||||
import android.os.Binder;
|
||||
import android.os.Build;
|
||||
import android.telephony.emergency.EmergencyNumber;
|
||||
@@ -545,9 +544,6 @@ public class TelephonyCallback {
|
||||
/**
|
||||
* Event for changes to allowed network list based on all active subscriptions.
|
||||
*
|
||||
* <p>Requires permission {@link android.Manifest.permission#READ_PHONE_STATE} or the calling
|
||||
* app has carrier privileges (see {@link TelephonyManager#hasCarrierPrivileges}).
|
||||
*
|
||||
* @hide
|
||||
* @see AllowedNetworkTypesListener#onAllowedNetworkTypesChanged
|
||||
*/
|
||||
@@ -1259,30 +1255,34 @@ public class TelephonyCallback {
|
||||
public interface AllowedNetworkTypesListener {
|
||||
/**
|
||||
* Callback invoked when the current allowed network type list has changed on the
|
||||
* registered subscription.
|
||||
* registered subscription for a specified reason.
|
||||
* Note, the registered subscription is associated with {@link TelephonyManager} object
|
||||
* on which
|
||||
* {@link TelephonyManager#registerTelephonyCallback(Executor, TelephonyCallback)}
|
||||
* on which {@link TelephonyManager#registerTelephonyCallback(Executor, TelephonyCallback)}
|
||||
* was called.
|
||||
* If this TelephonyManager object was created with
|
||||
* {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the
|
||||
* given subscription ID. Otherwise, this callback applies to
|
||||
* {@link SubscriptionManager#getDefaultSubscriptionId()}.
|
||||
*
|
||||
* @param allowedNetworkTypesList Map associating all allowed network type reasons
|
||||
* ({@link TelephonyManager#ALLOWED_NETWORK_TYPES_REASON_USER},
|
||||
* {@link TelephonyManager#ALLOWED_NETWORK_TYPES_REASON_POWER},
|
||||
* {@link TelephonyManager#ALLOWED_NETWORK_TYPES_REASON_CARRIER}, and
|
||||
* {@link TelephonyManager#ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G}) with reason's allowed
|
||||
* network type values.
|
||||
* @param reason an allowed network type reasons.
|
||||
* @see TelephonyManager#ALLOWED_NETWORK_TYPES_REASON_USER
|
||||
* @see TelephonyManager#ALLOWED_NETWORK_TYPES_REASON_POWER
|
||||
* @see TelephonyManager#ALLOWED_NETWORK_TYPES_REASON_CARRIER
|
||||
* @see TelephonyManager#ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G
|
||||
*
|
||||
* @param allowedNetworkType an allowed network type bitmask value. (for example,
|
||||
* the long bitmask value is {{@link TelephonyManager#NETWORK_TYPE_BITMASK_NR}|
|
||||
* {@link TelephonyManager#NETWORK_TYPE_BITMASK_LTE}})
|
||||
*
|
||||
* For example:
|
||||
* map{{TelephonyManager#ALLOWED_NETWORK_TYPES_REASON_USER, long type value},
|
||||
* {TelephonyManager#ALLOWED_NETWORK_TYPES_REASON_POWER, long type value},
|
||||
* {TelephonyManager#ALLOWED_NETWORK_TYPES_REASON_CARRIER, long type value},
|
||||
* {TelephonyManager#ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G, long type value}}
|
||||
* If the latest allowed network type is changed by user, then the system
|
||||
* notifies the {@link TelephonyManager#ALLOWED_NETWORK_TYPES_REASON_USER} and
|
||||
* long type value}.
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
|
||||
void onAllowedNetworkTypesChanged(@NonNull Map<Integer, Long> allowedNetworkTypesList);
|
||||
void onAllowedNetworkTypesChanged(
|
||||
@TelephonyManager.AllowedNetworkTypesReason int reason,
|
||||
@TelephonyManager.NetworkTypeBitMask long allowedNetworkType);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1697,14 +1697,15 @@ public class TelephonyCallback {
|
||||
enabled, reason)));
|
||||
}
|
||||
|
||||
public void onAllowedNetworkTypesChanged(Map allowedNetworkTypesList) {
|
||||
public void onAllowedNetworkTypesChanged(int reason, long allowedNetworkType) {
|
||||
AllowedNetworkTypesListener listener =
|
||||
(AllowedNetworkTypesListener) mTelephonyCallbackWeakRef.get();
|
||||
if (listener == null) return;
|
||||
|
||||
Binder.withCleanCallingIdentity(
|
||||
() -> mExecutor.execute(
|
||||
() -> listener.onAllowedNetworkTypesChanged(allowedNetworkTypesList)));
|
||||
() -> listener.onAllowedNetworkTypesChanged(reason,
|
||||
allowedNetworkType)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -825,16 +825,18 @@ public class TelephonyRegistryManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify emergency number list changed on certain subscription.
|
||||
*
|
||||
* @param slotIndex for which emergency number list changed. Can be derived from subId except
|
||||
* when subId is invalid.
|
||||
* @param subId for which emergency number list changed.
|
||||
* Notify the allowed network types has changed for a specific subscription and the specific
|
||||
* reason.
|
||||
* @param slotIndex for which allowed network types changed.
|
||||
* @param subId for which allowed network types changed.
|
||||
* @param reason an allowed network type reasons.
|
||||
* @param allowedNetworkType an allowed network type bitmask value.
|
||||
*/
|
||||
public void notifyAllowedNetworkTypesChanged(int slotIndex, int subId,
|
||||
Map<Integer, Long> allowedNetworkTypeList) {
|
||||
int reason, long allowedNetworkType) {
|
||||
try {
|
||||
sRegistry.notifyAllowedNetworkTypesChanged(slotIndex, subId, allowedNetworkTypeList);
|
||||
sRegistry.notifyAllowedNetworkTypesChanged(slotIndex, subId, reason,
|
||||
allowedNetworkType);
|
||||
} catch (RemoteException ex) {
|
||||
// system process is dead
|
||||
}
|
||||
|
||||
@@ -71,5 +71,5 @@ oneway interface IPhoneStateListener {
|
||||
void onBarringInfoChanged(in BarringInfo barringInfo);
|
||||
void onPhysicalChannelConfigChanged(in List<PhysicalChannelConfig> configs);
|
||||
void onDataEnabledChanged(boolean enabled, int reason);
|
||||
void onAllowedNetworkTypesChanged(in Map allowedNetworkTypeList);
|
||||
void onAllowedNetworkTypesChanged(in int reason, in long allowedNetworkType);
|
||||
}
|
||||
|
||||
@@ -95,5 +95,5 @@ interface ITelephonyRegistry {
|
||||
void notifyPhysicalChannelConfigForSubscriber(in int subId,
|
||||
in List<PhysicalChannelConfig> configs);
|
||||
void notifyDataEnabled(in int phoneId, int subId, boolean enabled, int reason);
|
||||
void notifyAllowedNetworkTypesChanged(in int phoneId, in int subId, in Map allowedNetworkTypeList);
|
||||
void notifyAllowedNetworkTypesChanged(in int phoneId, in int subId, in int reason, in long allowedNetworkType);
|
||||
}
|
||||
|
||||
@@ -318,7 +318,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
|
||||
private int[] mDataEnabledReason;
|
||||
|
||||
private Map<Integer, Long> mAllowedNetworkTypesList;
|
||||
private int[] mAllowedNetworkTypeReason;
|
||||
private long[] mAllowedNetworkTypeValue;
|
||||
|
||||
/**
|
||||
* Per-phone map of precise data connection state. The key of the map is the pair of transport
|
||||
@@ -383,7 +384,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
private boolean isPrivilegedPhoneStatePermissionRequired(Set<Integer> events) {
|
||||
return events.contains(TelephonyCallback.EVENT_SRVCC_STATE_CHANGED)
|
||||
|| events.contains(TelephonyCallback.EVENT_VOICE_ACTIVATION_STATE_CHANGED)
|
||||
|| events.contains(TelephonyCallback.EVENT_RADIO_POWER_STATE_CHANGED);
|
||||
|| events.contains(TelephonyCallback.EVENT_RADIO_POWER_STATE_CHANGED)
|
||||
|| events.contains(TelephonyCallback.EVENT_ALLOWED_NETWORK_TYPE_LIST_CHANGED);
|
||||
}
|
||||
|
||||
private static final int MSG_USER_SWITCHED = 1;
|
||||
@@ -527,6 +529,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
mTelephonyDisplayInfos = copyOf(mTelephonyDisplayInfos, mNumPhones);
|
||||
mIsDataEnabled= copyOf(mIsDataEnabled, mNumPhones);
|
||||
mDataEnabledReason = copyOf(mDataEnabledReason, mNumPhones);
|
||||
mAllowedNetworkTypeReason = copyOf(mAllowedNetworkTypeReason, mNumPhones);
|
||||
mAllowedNetworkTypeValue = copyOf(mAllowedNetworkTypeValue, mNumPhones);
|
||||
|
||||
// ds -> ss switch.
|
||||
if (mNumPhones < oldNumPhones) {
|
||||
@@ -571,6 +575,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
mIsDataEnabled[i] = false;
|
||||
mDataEnabledReason[i] = TelephonyManager.DATA_ENABLED_REASON_USER;
|
||||
mPhysicalChannelConfigs.add(i, new PhysicalChannelConfig.Builder().build());
|
||||
mAllowedNetworkTypeReason[i] = -1;
|
||||
mAllowedNetworkTypeValue[i] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -630,9 +636,11 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
mBarringInfo = new ArrayList<>();
|
||||
mTelephonyDisplayInfos = new TelephonyDisplayInfo[numPhones];
|
||||
mPhysicalChannelConfigs = new ArrayList<>();
|
||||
mAllowedNetworkTypesList = new HashMap<>();
|
||||
mAllowedNetworkTypeReason = new int[numPhones];
|
||||
mAllowedNetworkTypeValue = new long[numPhones];
|
||||
mIsDataEnabled = new boolean[numPhones];
|
||||
mDataEnabledReason = new int[numPhones];
|
||||
|
||||
for (int i = 0; i < numPhones; i++) {
|
||||
mCallState[i] = TelephonyManager.CALL_STATE_IDLE;
|
||||
mDataActivity[i] = TelephonyManager.DATA_ACTIVITY_NONE;
|
||||
@@ -665,6 +673,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
mIsDataEnabled[i] = false;
|
||||
mDataEnabledReason[i] = TelephonyManager.DATA_ENABLED_REASON_USER;
|
||||
mPhysicalChannelConfigs.add(i, new PhysicalChannelConfig.Builder().build());
|
||||
mAllowedNetworkTypeReason[i] = -1;
|
||||
mAllowedNetworkTypeValue[i] = -1;
|
||||
}
|
||||
|
||||
mAppOps = mContext.getSystemService(AppOpsManager.class);
|
||||
@@ -1165,14 +1175,6 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
remove(r.binder);
|
||||
}
|
||||
}
|
||||
if (events.contains(
|
||||
TelephonyCallback.EVENT_ALLOWED_NETWORK_TYPE_LIST_CHANGED)) {
|
||||
try {
|
||||
r.callback.onAllowedNetworkTypesChanged(mAllowedNetworkTypesList);
|
||||
} catch (RemoteException ex) {
|
||||
remove(r.binder);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2423,18 +2425,19 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
*
|
||||
* @param phoneId the phone id.
|
||||
* @param subId the subId.
|
||||
* @param allowedNetworkTypesList Map associating all allowed network type reasons with reason's
|
||||
* allowed network type values.
|
||||
* @param reason the allowed network type reason.
|
||||
* @param allowedNetworkType the allowed network type value.
|
||||
*/
|
||||
public void notifyAllowedNetworkTypesChanged(int phoneId, int subId,
|
||||
Map allowedNetworkTypesList) {
|
||||
public void notifyAllowedNetworkTypesChanged(int phoneId, int subId, int reason,
|
||||
long allowedNetworkType) {
|
||||
if (!checkNotifyPermission("notifyAllowedNetworkTypesChanged()")) {
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (mRecords) {
|
||||
if (validatePhoneId(phoneId)) {
|
||||
mAllowedNetworkTypesList = allowedNetworkTypesList;
|
||||
mAllowedNetworkTypeReason[phoneId] = reason;
|
||||
mAllowedNetworkTypeValue[phoneId] = allowedNetworkType;
|
||||
|
||||
for (Record r : mRecords) {
|
||||
if (r.matchTelephonyCallbackEvent(
|
||||
@@ -2442,10 +2445,12 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
&& idMatch(r.subId, subId, phoneId)) {
|
||||
try {
|
||||
if (VDBG) {
|
||||
log("notifyAllowedNetworkTypesChanged: AllowedNetworkTypesList= "
|
||||
+ mAllowedNetworkTypesList.toString());
|
||||
log("notifyAllowedNetworkTypesChanged: reason= " + reason
|
||||
+ ", allowed network type:"
|
||||
+ TelephonyManager.convertNetworkTypeBitmaskToString(
|
||||
allowedNetworkType));
|
||||
}
|
||||
r.callback.onAllowedNetworkTypesChanged(mAllowedNetworkTypesList);
|
||||
r.callback.onAllowedNetworkTypesChanged(reason, allowedNetworkType);
|
||||
} catch (RemoteException ex) {
|
||||
mRemoveList.add(r.binder);
|
||||
}
|
||||
@@ -2500,6 +2505,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
pw.println("mTelephonyDisplayInfo=" + mTelephonyDisplayInfos[i]);
|
||||
pw.println("mIsDataEnabled=" + mIsDataEnabled);
|
||||
pw.println("mDataEnabledReason=" + mDataEnabledReason);
|
||||
pw.println("mAllowedNetworkTypeReason=" + mAllowedNetworkTypeReason[i]);
|
||||
pw.println("mAllowedNetworkTypeValue=" + mAllowedNetworkTypeValue[i]);
|
||||
pw.decreaseIndent();
|
||||
}
|
||||
pw.println("mCarrierNetworkChangeState=" + mCarrierNetworkChangeState);
|
||||
|
||||
@@ -139,6 +139,8 @@ import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
/**
|
||||
* Provides access to information about the telephony services on
|
||||
@@ -3147,6 +3149,10 @@ public class TelephonyManager {
|
||||
return NETWORK_TYPE_BITMASK_LTE_CA;
|
||||
case NETWORK_TYPE_NR:
|
||||
return NETWORK_TYPE_BITMASK_NR;
|
||||
case NETWORK_TYPE_IWLAN:
|
||||
return NETWORK_TYPE_BITMASK_IWLAN;
|
||||
case NETWORK_TYPE_IDEN:
|
||||
return (1 << (NETWORK_TYPE_IDEN - 1));
|
||||
default:
|
||||
return NETWORK_TYPE_BITMASK_UNKNOWN;
|
||||
}
|
||||
@@ -8642,8 +8648,8 @@ public class TelephonyManager {
|
||||
public static final int ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G = 3;
|
||||
|
||||
/**
|
||||
* Set the allowed network types of the device and
|
||||
* provide the reason triggering the allowed network change.
|
||||
* Set the allowed network types of the device and provide the reason triggering the allowed
|
||||
* network change.
|
||||
* This can be called for following reasons
|
||||
* <ol>
|
||||
* <li>Allowed network types control by USER {@link #ALLOWED_NETWORK_TYPES_REASON_USER}
|
||||
@@ -8655,10 +8661,15 @@ public class TelephonyManager {
|
||||
* </ol>
|
||||
* This API will result in allowing an intersection of allowed network types for all reasons,
|
||||
* including the configuration done through other reasons.
|
||||
*
|
||||
* The functionality of this API with the parameter
|
||||
* {@link #ALLOWED_NETWORK_TYPES_REASON_CARRIER} is the same as the API
|
||||
* {@link TelephonyManager#setAllowedNetworkTypes}. Use this API instead of
|
||||
* {@link TelephonyManager#setAllowedNetworkTypes}.
|
||||
* <p>
|
||||
* If {@link android.telephony.TelephonyManager#isRadioInterfaceCapabilitySupported}
|
||||
* ({@link TelephonyManager#CAPABILITY_ALLOWED_NETWORK_TYPES_USED}) returns true, then
|
||||
* setAllowedNetworkTypesBitmap is used on the radio interface. Otherwise,
|
||||
* setAllowedNetworkTypesBitmap is used on the radio interface. Otherwise,
|
||||
* setPreferredNetworkTypesBitmap is used instead.
|
||||
*
|
||||
* @param reason the reason the allowed network type change is taking place
|
||||
@@ -8698,21 +8709,17 @@ public class TelephonyManager {
|
||||
* {@link #getAllowedNetworkTypesForReason} returns allowed network type for a
|
||||
* specific reason.
|
||||
*
|
||||
* <p>Requires Permission:
|
||||
* {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE READ_PRIVILEGED_PHONE_STATE}
|
||||
* or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}).
|
||||
*
|
||||
* @param reason the reason the allowed network type change is taking place
|
||||
* @return the allowed network type bitmask
|
||||
* @throws IllegalStateException if the Telephony process is not currently available.
|
||||
* @throws IllegalArgumentException if invalid AllowedNetworkTypesReason is passed.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
|
||||
@RequiresFeature(
|
||||
enforcement = "android.telephony.TelephonyManager#isRadioInterfaceCapabilitySupported",
|
||||
value = TelephonyManager.CAPABILITY_ALLOWED_NETWORK_TYPES_USED)
|
||||
@SystemApi
|
||||
public @NetworkTypeBitMask long getAllowedNetworkTypesForReason(
|
||||
@AllowedNetworkTypesReason int reason) {
|
||||
if (!isValidAllowedNetworkTypesReason(reason)) {
|
||||
@@ -8756,6 +8763,25 @@ public class TelephonyManager {
|
||||
return NETWORK_STANDARDS_FAMILY_BITMASK_3GPP | NETWORK_STANDARDS_FAMILY_BITMASK_3GPP2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the allowed network types{@link NetworkTypeBitMask}.
|
||||
*
|
||||
* @param networkTypeBitmask The bitmask of allowed network types.
|
||||
* @return the name of the allowed network types
|
||||
* @hide
|
||||
*/
|
||||
public static String convertNetworkTypeBitmaskToString(
|
||||
@NetworkTypeBitMask long networkTypeBitmask) {
|
||||
String networkTypeName = IntStream.rangeClosed(NETWORK_TYPE_GPRS, NETWORK_TYPE_NR)
|
||||
.filter(x -> {
|
||||
return (networkTypeBitmask & getBitMaskForNetworkType(x))
|
||||
== getBitMaskForNetworkType(x);
|
||||
})
|
||||
.mapToObj(x -> getNetworkTypeName(x))
|
||||
.collect(Collectors.joining("|"));
|
||||
return TextUtils.isEmpty(networkTypeName) ? "UNKNOWN" : networkTypeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the preferred network type to global mode which includes LTE, CDMA, EvDo and GSM/WCDMA.
|
||||
*
|
||||
@@ -12579,6 +12605,7 @@ public class TelephonyManager {
|
||||
NETWORK_TYPE_BITMASK_LTE,
|
||||
NETWORK_TYPE_BITMASK_LTE_CA,
|
||||
NETWORK_TYPE_BITMASK_NR,
|
||||
NETWORK_TYPE_BITMASK_IWLAN
|
||||
})
|
||||
public @interface NetworkTypeBitMask {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user