Bug 1169225 - [MobileConnectionService] Support setting/getting call waiting on all serviceClass. r=aknow

This commit is contained in:
Edgar Chen 2015-05-28 19:18:22 +08:00
Родитель d94b17a5a2
Коммит 42f3c9a428
15 изменённых файлов: 135 добавлений и 26 удалений

Просмотреть файл

@ -876,7 +876,9 @@ MobileConnection::SetCallWaitingOption(bool aEnabled, ErrorResult& aRv)
nsRefPtr<MobileConnectionCallback> requestCallback =
new MobileConnectionCallback(GetOwner(), request);
nsresult rv = mMobileConnection->SetCallWaiting(aEnabled, requestCallback);
nsresult rv = mMobileConnection->SetCallWaiting(aEnabled,
nsIMobileConnection::ICC_SERVICE_CLASS_VOICE,
requestCallback);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;

Просмотреть файл

@ -191,6 +191,14 @@ MobileConnectionCallback::NotifyGetCallBarringSuccess(uint16_t aProgram,
return NotifySuccess(jsResult);
}
NS_IMETHODIMP
MobileConnectionCallback::NotifyGetCallWaitingSuccess(uint16_t aServiceClass)
{
return (aServiceClass & nsIMobileConnection::ICC_SERVICE_CLASS_VOICE)
? NotifySuccess(JS::TrueHandleValue)
: NotifySuccess(JS::FalseHandleValue);
}
NS_IMETHODIMP
MobileConnectionCallback::NotifyGetClirStatusSuccess(uint16_t aN, uint16_t aM)
{

Просмотреть файл

@ -1118,9 +1118,13 @@ MobileConnectionProvider.prototype = {
}).bind(this));
},
setCallWaiting: function(aEnabled, aCallback) {
this._radioInterface.sendWorkerMessage("setCallWaiting",
{enabled: aEnabled},
setCallWaiting: function(aEnabled, aServiceClass, aCallback) {
let options = {
enabled: aEnabled,
serviceClass: aServiceClass
};
this._radioInterface.sendWorkerMessage("setCallWaiting", options,
(function(aResponse) {
if (aResponse.errorMsg) {
aCallback.notifyError(aResponse.errorMsg);
@ -1140,7 +1144,7 @@ MobileConnectionProvider.prototype = {
return false;
}
aCallback.notifySuccessWithBoolean(aResponse.enabled);
aCallback.notifyGetCallWaitingSuccess(aResponse.serviceClass);
return false;
}).bind(this));
},

Просмотреть файл

@ -108,7 +108,7 @@ interface nsIMobileConnectionListener : nsISupports
#define NO_ADDITIONAL_INFORMATION 0
%}
[scriptable, uuid(14d66926-8434-11e4-8c3f-f724194bb5f1)]
[scriptable, uuid(ef5e02a6-adff-4425-8634-ec49ced1f14f)]
interface nsIMobileConnectionCallback : nsISupports
{
/**
@ -128,6 +128,8 @@ interface nsIMobileConnectionCallback : nsISupports
in boolean enabled,
in unsigned short serviceClass);
void notifyGetCallWaitingSuccess(in unsigned short serviceClass);
void notifyGetClirStatusSuccess(in unsigned short n, in unsigned short m);
void notifyGetPreferredNetworkTypeSuccess(in long type);
@ -163,7 +165,7 @@ already_AddRefed<nsIMobileConnectionService>
NS_CreateMobileConnectionService();
%}
[scriptable, uuid(59a6d450-144b-47f9-8f4a-2132331e9e05)]
[scriptable, uuid(d7173ff3-a8da-41c1-a976-440e5402b856)]
interface nsIMobileConnection : nsISupports
{
/*
@ -601,6 +603,8 @@ interface nsIMobileConnection : nsISupports
*
* @param enabled
* Boolean indicates the desired call waiting status.
* @param serviceClass
* One of the nsIMobileConnection.ICC_SERVICE_CLASS_* values.
* @param requestCallback
* Called when request is finished.
*
@ -611,6 +615,7 @@ interface nsIMobileConnection : nsISupports
* 'GenericFailure'.
*/
void setCallWaiting(in bool enabled,
in unsigned short serviceClass,
in nsIMobileConnectionCallback requestCallback);
/**
@ -619,8 +624,12 @@ interface nsIMobileConnection : nsISupports
* @param requestCallback
* Called when request is finished.
*
* If successful, the notifySuccessWithBoolean() will be called. And the result
* will be a boolean indicating the call waiting status.
* If successful, the notifyGetCallWaitingSuccess() will be called. And the
* result will be a service class bit vector of services for which call
* waiting is enabled. e.g. 3 means call waiting is enabled for data
* and voice and disabled for everything else. 0 means call waiting is
* disabled for all service.
* @see nsIMobileConnection.ICC_SERVICE_CLASS_*.
*
* Otherwise, the notifyError() will be called, and the error will be either
* 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or

Просмотреть файл

@ -276,9 +276,10 @@ MobileConnectionChild::ChangeCallBarringPassword(const nsAString& aPin,
NS_IMETHODIMP
MobileConnectionChild::SetCallWaiting(bool aEnabled,
uint16_t aServiceClass,
nsIMobileConnectionCallback* aCallback)
{
return SendRequest(SetCallWaitingRequest(aEnabled), aCallback)
return SendRequest(SetCallWaitingRequest(aEnabled, aServiceClass), aCallback)
? NS_OK : NS_ERROR_FAILURE;
}
@ -550,6 +551,12 @@ MobileConnectionRequestChild::DoReply(const MobileConnectionReplySuccessCallBarr
aReply.serviceClass()));
}
bool
MobileConnectionRequestChild::DoReply(const MobileConnectionReplySuccessCallWaiting& aReply)
{
return NS_SUCCEEDED(mRequestCallback->NotifyGetCallWaitingSuccess(aReply.serviceClass()));
}
bool
MobileConnectionRequestChild::DoReply(const MobileConnectionReplySuccessClirStatus& aReply)
{
@ -591,6 +598,8 @@ MobileConnectionRequestChild::Recv__delete__(const MobileConnectionReply& aReply
return DoReply(aReply.get_MobileConnectionReplySuccessCallForwarding());
case MobileConnectionReply::TMobileConnectionReplySuccessCallBarring:
return DoReply(aReply.get_MobileConnectionReplySuccessCallBarring());
case MobileConnectionReply::TMobileConnectionReplySuccessCallWaiting:
return DoReply(aReply.get_MobileConnectionReplySuccessCallWaiting());
case MobileConnectionReply::TMobileConnectionReplySuccessClirStatus:
return DoReply(aReply.get_MobileConnectionReplySuccessClirStatus());
case MobileConnectionReply::TMobileConnectionReplySuccessPreferredNetworkType:

Просмотреть файл

@ -148,6 +148,9 @@ public:
bool
DoReply(const MobileConnectionReplySuccessCallBarring& aReply);
bool
DoReply(const MobileConnectionReplySuccessCallWaiting& aReply);
bool
DoReply(const MobileConnectionReplySuccessClirStatus& aReply);

Просмотреть файл

@ -434,7 +434,9 @@ MobileConnectionRequestParent::DoRequest(const SetCallWaitingRequest& aRequest)
{
NS_ENSURE_TRUE(mMobileConnection, false);
return NS_SUCCEEDED(mMobileConnection->SetCallWaiting(aRequest.enabled(), this));
return NS_SUCCEEDED(mMobileConnection->SetCallWaiting(aRequest.enabled(),
aRequest.serviceClass(),
this));
}
bool
@ -536,6 +538,12 @@ MobileConnectionRequestParent::NotifyGetCallBarringSuccess(uint16_t aProgram,
aServiceClass));
}
NS_IMETHODIMP
MobileConnectionRequestParent::NotifyGetCallWaitingSuccess(uint16_t aServiceClass)
{
return SendReply(MobileConnectionReplySuccessCallWaiting(aServiceClass));
}
NS_IMETHODIMP
MobileConnectionRequestParent::NotifyGetClirStatusSuccess(uint16_t aN,
uint16_t aM)

Просмотреть файл

@ -133,6 +133,7 @@ struct ChangeCallBarringPasswordRequest
struct SetCallWaitingRequest
{
bool enabled;
uint16_t serviceClass;
};
struct GetCallWaitingRequest

Просмотреть файл

@ -52,6 +52,11 @@ struct MobileConnectionReplySuccessCallBarring
uint16_t serviceClass;
};
struct MobileConnectionReplySuccessCallWaiting
{
uint16_t serviceClass;
};
struct MobileConnectionReplySuccessClirStatus
{
uint16_t n;
@ -82,6 +87,7 @@ union MobileConnectionReply
MobileConnectionReplySuccessNetworks;
MobileConnectionReplySuccessCallForwarding;
MobileConnectionReplySuccessCallBarring;
MobileConnectionReplySuccessCallWaiting;
MobileConnectionReplySuccessClirStatus;
MobileConnectionReplySuccessPreferredNetworkType;
MobileConnectionReplySuccessRoamingPreference;

Просмотреть файл

@ -640,6 +640,37 @@ function selectNetworkAutomaticallyAndWait() {
return request.then(null, () => { throw request.error });
}
/**
* Configures call waiting options.
*
* Fulfill params: (none)
* Reject params:
* 'RadioNotAvailable', 'RequestNotSupported', 'InvalidParameter' or
* 'GenericFailure'.
*
* @return A deferred promise.
*/
function setCallWaitingOption(aEnabled) {
let request = mobileConnection.setCallWaitingOption(aEnabled);
return request.then(null, () => { throw request.error });
}
/**
* Queries current call waiting status.
*
* Fulfill params:
* A boolean indicating the call waiting status.
* Reject params:
* 'RadioNotAvailable', 'RequestNotSupported', 'InvalidParameter' or
* 'GenericFailure'.
*
* @return A deferred promise.
*/
function getCallWaitingOption() {
let request = mobileConnection.getCallWaitingOption();
return request.then(() => request.result, () => { throw request.error });
}
/**
* Set data connection enabling state and wait for "datachange" event.
*

Просмотреть файл

@ -19,6 +19,7 @@ qemu = true
[test_call_barring_get_error.js]
[test_call_barring_set_error.js]
[test_call_barring_change_password.js]
[test_call_waiting.js]
[test_mobile_set_radio.js]
[test_mobile_last_known_network.js]
[test_mobile_icc_change.js]

Просмотреть файл

@ -0,0 +1,29 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = "head.js";
// Start tests
startTestCommon(function() {
return Promise.resolve()
// TODO: Bug 1090811 - [B2G] support SET_CALL_WAITING and QUERY_CALL_WAITING
// Currently emulator doesn't support RIL_REQUEST_QUERY_CALL_WAITING and
// RIL_REQUEST_SET_CALL_WAITING, so we expect to get a 'RequestNotSupported'
// error here.
.then(() => setCallWaitingOption(true))
.then(() => {
ok(false, "setCallWaitingOption should not success");
}, aError => {
is(aError.name, "RequestNotSupported",
"failed to setCallWaitingOption");
})
.then(() => getCallWaitingOption())
.then(() => {
ok(false, "getCallWaitingOption should not success");
}, aError => {
is(aError.name, "RequestNotSupported",
"failed to getCallWaitingOption");
});
});

Просмотреть файл

@ -933,7 +933,7 @@ RilObject.prototype = {
Buf.newParcel(REQUEST_QUERY_CALL_WAITING, options);
Buf.writeInt32(1);
// As per 3GPP TS 24.083, section 1.6 UE doesn't need to send service
// class parameter in call waiting interrogation to network
// class parameter in call waiting interrogation to network.
Buf.writeInt32(ICC_SERVICE_CLASS_NONE);
Buf.sendParcel();
},
@ -941,16 +941,17 @@ RilObject.prototype = {
/**
* Set call waiting status.
*
* @param on
* @param enabled
* Boolean indicating the desired waiting status.
* @param serviceClass
* One of ICC_SERVICE_CLASS_* constants.
*/
setCallWaiting: function(options) {
let Buf = this.context.Buf;
Buf.newParcel(REQUEST_SET_CALL_WAITING, options);
Buf.writeInt32(2);
Buf.writeInt32(options.enabled ? 1 : 0);
Buf.writeInt32(options.serviceClass !== undefined ?
options.serviceClass : ICC_SERVICE_CLASS_VOICE);
Buf.writeInt32(options.serviceClass);
Buf.sendParcel();
},
@ -4937,9 +4938,9 @@ RilObject.prototype[REQUEST_QUERY_CALL_WAITING] =
}
let Buf = this.context.Buf;
options.length = Buf.readInt32();
options.enabled = ((Buf.readInt32() == 1) &&
((Buf.readInt32() & ICC_SERVICE_CLASS_VOICE) == 0x01));
let results = Buf.readInt32List();
let enabled = (results[0] === 1);
options.serviceClass = enabled ? results[1] : ICC_SERVICE_CLASS_NONE;
this.sendChromeMessage(options);
};

Просмотреть файл

@ -62,7 +62,7 @@ add_test(function test_queryCallWaiting_success_enabled_true() {
context.Buf.int32Array = [
1, // serviceClass
1, // enabled
1 // length
2 // length
];
context.RIL[REQUEST_QUERY_CALL_WAITING](1, {});
};
@ -72,8 +72,7 @@ add_test(function test_queryCallWaiting_success_enabled_true() {
let postedMessage = workerHelper.postedMessage;
equal(postedMessage.errorMsg, undefined);
equal(postedMessage.length, 1);
ok(postedMessage.enabled);
equal(postedMessage.serviceClass, 1);
run_next_test();
});
@ -90,7 +89,7 @@ add_test(function test_queryCallWaiting_success_enabled_false() {
context.Buf.int32Array = [
1, // serviceClass
0, // enabled
1 // length
2 // length
];
context.RIL[REQUEST_QUERY_CALL_WAITING](1, {});
};
@ -100,7 +99,6 @@ add_test(function test_queryCallWaiting_success_enabled_false() {
let postedMessage = workerHelper.postedMessage;
equal(postedMessage.errorMsg, undefined);
equal(postedMessage.length, 1);
ok(!postedMessage.enabled);
equal(postedMessage.serviceClass, ICC_SERVICE_CLASS_NONE);
run_next_test();
});

Просмотреть файл

@ -508,7 +508,6 @@ add_test(function test_sendMMI_call_waiting_interrogation() {
let postedMessage = workerhelper.postedMessage;
equal(postedMessage.errorMsg, undefined);
equal(postedMessage.length, 2);
ok(postedMessage.enabled);
equal(postedMessage.serviceClass, 7);
run_next_test();
});