Merge "[Telephony] Store correct value for multi-sim case - DataEnabled" into sc-dev

This commit is contained in:
Zoey Chen
2021-02-25 13:31:04 +00:00
committed by Android (Google) Code Review
3 changed files with 63 additions and 47 deletions

View File

@@ -270,13 +270,13 @@ public class TelephonyRegistryManager {
/** /**
* Notify call state changed on certain subscription. * Notify call state changed on certain subscription.
* *
* @param subId for which call state changed.
* @param slotIndex for which call state changed. Can be derived from subId except when subId is * @param slotIndex for which call state changed. Can be derived from subId except when subId is
* invalid. * invalid.
* @param subId for which call state changed.
* @param state latest call state. e.g, offhook, ringing * @param state latest call state. e.g, offhook, ringing
* @param incomingNumber incoming phone number. * @param incomingNumber incoming phone number.
*/ */
public void notifyCallStateChanged(int subId, int slotIndex, @CallState int state, public void notifyCallStateChanged(int slotIndex, int subId, @CallState int state,
@Nullable String incomingNumber) { @Nullable String incomingNumber) {
try { try {
sRegistry.notifyCallState(slotIndex, subId, state, incomingNumber); sRegistry.notifyCallState(slotIndex, subId, state, incomingNumber);
@@ -329,12 +329,12 @@ public class TelephonyRegistryManager {
/** /**
* Notify {@link ServiceState} update on certain subscription. * Notify {@link ServiceState} update on certain subscription.
* *
* @param subId for which the service state changed.
* @param slotIndex for which the service state changed. Can be derived from subId except * @param slotIndex for which the service state changed. Can be derived from subId except
* subId is invalid. * subId is invalid.
* @param subId for which the service state changed.
* @param state service state e.g, in service, out of service or roaming status. * @param state service state e.g, in service, out of service or roaming status.
*/ */
public void notifyServiceStateChanged(int subId, int slotIndex, @NonNull ServiceState state) { public void notifyServiceStateChanged(int slotIndex, int subId, @NonNull ServiceState state) {
try { try {
sRegistry.notifyServiceStateForPhoneId(slotIndex, subId, state); sRegistry.notifyServiceStateForPhoneId(slotIndex, subId, state);
} catch (RemoteException ex) { } catch (RemoteException ex) {
@@ -345,12 +345,12 @@ public class TelephonyRegistryManager {
/** /**
* Notify {@link SignalStrength} update on certain subscription. * Notify {@link SignalStrength} update on certain subscription.
* *
* @param subId for which the signalstrength changed.
* @param slotIndex for which the signalstrength changed. Can be derived from subId except when * @param slotIndex for which the signalstrength changed. Can be derived from subId except when
* subId is invalid. * subId is invalid.
* @param subId for which the signalstrength changed.
* @param signalStrength e.g, signalstrength level {@see SignalStrength#getLevel()} * @param signalStrength e.g, signalstrength level {@see SignalStrength#getLevel()}
*/ */
public void notifySignalStrengthChanged(int subId, int slotIndex, public void notifySignalStrengthChanged(int slotIndex, int subId,
@NonNull SignalStrength signalStrength) { @NonNull SignalStrength signalStrength) {
try { try {
sRegistry.notifySignalStrengthForPhoneId(slotIndex, subId, signalStrength); sRegistry.notifySignalStrengthForPhoneId(slotIndex, subId, signalStrength);
@@ -363,13 +363,13 @@ public class TelephonyRegistryManager {
* Notify changes to the message-waiting indicator on certain subscription. e.g, The status bar * Notify changes to the message-waiting indicator on certain subscription. e.g, The status bar
* uses message waiting indicator to determine when to display the voicemail icon. * uses message waiting indicator to determine when to display the voicemail icon.
* *
* @param subId for which message waiting indicator changed.
* @param slotIndex for which message waiting indicator changed. Can be derived from subId * @param slotIndex for which message waiting indicator changed. Can be derived from subId
* except when subId is invalid. * except when subId is invalid.
* @param subId for which message waiting indicator changed.
* @param msgWaitingInd {@code true} indicates there is message-waiting indicator, {@code false} * @param msgWaitingInd {@code true} indicates there is message-waiting indicator, {@code false}
* otherwise. * otherwise.
*/ */
public void notifyMessageWaitingChanged(int subId, int slotIndex, boolean msgWaitingInd) { public void notifyMessageWaitingChanged(int slotIndex, int subId, boolean msgWaitingInd) {
try { try {
sRegistry.notifyMessageWaitingChangedForPhoneId(slotIndex, subId, msgWaitingInd); sRegistry.notifyMessageWaitingChangedForPhoneId(slotIndex, subId, msgWaitingInd);
} catch (RemoteException ex) { } catch (RemoteException ex) {
@@ -410,9 +410,9 @@ public class TelephonyRegistryManager {
/** /**
* Notify changes to default (Internet) data connection state on certain subscription. * Notify changes to default (Internet) data connection state on certain subscription.
* *
* @param subId for which data connection state changed.
* @param slotIndex for which data connections state changed. Can be derived from subId except * @param slotIndex for which data connections state changed. Can be derived from subId except
* when subId is invalid. * when subId is invalid.
* @param subId for which data connection state changed.
* @param preciseState the PreciseDataConnectionState * @param preciseState the PreciseDataConnectionState
* *
* @see PreciseDataConnectionState * @see PreciseDataConnectionState
@@ -431,13 +431,13 @@ public class TelephonyRegistryManager {
/** /**
* Notify {@link CallQuality} change on certain subscription. * Notify {@link CallQuality} change on certain subscription.
* *
* @param subId for which call quality state changed.
* @param slotIndex for which call quality state changed. Can be derived from subId except when * @param slotIndex for which call quality state changed. Can be derived from subId except when
* subId is invalid. * subId is invalid.
* @param subId for which call quality state changed.
* @param callQuality Information about call quality e.g, call quality level * @param callQuality Information about call quality e.g, call quality level
* @param networkType associated with this data connection. e.g, LTE * @param networkType associated with this data connection. e.g, LTE
*/ */
public void notifyCallQualityChanged(int subId, int slotIndex, @NonNull CallQuality callQuality, public void notifyCallQualityChanged(int slotIndex, int subId, @NonNull CallQuality callQuality,
@NetworkType int networkType) { @NetworkType int networkType) {
try { try {
sRegistry.notifyCallQualityChanged(callQuality, slotIndex, subId, networkType); sRegistry.notifyCallQualityChanged(callQuality, slotIndex, subId, networkType);
@@ -449,11 +449,11 @@ public class TelephonyRegistryManager {
/** /**
* Notify emergency number list changed on certain subscription. * Notify emergency number list changed on certain subscription.
* *
* @param subId for which emergency number list changed.
* @param slotIndex for which emergency number list changed. Can be derived from subId except * @param slotIndex for which emergency number list changed. Can be derived from subId except
* when subId is invalid. * when subId is invalid.
* @param subId for which emergency number list changed.
*/ */
public void notifyEmergencyNumberList(int subId, int slotIndex) { public void notifyEmergencyNumberList( int slotIndex, int subId) {
try { try {
sRegistry.notifyEmergencyNumberList(slotIndex, subId); sRegistry.notifyEmergencyNumberList(slotIndex, subId);
} catch (RemoteException ex) { } catch (RemoteException ex) {
@@ -494,13 +494,13 @@ public class TelephonyRegistryManager {
/** /**
* Notify radio power state changed on certain subscription. * Notify radio power state changed on certain subscription.
* *
* @param subId for which radio power state changed.
* @param slotIndex for which radio power state changed. Can be derived from subId except when * @param slotIndex for which radio power state changed. Can be derived from subId except when
* subId is invalid. * subId is invalid.
* @param subId for which radio power state changed.
* @param radioPowerState the current modem radio state. * @param radioPowerState the current modem radio state.
*/ */
public void notifyRadioPowerStateChanged(int subId, int slotIndex, public void notifyRadioPowerStateChanged(int slotIndex, int subId,
@RadioPowerState int radioPowerState) { @RadioPowerState int radioPowerState) {
try { try {
sRegistry.notifyRadioPowerStateChanged(slotIndex, subId, radioPowerState); sRegistry.notifyRadioPowerStateChanged(slotIndex, subId, radioPowerState);
} catch (RemoteException ex) { } catch (RemoteException ex) {
@@ -538,13 +538,13 @@ public class TelephonyRegistryManager {
* Notify data activation state changed on certain subscription. * Notify data activation state changed on certain subscription.
* @see TelephonyManager#getDataActivationState() * @see TelephonyManager#getDataActivationState()
* *
* @param subId for which data activation state changed.
* @param slotIndex for which data activation state changed. Can be derived from subId except * @param slotIndex for which data activation state changed. Can be derived from subId except
* when subId is invalid. * when subId is invalid.
* @param subId for which data activation state changed.
* @param activationState sim activation state e.g, activated. * @param activationState sim activation state e.g, activated.
*/ */
public void notifyDataActivationStateChanged(int subId, int slotIndex, public void notifyDataActivationStateChanged(int slotIndex, int subId,
@SimActivationState int activationState) { @SimActivationState int activationState) {
try { try {
sRegistry.notifySimActivationStateChangedForPhoneId(slotIndex, subId, sRegistry.notifySimActivationStateChangedForPhoneId(slotIndex, subId,
SIM_ACTIVATION_TYPE_DATA, activationState); SIM_ACTIVATION_TYPE_DATA, activationState);
@@ -557,13 +557,13 @@ public class TelephonyRegistryManager {
* Notify voice activation state changed on certain subscription. * Notify voice activation state changed on certain subscription.
* @see TelephonyManager#getVoiceActivationState() * @see TelephonyManager#getVoiceActivationState()
* *
* @param subId for which voice activation state changed.
* @param slotIndex for which voice activation state changed. Can be derived from subId except * @param slotIndex for which voice activation state changed. Can be derived from subId except
* subId is invalid. * subId is invalid.
* @param subId for which voice activation state changed.
* @param activationState sim activation state e.g, activated. * @param activationState sim activation state e.g, activated.
*/ */
public void notifyVoiceActivationStateChanged(int subId, int slotIndex, public void notifyVoiceActivationStateChanged(int slotIndex, int subId,
@SimActivationState int activationState) { @SimActivationState int activationState) {
try { try {
sRegistry.notifySimActivationStateChangedForPhoneId(slotIndex, subId, sRegistry.notifySimActivationStateChangedForPhoneId(slotIndex, subId,
SIM_ACTIVATION_TYPE_VOICE, activationState); SIM_ACTIVATION_TYPE_VOICE, activationState);
@@ -576,9 +576,9 @@ public class TelephonyRegistryManager {
* Notify User mobile data state changed on certain subscription. e.g, mobile data is enabled * Notify User mobile data state changed on certain subscription. e.g, mobile data is enabled
* or disabled. * or disabled.
* *
* @param subId for which mobile data state has changed.
* @param slotIndex for which mobile data state has changed. Can be derived from subId except * @param slotIndex for which mobile data state has changed. Can be derived from subId except
* when subId is invalid. * when subId is invalid.
* @param subId for which mobile data state has changed.
* @param state {@code true} indicates mobile data is enabled/on. {@code false} otherwise. * @param state {@code true} indicates mobile data is enabled/on. {@code false} otherwise.
*/ */
public void notifyUserMobileDataStateChanged(int slotIndex, int subId, boolean state) { public void notifyUserMobileDataStateChanged(int slotIndex, int subId, boolean state) {
@@ -599,7 +599,7 @@ public class TelephonyRegistryManager {
* @param telephonyDisplayInfo The display info. * @param telephonyDisplayInfo The display info.
*/ */
public void notifyDisplayInfoChanged(int slotIndex, int subscriptionId, public void notifyDisplayInfoChanged(int slotIndex, int subscriptionId,
@NonNull TelephonyDisplayInfo telephonyDisplayInfo) { @NonNull TelephonyDisplayInfo telephonyDisplayInfo) {
try { try {
sRegistry.notifyDisplayInfoChanged(slotIndex, subscriptionId, telephonyDisplayInfo); sRegistry.notifyDisplayInfoChanged(slotIndex, subscriptionId, telephonyDisplayInfo);
} catch (RemoteException ex) { } catch (RemoteException ex) {
@@ -640,14 +640,14 @@ public class TelephonyRegistryManager {
* Notify precise call state changed on certain subscription, including foreground, background * Notify precise call state changed on certain subscription, including foreground, background
* and ringcall states. * and ringcall states.
* *
* @param subId for which precise call state changed.
* @param slotIndex for which precise call state changed. Can be derived from subId except when * @param slotIndex for which precise call state changed. Can be derived from subId except when
* subId is invalid. * subId is invalid.
* @param subId for which precise call state changed.
* @param ringCallPreciseState ringCall state. * @param ringCallPreciseState ringCall state.
* @param foregroundCallPreciseState foreground call state. * @param foregroundCallPreciseState foreground call state.
* @param backgroundCallPreciseState background call state. * @param backgroundCallPreciseState background call state.
*/ */
public void notifyPreciseCallState(int subId, int slotIndex, public void notifyPreciseCallState(int slotIndex, int subId,
@PreciseCallStates int ringCallPreciseState, @PreciseCallStates int ringCallPreciseState,
@PreciseCallStates int foregroundCallPreciseState, @PreciseCallStates int foregroundCallPreciseState,
@PreciseCallStates int backgroundCallPreciseState) { @PreciseCallStates int backgroundCallPreciseState) {
@@ -790,9 +790,10 @@ public class TelephonyRegistryManager {
* @param reason Reason for data enabled/disabled. See {@code REASON_*} in * @param reason Reason for data enabled/disabled. See {@code REASON_*} in
* {@link TelephonyManager}. * {@link TelephonyManager}.
*/ */
public void notifyDataEnabled(boolean enabled, @TelephonyManager.DataEnabledReason int reason) { public void notifyDataEnabled(int slotIndex, int subId, boolean enabled,
@TelephonyManager.DataEnabledReason int reason) {
try { try {
sRegistry.notifyDataEnabled(enabled, reason); sRegistry.notifyDataEnabled(slotIndex, subId, enabled, reason);
} catch (RemoteException ex) { } catch (RemoteException ex) {
// system server crash // system server crash
} }
@@ -801,11 +802,11 @@ public class TelephonyRegistryManager {
/** /**
* Notify emergency number list changed on certain subscription. * Notify emergency number list changed on certain subscription.
* *
* @param subId for which emergency number list changed.
* @param slotIndex for which emergency number list changed. Can be derived from subId except * @param slotIndex for which emergency number list changed. Can be derived from subId except
* when subId is invalid. * when subId is invalid.
* @param subId for which emergency number list changed.
*/ */
public void notifyAllowedNetworkTypesChanged(int subId, int slotIndex, public void notifyAllowedNetworkTypesChanged(int slotIndex, int subId,
Map<Integer, Long> allowedNetworkTypeList) { Map<Integer, Long> allowedNetworkTypeList) {
try { try {
sRegistry.notifyAllowedNetworkTypesChanged(slotIndex, subId, allowedNetworkTypeList); sRegistry.notifyAllowedNetworkTypesChanged(slotIndex, subId, allowedNetworkTypeList);

View File

@@ -94,6 +94,6 @@ interface ITelephonyRegistry {
void notifyBarringInfoChanged(int slotIndex, int subId, in BarringInfo barringInfo); void notifyBarringInfoChanged(int slotIndex, int subId, in BarringInfo barringInfo);
void notifyPhysicalChannelConfigForSubscriber(in int subId, void notifyPhysicalChannelConfigForSubscriber(in int subId,
in List<PhysicalChannelConfig> configs); in List<PhysicalChannelConfig> configs);
void notifyDataEnabled(boolean enabled, int reason); 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 Map allowedNetworkTypeList);
} }

View File

@@ -313,9 +313,9 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
private List<PhysicalChannelConfig> mPhysicalChannelConfigs; private List<PhysicalChannelConfig> mPhysicalChannelConfigs;
private boolean mIsDataEnabled = false; private boolean[] mIsDataEnabled;
private int mDataEnabledReason; private int[] mDataEnabledReason;
private Map<Integer, Long> mAllowedNetworkTypesList; private Map<Integer, Long> mAllowedNetworkTypesList;
@@ -524,6 +524,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
mOutgoingCallEmergencyNumber = copyOf(mOutgoingCallEmergencyNumber, mNumPhones); mOutgoingCallEmergencyNumber = copyOf(mOutgoingCallEmergencyNumber, mNumPhones);
mOutgoingSmsEmergencyNumber = copyOf(mOutgoingSmsEmergencyNumber, mNumPhones); mOutgoingSmsEmergencyNumber = copyOf(mOutgoingSmsEmergencyNumber, mNumPhones);
mTelephonyDisplayInfos = copyOf(mTelephonyDisplayInfos, mNumPhones); mTelephonyDisplayInfos = copyOf(mTelephonyDisplayInfos, mNumPhones);
mIsDataEnabled= copyOf(mIsDataEnabled, mNumPhones);
mDataEnabledReason = copyOf(mDataEnabledReason, mNumPhones);
// ds -> ss switch. // ds -> ss switch.
if (mNumPhones < oldNumPhones) { if (mNumPhones < oldNumPhones) {
@@ -565,6 +567,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
mPreciseDataConnectionStates.add(new ArrayMap<>()); mPreciseDataConnectionStates.add(new ArrayMap<>());
mBarringInfo.add(i, new BarringInfo()); mBarringInfo.add(i, new BarringInfo());
mTelephonyDisplayInfos[i] = null; mTelephonyDisplayInfos[i] = null;
mIsDataEnabled[i] = false;
mDataEnabledReason[i] = TelephonyManager.DATA_ENABLED_REASON_USER;
mPhysicalChannelConfigs.add(i, new PhysicalChannelConfig.Builder().build()); mPhysicalChannelConfigs.add(i, new PhysicalChannelConfig.Builder().build());
} }
} }
@@ -626,6 +630,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
mTelephonyDisplayInfos = new TelephonyDisplayInfo[numPhones]; mTelephonyDisplayInfos = new TelephonyDisplayInfo[numPhones];
mPhysicalChannelConfigs = new ArrayList<>(); mPhysicalChannelConfigs = new ArrayList<>();
mAllowedNetworkTypesList = new HashMap<>(); mAllowedNetworkTypesList = new HashMap<>();
mIsDataEnabled = new boolean[numPhones];
mDataEnabledReason = new int[numPhones];
for (int i = 0; i < numPhones; i++) { for (int i = 0; i < numPhones; i++) {
mCallState[i] = TelephonyManager.CALL_STATE_IDLE; mCallState[i] = TelephonyManager.CALL_STATE_IDLE;
mDataActivity[i] = TelephonyManager.DATA_ACTIVITY_NONE; mDataActivity[i] = TelephonyManager.DATA_ACTIVITY_NONE;
@@ -655,6 +661,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
mPreciseDataConnectionStates.add(new ArrayMap<>()); mPreciseDataConnectionStates.add(new ArrayMap<>());
mBarringInfo.add(i, new BarringInfo()); mBarringInfo.add(i, new BarringInfo());
mTelephonyDisplayInfos[i] = null; mTelephonyDisplayInfos[i] = null;
mIsDataEnabled[i] = false;
mDataEnabledReason[i] = TelephonyManager.DATA_ENABLED_REASON_USER;
mPhysicalChannelConfigs.add(i, new PhysicalChannelConfig.Builder().build()); mPhysicalChannelConfigs.add(i, new PhysicalChannelConfig.Builder().build());
} }
@@ -1150,7 +1158,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
if (events.contains( if (events.contains(
PhoneStateListener.EVENT_DATA_ENABLED_CHANGED)) { PhoneStateListener.EVENT_DATA_ENABLED_CHANGED)) {
try { try {
r.callback.onDataEnabledChanged(mIsDataEnabled, mDataEnabledReason); r.callback.onDataEnabledChanged(
mIsDataEnabled[phoneId], mDataEnabledReason[phoneId]);
} catch (RemoteException ex) { } catch (RemoteException ex) {
remove(r.binder); remove(r.binder);
} }
@@ -2370,30 +2379,36 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
/** /**
* Notify that the data enabled has changed. * Notify that the data enabled has changed.
* *
* @param phoneId the phone id.
* @param subId the subId.
* @param enabled True if data is enabled, otherwise disabled. * @param enabled True if data is enabled, otherwise disabled.
* @param reason Reason for data enabled/disabled. See {@code DATA_*} in * @param reason Reason for data enabled/disabled. See {@code DATA_*} in
* {@link TelephonyManager}. * {@link TelephonyManager}.
*/ */
public void notifyDataEnabled(boolean enabled, public void notifyDataEnabled(int phoneId, int subId, boolean enabled,
@TelephonyManager.DataEnabledReason int reason) { @TelephonyManager.DataEnabledReason int reason) {
if (!checkNotifyPermission("notifyDataEnabled()")) { if (!checkNotifyPermission("notifyDataEnabled()")) {
return; return;
} }
if (VDBG) { if (VDBG) {
log("notifyDataEnabled: enabled=" + enabled + " reason=" + reason); log("notifyDataEnabled: PhoneId=" + phoneId + " subId=" + subId +
" enabled=" + enabled + " reason=" + reason);
} }
mIsDataEnabled = enabled;
mDataEnabledReason = reason;
synchronized (mRecords) { synchronized (mRecords) {
for (Record r : mRecords) { if (validatePhoneId(phoneId)) {
if (r.matchPhoneStateListenerEvent( mIsDataEnabled[phoneId] = enabled;
PhoneStateListener.EVENT_DATA_ENABLED_CHANGED)) { mDataEnabledReason[phoneId] = reason;
try { for (Record r : mRecords) {
r.callback.onDataEnabledChanged(enabled, reason); if (r.matchPhoneStateListenerEvent(
} catch (RemoteException ex) { PhoneStateListener.EVENT_DATA_ENABLED_CHANGED)
mRemoveList.add(r.binder); && idMatch(r.subId, subId, phoneId)) {
try {
r.callback.onDataEnabledChanged(enabled, reason);
} catch (RemoteException ex) {
mRemoveList.add(r.binder);
}
} }
} }
} }
@@ -2481,6 +2496,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
pw.println("mOutgoingSmsEmergencyNumber=" + mOutgoingSmsEmergencyNumber[i]); pw.println("mOutgoingSmsEmergencyNumber=" + mOutgoingSmsEmergencyNumber[i]);
pw.println("mBarringInfo=" + mBarringInfo.get(i)); pw.println("mBarringInfo=" + mBarringInfo.get(i));
pw.println("mTelephonyDisplayInfo=" + mTelephonyDisplayInfos[i]); pw.println("mTelephonyDisplayInfo=" + mTelephonyDisplayInfos[i]);
pw.println("mIsDataEnabled=" + mIsDataEnabled);
pw.println("mDataEnabledReason=" + mDataEnabledReason);
pw.decreaseIndent(); pw.decreaseIndent();
} }
pw.println("mCarrierNetworkChangeState=" + mCarrierNetworkChangeState); pw.println("mCarrierNetworkChangeState=" + mCarrierNetworkChangeState);
@@ -2491,8 +2508,6 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
pw.println("mDefaultPhoneId=" + mDefaultPhoneId); pw.println("mDefaultPhoneId=" + mDefaultPhoneId);
pw.println("mDefaultSubId=" + mDefaultSubId); pw.println("mDefaultSubId=" + mDefaultSubId);
pw.println("mPhysicalChannelConfigs=" + mPhysicalChannelConfigs); pw.println("mPhysicalChannelConfigs=" + mPhysicalChannelConfigs);
pw.println("mIsDataEnabled=" + mIsDataEnabled);
pw.println("mDataEnabledReason=" + mDataEnabledReason);
pw.decreaseIndent(); pw.decreaseIndent();