diff options
4 files changed, 30 insertions, 34 deletions
diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java index 81209763d3a8..fd946cdfa48a 100644 --- a/services/core/java/com/android/server/TelephonyRegistry.java +++ b/services/core/java/com/android/server/TelephonyRegistry.java @@ -237,7 +237,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { private PhoneCapability mPhoneCapability = null; - private int mPreferredDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; + private int mActiveDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; @TelephonyManager.RadioPowerState private int mRadioPowerState = TelephonyManager.RADIO_POWER_UNAVAILABLE; @@ -257,7 +257,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { static final int ENFORCE_PHONE_STATE_PERMISSION_MASK = PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR - | PhoneStateListener.LISTEN_EMERGENCY_NUMBER_LIST; + | PhoneStateListener.LISTEN_EMERGENCY_NUMBER_LIST + | PhoneStateListener.LISTEN_ACTIVE_DATA_SUBID_CHANGE; static final int PRECISE_PHONE_STATE_PERMISSION_MASK = PhoneStateListener.LISTEN_PRECISE_CALL_STATE | @@ -819,9 +820,9 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { remove(r.binder); } } - if ((events & PhoneStateListener.LISTEN_PREFERRED_DATA_SUBID_CHANGE) != 0) { + if ((events & PhoneStateListener.LISTEN_ACTIVE_DATA_SUBID_CHANGE) != 0) { try { - r.callback.onPreferredDataSubIdChanged(mPreferredDataSubId); + r.callback.onActiveDataSubIdChanged(mActiveDataSubId); } catch (RemoteException ex) { remove(r.binder); } @@ -1757,23 +1758,23 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { } } - public void notifyPreferredDataSubIdChanged(int preferredSubId) { - if (!checkNotifyPermission("notifyPreferredDataSubIdChanged()")) { + public void notifyActiveDataSubIdChanged(int activeDataSubId) { + if (!checkNotifyPermission("notifyActiveDataSubIdChanged()")) { return; } if (VDBG) { - log("notifyPreferredDataSubIdChanged: preferredSubId=" + preferredSubId); + log("notifyActiveDataSubIdChanged: activeDataSubId=" + activeDataSubId); } synchronized (mRecords) { - mPreferredDataSubId = preferredSubId; + mActiveDataSubId = activeDataSubId; for (Record r : mRecords) { if (r.matchPhoneStateListenerEvent( - PhoneStateListener.LISTEN_PREFERRED_DATA_SUBID_CHANGE)) { + PhoneStateListener.LISTEN_ACTIVE_DATA_SUBID_CHANGE)) { try { - r.callback.onPreferredDataSubIdChanged(preferredSubId); + r.callback.onActiveDataSubIdChanged(activeDataSubId); } catch (RemoteException ex) { mRemoveList.add(r.binder); } @@ -1909,7 +1910,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { pw.println("mBackgroundCallState=" + mBackgroundCallState); pw.println("mSrvccState=" + mSrvccState); pw.println("mPhoneCapability=" + mPhoneCapability); - pw.println("mPreferredDataSubId=" + mPreferredDataSubId); + pw.println("mActiveDataSubId=" + mActiveDataSubId); pw.println("mRadioPowerState=" + mRadioPowerState); pw.println("mEmergencyNumberList=" + mEmergencyNumberList); pw.println("mCallQuality=" + mCallQuality); @@ -2181,14 +2182,6 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null); } - if ((events & PhoneStateListener.LISTEN_PREFERRED_DATA_SUBID_CHANGE) != 0) { - // It can have either READ_PHONE_STATE or READ_PRIVILEGED_PHONE_STATE. - TelephonyPermissions.checkReadPhoneState(mContext, - SubscriptionManager.INVALID_SUBSCRIPTION_ID, Binder.getCallingPid(), - Binder.getCallingUid(), callingPackage, "listen to " - + "LISTEN_PREFERRED_DATA_SUBID_CHANGE"); - } - if ((events & PhoneStateListener.LISTEN_CALL_DISCONNECT_CAUSES) != 0) { mContext.enforceCallingOrSelfPermission( android.Manifest.permission.READ_PRECISE_PHONE_STATE, null); diff --git a/telephony/java/android/telephony/PhoneStateListener.java b/telephony/java/android/telephony/PhoneStateListener.java index 3ce646cb400b..ffebc04c39e6 100644 --- a/telephony/java/android/telephony/PhoneStateListener.java +++ b/telephony/java/android/telephony/PhoneStateListener.java @@ -297,14 +297,17 @@ public class PhoneStateListener { public static final int LISTEN_PHONE_CAPABILITY_CHANGE = 0x00200000; /** - * Listen for changes to preferred data subId. - * See {@link SubscriptionManager#setPreferredDataSubId(int)} - * for more details. + * Listen for changes to active data subId. Active data subscription + * is whichever is being used for Internet data. For most of the case, it's + * default data subscription but it could be others. For example, when data is + * switched to opportunistic subscription, that becomes the active data sub. * - * @see #onPreferredDataSubIdChanged + * Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE + * READ_PHONE_STATE} + * @see #onActiveDataSubIdChanged * @hide */ - public static final int LISTEN_PREFERRED_DATA_SUBID_CHANGE = 0x00400000; + public static final int LISTEN_ACTIVE_DATA_SUBID_CHANGE = 0x00400000; /** * Listen for changes to the radio power state. @@ -710,14 +713,14 @@ public class PhoneStateListener { } /** - * Callback invoked when preferred data subId changes. Requires - * the READ_PRIVILEGED_PHONE_STATE permission. - * @param subId the new preferred data subId. If it's INVALID_SUBSCRIPTION_ID, - * it means it's unset and defaultDataSub is used to determine which - * modem is preferred. + * Callback invoked when active data subId changes. Requires + * the READ_PHONE_STATE permission. + * @param subId current data subId used for Internet data. It will be default data subscription + * most cases. And it could be other subscriptions for example opportunistic + * subscription if data is switched onto it. * @hide */ - public void onPreferredDataSubIdChanged(int subId) { + public void onActiveDataSubIdChanged(int subId) { // default implementation empty } @@ -1001,12 +1004,12 @@ public class PhoneStateListener { () -> mExecutor.execute(() -> psl.onCallAttributesChanged(callAttributes))); } - public void onPreferredDataSubIdChanged(int subId) { + public void onActiveDataSubIdChanged(int subId) { PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); if (psl == null) return; Binder.withCleanCallingIdentity( - () -> mExecutor.execute(() -> psl.onPreferredDataSubIdChanged(subId))); + () -> mExecutor.execute(() -> psl.onActiveDataSubIdChanged(subId))); } public void onImsCallDisconnectCauseChanged(ImsReasonInfo disconnectCause) { diff --git a/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl b/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl index 322ce45797ec..4a263f060ca5 100644 --- a/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl +++ b/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl @@ -54,7 +54,7 @@ oneway interface IPhoneStateListener { void onCarrierNetworkChange(in boolean active); void onUserMobileDataStateChanged(in boolean enabled); void onPhoneCapabilityChanged(in PhoneCapability capability); - void onPreferredDataSubIdChanged(in int subId); + void onActiveDataSubIdChanged(in int subId); void onRadioPowerStateChanged(in int state); void onCallAttributesChanged(in CallAttributes callAttributes); void onEmergencyNumberListChanged(in Map emergencyNumberList); diff --git a/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl b/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl index e9eba324acb0..a922ab601442 100644 --- a/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl @@ -81,7 +81,7 @@ interface ITelephonyRegistry { void notifyCarrierNetworkChange(in boolean active); void notifyUserMobileDataStateChangedForPhoneId(in int phoneId, in int subId, in boolean state); void notifyPhoneCapabilityChanged(in PhoneCapability capability); - void notifyPreferredDataSubIdChanged(int preferredSubId); + void notifyActiveDataSubIdChanged(int activeDataSubId); void notifyRadioPowerStateChanged(in int state); void notifyEmergencyNumberList(); void notifyCallQualityChanged(in CallQuality callQuality, int phoneId); |