Merge "improve mism support for phonestatelistner" am: ed4d220c97
am: a05023c222
Change-Id: Icaade79b765a2c27bcf203f40a095b50d2087763
This commit is contained in:
@@ -627,6 +627,11 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
|||||||
r.callingPackage = callingPackage;
|
r.callingPackage = callingPackage;
|
||||||
r.callerUid = Binder.getCallingUid();
|
r.callerUid = Binder.getCallingUid();
|
||||||
r.callerPid = Binder.getCallingPid();
|
r.callerPid = Binder.getCallingPid();
|
||||||
|
if (r.subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID && r.subId != subId) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"PhoneStateListener cannot concurrently listen on multiple " +
|
||||||
|
"subscriptions. Previously registered on subId: " + r.subId);
|
||||||
|
}
|
||||||
// Legacy applications pass SubscriptionManager.DEFAULT_SUB_ID,
|
// Legacy applications pass SubscriptionManager.DEFAULT_SUB_ID,
|
||||||
// force all illegal subId to SubscriptionManager.DEFAULT_SUB_ID
|
// force all illegal subId to SubscriptionManager.DEFAULT_SUB_ID
|
||||||
if (!SubscriptionManager.isValidSubscriptionId(subId)) {
|
if (!SubscriptionManager.isValidSubscriptionId(subId)) {
|
||||||
|
|||||||
@@ -4755,18 +4755,22 @@ public class TelephonyManager {
|
|||||||
* Registers a listener object to receive notification of changes
|
* Registers a listener object to receive notification of changes
|
||||||
* in specified telephony states.
|
* in specified telephony states.
|
||||||
* <p>
|
* <p>
|
||||||
* To register a listener, pass a {@link PhoneStateListener}
|
* To register a listener, pass a {@link PhoneStateListener} and specify at least one telephony
|
||||||
* and specify at least one telephony state of interest in
|
* state of interest in the events argument.
|
||||||
* the events argument.
|
|
||||||
*
|
*
|
||||||
* At registration, and when a specified telephony state
|
* At registration, and when a specified telephony state changes, the telephony manager invokes
|
||||||
* changes, the telephony manager invokes the appropriate
|
* the appropriate callback method on the listener object and passes the current (updated)
|
||||||
* callback method on the listener object and passes the
|
* values.
|
||||||
* current (updated) values.
|
|
||||||
* <p>
|
* <p>
|
||||||
* To unregister a listener, pass the listener object and set the
|
* To un-register a listener, pass the listener object and set the events argument to
|
||||||
* events argument to
|
|
||||||
* {@link PhoneStateListener#LISTEN_NONE LISTEN_NONE} (0).
|
* {@link PhoneStateListener#LISTEN_NONE LISTEN_NONE} (0).
|
||||||
|
*
|
||||||
|
* If this TelephonyManager object has been created with {@link #createForSubscriptionId},
|
||||||
|
* applies to the given subId. Otherwise, applies to
|
||||||
|
* {@link SubscriptionManager#getDefaultSubscriptionId()}. To listen events for multiple subIds,
|
||||||
|
* pass a separate listener object to each TelephonyManager object created with
|
||||||
|
* {@link #createForSubscriptionId}.
|
||||||
|
*
|
||||||
* Note: if you call this method while in the middle of a binder transaction, you <b>must</b>
|
* Note: if you call this method while in the middle of a binder transaction, you <b>must</b>
|
||||||
* call {@link android.os.Binder#clearCallingIdentity()} before calling this method. A
|
* call {@link android.os.Binder#clearCallingIdentity()} before calling this method. A
|
||||||
* {@link SecurityException} will be thrown otherwise.
|
* {@link SecurityException} will be thrown otherwise.
|
||||||
@@ -4781,17 +4785,18 @@ public class TelephonyManager {
|
|||||||
if (mContext == null) return;
|
if (mContext == null) return;
|
||||||
try {
|
try {
|
||||||
boolean notifyNow = (getITelephony() != null);
|
boolean notifyNow = (getITelephony() != null);
|
||||||
// If the listener has not explicitly set the subId (for example, created with the
|
|
||||||
// default constructor), replace the subId so it will listen to the account the
|
|
||||||
// telephony manager is created with.
|
|
||||||
if (listener.mSubId == null) {
|
|
||||||
listener.mSubId = mSubId;
|
|
||||||
}
|
|
||||||
|
|
||||||
ITelephonyRegistry registry = getTelephonyRegistry();
|
ITelephonyRegistry registry = getTelephonyRegistry();
|
||||||
if (registry != null) {
|
if (registry != null) {
|
||||||
registry.listenForSubscriber(listener.mSubId, getOpPackageName(),
|
// listen to the subId the telephony manager is created with. Ignore subId in
|
||||||
|
// PhoneStateListener.
|
||||||
|
registry.listenForSubscriber(mSubId, getOpPackageName(),
|
||||||
listener.callback, events, notifyNow);
|
listener.callback, events, notifyNow);
|
||||||
|
// TODO: remove this once we remove PhoneStateListener constructor with subId.
|
||||||
|
if (events == PhoneStateListener.LISTEN_NONE) {
|
||||||
|
listener.mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||||
|
} else {
|
||||||
|
listener.mSubId = mSubId;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Rlog.w(TAG, "telephony registry not ready.");
|
Rlog.w(TAG, "telephony registry not ready.");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user