2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2014-07-01 14:28:18 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2014-09-21 11:24:42 +04:00
|
|
|
#include "mozilla/dom/mobileconnection/MobileConnectionChild.h"
|
2014-07-01 14:28:18 +04:00
|
|
|
|
|
|
|
#include "MobileConnectionCallback.h"
|
|
|
|
#include "mozilla/dom/MozMobileConnectionBinding.h"
|
|
|
|
#include "nsComponentManagerUtils.h"
|
|
|
|
|
|
|
|
using namespace mozilla::dom;
|
|
|
|
using namespace mozilla::dom::mobileconnection;
|
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
NS_IMPL_ISUPPORTS(MobileConnectionChild, nsIMobileConnection)
|
|
|
|
|
|
|
|
MobileConnectionChild::MobileConnectionChild(uint32_t aServiceId)
|
|
|
|
: mServiceId(aServiceId)
|
|
|
|
, mLive(true)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(MobileConnectionChild);
|
|
|
|
}
|
|
|
|
|
2014-07-01 14:28:18 +04:00
|
|
|
void
|
|
|
|
MobileConnectionChild::Init()
|
|
|
|
{
|
|
|
|
nsIMobileConnectionInfo* rawVoice;
|
|
|
|
nsIMobileConnectionInfo* rawData;
|
|
|
|
|
2014-11-13 14:12:11 +03:00
|
|
|
SendInit(&rawVoice, &rawData, &mLastNetwork, &mLastHomeNetwork,
|
2014-09-21 11:24:43 +04:00
|
|
|
&mNetworkSelectionMode, &mRadioState, &mSupportedNetworkTypes);
|
2014-07-01 14:28:18 +04:00
|
|
|
|
|
|
|
// Use dont_AddRef here because this instances is already AddRef-ed in
|
|
|
|
// MobileConnectionIPCSerializer.h
|
|
|
|
nsCOMPtr<nsIMobileConnectionInfo> voice = dont_AddRef(rawVoice);
|
|
|
|
mVoice = new MobileConnectionInfo(nullptr);
|
|
|
|
mVoice->Update(voice);
|
|
|
|
|
|
|
|
// Use dont_AddRef here because this instances is already AddRef-ed in
|
|
|
|
// MobileConnectionIPCSerializer.h
|
|
|
|
nsCOMPtr<nsIMobileConnectionInfo> data = dont_AddRef(rawData);
|
|
|
|
mData = new MobileConnectionInfo(nullptr);
|
|
|
|
mData->Update(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MobileConnectionChild::Shutdown()
|
|
|
|
{
|
|
|
|
if (mLive) {
|
|
|
|
mLive = false;
|
|
|
|
Send__delete__(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
mListeners.Clear();
|
|
|
|
mVoice = nullptr;
|
|
|
|
mData = nullptr;
|
|
|
|
}
|
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
// nsIMobileConnection
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionChild::GetServiceId(uint32_t* aServiceId)
|
|
|
|
{
|
|
|
|
*aServiceId = mServiceId;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-07-01 14:28:18 +04:00
|
|
|
MobileConnectionChild::RegisterListener(nsIMobileConnectionListener* aListener)
|
|
|
|
{
|
2014-09-21 11:24:43 +04:00
|
|
|
NS_ENSURE_TRUE(!mListeners.Contains(aListener), NS_ERROR_UNEXPECTED);
|
|
|
|
|
|
|
|
mListeners.AppendObject(aListener);
|
|
|
|
return NS_OK;
|
2014-07-01 14:28:18 +04:00
|
|
|
}
|
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
NS_IMETHODIMP
|
2014-07-01 14:28:18 +04:00
|
|
|
MobileConnectionChild::UnregisterListener(nsIMobileConnectionListener* aListener)
|
|
|
|
{
|
2014-09-21 11:24:43 +04:00
|
|
|
NS_ENSURE_TRUE(mListeners.Contains(aListener), NS_ERROR_UNEXPECTED);
|
|
|
|
|
2014-07-01 14:28:18 +04:00
|
|
|
mListeners.RemoveObject(aListener);
|
2014-09-21 11:24:43 +04:00
|
|
|
return NS_OK;
|
2014-07-01 14:28:18 +04:00
|
|
|
}
|
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionChild::GetVoice(nsIMobileConnectionInfo** aVoice)
|
2014-07-01 14:28:18 +04:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsIMobileConnectionInfo> voice(mVoice);
|
2014-09-21 11:24:43 +04:00
|
|
|
voice.forget(aVoice);
|
|
|
|
return NS_OK;
|
2014-07-01 14:28:18 +04:00
|
|
|
}
|
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionChild::GetData(nsIMobileConnectionInfo** aData)
|
2014-07-01 14:28:18 +04:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsIMobileConnectionInfo> data(mData);
|
2014-09-21 11:24:43 +04:00
|
|
|
data.forget(aData);
|
|
|
|
return NS_OK;
|
2014-07-01 14:28:18 +04:00
|
|
|
}
|
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
NS_IMETHODIMP
|
2014-10-24 13:12:33 +04:00
|
|
|
MobileConnectionChild::GetRadioState(int32_t* aRadioState)
|
2014-07-01 14:28:18 +04:00
|
|
|
{
|
2014-10-24 13:12:33 +04:00
|
|
|
*aRadioState = mRadioState;
|
2014-09-21 11:24:43 +04:00
|
|
|
return NS_OK;
|
2014-07-01 14:28:18 +04:00
|
|
|
}
|
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
NS_IMETHODIMP
|
2014-11-18 05:07:00 +03:00
|
|
|
MobileConnectionChild::GetSupportedNetworkTypes(int32_t** aTypes,
|
2014-09-21 11:24:43 +04:00
|
|
|
uint32_t* aLength)
|
2014-07-01 14:28:18 +04:00
|
|
|
{
|
2014-09-21 11:24:43 +04:00
|
|
|
NS_ENSURE_ARG(aTypes);
|
|
|
|
NS_ENSURE_ARG(aLength);
|
|
|
|
|
|
|
|
*aLength = mSupportedNetworkTypes.Length();
|
|
|
|
*aTypes =
|
2015-03-27 03:01:12 +03:00
|
|
|
static_cast<int32_t*>(moz_xmalloc((*aLength) * sizeof(int32_t)));
|
2014-09-21 11:24:43 +04:00
|
|
|
NS_ENSURE_TRUE(*aTypes, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < *aLength; i++) {
|
2014-11-18 05:07:00 +03:00
|
|
|
(*aTypes)[i] = mSupportedNetworkTypes[i];
|
2014-09-21 11:24:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
2014-07-01 14:28:18 +04:00
|
|
|
}
|
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionChild::GetLastKnownNetwork(nsAString& aNetwork)
|
2014-07-01 14:28:18 +04:00
|
|
|
{
|
|
|
|
aNetwork = mLastNetwork;
|
2014-09-21 11:24:43 +04:00
|
|
|
return NS_OK;
|
2014-07-01 14:28:18 +04:00
|
|
|
}
|
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionChild::GetLastKnownHomeNetwork(nsAString& aNetwork)
|
2014-07-01 14:28:18 +04:00
|
|
|
{
|
|
|
|
aNetwork = mLastHomeNetwork;
|
2014-09-21 11:24:43 +04:00
|
|
|
return NS_OK;
|
2014-07-01 14:28:18 +04:00
|
|
|
}
|
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
NS_IMETHODIMP
|
2014-10-21 10:31:44 +04:00
|
|
|
MobileConnectionChild::GetNetworkSelectionMode(int32_t* aMode)
|
2014-07-01 14:28:18 +04:00
|
|
|
{
|
2014-10-21 10:31:44 +04:00
|
|
|
*aMode = mNetworkSelectionMode;
|
2014-09-21 11:24:43 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionChild::GetNetworks(nsIMobileConnectionCallback* aCallback)
|
|
|
|
{
|
|
|
|
return SendRequest(GetNetworksRequest(), aCallback) ? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionChild::SelectNetwork(nsIMobileNetworkInfo* aNetwork,
|
|
|
|
nsIMobileConnectionCallback* aCallback)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIMobileNetworkInfo> network = aNetwork;
|
|
|
|
// We release the ref after serializing process is finished in
|
|
|
|
// MobileConnectionIPCSerializer.
|
|
|
|
return SendRequest(SelectNetworkRequest(network.forget().take()), aCallback)
|
|
|
|
? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionChild::SelectNetworkAutomatically(nsIMobileConnectionCallback* aCallback)
|
|
|
|
{
|
|
|
|
return SendRequest(SelectNetworkAutoRequest(), aCallback)
|
|
|
|
? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-10-30 09:56:00 +03:00
|
|
|
MobileConnectionChild::SetPreferredNetworkType(int32_t aType,
|
2014-09-21 11:24:43 +04:00
|
|
|
nsIMobileConnectionCallback* aCallback)
|
|
|
|
{
|
2014-10-30 09:56:00 +03:00
|
|
|
return SendRequest(SetPreferredNetworkTypeRequest(aType), aCallback)
|
2014-09-21 11:24:43 +04:00
|
|
|
? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionChild::GetPreferredNetworkType(nsIMobileConnectionCallback* aCallback)
|
|
|
|
{
|
|
|
|
return SendRequest(GetPreferredNetworkTypeRequest(), aCallback)
|
|
|
|
? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-11-10 12:56:13 +03:00
|
|
|
MobileConnectionChild::SetRoamingPreference(int32_t aMode,
|
2014-09-21 11:24:43 +04:00
|
|
|
nsIMobileConnectionCallback* aCallback)
|
|
|
|
{
|
2014-11-10 12:56:13 +03:00
|
|
|
return SendRequest(SetRoamingPreferenceRequest(aMode), aCallback)
|
2014-09-21 11:24:43 +04:00
|
|
|
? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionChild::GetRoamingPreference(nsIMobileConnectionCallback* aCallback)
|
|
|
|
{
|
|
|
|
return SendRequest(GetRoamingPreferenceRequest(), aCallback)
|
|
|
|
? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionChild::SetVoicePrivacyMode(bool aEnabled,
|
|
|
|
nsIMobileConnectionCallback* aCallback)
|
|
|
|
{
|
|
|
|
return SendRequest(SetVoicePrivacyModeRequest(aEnabled), aCallback)
|
|
|
|
? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionChild::GetVoicePrivacyMode(nsIMobileConnectionCallback* aCallback)
|
|
|
|
{
|
|
|
|
return SendRequest(GetVoicePrivacyModeRequest(), aCallback)
|
|
|
|
? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-10-08 10:34:00 +04:00
|
|
|
MobileConnectionChild::SetCallForwarding(uint16_t aAction, uint16_t aReason,
|
|
|
|
const nsAString& aNumber,
|
|
|
|
uint16_t aTimeSeconds, uint16_t aServiceClass,
|
2014-09-21 11:24:43 +04:00
|
|
|
nsIMobileConnectionCallback* aCallback)
|
|
|
|
{
|
2014-10-08 10:34:00 +04:00
|
|
|
return SendRequest(SetCallForwardingRequest(aAction, aReason,
|
|
|
|
nsString(aNumber),
|
|
|
|
aTimeSeconds, aServiceClass),
|
|
|
|
aCallback)
|
2014-09-21 11:24:43 +04:00
|
|
|
? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionChild::GetCallForwarding(uint16_t aReason,
|
|
|
|
nsIMobileConnectionCallback* aCallback)
|
|
|
|
{
|
|
|
|
return SendRequest(GetCallForwardingRequest(aReason), aCallback)
|
|
|
|
? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-10-08 10:34:00 +04:00
|
|
|
MobileConnectionChild::SetCallBarring(uint16_t aProgram, bool aEnabled,
|
|
|
|
const nsAString& aPassword,
|
|
|
|
uint16_t aServiceClass,
|
2014-09-21 11:24:43 +04:00
|
|
|
nsIMobileConnectionCallback* aCallback)
|
|
|
|
{
|
2014-10-08 10:34:00 +04:00
|
|
|
return SendRequest(SetCallBarringRequest(aProgram, aEnabled,
|
|
|
|
nsString(aPassword),
|
|
|
|
aServiceClass),
|
|
|
|
aCallback)
|
2014-09-21 11:24:43 +04:00
|
|
|
? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-10-08 10:34:00 +04:00
|
|
|
MobileConnectionChild::GetCallBarring(uint16_t aProgram,
|
|
|
|
const nsAString& aPassword,
|
|
|
|
uint16_t aServiceClass,
|
2014-09-21 11:24:43 +04:00
|
|
|
nsIMobileConnectionCallback* aCallback)
|
|
|
|
{
|
2014-10-08 10:34:00 +04:00
|
|
|
return SendRequest(GetCallBarringRequest(aProgram, nsString(aPassword),
|
|
|
|
aServiceClass),
|
|
|
|
aCallback)
|
2014-09-21 11:24:43 +04:00
|
|
|
? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-10-08 10:34:00 +04:00
|
|
|
MobileConnectionChild::ChangeCallBarringPassword(const nsAString& aPin,
|
|
|
|
const nsAString& aNewPin,
|
2014-09-21 11:24:43 +04:00
|
|
|
nsIMobileConnectionCallback* aCallback)
|
|
|
|
{
|
2014-10-08 10:34:00 +04:00
|
|
|
return SendRequest(ChangeCallBarringPasswordRequest(nsString(aPin),
|
|
|
|
nsString(aNewPin)),
|
|
|
|
aCallback)
|
2014-09-21 11:24:43 +04:00
|
|
|
? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionChild::SetCallWaiting(bool aEnabled,
|
2015-05-28 14:18:22 +03:00
|
|
|
uint16_t aServiceClass,
|
2014-09-21 11:24:43 +04:00
|
|
|
nsIMobileConnectionCallback* aCallback)
|
|
|
|
{
|
2015-05-28 14:18:22 +03:00
|
|
|
return SendRequest(SetCallWaitingRequest(aEnabled, aServiceClass), aCallback)
|
2014-09-21 11:24:43 +04:00
|
|
|
? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionChild::GetCallWaiting(nsIMobileConnectionCallback* aCallback)
|
|
|
|
{
|
|
|
|
return SendRequest(GetCallWaitingRequest(), aCallback)
|
|
|
|
? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionChild::SetCallingLineIdRestriction(uint16_t aMode,
|
|
|
|
nsIMobileConnectionCallback* aCallback)
|
|
|
|
{
|
|
|
|
return SendRequest(SetCallingLineIdRestrictionRequest(aMode), aCallback)
|
|
|
|
? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionChild::GetCallingLineIdRestriction(nsIMobileConnectionCallback* aCallback)
|
|
|
|
{
|
|
|
|
return SendRequest(GetCallingLineIdRestrictionRequest(), aCallback)
|
|
|
|
? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionChild::ExitEmergencyCbMode(nsIMobileConnectionCallback* aCallback)
|
|
|
|
{
|
|
|
|
return SendRequest(ExitEmergencyCbModeRequest(), aCallback)
|
|
|
|
? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionChild::SetRadioEnabled(bool aEnabled,
|
|
|
|
nsIMobileConnectionCallback* aCallback)
|
|
|
|
{
|
|
|
|
return SendRequest(SetRadioEnabledRequest(aEnabled), aCallback)
|
|
|
|
? NS_OK : NS_ERROR_FAILURE;
|
2014-07-01 14:28:18 +04:00
|
|
|
}
|
|
|
|
|
2014-10-22 14:12:07 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionChild::GetNeighboringCellIds(nsINeighboringCellIdsCallback* aCallback)
|
|
|
|
{
|
|
|
|
// This function is supported in chrome context only.
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionChild::GetCellInfoList(nsICellInfoListCallback* aCallback)
|
|
|
|
{
|
|
|
|
// This function is supported in chrome context only.
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2014-07-01 14:37:32 +04:00
|
|
|
bool
|
2014-09-21 11:24:43 +04:00
|
|
|
MobileConnectionChild::SendRequest(const MobileConnectionRequest& aRequest,
|
|
|
|
nsIMobileConnectionCallback* aCallback)
|
2014-07-01 14:37:32 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(mLive, false);
|
|
|
|
|
|
|
|
// Deallocated in MobileConnectionChild::DeallocPMobileConnectionRequestChild().
|
2014-09-21 11:24:43 +04:00
|
|
|
MobileConnectionRequestChild* actor =
|
|
|
|
new MobileConnectionRequestChild(aCallback);
|
2014-07-01 14:37:32 +04:00
|
|
|
SendPMobileConnectionRequestConstructor(actor, aRequest);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-07-01 14:28:18 +04:00
|
|
|
void
|
|
|
|
MobileConnectionChild::ActorDestroy(ActorDestroyReason why)
|
|
|
|
{
|
|
|
|
mLive = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
PMobileConnectionRequestChild*
|
|
|
|
MobileConnectionChild::AllocPMobileConnectionRequestChild(const MobileConnectionRequest& request)
|
|
|
|
{
|
|
|
|
MOZ_CRASH("Caller is supposed to manually construct a request!");
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionChild::DeallocPMobileConnectionRequestChild(PMobileConnectionRequestChild* aActor)
|
|
|
|
{
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionChild::RecvNotifyVoiceInfoChanged(nsIMobileConnectionInfo* const& aInfo)
|
|
|
|
{
|
|
|
|
// Use dont_AddRef here because this instances is already AddRef-ed in
|
|
|
|
// MobileConnectionIPCSerializer.h
|
|
|
|
nsCOMPtr<nsIMobileConnectionInfo> voice = dont_AddRef(aInfo);
|
|
|
|
mVoice->Update(voice);
|
|
|
|
|
|
|
|
for (int32_t i = 0; i < mListeners.Count(); i++) {
|
|
|
|
mListeners[i]->NotifyVoiceChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionChild::RecvNotifyDataInfoChanged(nsIMobileConnectionInfo* const& aInfo)
|
|
|
|
{
|
|
|
|
// Use dont_AddRef here because this instances is already AddRef-ed in
|
|
|
|
// MobileConnectionIPCSerializer.h
|
|
|
|
nsCOMPtr<nsIMobileConnectionInfo> data = dont_AddRef(aInfo);
|
|
|
|
mData->Update(data);
|
|
|
|
|
|
|
|
for (int32_t i = 0; i < mListeners.Count(); i++) {
|
|
|
|
mListeners[i]->NotifyDataChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionChild::RecvNotifyDataError(const nsString& aMessage)
|
|
|
|
{
|
|
|
|
for (int32_t i = 0; i < mListeners.Count(); i++) {
|
|
|
|
mListeners[i]->NotifyDataError(aMessage);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2014-10-23 18:13:35 +04:00
|
|
|
MobileConnectionChild::RecvNotifyCFStateChanged(const uint16_t& aAction,
|
2014-07-01 14:28:18 +04:00
|
|
|
const uint16_t& aReason,
|
|
|
|
const nsString& aNumber,
|
|
|
|
const uint16_t& aTimeSeconds,
|
|
|
|
const uint16_t& aServiceClass)
|
|
|
|
{
|
|
|
|
for (int32_t i = 0; i < mListeners.Count(); i++) {
|
2014-10-23 18:13:35 +04:00
|
|
|
mListeners[i]->NotifyCFStateChanged(aAction, aReason, aNumber, aTimeSeconds,
|
|
|
|
aServiceClass);
|
2014-07-01 14:28:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionChild::RecvNotifyEmergencyCbModeChanged(const bool& aActive,
|
|
|
|
const uint32_t& aTimeoutMs)
|
|
|
|
{
|
|
|
|
for (int32_t i = 0; i < mListeners.Count(); i++) {
|
|
|
|
mListeners[i]->NotifyEmergencyCbModeChanged(aActive, aTimeoutMs);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionChild::RecvNotifyOtaStatusChanged(const nsString& aStatus)
|
|
|
|
{
|
|
|
|
for (int32_t i = 0; i < mListeners.Count(); i++) {
|
|
|
|
mListeners[i]->NotifyOtaStatusChanged(aStatus);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2014-10-24 13:12:33 +04:00
|
|
|
MobileConnectionChild::RecvNotifyRadioStateChanged(const int32_t& aRadioState)
|
2014-07-01 14:28:18 +04:00
|
|
|
{
|
2014-10-24 13:12:33 +04:00
|
|
|
mRadioState = aRadioState;
|
2014-07-01 14:28:18 +04:00
|
|
|
|
|
|
|
for (int32_t i = 0; i < mListeners.Count(); i++) {
|
|
|
|
mListeners[i]->NotifyRadioStateChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionChild::RecvNotifyClirModeChanged(const uint32_t& aMode)
|
|
|
|
{
|
|
|
|
for (int32_t i = 0; i < mListeners.Count(); i++) {
|
|
|
|
mListeners[i]->NotifyClirModeChanged(aMode);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionChild::RecvNotifyLastNetworkChanged(const nsString& aNetwork)
|
|
|
|
{
|
|
|
|
mLastNetwork.Assign(aNetwork);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionChild::RecvNotifyLastHomeNetworkChanged(const nsString& aNetwork)
|
|
|
|
{
|
|
|
|
mLastHomeNetwork.Assign(aNetwork);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2014-10-21 10:31:44 +04:00
|
|
|
MobileConnectionChild::RecvNotifyNetworkSelectionModeChanged(const int32_t& aMode)
|
2014-07-01 14:28:18 +04:00
|
|
|
{
|
2014-10-21 10:31:44 +04:00
|
|
|
mNetworkSelectionMode = aMode;
|
2014-07-01 14:28:18 +04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* MobileConnectionRequestChild
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
void
|
|
|
|
MobileConnectionRequestChild::ActorDestroy(ActorDestroyReason why)
|
|
|
|
{
|
|
|
|
mRequestCallback = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionRequestChild::DoReply(const MobileConnectionReplySuccess& aReply)
|
|
|
|
{
|
|
|
|
return NS_SUCCEEDED(mRequestCallback->NotifySuccess());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionRequestChild::DoReply(const MobileConnectionReplySuccessBoolean& aReply)
|
|
|
|
{
|
|
|
|
return NS_SUCCEEDED(mRequestCallback->NotifySuccessWithBoolean(aReply.result()));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionRequestChild::DoReply(const MobileConnectionReplySuccessNetworks& aReply)
|
|
|
|
{
|
|
|
|
uint32_t count = aReply.results().Length();
|
|
|
|
nsTArray<nsCOMPtr<nsIMobileNetworkInfo>> results;
|
|
|
|
for (uint32_t i = 0; i < count; i++) {
|
|
|
|
// Use dont_AddRef here because these instances are already AddRef-ed in
|
|
|
|
// MobileConnectionIPCSerializer.h
|
|
|
|
nsCOMPtr<nsIMobileNetworkInfo> item = dont_AddRef(aReply.results()[i]);
|
|
|
|
results.AppendElement(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_SUCCEEDED(mRequestCallback->NotifyGetNetworksSuccess(count,
|
|
|
|
const_cast<nsIMobileNetworkInfo**>(aReply.results().Elements())));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionRequestChild::DoReply(const MobileConnectionReplySuccessCallForwarding& aReply)
|
|
|
|
{
|
2014-10-08 10:34:00 +04:00
|
|
|
uint32_t count = aReply.results().Length();
|
|
|
|
nsTArray<nsCOMPtr<nsIMobileCallForwardingOptions>> results;
|
|
|
|
for (uint32_t i = 0; i < count; i++) {
|
|
|
|
// Use dont_AddRef here because these instances are already AddRef-ed in
|
|
|
|
// MobileConnectionIPCSerializer.h
|
|
|
|
nsCOMPtr<nsIMobileCallForwardingOptions> item = dont_AddRef(aReply.results()[i]);
|
|
|
|
results.AppendElement(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_SUCCEEDED(mRequestCallback->NotifyGetCallForwardingSuccess(
|
|
|
|
count, const_cast<nsIMobileCallForwardingOptions**>(aReply.results().Elements())));
|
2014-07-01 14:28:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionRequestChild::DoReply(const MobileConnectionReplySuccessCallBarring& aReply)
|
|
|
|
{
|
|
|
|
return NS_SUCCEEDED(mRequestCallback->NotifyGetCallBarringSuccess(aReply.program(),
|
|
|
|
aReply.enabled(),
|
|
|
|
aReply.serviceClass()));
|
|
|
|
}
|
|
|
|
|
2015-05-28 14:18:22 +03:00
|
|
|
bool
|
|
|
|
MobileConnectionRequestChild::DoReply(const MobileConnectionReplySuccessCallWaiting& aReply)
|
|
|
|
{
|
|
|
|
return NS_SUCCEEDED(mRequestCallback->NotifyGetCallWaitingSuccess(aReply.serviceClass()));
|
|
|
|
}
|
|
|
|
|
2014-07-01 14:28:18 +04:00
|
|
|
bool
|
|
|
|
MobileConnectionRequestChild::DoReply(const MobileConnectionReplySuccessClirStatus& aReply)
|
|
|
|
{
|
|
|
|
return NS_SUCCEEDED(mRequestCallback->NotifyGetClirStatusSuccess(aReply.n(),
|
|
|
|
aReply.m()));
|
|
|
|
}
|
|
|
|
|
2014-10-30 09:56:00 +03:00
|
|
|
bool
|
|
|
|
MobileConnectionRequestChild::DoReply(const MobileConnectionReplySuccessPreferredNetworkType& aReply)
|
|
|
|
{
|
|
|
|
return NS_SUCCEEDED(mRequestCallback->NotifyGetPreferredNetworkTypeSuccess(aReply.type()));
|
|
|
|
}
|
|
|
|
|
2014-11-10 12:56:13 +03:00
|
|
|
bool
|
|
|
|
MobileConnectionRequestChild::DoReply(const MobileConnectionReplySuccessRoamingPreference& aReply)
|
|
|
|
{
|
|
|
|
return NS_SUCCEEDED(mRequestCallback->NotifyGetRoamingPreferenceSuccess(aReply.mode()));
|
|
|
|
}
|
|
|
|
|
2014-07-01 14:28:18 +04:00
|
|
|
bool
|
|
|
|
MobileConnectionRequestChild::DoReply(const MobileConnectionReplyError& aReply)
|
|
|
|
{
|
|
|
|
return NS_SUCCEEDED(mRequestCallback->NotifyError(aReply.message()));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionRequestChild::Recv__delete__(const MobileConnectionReply& aReply)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mRequestCallback);
|
|
|
|
|
|
|
|
switch (aReply.type()) {
|
|
|
|
case MobileConnectionReply::TMobileConnectionReplySuccess:
|
|
|
|
return DoReply(aReply.get_MobileConnectionReplySuccess());
|
|
|
|
case MobileConnectionReply::TMobileConnectionReplySuccessBoolean:
|
|
|
|
return DoReply(aReply.get_MobileConnectionReplySuccessBoolean());
|
|
|
|
case MobileConnectionReply::TMobileConnectionReplySuccessNetworks:
|
|
|
|
return DoReply(aReply.get_MobileConnectionReplySuccessNetworks());
|
|
|
|
case MobileConnectionReply::TMobileConnectionReplySuccessCallForwarding:
|
|
|
|
return DoReply(aReply.get_MobileConnectionReplySuccessCallForwarding());
|
|
|
|
case MobileConnectionReply::TMobileConnectionReplySuccessCallBarring:
|
|
|
|
return DoReply(aReply.get_MobileConnectionReplySuccessCallBarring());
|
2015-05-28 14:18:22 +03:00
|
|
|
case MobileConnectionReply::TMobileConnectionReplySuccessCallWaiting:
|
|
|
|
return DoReply(aReply.get_MobileConnectionReplySuccessCallWaiting());
|
2014-07-01 14:28:18 +04:00
|
|
|
case MobileConnectionReply::TMobileConnectionReplySuccessClirStatus:
|
|
|
|
return DoReply(aReply.get_MobileConnectionReplySuccessClirStatus());
|
2014-10-30 09:56:00 +03:00
|
|
|
case MobileConnectionReply::TMobileConnectionReplySuccessPreferredNetworkType:
|
|
|
|
return DoReply(aReply.get_MobileConnectionReplySuccessPreferredNetworkType());
|
2014-11-10 12:56:13 +03:00
|
|
|
case MobileConnectionReply::TMobileConnectionReplySuccessRoamingPreference:
|
|
|
|
return DoReply(aReply.get_MobileConnectionReplySuccessRoamingPreference());
|
2014-07-01 14:28:18 +04:00
|
|
|
case MobileConnectionReply::TMobileConnectionReplyError:
|
|
|
|
return DoReply(aReply.get_MobileConnectionReplyError());
|
|
|
|
default:
|
|
|
|
MOZ_CRASH("Received invalid response type!");
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|