mirror of
https://gitee.com/openharmony/telephony_core_service
synced 2024-11-30 11:40:54 +00:00
commit
67ca8fa93a
7
BUILD.gn
7
BUILD.gn
@ -18,6 +18,8 @@ TELEPHONY_NETWORK_SEARCH_ROOT = "services/network_search"
|
||||
TELEPHONY_SIM_ROOT = "services/sim"
|
||||
TELEPHONY_TEL_RIL_ROOT = "services/tel_ril"
|
||||
TELEPHONY_IMS_CORE_SERVICE_SRC_PATH = "services/ims_service_interaction/src"
|
||||
TELEPHONY_SATELLITE_CORE_SERVICE_SRC_PATH =
|
||||
"services/satellite_service_interaction/src"
|
||||
TELEPHONY_EXT_WRAPPER_ROOT = "services/telephony_ext_wrapper"
|
||||
|
||||
ohos_shared_library("tel_core_service") {
|
||||
@ -58,6 +60,10 @@ ohos_shared_library("tel_core_service") {
|
||||
"$TELEPHONY_NETWORK_SEARCH_ROOT/src/time_zone_location_update.cpp",
|
||||
"$TELEPHONY_NETWORK_SEARCH_ROOT/src/time_zone_manager.cpp",
|
||||
"$TELEPHONY_NETWORK_SEARCH_ROOT/src/time_zone_updater.cpp",
|
||||
"$TELEPHONY_SATELLITE_CORE_SERVICE_SRC_PATH/satellite_core_callback.cpp",
|
||||
"$TELEPHONY_SATELLITE_CORE_SERVICE_SRC_PATH/satellite_core_callback_stub.cpp",
|
||||
"$TELEPHONY_SATELLITE_CORE_SERVICE_SRC_PATH/satellite_service_client.cpp",
|
||||
"$TELEPHONY_SATELLITE_CORE_SERVICE_SRC_PATH/satellite_service_proxy.cpp",
|
||||
"$TELEPHONY_SIM_ROOT/src/csim_file_controller.cpp",
|
||||
"$TELEPHONY_SIM_ROOT/src/icc_dialling_numbers_cache.cpp",
|
||||
"$TELEPHONY_SIM_ROOT/src/icc_dialling_numbers_handler.cpp",
|
||||
@ -123,6 +129,7 @@ ohos_shared_library("tel_core_service") {
|
||||
"$TELEPHONY_NETWORK_SEARCH_ROOT/include",
|
||||
"$TELEPHONY_EXT_WRAPPER_ROOT/include",
|
||||
"services/core/include",
|
||||
"services/satellite_service_interaction/include",
|
||||
"utils/log/include",
|
||||
]
|
||||
|
||||
|
@ -1546,6 +1546,14 @@ bool CoreManagerInner::IsNrSupported(int32_t slotId)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CoreManagerInner::IsSatelliteEnabled()
|
||||
{
|
||||
if (networkSearchManager_ != nullptr) {
|
||||
return networkSearchManager_->IsSatelliteEnabled();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CoreManagerInner::DcPhysicalLinkActiveUpdate(int32_t slotId, bool isActive)
|
||||
{
|
||||
if (networkSearchManager_ != nullptr) {
|
||||
|
@ -26,6 +26,7 @@ config("tel_core_service_api_config") {
|
||||
include_dirs = [
|
||||
"$TELEPHONY_INTERFACES_INNERKITS/include",
|
||||
"$TELEPHONY_INTERFACES_INNERKITS/ims/include",
|
||||
"$TELEPHONY_INTERFACES_INNERKITS/satellite",
|
||||
]
|
||||
|
||||
cflags = []
|
||||
|
@ -222,6 +222,7 @@ public:
|
||||
int32_t UpdateRadioOn(int32_t slotId);
|
||||
|
||||
bool IsNrSupported(int32_t slotId);
|
||||
bool IsSatelliteEnabled();
|
||||
int32_t GetNrOptionMode(int32_t slotId, NrMode &mode);
|
||||
FrequencyType GetFrequencyType(int32_t slotId) const;
|
||||
NrState GetNrState(int32_t slotId) const;
|
||||
|
@ -180,6 +180,15 @@ public:
|
||||
* @return false not support
|
||||
*/
|
||||
virtual bool IsNrSupported(int32_t slotId) = 0;
|
||||
|
||||
/**
|
||||
* @brief support Satellite network or not
|
||||
*
|
||||
* @return true support
|
||||
* @return false not support
|
||||
*/
|
||||
virtual bool IsSatelliteEnabled() = 0;
|
||||
|
||||
/**
|
||||
* @brief Update physical link active status
|
||||
*
|
||||
|
@ -232,5 +232,9 @@ enum RadioEvent {
|
||||
RADIO_IMS_GET_COLR,
|
||||
RADIO_IMS_SET_COLP,
|
||||
RADIO_IMS_GET_COLP,
|
||||
|
||||
// Satellite status
|
||||
SATELLITE_STATUS_CHANGED,
|
||||
GET_SATELLITE_CAPABILITY
|
||||
};
|
||||
#endif // RADIO_EVENT_H
|
||||
|
@ -36,6 +36,7 @@ inline const int32_t DSDS_MODE_V2 = 0;
|
||||
inline const int32_t DSDS_MODE_V3 = 1;
|
||||
inline const size_t MAX_PARAMETER_LENGTH = 100;
|
||||
inline int32_t maxSlotCount_ = 0;
|
||||
inline constexpr const char *SATELLITE_DEFAULT_VALUE = "0";
|
||||
inline constexpr const char *DEFAULT_SLOT_COUNT = "1";
|
||||
inline constexpr const char *TEL_SIM_SLOT_COUNT = "const.telephony.slotCount";
|
||||
inline constexpr const char *DEFAULT_PREFERRED_NETWORK_TYPE = "5"; // CORE_NETWORK_MODE_LTE_WCDMA_GSM
|
||||
@ -45,6 +46,7 @@ inline constexpr const char *INITIAL_OPKEY = "-1";
|
||||
inline constexpr const char *DEFAULT_OPERATOR_CONFIG = "default_operator_config.json";
|
||||
inline constexpr const char *OPKEY_PROP_PREFIX = "telephony.sim.opkey";
|
||||
inline constexpr const char *COUNTRY_CODE_KEY = "telephony.sim.countryCode";
|
||||
inline constexpr const char *TEL_SATELLITE_SUPPORTED = "const.telephony.satellite.supported";
|
||||
|
||||
template<typename T>
|
||||
inline T GetMaxSlotCount()
|
||||
@ -66,6 +68,11 @@ inline T GetPreferredNetworkType()
|
||||
return networkType;
|
||||
}
|
||||
|
||||
enum SatelliteValue {
|
||||
SATELLITE_NOT_SUPPORTED = 0,
|
||||
SATELLITE_SUPPORTED = 1,
|
||||
};
|
||||
|
||||
enum SimSlotId {
|
||||
SIM_SLOT_0 = 0,
|
||||
SIM_SLOT_1,
|
||||
|
@ -45,6 +45,7 @@
|
||||
*TelephonyStateRegistryProxy*;
|
||||
*WcdmaCellInformation*;
|
||||
*WcdmaSignalInformation*;
|
||||
*SatelliteServiceClient*;
|
||||
};
|
||||
local:
|
||||
*;
|
||||
|
83
interfaces/innerkits/satellite/i_satellite_core_callback.h
Executable file
83
interfaces/innerkits/satellite/i_satellite_core_callback.h
Executable file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef I_SATELLITE_CORE_CALLBACK_H
|
||||
#define I_SATELLITE_CORE_CALLBACK_H
|
||||
|
||||
#include "event_handler.h"
|
||||
#include "iremote_proxy.h"
|
||||
#include "satellite_core_callback_ipc_interface_code.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
using namespace AppExecFwk;
|
||||
|
||||
class ISatelliteCoreCallback : public IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.telephony.ISatelliteCoreCallback");
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief SetRadioStateResponse.
|
||||
*
|
||||
* @param event event which contains the response data.
|
||||
* @return Returns {@code TELEPHONY_SUCCESS} on success, others on failure.
|
||||
*/
|
||||
virtual int32_t SetRadioStateResponse(InnerEvent::Pointer &event) = 0;
|
||||
|
||||
/**
|
||||
* @brief GetImeiResponse.
|
||||
*
|
||||
* @param event event which contains the response data.
|
||||
* @return Returns {@code TELEPHONY_SUCCESS} on success, others on failure.
|
||||
*/
|
||||
virtual int32_t GetImeiResponse(InnerEvent::Pointer &event) = 0;
|
||||
|
||||
/**
|
||||
* @brief GetSatelliteCapabilityResponse.
|
||||
*
|
||||
* @param event event which contains the response data.
|
||||
* @return Returns {@code TELEPHONY_SUCCESS} on success, others on failure.
|
||||
*/
|
||||
virtual int32_t GetSatelliteCapabilityResponse(InnerEvent::Pointer &event) = 0;
|
||||
|
||||
/**
|
||||
* @brief RadioStateChanged.
|
||||
*
|
||||
* @param event event which contains the response data.
|
||||
* @return Returns {@code TELEPHONY_SUCCESS} on success, others on failure.
|
||||
*/
|
||||
virtual int32_t RadioStateChanged(InnerEvent::Pointer &event) = 0;
|
||||
|
||||
/**
|
||||
* @brief SimStateChanged.
|
||||
*
|
||||
* @param event event which contains the response data.
|
||||
* @return Returns {@code TELEPHONY_SUCCESS} on success, others on failure.
|
||||
*/
|
||||
virtual int32_t SimStateChanged(InnerEvent::Pointer &event) = 0;
|
||||
|
||||
/**
|
||||
* @brief SatelliteStatusChanged.
|
||||
*
|
||||
* @param event event which contains the response data.
|
||||
* @return Returns {@code TELEPHONY_SUCCESS} on success, others on failure.
|
||||
*/
|
||||
virtual int32_t SatelliteStatusChanged(InnerEvent::Pointer &event) = 0;
|
||||
};
|
||||
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
#endif // I_SATELLITE_CORE_CALLBACK_H
|
106
interfaces/innerkits/satellite/i_satellite_service.h
Executable file
106
interfaces/innerkits/satellite/i_satellite_service.h
Executable file
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef I_SATELLITE_SERVICE_H
|
||||
#define I_SATELLITE_SERVICE_H
|
||||
|
||||
#include "event_handler.h"
|
||||
#include "i_satellite_core_callback.h"
|
||||
#include "iremote_proxy.h"
|
||||
#include "telephony_types.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
using SatelliteMessage = GsmSimMessageParam;
|
||||
|
||||
namespace {
|
||||
const int32_t TELEPHONY_SATELLITE_SERVICE_ABILITY_ID = 4012;
|
||||
}
|
||||
|
||||
enum SatelliteServiceProxyType {
|
||||
PROXY_SATELLITE_CALL = 0,
|
||||
PROXY_SATELLITE_SMS = 1,
|
||||
};
|
||||
class ISatelliteService : public IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.telephony.ISatelliteService");
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Get the result of whether the satellite mode is on.
|
||||
*
|
||||
* @return True if satellite mode is turn on, false otherwise.
|
||||
*/
|
||||
virtual bool IsSatelliteEnabled() = 0;
|
||||
|
||||
/**
|
||||
* @brief Register a callback to service, so that service can send result to the caller.
|
||||
*
|
||||
* @param slotId sim slot id
|
||||
* @param what identify the callback data
|
||||
* @param callback callback object to deal with the callback data
|
||||
* @return Returns TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
virtual int32_t RegisterCoreNotify(int32_t slotId, int32_t what, const sptr<ISatelliteCoreCallback> &callback) = 0;
|
||||
|
||||
/**
|
||||
* @brief Register a callback to service, so that service can send result to the caller.
|
||||
*
|
||||
* @param slotId sim slot id
|
||||
* @param what identify which callback should be unregister
|
||||
* @param callback callback object to deal with the callback data
|
||||
* @return Returns TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
virtual int32_t UnRegisterCoreNotify(int32_t slotId, int32_t what) = 0;
|
||||
|
||||
/**
|
||||
* @brief Set the radio state.
|
||||
*
|
||||
* @param slotId sim slot id
|
||||
* @param eventId radio event id
|
||||
* @param isRadioOn radio on or off
|
||||
* @param rst whether to enable automatic reset of the modem
|
||||
* @return Returns TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
virtual int32_t SetRadioState(int32_t slotId, int32_t isRadioOn, int32_t rst) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get satellite imei
|
||||
*
|
||||
* @param slotId sim slot id
|
||||
* @return Returns TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
virtual int32_t GetImei(int32_t slotId) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get satellite capability
|
||||
*
|
||||
* @param slotId sim slot id
|
||||
*
|
||||
* @return Returns TELEPHONY_SUCCESS on success, others on failure.
|
||||
*/
|
||||
virtual int32_t GetSatelliteCapability(int32_t slotId) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get the pointer of service.
|
||||
*
|
||||
* @param SatelliteServiceProxyType service type, call or sms
|
||||
* @return Remote object of the service.
|
||||
*/
|
||||
virtual sptr<IRemoteObject> GetProxyObjectPtr(SatelliteServiceProxyType proxyType) = 0;
|
||||
};
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
#endif // I_SATELLITE_SERVICE_H
|
47
interfaces/innerkits/satellite/satellite_core_callback.h
Normal file
47
interfaces/innerkits/satellite/satellite_core_callback.h
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SATELLITE_CORE_CALLBACK_H
|
||||
#define SATELLITE_CORE_CALLBACK_H
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "event_handler.h"
|
||||
#include "event_runner.h"
|
||||
#include "iremote_stub.h"
|
||||
#include "satellite_core_callback_ipc_interface_code.h"
|
||||
#include "satellite_core_callback_stub.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
class SatelliteCoreCallback : public SatelliteCoreCallbackStub {
|
||||
public:
|
||||
explicit SatelliteCoreCallback(const std::shared_ptr<AppExecFwk::EventHandler> &handler);
|
||||
virtual ~SatelliteCoreCallback();
|
||||
|
||||
int32_t SetRadioStateResponse(InnerEvent::Pointer &event) override;
|
||||
int32_t RadioStateChanged(InnerEvent::Pointer &event) override;
|
||||
int32_t SimStateChanged(InnerEvent::Pointer &event) override;
|
||||
int32_t SatelliteStatusChanged(InnerEvent::Pointer &event) override;
|
||||
int32_t GetImeiResponse(InnerEvent::Pointer &event) override;
|
||||
int32_t GetSatelliteCapabilityResponse(InnerEvent::Pointer &event) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<AppExecFwk::EventHandler> handler_;
|
||||
};
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // SATELLITE_CORE_CALLBACK_H
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SATELLITE_CORE_CALLBACK_INTERFACE_CODE_H
|
||||
#define SATELLITE_CORE_CALLBACK_INTERFACE_CODE_H
|
||||
|
||||
/* SAID:4012 */
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
enum class SatelliteCoreCallbackInterfaceCode {
|
||||
SET_RADIO_STATE_RESPONSE = 0,
|
||||
GET_IMEI_RESPONSE,
|
||||
RADIO_STATE_CHANGED,
|
||||
SIM_STATE_CHANGED,
|
||||
GET_SATELLITE_CAPABILITY_RESPONSE,
|
||||
SATELLITE_STATUS_CHANGED,
|
||||
};
|
||||
|
||||
enum SatelliteRadioResponseType {
|
||||
DEFAULT_RADIO_RESPONSE = 1,
|
||||
RADIO_STATE_INFO,
|
||||
};
|
||||
|
||||
struct SatelliteStatus {
|
||||
int32_t slotId = -1;
|
||||
int32_t mode = 0;
|
||||
};
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
#endif // SATELLITE_CORE_CALLBACK_INTERFACE_CODE_H
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SATELLITE_CORE_CALLBACK_STUB_H
|
||||
#define SATELLITE_CORE_CALLBACK_STUB_H
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "event_handler.h"
|
||||
#include "event_runner.h"
|
||||
#include "i_satellite_core_callback.h"
|
||||
#include "iremote_stub.h"
|
||||
#include "satellite_core_callback_ipc_interface_code.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
class SatelliteCoreCallbackStub : public IRemoteStub<ISatelliteCoreCallback> {
|
||||
public:
|
||||
SatelliteCoreCallbackStub();
|
||||
virtual ~SatelliteCoreCallbackStub();
|
||||
int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
|
||||
|
||||
private:
|
||||
void InitFuncMap();
|
||||
|
||||
int32_t OnSetRadioStateResponse(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnGetImeiResponse(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnGetSatelliteCapabilityResponse(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnRadioStateChanged(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnSatelliteStatusChanged(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnSimStateChanged(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
private:
|
||||
using RequestFuncType = int32_t (SatelliteCoreCallbackStub::*)(MessageParcel &data, MessageParcel &reply);
|
||||
std::map<uint32_t, RequestFuncType> requestFuncMap_;
|
||||
};
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // SATELLITE_CORE_CALLBACK_STUB_H
|
83
interfaces/innerkits/satellite/satellite_service_client.h
Executable file
83
interfaces/innerkits/satellite/satellite_service_client.h
Executable file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SATELLITE_SERVICE_CLIENT_H
|
||||
#define SATELLITE_SERVICE_CLIENT_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "i_satellite_service.h"
|
||||
#include "iremote_object.h"
|
||||
#include "network_search_handler.h"
|
||||
#include "sim_state_handle.h"
|
||||
#include "singleton.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
class SatelliteServiceClient : public std::enable_shared_from_this<SatelliteServiceClient> {
|
||||
DECLARE_DELAYED_SINGLETON(SatelliteServiceClient);
|
||||
|
||||
public:
|
||||
sptr<ISatelliteService> GetProxy();
|
||||
void OnRemoteDied(const wptr<IRemoteObject> &remote);
|
||||
bool IsSatelliteEnabled();
|
||||
int32_t AddSimHandler(int32_t slotId, const std::shared_ptr<AppExecFwk::EventHandler> &handler);
|
||||
int32_t AddNetworkHandler(int32_t slotId, const std::shared_ptr<AppExecFwk::EventHandler> &handler);
|
||||
int32_t RegisterCoreNotify(int32_t slotId, int32_t what, const sptr<ISatelliteCoreCallback> &callback);
|
||||
int32_t UnRegisterCoreNotify(int32_t slotId, int32_t what);
|
||||
int32_t SetRadioState(int32_t slotId, int32_t isRadioOn, int32_t rst);
|
||||
int32_t GetImei(int32_t slotId);
|
||||
int32_t GetSatelliteCapability(int32_t slotId);
|
||||
sptr<IRemoteObject> GetProxyObjectPtr(SatelliteServiceProxyType type);
|
||||
|
||||
private:
|
||||
void RemoveDeathRecipient(const wptr<IRemoteObject> &remote, bool isRemoteDied);
|
||||
void ServiceOn();
|
||||
void ServiceOff();
|
||||
|
||||
class SatelliteServiceDeathRecipient : public IRemoteObject::DeathRecipient {
|
||||
public:
|
||||
explicit SatelliteServiceDeathRecipient(SatelliteServiceClient &client) : client_(client) {}
|
||||
~SatelliteServiceDeathRecipient() override = default;
|
||||
void OnRemoteDied(const wptr<IRemoteObject> &remote) override
|
||||
{
|
||||
client_.OnRemoteDied(remote);
|
||||
}
|
||||
|
||||
private:
|
||||
SatelliteServiceClient &client_;
|
||||
};
|
||||
|
||||
class SystemAbilityListener : public SystemAbilityStatusChangeStub {
|
||||
public:
|
||||
SystemAbilityListener() {}
|
||||
~SystemAbilityListener() {}
|
||||
|
||||
public:
|
||||
void OnAddSystemAbility(int32_t systemAbilityId, const std::string &deviceId) override;
|
||||
void OnRemoveSystemAbility(int32_t systemAbilityId, const std::string &deviceId) override;
|
||||
};
|
||||
|
||||
private:
|
||||
std::mutex mutexProxy_;
|
||||
sptr<ISystemAbilityStatusChange> statusChangeListener_ = nullptr;
|
||||
sptr<ISatelliteService> proxy_ { nullptr };
|
||||
sptr<IRemoteObject::DeathRecipient> deathRecipient_ { nullptr };
|
||||
std::map<int32_t, std::shared_ptr<AppExecFwk::EventHandler>> simHandlerMap_;
|
||||
std::map<int32_t, std::shared_ptr<AppExecFwk::EventHandler>> networkHandlerMap_;
|
||||
};
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
#endif // SATELLITE_SERVICE_CLIENT_H
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SATELLITE_SERVICE_INTERFACE_CODE_H
|
||||
#define SATELLITE_SERVICE_INTERFACE_CODE_H
|
||||
|
||||
/* SAID:4012 */
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
enum class SatelliteServiceInterfaceCode {
|
||||
IS_SATELLITE_ENABLED,
|
||||
SET_RADIO_STATE,
|
||||
REGISTER_CORE_NOTIFY,
|
||||
UNREGISTER_CORE_NOTIFY,
|
||||
GET_PROXY_OBJECT_PTR,
|
||||
GET_IMEI,
|
||||
GET_SATELLITE_CAPABILITY,
|
||||
};
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
#endif // SATELLITE_SERVICE_INTERFACE_CODE_H
|
44
interfaces/innerkits/satellite/satellite_service_proxy.h
Executable file
44
interfaces/innerkits/satellite/satellite_service_proxy.h
Executable file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SATELLITE_SERVICE_PROXY_H
|
||||
#define SATELLITE_SERVICE_PROXY_H
|
||||
|
||||
#include "i_satellite_service.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
class SatelliteServiceProxy : public IRemoteProxy<ISatelliteService> {
|
||||
public:
|
||||
explicit SatelliteServiceProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<ISatelliteService>(impl) {}
|
||||
virtual ~SatelliteServiceProxy() = default;
|
||||
|
||||
bool IsSatelliteEnabled() override;
|
||||
int32_t RegisterCoreNotify(int32_t slotId, int32_t what, const sptr<ISatelliteCoreCallback> &callback) override;
|
||||
int32_t UnRegisterCoreNotify(int32_t slotId, int32_t what) override;
|
||||
int32_t SetRadioState(int32_t slotId, int32_t isRadioOn, int32_t rst) override;
|
||||
int32_t GetImei(int32_t slotId) override;
|
||||
int32_t GetSatelliteCapability(int32_t slotId) override;
|
||||
sptr<IRemoteObject> GetProxyObjectPtr(SatelliteServiceProxyType proxyType) override;
|
||||
|
||||
private:
|
||||
bool WriteInterfaceToken(MessageParcel &data);
|
||||
|
||||
private:
|
||||
static inline BrokerDelegator<SatelliteServiceProxy> delegator_;
|
||||
};
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
#endif // SATELLITE_SERVICE_PROXY_H
|
@ -15,3 +15,4 @@ const.telephony.slotCount=1
|
||||
telephony.sim.opkey0=-1
|
||||
telephony.sim.opkey1=-1
|
||||
const.telephony.sms.expire.days=7
|
||||
const.telephony.satellite.supported=0
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "operator_name.h"
|
||||
#include "radio_event.h"
|
||||
#include "radio_info.h"
|
||||
#include "satellite_core_callback.h"
|
||||
#include "signal_info.h"
|
||||
#include "system_ability_status_change_stub.h"
|
||||
#include "tel_event_handler.h"
|
||||
@ -57,6 +58,8 @@ public:
|
||||
int32_t RevertLastTechnology();
|
||||
void UpdateImsServiceStatus(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
void UpdateImsRegisterState(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
void RegisterSatelliteCallback();
|
||||
void UnregisterSatelliteCallback();
|
||||
int32_t SendUpdateCellLocationRequest();
|
||||
PhoneType GetPhoneType();
|
||||
int32_t GetNrSsbId(const std::shared_ptr<NrSsbInformation> &nrCellSsbIdsInfo);
|
||||
@ -134,7 +137,9 @@ private:
|
||||
void GetNrOptionModeResponse(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
void RadioGetRrcConnectionState(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
void RadioResidentNetworkChange(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
void SatelliteStatusChanged(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
bool InitOperatorName();
|
||||
int32_t IsSatelliteSupported();
|
||||
void GetNrSsbIdResponse(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
void SyncGetSsbInfoResponse();
|
||||
bool SubModuleInit();
|
||||
@ -162,6 +167,7 @@ private:
|
||||
uint32_t cellRequestMinInterval_ = 2; // This is the minimum interval in seconds for cell requests
|
||||
uint32_t lastCellRequestTime_ = 0;
|
||||
sptr<ISystemAbilityStatusChange> statusChangeListener_ = nullptr;
|
||||
sptr<ISatelliteCoreCallback> satelliteCallback_ = nullptr;
|
||||
|
||||
private:
|
||||
class SystemAbilityStatusChangeListener : public OHOS::SystemAbilityStatusChangeStub {
|
||||
|
@ -182,6 +182,7 @@ public:
|
||||
int32_t GetMeid(int32_t slotId, std::u16string &meid) override;
|
||||
int32_t GetUniqueDeviceId(int32_t slotId, std::u16string &deviceId) override;
|
||||
bool IsNrSupported(int32_t slotId) override;
|
||||
bool IsSatelliteEnabled() override;
|
||||
FrequencyType GetFrequencyType(int32_t slotId) override;
|
||||
NrState GetNrState(int32_t slotId) override;
|
||||
void DcPhysicalLinkActiveUpdate(int32_t slotId, bool isActive) override;
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "ims_core_service_client.h"
|
||||
#include "mcc_pool.h"
|
||||
#include "network_search_manager.h"
|
||||
#include "satellite_service_client.h"
|
||||
#include "telephony_log_wrapper.h"
|
||||
#include "time_zone_manager.h"
|
||||
|
||||
@ -28,6 +29,7 @@ std::mutex NetworkSearchManager::ctx_;
|
||||
bool NetworkSearchManager::ssbResponseReady_ = false;
|
||||
std::condition_variable NetworkSearchManager::cv_;
|
||||
static const int32_t REQ_INTERVAL = 30;
|
||||
const int32_t SATELLITE_STATUS_ON = 1;
|
||||
const size_t MCC_LEN = 3;
|
||||
const std::map<uint32_t, NetworkSearchHandler::NsHandlerFunc> NetworkSearchHandler::memberFuncMap_ = {
|
||||
{ RadioEvent::RADIO_SIM_STATE_CHANGE, &NetworkSearchHandler::SimStateChange },
|
||||
@ -70,7 +72,8 @@ const std::map<uint32_t, NetworkSearchHandler::NsHandlerFunc> NetworkSearchHandl
|
||||
{ RadioEvent::RADIO_RESIDENT_NETWORK_CHANGE, &NetworkSearchHandler::RadioResidentNetworkChange },
|
||||
{ RadioEvent::RADIO_GET_NR_SSBID_INFO, &NetworkSearchHandler::GetNrSsbIdResponse },
|
||||
{ SettingEventCode::MSG_AUTO_TIME, &NetworkSearchHandler::AutoTimeChange },
|
||||
{ SettingEventCode::MSG_AUTO_AIRPLANE_MODE, &NetworkSearchHandler::AirplaneModeChange }
|
||||
{ SettingEventCode::MSG_AUTO_AIRPLANE_MODE, &NetworkSearchHandler::AirplaneModeChange },
|
||||
{ RadioEvent::SATELLITE_STATUS_CHANGED, &NetworkSearchHandler::SatelliteStatusChanged }
|
||||
};
|
||||
|
||||
NetworkSearchHandler::NetworkSearchHandler(const std::weak_ptr<NetworkSearchManager> &networkSearchManager,
|
||||
@ -210,6 +213,13 @@ void NetworkSearchHandler::RegisterEvents()
|
||||
slotId_, shared_from_this(), RadioEvent::RADIO_RESIDENT_NETWORK_CHANGE, nullptr);
|
||||
}
|
||||
}
|
||||
{
|
||||
if (IsSatelliteSupported() == static_cast<int32_t>(SatelliteValue::SATELLITE_SUPPORTED)) {
|
||||
std::shared_ptr<SatelliteServiceClient> satelliteClient =
|
||||
DelayedSingleton<SatelliteServiceClient>::GetInstance();
|
||||
satelliteClient->AddNetworkHandler(slotId_, shared_from_this());
|
||||
}
|
||||
}
|
||||
// Register IMS
|
||||
{
|
||||
std::shared_ptr<ImsCoreServiceClient> imsCoreServiceClient =
|
||||
@ -220,6 +230,25 @@ void NetworkSearchHandler::RegisterEvents()
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkSearchHandler::RegisterSatelliteCallback()
|
||||
{
|
||||
if (IsSatelliteSupported() == static_cast<int32_t>(SatelliteValue::SATELLITE_SUPPORTED)) {
|
||||
satelliteCallback_ = std::make_unique<SatelliteCoreCallback>(shared_from_this()).release();
|
||||
std::shared_ptr<SatelliteServiceClient> satelliteClient =
|
||||
DelayedSingleton<SatelliteServiceClient>::GetInstance();
|
||||
satelliteClient->RegisterCoreNotify(slotId_, RadioEvent::RADIO_SET_STATUS, satelliteCallback_);
|
||||
satelliteClient->RegisterCoreNotify(slotId_, RadioEvent::RADIO_STATE_CHANGED, satelliteCallback_);
|
||||
satelliteClient->RegisterCoreNotify(slotId_, RadioEvent::SATELLITE_STATUS_CHANGED, satelliteCallback_);
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkSearchHandler::UnregisterSatelliteCallback()
|
||||
{
|
||||
if (IsSatelliteSupported() == static_cast<int32_t>(SatelliteValue::SATELLITE_SUPPORTED)) {
|
||||
satelliteCallback_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkSearchHandler::UnregisterEvents()
|
||||
{
|
||||
{
|
||||
@ -246,6 +275,14 @@ void NetworkSearchHandler::UnregisterEvents()
|
||||
telRilManager->UnRegisterCoreNotify(slotId_, shared_from_this(), RadioEvent::RADIO_RESIDENT_NETWORK_CHANGE);
|
||||
}
|
||||
}
|
||||
if (IsSatelliteSupported() == static_cast<int32_t>(SatelliteValue::SATELLITE_SUPPORTED) &&
|
||||
satelliteCallback_ != nullptr) {
|
||||
std::shared_ptr<SatelliteServiceClient> satelliteClient =
|
||||
DelayedSingleton<SatelliteServiceClient>::GetInstance();
|
||||
satelliteClient->UnRegisterCoreNotify(slotId_, RadioEvent::RADIO_STATE_CHANGED);
|
||||
satelliteClient->UnRegisterCoreNotify(slotId_, RadioEvent::RADIO_SET_STATUS);
|
||||
satelliteClient->UnRegisterCoreNotify(slotId_, RadioEvent::SATELLITE_STATUS_CHANGED);
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkSearchHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
@ -1130,11 +1167,34 @@ void NetworkSearchHandler::RadioResidentNetworkChange(const AppExecFwk::InnerEve
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkSearchHandler::SatelliteStatusChanged(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
{
|
||||
if (event == nullptr) {
|
||||
TELEPHONY_LOGE("NetworkSearchHandler::RadioResidentNetworkChange event is nullptr!");
|
||||
return;
|
||||
}
|
||||
auto satelliteStatus = event->GetSharedObject<SatelliteStatus>();
|
||||
if (satelliteStatus->mode == SATELLITE_STATUS_ON) {
|
||||
std::shared_ptr<SatelliteServiceClient> satelliteClient =
|
||||
DelayedSingleton<SatelliteServiceClient>::GetInstance();
|
||||
satelliteClient->SetRadioState(
|
||||
satelliteStatus->slotId, static_cast<int32_t>(ModemPowerState::CORE_SERVICE_POWER_ON), 0);
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkSearchHandler::SetCellRequestMinInterval(uint32_t minInterval)
|
||||
{
|
||||
cellRequestMinInterval_ = minInterval;
|
||||
}
|
||||
|
||||
int32_t NetworkSearchHandler::IsSatelliteSupported()
|
||||
{
|
||||
char satelliteSupported[SYSPARA_SIZE] = { 0 };
|
||||
GetParameter(TEL_SATELLITE_SUPPORTED, SATELLITE_DEFAULT_VALUE, satelliteSupported, SYSPARA_SIZE);
|
||||
TELEPHONY_LOGI("satelliteSupported is %{public}s", satelliteSupported);
|
||||
return std::atoi(satelliteSupported);
|
||||
}
|
||||
|
||||
NetworkSearchHandler::SystemAbilityStatusChangeListener::SystemAbilityStatusChangeListener(
|
||||
std::shared_ptr<OperatorName> &operatorName) : opName_(operatorName)
|
||||
{}
|
||||
|
@ -15,16 +15,17 @@
|
||||
|
||||
#include "network_search_manager.h"
|
||||
|
||||
#include <parameters.h>
|
||||
#include <string_ex.h>
|
||||
#include <securec.h>
|
||||
#include <cinttypes>
|
||||
#include <parameters.h>
|
||||
#include <securec.h>
|
||||
#include <string_ex.h>
|
||||
|
||||
#include "core_service_errors.h"
|
||||
#include "enum_convert.h"
|
||||
#include "mcc_pool.h"
|
||||
#include "network_search_types.h"
|
||||
#include "parameter.h"
|
||||
#include "satellite_service_client.h"
|
||||
#include "telephony_common_utils.h"
|
||||
#include "telephony_config.h"
|
||||
#include "telephony_errors.h"
|
||||
@ -945,7 +946,14 @@ int32_t NetworkSearchManager::GetImei(int32_t slotId, std::u16string &imei)
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
if (inner->imei_.empty()) {
|
||||
eventSender_->SendBase(slotId, RadioEvent::RADIO_GET_IMEI);
|
||||
std::shared_ptr<SatelliteServiceClient> satelliteClient =
|
||||
DelayedSingleton<SatelliteServiceClient>::GetInstance();
|
||||
bool isSatelliteEnable = IsSatelliteEnabled();
|
||||
if (isSatelliteEnable) {
|
||||
satelliteClient->GetImei(slotId);
|
||||
} else {
|
||||
eventSender_->SendBase(slotId, RadioEvent::RADIO_GET_IMEI);
|
||||
}
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
imei = inner->imei_;
|
||||
@ -1118,6 +1126,16 @@ bool NetworkSearchManager::IsNrSupported(int32_t slotId)
|
||||
static_cast<uint32_t>(RadioProtocolTech::RADIO_PROTOCOL_TECH_NR);
|
||||
}
|
||||
|
||||
bool NetworkSearchManager::IsSatelliteEnabled()
|
||||
{
|
||||
std::shared_ptr<SatelliteServiceClient> satelliteClient = DelayedSingleton<SatelliteServiceClient>::GetInstance();
|
||||
if (satelliteClient == nullptr) {
|
||||
TELEPHONY_LOGE("satelliteClient is nullptr");
|
||||
return false;
|
||||
}
|
||||
return satelliteClient->IsSatelliteEnabled();
|
||||
}
|
||||
|
||||
int32_t NetworkSearchManager::HandleRrcStateChanged(int32_t slotId, int32_t status)
|
||||
{
|
||||
auto inner = FindManagerInner(slotId);
|
||||
|
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "satellite_core_callback.h"
|
||||
|
||||
#include "radio_event.h"
|
||||
#include "telephony_errors.h"
|
||||
#include "telephony_log_wrapper.h"
|
||||
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
SatelliteCoreCallback::SatelliteCoreCallback(const std::shared_ptr<AppExecFwk::EventHandler> &handler)
|
||||
: handler_(handler)
|
||||
{}
|
||||
|
||||
SatelliteCoreCallback::~SatelliteCoreCallback() {}
|
||||
|
||||
int32_t SatelliteCoreCallback::SetRadioStateResponse(InnerEvent::Pointer &event)
|
||||
{
|
||||
if (handler_ == nullptr) {
|
||||
TELEPHONY_LOGE("SetRadioStateResponse handler is null!");
|
||||
return TELEPHONY_ERROR;
|
||||
}
|
||||
handler_->SendEvent(event, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE);
|
||||
return TELEPHONY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t SatelliteCoreCallback::RadioStateChanged(InnerEvent::Pointer &event)
|
||||
{
|
||||
if (handler_ == nullptr) {
|
||||
TELEPHONY_LOGE("RadioStateChanged handler is null!");
|
||||
return TELEPHONY_ERROR;
|
||||
}
|
||||
handler_->SendEvent(event, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE);
|
||||
return TELEPHONY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t SatelliteCoreCallback::SatelliteStatusChanged(InnerEvent::Pointer &event)
|
||||
{
|
||||
if (handler_ == nullptr) {
|
||||
TELEPHONY_LOGE("SatelliteStatusChanged handler is null!");
|
||||
return TELEPHONY_ERROR;
|
||||
}
|
||||
handler_->SendEvent(event, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE);
|
||||
return TELEPHONY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t SatelliteCoreCallback::SimStateChanged(InnerEvent::Pointer &event)
|
||||
{
|
||||
if (handler_ == nullptr) {
|
||||
TELEPHONY_LOGE("SimStateChanged handler is null!");
|
||||
return TELEPHONY_ERROR;
|
||||
}
|
||||
handler_->SendEvent(event, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE);
|
||||
return TELEPHONY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t SatelliteCoreCallback::GetImeiResponse(InnerEvent::Pointer &event)
|
||||
{
|
||||
if (handler_ == nullptr) {
|
||||
TELEPHONY_LOGE("GetImeiResponse handler is null!");
|
||||
return TELEPHONY_ERROR;
|
||||
}
|
||||
handler_->SendEvent(event, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE);
|
||||
return TELEPHONY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t SatelliteCoreCallback::GetSatelliteCapabilityResponse(InnerEvent::Pointer &event)
|
||||
{
|
||||
if (handler_ == nullptr) {
|
||||
TELEPHONY_LOGE("GetSatelliteCapabilityResponse handler is null!");
|
||||
return TELEPHONY_ERROR;
|
||||
}
|
||||
handler_->SendEvent(event, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE);
|
||||
return TELEPHONY_SUCCESS;
|
||||
}
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
@ -0,0 +1,196 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "satellite_core_callback_stub.h"
|
||||
|
||||
#include "hril_base_parcel.h"
|
||||
#include "radio_event.h"
|
||||
#include "telephony_errors.h"
|
||||
#include "telephony_log_wrapper.h"
|
||||
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
SatelliteCoreCallbackStub::SatelliteCoreCallbackStub()
|
||||
{
|
||||
TELEPHONY_LOGD("SatelliteCoreCallbackStub");
|
||||
InitFuncMap();
|
||||
}
|
||||
|
||||
void SatelliteCoreCallbackStub::InitFuncMap()
|
||||
{
|
||||
requestFuncMap_[static_cast<uint32_t>(SatelliteCoreCallbackInterfaceCode::SET_RADIO_STATE_RESPONSE)] =
|
||||
&SatelliteCoreCallbackStub::OnSetRadioStateResponse;
|
||||
requestFuncMap_[static_cast<uint32_t>(SatelliteCoreCallbackInterfaceCode::GET_IMEI_RESPONSE)] =
|
||||
&SatelliteCoreCallbackStub::OnGetImeiResponse;
|
||||
requestFuncMap_[static_cast<uint32_t>(SatelliteCoreCallbackInterfaceCode::GET_SATELLITE_CAPABILITY_RESPONSE)] =
|
||||
&SatelliteCoreCallbackStub::OnGetSatelliteCapabilityResponse;
|
||||
requestFuncMap_[static_cast<uint32_t>(SatelliteCoreCallbackInterfaceCode::RADIO_STATE_CHANGED)] =
|
||||
&SatelliteCoreCallbackStub::OnRadioStateChanged;
|
||||
requestFuncMap_[static_cast<uint32_t>(SatelliteCoreCallbackInterfaceCode::SATELLITE_STATUS_CHANGED)] =
|
||||
&SatelliteCoreCallbackStub::OnSatelliteStatusChanged;
|
||||
requestFuncMap_[static_cast<uint32_t>(SatelliteCoreCallbackInterfaceCode::SIM_STATE_CHANGED)] =
|
||||
&SatelliteCoreCallbackStub::OnSimStateChanged;
|
||||
}
|
||||
|
||||
SatelliteCoreCallbackStub::~SatelliteCoreCallbackStub()
|
||||
{
|
||||
requestFuncMap_.clear();
|
||||
}
|
||||
|
||||
int32_t SatelliteCoreCallbackStub::OnRemoteRequest(
|
||||
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
std::u16string myDescriptor = SatelliteCoreCallbackStub::GetDescriptor();
|
||||
std::u16string remoteDescriptor = data.ReadInterfaceToken();
|
||||
if (myDescriptor != remoteDescriptor) {
|
||||
TELEPHONY_LOGE("Descriptor check failed, return");
|
||||
return TELEPHONY_ERR_DESCRIPTOR_MISMATCH;
|
||||
}
|
||||
auto itFunc = requestFuncMap_.find(code);
|
||||
if (itFunc != requestFuncMap_.end()) {
|
||||
auto requestFunc = itFunc->second;
|
||||
if (requestFunc != nullptr) {
|
||||
return (this->*requestFunc)(data, reply);
|
||||
}
|
||||
}
|
||||
TELEPHONY_LOGD("Do not found the requestFunc of code=%{public}d, need to check", code);
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
|
||||
int32_t SatelliteCoreCallbackStub::OnSetRadioStateResponse(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
int32_t eventCode = data.ReadInt32();
|
||||
int32_t dataType = data.ReadInt32();
|
||||
if (dataType == SatelliteRadioResponseType::DEFAULT_RADIO_RESPONSE) {
|
||||
int32_t flag = data.ReadInt32();
|
||||
int32_t serial = data.ReadInt32();
|
||||
int32_t error = data.ReadInt32();
|
||||
int32_t type = data.ReadInt32();
|
||||
auto info = std::make_shared<HRilRadioResponseInfo>();
|
||||
info->flag = flag;
|
||||
info->serial = serial;
|
||||
info->error = static_cast<HRilErrType>(error);
|
||||
info->type = static_cast<HRilResponseTypes>(type);
|
||||
AppExecFwk::InnerEvent::Pointer response = AppExecFwk::InnerEvent::Get(eventCode, info);
|
||||
if (response == nullptr) {
|
||||
TELEPHONY_LOGE("hril response is null!");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
reply.WriteInt32(SetRadioStateResponse(response));
|
||||
return TELEPHONY_SUCCESS;
|
||||
}
|
||||
|
||||
if (dataType == SatelliteRadioResponseType::RADIO_STATE_INFO) {
|
||||
int64_t flag = data.ReadInt64();
|
||||
int32_t state = data.ReadInt32();
|
||||
auto info = std::make_unique<HRilRadioStateInfo>();
|
||||
info->flag = flag;
|
||||
info->state = state;
|
||||
AppExecFwk::InnerEvent::Pointer response = AppExecFwk::InnerEvent::Get(eventCode, info);
|
||||
if (response == nullptr) {
|
||||
TELEPHONY_LOGE("radio info response is null!");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
reply.WriteInt32(SetRadioStateResponse(response));
|
||||
return TELEPHONY_SUCCESS;
|
||||
}
|
||||
|
||||
TELEPHONY_LOGE("SatelliteCoreCallbackStub: radio response is null!");
|
||||
return TELEPHONY_ERR_READ_DATA_FAIL;
|
||||
}
|
||||
|
||||
int32_t SatelliteCoreCallbackStub::OnGetImeiResponse(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
int32_t eventCode = data.ReadInt32();
|
||||
auto info = std::make_shared<HRilStringParcel>();
|
||||
if (!data.ReadString(info->data)) {
|
||||
TELEPHONY_LOGE("HRilStringParcel is null!");
|
||||
return TELEPHONY_ERR_READ_DATA_FAIL;
|
||||
}
|
||||
AppExecFwk::InnerEvent::Pointer response = AppExecFwk::InnerEvent::Get(eventCode, info);
|
||||
if (response == nullptr) {
|
||||
TELEPHONY_LOGE("response is null!");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
reply.WriteInt32(GetImeiResponse(response));
|
||||
return TELEPHONY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t SatelliteCoreCallbackStub::OnGetSatelliteCapabilityResponse(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
int32_t eventCode = data.ReadInt32();
|
||||
auto info = std::make_shared<HRilStringParcel>();
|
||||
if (!data.ReadString(info->data)) {
|
||||
TELEPHONY_LOGE("HRilStringParcel is null!");
|
||||
return TELEPHONY_ERR_READ_DATA_FAIL;
|
||||
}
|
||||
AppExecFwk::InnerEvent::Pointer response = AppExecFwk::InnerEvent::Get(eventCode, info);
|
||||
if (response == nullptr) {
|
||||
TELEPHONY_LOGE("response is null!");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
reply.WriteInt32(GetSatelliteCapabilityResponse(response));
|
||||
return TELEPHONY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t SatelliteCoreCallbackStub::OnRadioStateChanged(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
int32_t eventCode = data.ReadInt32();
|
||||
|
||||
auto info = std::make_shared<HRilInt32Parcel>();
|
||||
if (!data.ReadInt32(info->data)) {
|
||||
TELEPHONY_LOGE("HRilInt32Parcel is null!");
|
||||
return TELEPHONY_ERR_READ_DATA_FAIL;
|
||||
}
|
||||
|
||||
AppExecFwk::InnerEvent::Pointer response = AppExecFwk::InnerEvent::Get(eventCode, info);
|
||||
if (response == nullptr) {
|
||||
TELEPHONY_LOGE("response is null!");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
reply.WriteInt32(RadioStateChanged(response));
|
||||
return TELEPHONY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t SatelliteCoreCallbackStub::OnSatelliteStatusChanged(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
int32_t eventCode = data.ReadInt32();
|
||||
std::shared_ptr<SatelliteStatus> satelliteStatus = std::make_shared<SatelliteStatus>();
|
||||
satelliteStatus->slotId = data.ReadInt32();
|
||||
satelliteStatus->mode = data.ReadInt32();
|
||||
AppExecFwk::InnerEvent::Pointer response = AppExecFwk::InnerEvent::Get(eventCode, satelliteStatus);
|
||||
if (response == nullptr) {
|
||||
TELEPHONY_LOGE("response is null!");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
reply.WriteInt32(SatelliteStatusChanged(response));
|
||||
return TELEPHONY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t SatelliteCoreCallbackStub::OnSimStateChanged(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
int32_t eventCode = data.ReadInt32();
|
||||
|
||||
AppExecFwk::InnerEvent::Pointer response = AppExecFwk::InnerEvent::Get(eventCode);
|
||||
if (response == nullptr) {
|
||||
TELEPHONY_LOGE("response is null!");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
reply.WriteInt32(SimStateChanged(response));
|
||||
return TELEPHONY_SUCCESS;
|
||||
}
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
258
services/satellite_service_interaction/src/satellite_service_client.cpp
Executable file
258
services/satellite_service_interaction/src/satellite_service_client.cpp
Executable file
@ -0,0 +1,258 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "satellite_service_client.h"
|
||||
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "satellite_service_proxy.h"
|
||||
#include "telephony_errors.h"
|
||||
#include "telephony_log_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
SatelliteServiceClient::SatelliteServiceClient()
|
||||
{
|
||||
statusChangeListener_ = new (std::nothrow) SystemAbilityListener();
|
||||
if (statusChangeListener_ == nullptr) {
|
||||
TELEPHONY_LOGE("Init, failed to create statusChangeListener.");
|
||||
return;
|
||||
}
|
||||
auto managerPtr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (managerPtr == nullptr) {
|
||||
TELEPHONY_LOGE("Init, get system ability manager error.");
|
||||
return;
|
||||
}
|
||||
int32_t ret = managerPtr->SubscribeSystemAbility(TELEPHONY_SATELLITE_SERVICE_ABILITY_ID, statusChangeListener_);
|
||||
if (ret) {
|
||||
TELEPHONY_LOGE("Init, failed to subscribe sa:%{public}d", TELEPHONY_SATELLITE_SERVICE_ABILITY_ID);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SatelliteServiceClient::~SatelliteServiceClient()
|
||||
{
|
||||
RemoveDeathRecipient(nullptr, false);
|
||||
}
|
||||
|
||||
sptr<ISatelliteService> SatelliteServiceClient::GetProxy()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutexProxy_);
|
||||
if (proxy_ != nullptr) {
|
||||
return proxy_;
|
||||
}
|
||||
|
||||
sptr<ISystemAbilityManager> sam = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (sam == nullptr) {
|
||||
TELEPHONY_LOGE("Failed to get system ability manager");
|
||||
return nullptr;
|
||||
}
|
||||
sptr<IRemoteObject> obj = sam->CheckSystemAbility(TELEPHONY_SATELLITE_SERVICE_ABILITY_ID);
|
||||
if (obj == nullptr) {
|
||||
TELEPHONY_LOGE("Failed to get satellite service");
|
||||
return nullptr;
|
||||
}
|
||||
std::unique_ptr<SatelliteServiceDeathRecipient> recipient = std::make_unique<SatelliteServiceDeathRecipient>(*this);
|
||||
if (recipient == nullptr) {
|
||||
TELEPHONY_LOGE("recipient is null");
|
||||
return nullptr;
|
||||
}
|
||||
sptr<IRemoteObject::DeathRecipient> dr(recipient.release());
|
||||
if ((obj->IsProxyObject()) && (!obj->AddDeathRecipient(dr))) {
|
||||
TELEPHONY_LOGE("Failed to add death recipient");
|
||||
return nullptr;
|
||||
}
|
||||
proxy_ = iface_cast<ISatelliteService>(obj);
|
||||
deathRecipient_ = dr;
|
||||
TELEPHONY_LOGD("Succeed to connect satellite service %{public}d", proxy_ == nullptr);
|
||||
return proxy_;
|
||||
}
|
||||
|
||||
void SatelliteServiceClient::OnRemoteDied(const wptr<IRemoteObject> &remote)
|
||||
{
|
||||
RemoveDeathRecipient(remote, true);
|
||||
}
|
||||
|
||||
void SatelliteServiceClient::RemoveDeathRecipient(const wptr<IRemoteObject> &remote, bool isRemoteDied)
|
||||
{
|
||||
if (isRemoteDied && remote == nullptr) {
|
||||
TELEPHONY_LOGE("Remote died, remote is nullptr");
|
||||
return;
|
||||
}
|
||||
std::lock_guard<std::mutex> lock(mutexProxy_);
|
||||
if (proxy_ == nullptr) {
|
||||
TELEPHONY_LOGE("proxy_ is nullptr");
|
||||
return;
|
||||
}
|
||||
auto serviceRemote = proxy_->AsObject();
|
||||
if (serviceRemote == nullptr) {
|
||||
TELEPHONY_LOGE("serviceRemote is nullptr");
|
||||
return;
|
||||
}
|
||||
if (isRemoteDied && serviceRemote != remote.promote()) {
|
||||
TELEPHONY_LOGE("Remote died serviceRemote is not same");
|
||||
return;
|
||||
}
|
||||
serviceRemote->RemoveDeathRecipient(deathRecipient_);
|
||||
proxy_ = nullptr;
|
||||
TELEPHONY_LOGI("RemoveDeathRecipient success");
|
||||
}
|
||||
|
||||
void SatelliteServiceClient::SystemAbilityListener::OnAddSystemAbility(
|
||||
int32_t systemAbilityId, const std::string &deviceId)
|
||||
{
|
||||
TELEPHONY_LOGI("SA:%{public}d is added!", systemAbilityId);
|
||||
if (!CheckInputSysAbilityId(systemAbilityId)) {
|
||||
TELEPHONY_LOGE("add SA:%{public}d is invalid!", systemAbilityId);
|
||||
return;
|
||||
}
|
||||
|
||||
std::shared_ptr<SatelliteServiceClient> satelliteClient = DelayedSingleton<SatelliteServiceClient>::GetInstance();
|
||||
satelliteClient->ServiceOn();
|
||||
TELEPHONY_LOGI("SA:%{public}d reconnect service successfully!", systemAbilityId);
|
||||
}
|
||||
|
||||
void SatelliteServiceClient::SystemAbilityListener::OnRemoveSystemAbility(
|
||||
int32_t systemAbilityId, const std::string &deviceId)
|
||||
{
|
||||
TELEPHONY_LOGI("SA:%{public}d is removed!", systemAbilityId);
|
||||
std::shared_ptr<SatelliteServiceClient> satelliteClient = DelayedSingleton<SatelliteServiceClient>::GetInstance();
|
||||
satelliteClient->ServiceOff();
|
||||
}
|
||||
|
||||
int32_t SatelliteServiceClient::AddSimHandler(int32_t slotId, const std::shared_ptr<AppExecFwk::EventHandler> &handler)
|
||||
{
|
||||
if (handler == nullptr) {
|
||||
TELEPHONY_LOGE("AddSimHandler return, handler is null.");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
|
||||
simHandlerMap_.insert(std::make_pair(slotId, handler));
|
||||
TELEPHONY_LOGI("AddSimHandler success: %{public}d", slotId);
|
||||
return TELEPHONY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t SatelliteServiceClient::AddNetworkHandler(
|
||||
int32_t slotId, const std::shared_ptr<AppExecFwk::EventHandler> &handler)
|
||||
{
|
||||
if (handler == nullptr) {
|
||||
TELEPHONY_LOGE("AddNetworkHandler return, handler is null.");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
|
||||
networkHandlerMap_.insert(std::make_pair(slotId, handler));
|
||||
TELEPHONY_LOGI("AddNetworkHandler success: %{public}d", slotId);
|
||||
return TELEPHONY_SUCCESS;
|
||||
}
|
||||
|
||||
void SatelliteServiceClient::ServiceOn()
|
||||
{
|
||||
for (auto pair : simHandlerMap_) {
|
||||
auto handler = static_cast<SimStateHandle *>(pair.second.get());
|
||||
handler->RegisterSatelliteCallback();
|
||||
}
|
||||
for (auto pair : networkHandlerMap_) {
|
||||
auto handler = static_cast<NetworkSearchHandler *>(pair.second.get());
|
||||
handler->RegisterSatelliteCallback();
|
||||
}
|
||||
}
|
||||
|
||||
void SatelliteServiceClient::ServiceOff()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutexProxy_);
|
||||
proxy_ = nullptr;
|
||||
|
||||
for (auto pair : simHandlerMap_) {
|
||||
auto handler = static_cast<SimStateHandle *>(pair.second.get());
|
||||
handler->UnregisterSatelliteCallback();
|
||||
}
|
||||
for (auto pair : networkHandlerMap_) {
|
||||
auto handler = static_cast<NetworkSearchHandler *>(pair.second.get());
|
||||
handler->UnregisterSatelliteCallback();
|
||||
}
|
||||
}
|
||||
|
||||
int32_t SatelliteServiceClient::RegisterCoreNotify(
|
||||
int32_t slotId, int32_t what, const sptr<ISatelliteCoreCallback> &callback)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->RegisterCoreNotify(slotId, what, callback);
|
||||
}
|
||||
|
||||
int32_t SatelliteServiceClient::UnRegisterCoreNotify(int32_t slotId, int32_t what)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->UnRegisterCoreNotify(slotId, what);
|
||||
}
|
||||
|
||||
bool SatelliteServiceClient::IsSatelliteEnabled()
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return false;
|
||||
}
|
||||
return proxy->IsSatelliteEnabled();
|
||||
}
|
||||
|
||||
int32_t SatelliteServiceClient::GetSatelliteCapability(int32_t slotId)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return 0;
|
||||
}
|
||||
return proxy->GetSatelliteCapability(slotId);
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> SatelliteServiceClient::GetProxyObjectPtr(SatelliteServiceProxyType type)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return nullptr;
|
||||
}
|
||||
return proxy->GetProxyObjectPtr(type);
|
||||
}
|
||||
|
||||
int32_t SatelliteServiceClient::SetRadioState(int32_t slotId, int32_t isRadioOn, int32_t rst)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->SetRadioState(slotId, isRadioOn, rst);
|
||||
}
|
||||
|
||||
int32_t SatelliteServiceClient::GetImei(int32_t slotId)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
}
|
||||
return proxy->GetImei(slotId);
|
||||
}
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
267
services/satellite_service_interaction/src/satellite_service_proxy.cpp
Executable file
267
services/satellite_service_interaction/src/satellite_service_proxy.cpp
Executable file
@ -0,0 +1,267 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "satellite_service_proxy.h"
|
||||
|
||||
#include "satellite_service_ipc_interface_code.h"
|
||||
#include "telephony_errors.h"
|
||||
#include "telephony_log_wrapper.h"
|
||||
#include "telephony_types.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
bool SatelliteServiceProxy::WriteInterfaceToken(MessageParcel &data)
|
||||
{
|
||||
if (!data.WriteInterfaceToken(SatelliteServiceProxy::GetDescriptor())) {
|
||||
TELEPHONY_LOGE("write interface token failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SatelliteServiceProxy::IsSatelliteEnabled()
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
bool result = false;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
TELEPHONY_LOGE("IsSatelliteEnabled WriteInterfaceToken is false");
|
||||
return result;
|
||||
}
|
||||
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
TELEPHONY_LOGE("IsSatelliteEnabled Remote is null");
|
||||
return result;
|
||||
}
|
||||
int32_t ret =
|
||||
remote->SendRequest(uint32_t(SatelliteServiceInterfaceCode::IS_SATELLITE_ENABLED), data, reply, option);
|
||||
if (ret != ERR_NONE) {
|
||||
TELEPHONY_LOGE("IsSatelliteEnabled failed, error code is %{public}d ", ret);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!reply.ReadBool(result)) {
|
||||
TELEPHONY_LOGE("IsSatelliteEnabled ReadBool failed");
|
||||
}
|
||||
TELEPHONY_LOGD("Satellite IsSatelliteEnabled %{public}d", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t SatelliteServiceProxy::GetSatelliteCapability(int32_t slotId)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int32_t result = 0;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
TELEPHONY_LOGE("GetSatelliteCapability WriteInterfaceToken is false");
|
||||
return result;
|
||||
}
|
||||
if (!data.WriteInt32(slotId)) {
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
TELEPHONY_LOGE("GetSatelliteCapability Remote is null");
|
||||
return result;
|
||||
}
|
||||
int32_t ret =
|
||||
remote->SendRequest(uint32_t(SatelliteServiceInterfaceCode::GET_SATELLITE_CAPABILITY), data, reply, option);
|
||||
if (ret != ERR_NONE) {
|
||||
TELEPHONY_LOGE("GetSatelliteCapability failed, error code is %{public}d ", ret);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!reply.ReadInt32(result)) {
|
||||
TELEPHONY_LOGE("GetSatelliteCapability ReadInt32 failed");
|
||||
}
|
||||
TELEPHONY_LOGD("Satellite GetSatelliteCapability %{public}d", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t SatelliteServiceProxy::RegisterCoreNotify(
|
||||
int32_t slotId, int32_t what, const sptr<ISatelliteCoreCallback> &callback)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int32_t ret = TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
TELEPHONY_LOGE("RegisterCoreNotify WriteInterfaceToken is false");
|
||||
return ret;
|
||||
}
|
||||
if (!data.WriteInt32(slotId)) {
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
if (!data.WriteInt32(what)) {
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
if (!data.WriteRemoteObject(callback->AsObject().GetRefPtr())) {
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
TELEPHONY_LOGE("RegisterCoreNotify Remote is null");
|
||||
return ret;
|
||||
}
|
||||
|
||||
TELEPHONY_LOGD("Satellite RegisterCoreNotify slotId: %{public}d, what: %{public}d", slotId, what);
|
||||
ret = remote->SendRequest(uint32_t(SatelliteServiceInterfaceCode::REGISTER_CORE_NOTIFY), data, reply, option);
|
||||
if (ret != ERR_NONE) {
|
||||
TELEPHONY_LOGE("RegisterCoreNotify failed, error code is %{public}d ", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!reply.ReadInt32(ret)) {
|
||||
TELEPHONY_LOGE("RegisterCoreNotify read reply failed");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t SatelliteServiceProxy::UnRegisterCoreNotify(int32_t slotId, int32_t what)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int32_t ret = TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
TELEPHONY_LOGE("UnRegisterCoreNotify WriteInterfaceToken is false");
|
||||
return ret;
|
||||
}
|
||||
if (!data.WriteInt32(slotId)) {
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
if (!data.WriteInt32(what)) {
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
TELEPHONY_LOGE("UnRegisterCoreNotify Remote is null");
|
||||
return ret;
|
||||
}
|
||||
|
||||
TELEPHONY_LOGD("Satellite UnRegisterCoreNotify slotId: %{public}d, what: %{public}d", slotId, what);
|
||||
ret = remote->SendRequest(uint32_t(SatelliteServiceInterfaceCode::UNREGISTER_CORE_NOTIFY), data, reply, option);
|
||||
if (ret != ERR_NONE) {
|
||||
TELEPHONY_LOGE("UnRegisterCoreNotify failed, error code is %{public}d ", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!reply.ReadInt32(ret)) {
|
||||
TELEPHONY_LOGE("UnRegisterCoreNotify read reply failed");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t SatelliteServiceProxy::SetRadioState(int32_t slotId, int32_t isRadioOn, int32_t rst)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int32_t ret = TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
TELEPHONY_LOGE("SetRadioState WriteInterfaceToken is false");
|
||||
return ret;
|
||||
}
|
||||
if (!data.WriteInt32(slotId)) {
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
if (!data.WriteInt32(isRadioOn)) {
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
if (!data.WriteInt32(rst)) {
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
TELEPHONY_LOGE("SetRadioState Remote is null");
|
||||
return ret;
|
||||
}
|
||||
|
||||
TELEPHONY_LOGD("Satellite SetRadioState slotId: %{public}d", slotId);
|
||||
ret = remote->SendRequest(uint32_t(SatelliteServiceInterfaceCode::SET_RADIO_STATE), data, reply, option);
|
||||
if (ret != ERR_NONE) {
|
||||
TELEPHONY_LOGE("SetRadioState failed, error code is %{public}d ", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!reply.ReadInt32(ret)) {
|
||||
TELEPHONY_LOGE("SetRadioState read reply failed");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t SatelliteServiceProxy::GetImei(int32_t slotId)
|
||||
{
|
||||
MessageParcel data;
|
||||
int32_t ret = TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
TELEPHONY_LOGE("GetImei WriteInterfaceToken is false");
|
||||
return ret;
|
||||
}
|
||||
if (!data.WriteInt32(slotId)) {
|
||||
return TELEPHONY_ERR_WRITE_DATA_FAIL;
|
||||
}
|
||||
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
TELEPHONY_LOGE("GetImei Remote is null");
|
||||
return ret;
|
||||
}
|
||||
TELEPHONY_LOGD("Satellite GetImei slotId: %{public}d", slotId);
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
ret = remote->SendRequest(uint32_t(SatelliteServiceInterfaceCode::GET_IMEI), data, reply, option);
|
||||
if (ret != ERR_NONE) {
|
||||
TELEPHONY_LOGE("GetImei failed, error code is %{public}d ", ret);
|
||||
return ret;
|
||||
}
|
||||
if (!reply.ReadInt32(ret)) {
|
||||
TELEPHONY_LOGE("GetImei read reply failed");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> SatelliteServiceProxy::GetProxyObjectPtr(SatelliteServiceProxyType proxyType)
|
||||
{
|
||||
MessageParcel dataParcel;
|
||||
if (!dataParcel.WriteInterfaceToken(SatelliteServiceProxy::GetDescriptor())) {
|
||||
TELEPHONY_LOGE("write descriptor fail");
|
||||
return nullptr;
|
||||
}
|
||||
dataParcel.WriteInt32(static_cast<int32_t>(proxyType));
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
TELEPHONY_LOGE("function Remote() return nullptr!");
|
||||
return nullptr;
|
||||
}
|
||||
MessageParcel replyParcel;
|
||||
MessageOption option;
|
||||
int32_t error = remote->SendRequest(
|
||||
static_cast<int32_t>(SatelliteServiceInterfaceCode::GET_PROXY_OBJECT_PTR), dataParcel, replyParcel, option);
|
||||
if (error != TELEPHONY_SUCCESS) {
|
||||
TELEPHONY_LOGE("function GetProxyObjectPtr failed! errCode:%{public}d", error);
|
||||
return nullptr;
|
||||
}
|
||||
return replyParcel.ReadRemoteObject();
|
||||
}
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
@ -28,6 +28,7 @@
|
||||
#include "i_tel_ril_manager.h"
|
||||
#include "icc_state.h"
|
||||
#include "observer_handler.h"
|
||||
#include "satellite_core_callback.h"
|
||||
#include "sim_state_type.h"
|
||||
#include "tel_event_handler.h"
|
||||
#include "telephony_errors.h"
|
||||
@ -127,6 +128,8 @@ public:
|
||||
bool IsIccReady();
|
||||
void RegisterCoreNotify(const std::shared_ptr<AppExecFwk::EventHandler> &handler, int what);
|
||||
void UnRegisterCoreNotify(const std::shared_ptr<AppExecFwk::EventHandler> &observerCallBack, int what);
|
||||
void RegisterSatelliteCallback();
|
||||
void UnregisterSatelliteCallback();
|
||||
int32_t SimAuthentication(int32_t slotId, AuthType authType, const std::string &authData);
|
||||
SimAuthenticationResponse GetSimAuthenticationResponse();
|
||||
void SendSimMatchedOperatorInfo(
|
||||
@ -153,6 +156,7 @@ private:
|
||||
void GetSendSimMatchedOperatorInfoResult(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &event);
|
||||
std::string GetAidByCardType(CardType type);
|
||||
void OnRadioStateUnavailable(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
int32_t IsSatelliteSupported();
|
||||
|
||||
private:
|
||||
static const std::map<uint32_t, Func> memberFuncMap_;
|
||||
@ -169,6 +173,7 @@ private:
|
||||
std::weak_ptr<SimStateManager> simStateManager_;
|
||||
std::weak_ptr<Telephony::ITelRilManager> telRilManager_; // ril manager
|
||||
std::unique_ptr<ObserverHandler> observerHandler_ = nullptr;
|
||||
sptr<ISatelliteCoreCallback> satelliteCallback_ = nullptr;
|
||||
};
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "inner_event.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "radio_event.h"
|
||||
#include "satellite_service_client.h"
|
||||
#include "sim_constant.h"
|
||||
#include "sim_state_manager.h"
|
||||
#include "system_ability_definition.h"
|
||||
@ -65,6 +66,11 @@ void SimStateHandle::Init(int32_t slotId)
|
||||
slotId_ = slotId;
|
||||
TELEPHONY_LOGI("SimStateHandle::HasSimCard(), slotId_ = %{public}d", slotId_);
|
||||
ConnectService();
|
||||
if (IsSatelliteSupported() == static_cast<int32_t>(SatelliteValue::SATELLITE_SUPPORTED)) {
|
||||
std::shared_ptr<SatelliteServiceClient> satelliteClient =
|
||||
DelayedSingleton<SatelliteServiceClient>::GetInstance();
|
||||
satelliteClient->AddSimHandler(slotId_, shared_from_this());
|
||||
}
|
||||
auto telRilManager = telRilManager_.lock();
|
||||
if (telRilManager != nullptr) {
|
||||
TELEPHONY_LOGI("SimStateHandle::SimStateHandle RegisterEvent start");
|
||||
@ -84,6 +90,14 @@ void SimStateHandle::Init(int32_t slotId)
|
||||
externalType_ = CardType::UNKNOWN_CARD;
|
||||
}
|
||||
|
||||
int32_t SimStateHandle::IsSatelliteSupported()
|
||||
{
|
||||
char satelliteSupported[SYSPARA_SIZE] = { 0 };
|
||||
GetParameter(TEL_SATELLITE_SUPPORTED, SATELLITE_DEFAULT_VALUE, satelliteSupported, SYSPARA_SIZE);
|
||||
TELEPHONY_LOGI("satelliteSupported is %{public}s", satelliteSupported);
|
||||
return std::atoi(satelliteSupported);
|
||||
}
|
||||
|
||||
bool SimStateHandle::HasSimCard()
|
||||
{
|
||||
bool has = false;
|
||||
@ -326,6 +340,26 @@ void SimStateHandle::UnInit()
|
||||
telRilManager->UnRegisterCoreNotify(slotId_, shared_from_this(), RadioEvent::RADIO_SIM_STATE_CHANGE);
|
||||
telRilManager->UnRegisterCoreNotify(slotId_, shared_from_this(), RadioEvent::RADIO_STATE_CHANGED);
|
||||
}
|
||||
if (IsSatelliteSupported() == static_cast<int32_t>(SatelliteValue::SATELLITE_SUPPORTED) &&
|
||||
satelliteCallback_ != nullptr) {
|
||||
std::shared_ptr<SatelliteServiceClient> satelliteClient =
|
||||
DelayedSingleton<SatelliteServiceClient>::GetInstance();
|
||||
satelliteClient->UnRegisterCoreNotify(slotId_, RadioEvent::RADIO_SIM_STATE_CHANGE);
|
||||
}
|
||||
}
|
||||
|
||||
void SimStateHandle::RegisterSatelliteCallback()
|
||||
{
|
||||
satelliteCallback_ = std::make_unique<SatelliteCoreCallback>(shared_from_this()).release();
|
||||
std::shared_ptr<SatelliteServiceClient> satelliteClient = DelayedSingleton<SatelliteServiceClient>::GetInstance();
|
||||
satelliteClient->RegisterCoreNotify(slotId_, RadioEvent::RADIO_SIM_STATE_CHANGE, satelliteCallback_);
|
||||
}
|
||||
|
||||
void SimStateHandle::UnregisterSatelliteCallback()
|
||||
{
|
||||
if (IsSatelliteSupported() == static_cast<int32_t>(SatelliteValue::SATELLITE_SUPPORTED)) {
|
||||
satelliteCallback_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void SimStateHandle::ObtainIccStatus(int32_t slotId)
|
||||
|
Loading…
Reference in New Issue
Block a user