Add PhoneStateListener#onPreferredDataSubIdChanged
When SubscriptionManager#SetPreferredData changes preferredDataSub,
SubscriptionController notifies TelephonyRegistry and then notifies
all PhoneStateListeners that listen to the event.
Bug: 115550764
Test: unittest
Change-Id: Icb0b349b9f07a52d7d9c5e8512f731986f1a1fa3
diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java
index 98b88cb..32c9ce1 100644
--- a/services/core/java/com/android/server/TelephonyRegistry.java
+++ b/services/core/java/com/android/server/TelephonyRegistry.java
@@ -213,6 +213,8 @@
private PhoneCapability mPhoneCapability = null;
+ private int mPreferredDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+
private final LocalLog mLocalLog = new LocalLog(100);
private PreciseDataConnectionState mPreciseDataConnectionState =
@@ -752,6 +754,13 @@
remove(r.binder);
}
}
+ if ((events & PhoneStateListener.LISTEN_PREFERRED_DATA_SUBID_CHANGE) != 0) {
+ try {
+ r.callback.onPreferredDataSubIdChanged(mPreferredDataSubId);
+ } catch (RemoteException ex) {
+ remove(r.binder);
+ }
+ }
}
}
} else {
@@ -1573,6 +1582,31 @@
}
}
+ public void notifyPreferredDataSubIdChanged(int preferredSubId) {
+ if (!checkNotifyPermission("notifyPreferredDataSubIdChanged()")) {
+ return;
+ }
+
+ if (VDBG) {
+ log("notifyPreferredDataSubIdChanged: preferredSubId=" + preferredSubId);
+ }
+
+ synchronized (mRecords) {
+ mPreferredDataSubId = preferredSubId;
+
+ for (Record r : mRecords) {
+ if (r.matchPhoneStateListenerEvent(
+ PhoneStateListener.LISTEN_PREFERRED_DATA_SUBID_CHANGE)) {
+ try {
+ r.callback.onPreferredDataSubIdChanged(preferredSubId);
+ } catch (RemoteException ex) {
+ mRemoveList.add(r.binder);
+ }
+ }
+ }
+ handleRemoveListLocked();
+ }
+ }
@Override
public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
@@ -1610,6 +1644,7 @@
pw.println("mBackgroundCallState=" + mBackgroundCallState);
pw.println("mVoLteServiceState=" + mVoLteServiceState);
pw.println("mPhoneCapability=" + mPhoneCapability);
+ pw.println("mPreferredDataSubId=" + mPreferredDataSubId);
pw.decreaseIndent();