Merge "Register ServiceStateChanged to CallManager." into gingerbread

This commit is contained in:
Jaikumar Ganesh
2010-09-10 15:54:19 -07:00
committed by Android (Google) Code Review

View File

@@ -74,6 +74,7 @@ public final class CallManager {
private static final int EVENT_ECM_TIMER_RESET = 115; private static final int EVENT_ECM_TIMER_RESET = 115;
private static final int EVENT_SUBSCRIPTION_INFO_READY = 116; private static final int EVENT_SUBSCRIPTION_INFO_READY = 116;
private static final int EVENT_SUPP_SERVICE_FAILED = 117; private static final int EVENT_SUPP_SERVICE_FAILED = 117;
private static final int EVENT_SERVICE_STATE_CHANGED = 118;
// Singleton instance // Singleton instance
private static final CallManager INSTANCE = new CallManager(); private static final CallManager INSTANCE = new CallManager();
@@ -109,9 +110,6 @@ public final class CallManager {
protected final RegistrantList mDisconnectRegistrants protected final RegistrantList mDisconnectRegistrants
= new RegistrantList(); = new RegistrantList();
protected final RegistrantList mServiceStateRegistrants
= new RegistrantList();
protected final RegistrantList mMmiRegistrants protected final RegistrantList mMmiRegistrants
= new RegistrantList(); = new RegistrantList();
@@ -157,6 +155,9 @@ public final class CallManager {
protected final RegistrantList mSuppServiceFailedRegistrants protected final RegistrantList mSuppServiceFailedRegistrants
= new RegistrantList(); = new RegistrantList();
protected final RegistrantList mServiceStateChangedRegistrants
= new RegistrantList();
private CallManager() { private CallManager() {
mPhones = new ArrayList<Phone>(); mPhones = new ArrayList<Phone>();
mRingingCalls = new ArrayList<Call>(); mRingingCalls = new ArrayList<Call>();
@@ -351,6 +352,7 @@ public final class CallManager {
phone.registerForEcmTimerReset(mHandler, EVENT_ECM_TIMER_RESET, null); phone.registerForEcmTimerReset(mHandler, EVENT_ECM_TIMER_RESET, null);
phone.registerForSubscriptionInfoReady(mHandler, EVENT_SUBSCRIPTION_INFO_READY, null); phone.registerForSubscriptionInfoReady(mHandler, EVENT_SUBSCRIPTION_INFO_READY, null);
phone.registerForSuppServiceFailed(mHandler, EVENT_SUPP_SERVICE_FAILED, null); phone.registerForSuppServiceFailed(mHandler, EVENT_SUPP_SERVICE_FAILED, null);
phone.registerForServiceStateChanged(mHandler, EVENT_SERVICE_STATE_CHANGED, null);
} }
private void unregisterForPhoneStates(Phone phone) { private void unregisterForPhoneStates(Phone phone) {
@@ -372,6 +374,7 @@ public final class CallManager {
phone.unregisterForEcmTimerReset(mHandler); phone.unregisterForEcmTimerReset(mHandler);
phone.unregisterForSubscriptionInfoReady(mHandler); phone.unregisterForSubscriptionInfoReady(mHandler);
phone.unregisterForSuppServiceFailed(mHandler); phone.unregisterForSuppServiceFailed(mHandler);
phone.unregisterForServiceStateChanged(mHandler);
} }
/** /**
@@ -951,13 +954,17 @@ public final class CallManager {
* Message.obj will contain an AsyncResult. * Message.obj will contain an AsyncResult.
* AsyncResult.result will be a ServiceState instance * AsyncResult.result will be a ServiceState instance
*/ */
public void registerForServiceStateChanged(Handler h, int what, Object obj){} public void registerForServiceStateChanged(Handler h, int what, Object obj){
mServiceStateChangedRegistrants.addUnique(h, what, obj);
}
/** /**
* Unregisters for ServiceStateChange notification. * Unregisters for ServiceStateChange notification.
* Extraneous calls are tolerated silently * Extraneous calls are tolerated silently
*/ */
public void unregisterForServiceStateChanged(Handler h){} public void unregisterForServiceStateChanged(Handler h){
mServiceStateChangedRegistrants.remove(h);
}
/** /**
* Register for notifications when a supplementary service attempt fails. * Register for notifications when a supplementary service attempt fails.
@@ -1399,6 +1406,8 @@ public final class CallManager {
case EVENT_SUPP_SERVICE_FAILED: case EVENT_SUPP_SERVICE_FAILED:
mSuppServiceFailedRegistrants.notifyRegistrants((AsyncResult) msg.obj); mSuppServiceFailedRegistrants.notifyRegistrants((AsyncResult) msg.obj);
break; break;
case EVENT_SERVICE_STATE_CHANGED:
mServiceStateChangedRegistrants.notifyRegistrants((AsyncResult) msg.obj);
} }
} }
}; };