Merge "Add PhoneStateListener#onPreferredDataSubIdChanged"
am: 0875fbab4b
Change-Id: I4644f8e8522dc78e7febf28631f347df0bf16609
This commit is contained in:
@@ -217,6 +217,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
@TelephonyManager.RadioPowerState
|
||||
private int mRadioPowerState = TelephonyManager.RADIO_POWER_UNAVAILABLE;
|
||||
|
||||
private int mPreferredDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||
|
||||
private final LocalLog mLocalLog = new LocalLog(100);
|
||||
|
||||
private PreciseDataConnectionState mPreciseDataConnectionState =
|
||||
@@ -756,6 +758,13 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
remove(r.binder);
|
||||
}
|
||||
}
|
||||
if ((events & PhoneStateListener.LISTEN_PREFERRED_DATA_SUBID_CHANGE) != 0) {
|
||||
try {
|
||||
r.callback.onPreferredDataSubIdChanged(mPreferredDataSubId);
|
||||
} catch (RemoteException ex) {
|
||||
remove(r.binder);
|
||||
}
|
||||
}
|
||||
if ((events & PhoneStateListener.LISTEN_RADIO_POWER_STATE_CHANGED) != 0) {
|
||||
try {
|
||||
r.callback.onRadioPowerStateChanged(mRadioPowerState);
|
||||
@@ -1584,6 +1593,32 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
public void notifyRadioPowerStateChanged(@TelephonyManager.RadioPowerState int state) {
|
||||
if (!checkNotifyPermission("notifyRadioPowerStateChanged()")) {
|
||||
return;
|
||||
@@ -1647,6 +1682,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
pw.println("mBackgroundCallState=" + mBackgroundCallState);
|
||||
pw.println("mVoLteServiceState=" + mVoLteServiceState);
|
||||
pw.println("mPhoneCapability=" + mPhoneCapability);
|
||||
pw.println("mPreferredDataSubId=" + mPreferredDataSubId);
|
||||
pw.println("mRadioPowerState=" + mRadioPowerState);
|
||||
|
||||
pw.decreaseIndent();
|
||||
|
||||
@@ -282,6 +282,16 @@ public class PhoneStateListener {
|
||||
*/
|
||||
public static final int LISTEN_PHONE_CAPABILITY_CHANGE = 0x00200000;
|
||||
|
||||
/**
|
||||
* Listen for changes to preferred data subId.
|
||||
* See {@link SubscriptionManager#setPreferredData(int)}
|
||||
* for more details.
|
||||
*
|
||||
* @see #onPreferredDataSubIdChanged
|
||||
* @hide
|
||||
*/
|
||||
public static final int LISTEN_PREFERRED_DATA_SUBID_CHANGE = 0x00400000;
|
||||
|
||||
/**
|
||||
* Listen for changes to the radio power state.
|
||||
*
|
||||
@@ -420,6 +430,9 @@ public class PhoneStateListener {
|
||||
case LISTEN_RADIO_POWER_STATE_CHANGED:
|
||||
PhoneStateListener.this.onRadioPowerStateChanged((int) msg.obj);
|
||||
break;
|
||||
case LISTEN_PREFERRED_DATA_SUBID_CHANGE:
|
||||
PhoneStateListener.this.onPreferredDataSubIdChanged((int) msg.obj);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -670,6 +683,17 @@ public class PhoneStateListener {
|
||||
// default implementation empty
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @hide
|
||||
*/
|
||||
public void onPreferredDataSubIdChanged(int subId) {
|
||||
// default implementation empty
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback invoked when telephony has received notice from a carrier
|
||||
@@ -806,6 +830,10 @@ public class PhoneStateListener {
|
||||
public void onRadioPowerStateChanged(@TelephonyManager.RadioPowerState int state) {
|
||||
send(LISTEN_RADIO_POWER_STATE_CHANGED, 0, 0, state);
|
||||
}
|
||||
|
||||
public void onPreferredDataSubIdChanged(int subId) {
|
||||
send(LISTEN_PREFERRED_DATA_SUBID_CHANGE, 0, 0, subId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2211,10 +2211,11 @@ public class SubscriptionManager {
|
||||
* It's also usually what we set up internet connection on.
|
||||
*
|
||||
* PreferredData overwrites user setting of default data subscription. And it's used
|
||||
* by ANAS or carrier apps to switch primary and CBRS subscription dynamically in multi-SIM
|
||||
* devices.
|
||||
* by AlternativeNetworkAccessService or carrier apps to switch primary and CBRS
|
||||
* subscription dynamically in multi-SIM devices.
|
||||
*
|
||||
* @param slotId which slot is preferred to for cellular data.
|
||||
* @param slotId which slot is preferred to for cellular data. If it's INVALID, it means
|
||||
* it's unset and defaultDataSubId is used to determine which modem is preferred.
|
||||
* @hide
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -53,5 +53,6 @@ oneway interface IPhoneStateListener {
|
||||
void onUserMobileDataStateChanged(in boolean enabled);
|
||||
void onPhoneCapabilityChanged(in PhoneCapability capability);
|
||||
void onRadioPowerStateChanged(in int state);
|
||||
void onPreferredDataSubIdChanged(in int subId);
|
||||
}
|
||||
|
||||
|
||||
@@ -80,4 +80,5 @@ interface ITelephonyRegistry {
|
||||
void notifyUserMobileDataStateChangedForPhoneId(in int phoneId, in int subId, in boolean state);
|
||||
void notifyPhoneCapabilityChanged(in PhoneCapability capability);
|
||||
void notifyRadioPowerStateChanged(in int state);
|
||||
void notifyPreferredDataSubIdChanged(int preferredSubId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user