mirror of
https://github.com/openharmony/update_updateservice.git
synced 2026-06-30 21:07:54 -04:00
+17
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
# any change to interfaces/inner_api/include/updater_sa_ipc_interface_code.h need to be reviewed by @leonchan5
|
||||
interfaces/inner_api/include/updater_sa_ipc_interface_code.h @leonchan5
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "update_helper.h"
|
||||
#include "update_service_kits.h"
|
||||
#include "update_session.h"
|
||||
#include "updater_sa_ipc_interface_code.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -127,7 +128,8 @@ napi_value UpdateClient::CancelUpgrade(napi_env env, napi_callback_info info)
|
||||
args,
|
||||
[=](SessionType type, void *context) -> int {
|
||||
BusinessError *businessError = reinterpret_cast<BusinessError *>(context);
|
||||
return UpdateServiceKits::GetInstance().Cancel(upgradeInfo_, IUpdateService::DOWNLOAD, *businessError);
|
||||
return UpdateServiceKits::GetInstance().Cancel(upgradeInfo_,
|
||||
CAST_INT(UpdaterSaInterfaceCode::DOWNLOAD), *businessError);
|
||||
},
|
||||
nullptr);
|
||||
PARAM_CHECK(retValue != nullptr, sessionsMgr_->RemoveSession(sess->GetSessionId());
|
||||
|
||||
@@ -66,7 +66,7 @@ int32_t UpdateServiceProxy::RegisterUpdateCallback(const UpgradeInfo &info,
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int32_t ret = remote->SendRequest(REGISTER_CALLBACK, data, reply, option);
|
||||
int32_t ret = remote->SendRequest(CAST_INT(UpdaterSaInterfaceCode::REGISTER_CALLBACK), data, reply, option);
|
||||
RETURN_FAIL_WHEN_REMOTE_ERR("UpdateServiceProxy::RegisterUpdateCallback", ret);
|
||||
return INT_CALL_SUCCESS;
|
||||
}
|
||||
@@ -82,7 +82,7 @@ int32_t UpdateServiceProxy::UnregisterUpdateCallback(const UpgradeInfo &info)
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int32_t ret = remote->SendRequest(UNREGISTER_CALLBACK, data, reply, option);
|
||||
int32_t ret = remote->SendRequest(CAST_INT(UpdaterSaInterfaceCode::UNREGISTER_CALLBACK), data, reply, option);
|
||||
RETURN_FAIL_WHEN_REMOTE_ERR("UpdateServiceProxy::UnregisterUpdateCallback", ret);
|
||||
return INT_CALL_SUCCESS;
|
||||
}
|
||||
@@ -99,7 +99,7 @@ int32_t UpdateServiceProxy::CheckNewVersion(const UpgradeInfo &info)
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int32_t ret = remote->SendRequest(CHECK_VERSION, data, reply, option);
|
||||
int32_t ret = remote->SendRequest(CAST_INT(UpdaterSaInterfaceCode::CHECK_VERSION), data, reply, option);
|
||||
RETURN_FAIL_WHEN_REMOTE_ERR("UpdateServiceProxy::CheckNewVersion", ret);
|
||||
return INT_CALL_SUCCESS;
|
||||
}
|
||||
@@ -119,7 +119,7 @@ int32_t UpdateServiceProxy::Download(const UpgradeInfo &info, const VersionDiges
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int32_t ret = remote->SendRequest(DOWNLOAD, data, reply, option);
|
||||
int32_t ret = remote->SendRequest(CAST_INT(UpdaterSaInterfaceCode::DOWNLOAD), data, reply, option);
|
||||
RETURN_FAIL_WHEN_REMOTE_ERR("UpdateServiceProxy::Download", ret);
|
||||
BusinessError remoteBusinessError;
|
||||
MessageParcelHelper::ReadBusinessError(reply, remoteBusinessError);
|
||||
@@ -142,7 +142,7 @@ int32_t UpdateServiceProxy::PauseDownload(const UpgradeInfo &info, const Version
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int32_t ret = remote->SendRequest(PAUSE_DOWNLOAD, data, reply, option);
|
||||
int32_t ret = remote->SendRequest(CAST_INT(UpdaterSaInterfaceCode::PAUSE_DOWNLOAD), data, reply, option);
|
||||
RETURN_FAIL_WHEN_REMOTE_ERR("UpdateServiceProxy::ResumeDownload", ret);
|
||||
BusinessError remoteBusinessError;
|
||||
MessageParcelHelper::ReadBusinessError(reply, remoteBusinessError);
|
||||
@@ -165,7 +165,7 @@ int32_t UpdateServiceProxy::ResumeDownload(const UpgradeInfo &info, const Versio
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int32_t ret = remote->SendRequest(RESUME_DOWNLOAD, data, reply, option);
|
||||
int32_t ret = remote->SendRequest(CAST_INT(UpdaterSaInterfaceCode::RESUME_DOWNLOAD), data, reply, option);
|
||||
RETURN_FAIL_WHEN_REMOTE_ERR("UpdateServiceProxy::ResumeDownload", ret);
|
||||
BusinessError remoteBusinessError;
|
||||
MessageParcelHelper::ReadBusinessError(reply, remoteBusinessError);
|
||||
@@ -190,7 +190,7 @@ int32_t UpdateServiceProxy::Upgrade(const UpgradeInfo &info, const VersionDigest
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int32_t ret = remote->SendRequest(UPGRADE, data, reply, option);
|
||||
int32_t ret = remote->SendRequest(CAST_INT(UpdaterSaInterfaceCode::UPGRADE), data, reply, option);
|
||||
RETURN_FAIL_WHEN_REMOTE_ERR("UpdateServiceProxy::Upgrade", ret);
|
||||
BusinessError remoteBusinessError;
|
||||
MessageParcelHelper::ReadBusinessError(reply, remoteBusinessError);
|
||||
@@ -212,7 +212,7 @@ int32_t UpdateServiceProxy::ClearError(const UpgradeInfo &info, const VersionDig
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int32_t ret = remote->SendRequest(CLEAR_ERROR, data, reply, option);
|
||||
int32_t ret = remote->SendRequest(CAST_INT(UpdaterSaInterfaceCode::CLEAR_ERROR), data, reply, option);
|
||||
RETURN_FAIL_WHEN_REMOTE_ERR("UpdateServiceProxy::ClearError", ret);
|
||||
BusinessError remoteBusinessError;
|
||||
MessageParcelHelper::ReadBusinessError(reply, remoteBusinessError);
|
||||
@@ -231,7 +231,7 @@ int32_t UpdateServiceProxy::TerminateUpgrade(const UpgradeInfo &info, BusinessEr
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int32_t ret = remote->SendRequest(TERMINATE_UPGRADE, data, reply, option);
|
||||
int32_t ret = remote->SendRequest(CAST_INT(UpdaterSaInterfaceCode::TERMINATE_UPGRADE), data, reply, option);
|
||||
RETURN_FAIL_WHEN_REMOTE_ERR("UpdateServiceProxy::TerminateUpgrade", ret);
|
||||
BusinessError remoteBusinessError;
|
||||
MessageParcelHelper::ReadBusinessError(reply, remoteBusinessError);
|
||||
@@ -252,7 +252,7 @@ int32_t UpdateServiceProxy::GetNewVersionInfo(const UpgradeInfo &info, NewVersio
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int32_t ret = remote->SendRequest(GET_NEW_VERSION, data, reply, option);
|
||||
int32_t ret = remote->SendRequest(CAST_INT(UpdaterSaInterfaceCode::GET_NEW_VERSION), data, reply, option);
|
||||
RETURN_FAIL_WHEN_REMOTE_ERR("UpdateServiceProxy::GetNewVersionInfo", ret);
|
||||
|
||||
BusinessError remoteBusinessError;
|
||||
@@ -280,7 +280,8 @@ int32_t UpdateServiceProxy::GetNewVersionDescription(const UpgradeInfo &info,
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int32_t ret = remote->SendRequest(GET_NEW_VERSION_DESCRIPTION, data, reply, option);
|
||||
int32_t ret = remote->SendRequest(CAST_INT(UpdaterSaInterfaceCode::GET_NEW_VERSION_DESCRIPTION),
|
||||
data, reply, option);
|
||||
RETURN_FAIL_WHEN_REMOTE_ERR("UpdateServiceProxy::GetNewVersionDescription", ret);
|
||||
|
||||
BusinessError remoteBusinessError;
|
||||
@@ -305,7 +306,7 @@ int32_t UpdateServiceProxy::GetCurrentVersionInfo(const UpgradeInfo &info, Curre
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int32_t ret = remote->SendRequest(GET_CURRENT_VERSION, data, reply, option);
|
||||
int32_t ret = remote->SendRequest(CAST_INT(UpdaterSaInterfaceCode::GET_CURRENT_VERSION), data, reply, option);
|
||||
RETURN_FAIL_WHEN_REMOTE_ERR("UpdateServiceProxy::GetCurrentVersionInfo", ret);
|
||||
|
||||
BusinessError remoteBusinessError;
|
||||
@@ -332,7 +333,8 @@ int32_t UpdateServiceProxy::GetCurrentVersionDescription(const UpgradeInfo &info
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int32_t ret = remote->SendRequest(GET_CURRENT_VERSION_DESCRIPTION, data, reply, option);
|
||||
int32_t ret = remote->SendRequest(CAST_INT(UpdaterSaInterfaceCode::GET_CURRENT_VERSION_DESCRIPTION),
|
||||
data, reply, option);
|
||||
RETURN_FAIL_WHEN_REMOTE_ERR("UpdateServiceProxy::GetCurrentVersionDescription", ret);
|
||||
|
||||
BusinessError remoteBusinessError;
|
||||
@@ -356,7 +358,7 @@ int32_t UpdateServiceProxy::GetTaskInfo(const UpgradeInfo &info, TaskInfo &taskI
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int32_t ret = remote->SendRequest(GET_TASK_INFO, data, reply, option);
|
||||
int32_t ret = remote->SendRequest(CAST_INT(UpdaterSaInterfaceCode::GET_TASK_INFO), data, reply, option);
|
||||
RETURN_FAIL_WHEN_REMOTE_ERR("UpdateServiceProxy::GetTaskInfo", ret);
|
||||
|
||||
BusinessError remoteBusinessError;
|
||||
@@ -382,7 +384,7 @@ int32_t UpdateServiceProxy::SetUpgradePolicy(const UpgradeInfo &info, const Upgr
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int32_t ret = remote->SendRequest(SET_POLICY, data, reply, option);
|
||||
int32_t ret = remote->SendRequest(CAST_INT(UpdaterSaInterfaceCode::SET_POLICY), data, reply, option);
|
||||
RETURN_FAIL_WHEN_REMOTE_ERR("UpdateServiceProxy::SetUpgradePolicy", ret);
|
||||
|
||||
BusinessError remoteBusinessError;
|
||||
@@ -404,7 +406,7 @@ int32_t UpdateServiceProxy::GetUpgradePolicy(const UpgradeInfo &info, UpgradePol
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int32_t ret = remote->SendRequest(GET_POLICY, data, reply, option);
|
||||
int32_t ret = remote->SendRequest(CAST_INT(UpdaterSaInterfaceCode::GET_POLICY), data, reply, option);
|
||||
RETURN_FAIL_WHEN_REMOTE_ERR("UpdateServiceProxy::GetUpgradePolicy", ret);
|
||||
|
||||
BusinessError remoteBusinessError;
|
||||
@@ -429,7 +431,7 @@ int32_t UpdateServiceProxy::Cancel(const UpgradeInfo &info, int32_t service, Bus
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int32_t ret = remote->SendRequest(CANCEL, data, reply, option);
|
||||
int32_t ret = remote->SendRequest(CAST_INT(UpdaterSaInterfaceCode::CANCEL), data, reply, option);
|
||||
RETURN_FAIL_WHEN_REMOTE_ERR("UpdateServiceProxy::Cancel", ret);
|
||||
|
||||
BusinessError remoteBusinessError;
|
||||
@@ -451,7 +453,7 @@ int32_t UpdateServiceProxy::FactoryReset(BusinessError &businessError)
|
||||
MessageOption option;
|
||||
int32_t ret = ERR_NONE; // IPC errCode: defined in ipc_types.h
|
||||
#ifndef UPDATER_UT
|
||||
ret = remote->SendRequest(FACTORY_RESET, data, reply, option);
|
||||
ret = remote->SendRequest(CAST_INT(UpdaterSaInterfaceCode::FACTORY_RESET), data, reply, option);
|
||||
#endif
|
||||
RETURN_FAIL_WHEN_REMOTE_ERR("UpdateServiceProxy::FactoryReset", ret);
|
||||
|
||||
@@ -478,7 +480,7 @@ int32_t UpdateServiceProxy::ApplyNewVersion(const UpgradeInfo &info, const std::
|
||||
MessageOption option;
|
||||
int32_t ret = ERR_NONE;
|
||||
#ifndef UPDATER_UT
|
||||
ret = remote->SendRequest(APPLY_NEW_VERSION, data, reply, option);
|
||||
ret = remote->SendRequest(CAST_INT(UpdaterSaInterfaceCode::APPLY_NEW_VERSION), data, reply, option);
|
||||
#endif
|
||||
RETURN_FAIL_WHEN_REMOTE_ERR("UpdateServiceProxy::ApplyNewVersion", ret);
|
||||
|
||||
@@ -502,7 +504,7 @@ int32_t UpdateServiceProxy::VerifyUpgradePackage(const std::string &packagePath,
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int32_t ret = remote->SendRequest(VERIFY_UPGRADE_PACKAGE, data, reply, option);
|
||||
int32_t ret = remote->SendRequest(CAST_INT(UpdaterSaInterfaceCode::VERIFY_UPGRADE_PACKAGE), data, reply, option);
|
||||
RETURN_FAIL_WHEN_REMOTE_ERR("UpdateServiceProxy::VerifyUpgradePackage", ret);
|
||||
|
||||
BusinessError remoteBusinessError;
|
||||
|
||||
@@ -30,29 +30,6 @@ namespace UpdateEngine {
|
||||
class IUpdateService : public OHOS::IRemoteBroker, public IServiceOnlineUpdater, public IServiceRestorer,
|
||||
public IServiceLocalUpdater {
|
||||
public:
|
||||
enum {
|
||||
CHECK_VERSION = 1,
|
||||
DOWNLOAD,
|
||||
PAUSE_DOWNLOAD,
|
||||
RESUME_DOWNLOAD,
|
||||
UPGRADE,
|
||||
CLEAR_ERROR,
|
||||
TERMINATE_UPGRADE,
|
||||
SET_POLICY,
|
||||
GET_POLICY,
|
||||
GET_NEW_VERSION,
|
||||
GET_NEW_VERSION_DESCRIPTION,
|
||||
GET_CURRENT_VERSION,
|
||||
GET_CURRENT_VERSION_DESCRIPTION,
|
||||
GET_TASK_INFO,
|
||||
REGISTER_CALLBACK,
|
||||
UNREGISTER_CALLBACK,
|
||||
CANCEL,
|
||||
FACTORY_RESET,
|
||||
APPLY_NEW_VERSION,
|
||||
VERIFY_UPGRADE_PACKAGE
|
||||
};
|
||||
|
||||
virtual int32_t RegisterUpdateCallback(const UpgradeInfo &info, const sptr<IUpdateCallback>& updateCallback) = 0;
|
||||
|
||||
virtual int32_t UnregisterUpdateCallback(const UpgradeInfo &info) = 0;
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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 UPDATER_SA_IPC_INTERFACE_CODE_H
|
||||
#define UPDATER_SA_IPC_INTERFACE_CODE_H
|
||||
|
||||
namespace OHOS {
|
||||
namespace UpdateEngine {
|
||||
/* SAID: 3006 */
|
||||
enum class UpdaterSaInterfaceCode {
|
||||
CHECK_VERSION = 1,
|
||||
DOWNLOAD,
|
||||
PAUSE_DOWNLOAD,
|
||||
RESUME_DOWNLOAD,
|
||||
UPGRADE,
|
||||
CLEAR_ERROR,
|
||||
TERMINATE_UPGRADE,
|
||||
SET_POLICY,
|
||||
GET_POLICY,
|
||||
GET_NEW_VERSION,
|
||||
GET_NEW_VERSION_DESCRIPTION,
|
||||
GET_CURRENT_VERSION,
|
||||
GET_CURRENT_VERSION_DESCRIPTION,
|
||||
GET_TASK_INFO,
|
||||
REGISTER_CALLBACK,
|
||||
UNREGISTER_CALLBACK,
|
||||
CANCEL,
|
||||
FACTORY_RESET,
|
||||
APPLY_NEW_VERSION,
|
||||
VERIFY_UPGRADE_PACKAGE
|
||||
};
|
||||
} // namespace UpdateEngine
|
||||
} // namespace OHOS
|
||||
#endif // UPDATER_SA_IPC_INTERFACE_CODE_H
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "iremote_proxy.h"
|
||||
#include "iupdate_service.h"
|
||||
#include "updater_sa_ipc_interface_code.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace UpdateEngine {
|
||||
|
||||
@@ -27,12 +27,61 @@ namespace OHOS {
|
||||
namespace UpdateEngine {
|
||||
class UpdateServiceStub : public IRemoteStub<IUpdateService> {
|
||||
public:
|
||||
UpdateServiceStub();
|
||||
~UpdateServiceStub() = default;
|
||||
int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply,
|
||||
MessageOption &option) override;
|
||||
|
||||
using UpdateServiceStubPtr = UpdateServiceStub *;
|
||||
using RequestFuncType = std::function<int(UpdateServiceStubPtr service,
|
||||
MessageParcel &data, MessageParcel &reply, MessageOption &option)>;
|
||||
using RequestFuncType = int32_t (UpdateServiceStub::*)(UpdateServiceStubPtr service,
|
||||
MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
||||
|
||||
private:
|
||||
int32_t GetNewVersionStub(UpdateServiceStubPtr service,
|
||||
MessageParcel& data, MessageParcel& reply, MessageOption &option);
|
||||
int32_t GetNewVersionDescriptionStub(UpdateServiceStubPtr service,
|
||||
MessageParcel& data, MessageParcel& reply, MessageOption &option);
|
||||
int32_t GetCurrentVersionStub(UpdateServiceStubPtr service,
|
||||
MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
||||
int32_t GetCurrentVersionDescriptionStub(UpdateServiceStubPtr service,
|
||||
MessageParcel& data, MessageParcel& reply, MessageOption &option);
|
||||
int32_t GetTaskInfoStub(UpdateServiceStubPtr service,
|
||||
MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
||||
int32_t CheckNewVersionStub(UpdateServiceStubPtr service,
|
||||
MessageParcel& data, MessageParcel& reply, MessageOption &option);
|
||||
int32_t DownloadVersionStub(UpdateServiceStubPtr service,
|
||||
MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
||||
int32_t PauseDownloadStub(UpdateServiceStubPtr service,
|
||||
MessageParcel& data, MessageParcel& reply, MessageOption &option);
|
||||
int32_t ResumeDownloadStub(UpdateServiceStubPtr service,
|
||||
MessageParcel& data, MessageParcel& reply, MessageOption &option);
|
||||
int32_t DoUpdateStub(UpdateServiceStubPtr service,
|
||||
MessageParcel& data, MessageParcel& reply, MessageOption &option);
|
||||
int32_t ClearErrorStub(UpdateServiceStubPtr service,
|
||||
MessageParcel& data, MessageParcel& reply, MessageOption &option);
|
||||
int32_t TerminateUpgradeStub(UpdateServiceStubPtr service,
|
||||
MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
||||
int32_t SetUpgradePolicyStub(UpdateServiceStubPtr service,
|
||||
MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
||||
int32_t GetUpgradePolicyStub(UpdateServiceStubPtr service,
|
||||
MessageParcel& data, MessageParcel& reply, MessageOption &option);
|
||||
int32_t RegisterUpdateCallbackStub(UpdateServiceStubPtr service,
|
||||
MessageParcel& data, MessageParcel& reply, MessageOption &option);
|
||||
int32_t UnregisterUpdateCallbackStub(UpdateServiceStubPtr service,
|
||||
MessageParcel& data, MessageParcel& reply, MessageOption &option);
|
||||
int32_t CancelStub(UpdateServiceStubPtr service,
|
||||
MessageParcel& data, MessageParcel& reply, MessageOption &option);
|
||||
int32_t FactoryResetStub(UpdateServiceStubPtr service,
|
||||
MessageParcel& data, MessageParcel& reply, MessageOption &option);
|
||||
int32_t ApplyNewVersionStub(UpdateServiceStubPtr service,
|
||||
MessageParcel& data, MessageParcel& reply, MessageOption &option);
|
||||
int32_t VerifyUpgradePackageStub(UpdateServiceStubPtr service,
|
||||
MessageParcel& data, MessageParcel& reply, MessageOption &option);
|
||||
bool IsCallerValid();
|
||||
bool IsPermissionGranted(uint32_t code);
|
||||
|
||||
private:
|
||||
std::map<uint32_t, RequestFuncType> requestFuncMap_;
|
||||
};
|
||||
} // namespace UpdateEngine
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "update_log.h"
|
||||
#include "update_service_stub.h"
|
||||
#include "update_system_event.h"
|
||||
#include "updater_sa_ipc_interface_code.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -37,7 +38,35 @@ constexpr const pid_t EDM_UID = 3057;
|
||||
#define RETURN_FAIL_WHEN_SERVICE_NULL(service) \
|
||||
ENGINE_CHECK((service) != nullptr, return INT_CALL_IPC_ERR, "service null")
|
||||
|
||||
static int32_t GetNewVersionStub(UpdateServiceStub::UpdateServiceStubPtr service,
|
||||
UpdateServiceStub::UpdateServiceStub()
|
||||
{
|
||||
requestFuncMap_ = {
|
||||
{CAST_UINT(UpdaterSaInterfaceCode::CHECK_VERSION), &UpdateServiceStub::CheckNewVersionStub},
|
||||
{CAST_UINT(UpdaterSaInterfaceCode::DOWNLOAD), &UpdateServiceStub::DownloadVersionStub},
|
||||
{CAST_UINT(UpdaterSaInterfaceCode::PAUSE_DOWNLOAD), &UpdateServiceStub::PauseDownloadStub},
|
||||
{CAST_UINT(UpdaterSaInterfaceCode::RESUME_DOWNLOAD), &UpdateServiceStub::ResumeDownloadStub},
|
||||
{CAST_UINT(UpdaterSaInterfaceCode::UPGRADE), &UpdateServiceStub::DoUpdateStub},
|
||||
{CAST_UINT(UpdaterSaInterfaceCode::CLEAR_ERROR), &UpdateServiceStub::ClearErrorStub},
|
||||
{CAST_UINT(UpdaterSaInterfaceCode::TERMINATE_UPGRADE), &UpdateServiceStub::TerminateUpgradeStub},
|
||||
{CAST_UINT(UpdaterSaInterfaceCode::SET_POLICY), &UpdateServiceStub::SetUpgradePolicyStub},
|
||||
{CAST_UINT(UpdaterSaInterfaceCode::GET_POLICY), &UpdateServiceStub::GetUpgradePolicyStub},
|
||||
{CAST_UINT(UpdaterSaInterfaceCode::GET_NEW_VERSION), &UpdateServiceStub::GetNewVersionStub},
|
||||
{CAST_UINT(UpdaterSaInterfaceCode::GET_NEW_VERSION_DESCRIPTION),
|
||||
&UpdateServiceStub::GetNewVersionDescriptionStub},
|
||||
{CAST_UINT(UpdaterSaInterfaceCode::GET_CURRENT_VERSION), &UpdateServiceStub::GetCurrentVersionStub},
|
||||
{CAST_UINT(UpdaterSaInterfaceCode::GET_CURRENT_VERSION_DESCRIPTION),
|
||||
&UpdateServiceStub::GetCurrentVersionDescriptionStub},
|
||||
{CAST_UINT(UpdaterSaInterfaceCode::GET_TASK_INFO), &UpdateServiceStub::GetTaskInfoStub},
|
||||
{CAST_UINT(UpdaterSaInterfaceCode::REGISTER_CALLBACK), &UpdateServiceStub::RegisterUpdateCallbackStub},
|
||||
{CAST_UINT(UpdaterSaInterfaceCode::UNREGISTER_CALLBACK), &UpdateServiceStub::UnregisterUpdateCallbackStub},
|
||||
{CAST_UINT(UpdaterSaInterfaceCode::CANCEL), &UpdateServiceStub::CancelStub},
|
||||
{CAST_UINT(UpdaterSaInterfaceCode::FACTORY_RESET), &UpdateServiceStub::FactoryResetStub},
|
||||
{CAST_UINT(UpdaterSaInterfaceCode::APPLY_NEW_VERSION), &UpdateServiceStub::ApplyNewVersionStub},
|
||||
{CAST_UINT(UpdaterSaInterfaceCode::VERIFY_UPGRADE_PACKAGE), &UpdateServiceStub::VerifyUpgradePackageStub}
|
||||
};
|
||||
}
|
||||
|
||||
int32_t UpdateServiceStub::GetNewVersionStub(UpdateServiceStubPtr service,
|
||||
MessageParcel& data, MessageParcel& reply, MessageOption &option)
|
||||
{
|
||||
RETURN_FAIL_WHEN_SERVICE_NULL(service);
|
||||
@@ -52,7 +81,7 @@ static int32_t GetNewVersionStub(UpdateServiceStub::UpdateServiceStubPtr service
|
||||
return INT_CALL_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t GetNewVersionDescriptionStub(UpdateServiceStub::UpdateServiceStubPtr service,
|
||||
int32_t UpdateServiceStub::GetNewVersionDescriptionStub(UpdateServiceStubPtr service,
|
||||
MessageParcel& data, MessageParcel& reply, MessageOption &option)
|
||||
{
|
||||
RETURN_FAIL_WHEN_SERVICE_NULL(service);
|
||||
@@ -73,7 +102,7 @@ static int32_t GetNewVersionDescriptionStub(UpdateServiceStub::UpdateServiceStub
|
||||
return INT_CALL_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t GetCurrentVersionStub(UpdateServiceStub::UpdateServiceStubPtr service,
|
||||
int32_t UpdateServiceStub::GetCurrentVersionStub(UpdateServiceStubPtr service,
|
||||
MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
RETURN_FAIL_WHEN_SERVICE_NULL(service);
|
||||
@@ -88,7 +117,7 @@ static int32_t GetCurrentVersionStub(UpdateServiceStub::UpdateServiceStubPtr ser
|
||||
return INT_CALL_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t GetCurrentVersionDescriptionStub(UpdateServiceStub::UpdateServiceStubPtr service,
|
||||
int32_t UpdateServiceStub::GetCurrentVersionDescriptionStub(UpdateServiceStubPtr service,
|
||||
MessageParcel& data, MessageParcel& reply, MessageOption &option)
|
||||
{
|
||||
RETURN_FAIL_WHEN_SERVICE_NULL(service);
|
||||
@@ -107,7 +136,7 @@ static int32_t GetCurrentVersionDescriptionStub(UpdateServiceStub::UpdateService
|
||||
return INT_CALL_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t GetTaskInfoStub(UpdateServiceStub::UpdateServiceStubPtr service,
|
||||
int32_t UpdateServiceStub::GetTaskInfoStub(UpdateServiceStubPtr service,
|
||||
MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
RETURN_FAIL_WHEN_SERVICE_NULL(service);
|
||||
@@ -122,7 +151,7 @@ static int32_t GetTaskInfoStub(UpdateServiceStub::UpdateServiceStubPtr service,
|
||||
return INT_CALL_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t CheckNewVersionStub(UpdateServiceStub::UpdateServiceStubPtr service,
|
||||
int32_t UpdateServiceStub::CheckNewVersionStub(UpdateServiceStubPtr service,
|
||||
MessageParcel& data, MessageParcel& reply, MessageOption &option)
|
||||
{
|
||||
RETURN_FAIL_WHEN_SERVICE_NULL(service);
|
||||
@@ -131,8 +160,8 @@ static int32_t CheckNewVersionStub(UpdateServiceStub::UpdateServiceStubPtr servi
|
||||
return service->CheckNewVersion(upgradeInfo);
|
||||
}
|
||||
|
||||
static int32_t DownloadVersionStub(UpdateServiceStub::UpdateServiceStubPtr service, MessageParcel &data,
|
||||
MessageParcel &reply, MessageOption &option)
|
||||
int32_t UpdateServiceStub::DownloadVersionStub(UpdateServiceStubPtr service,
|
||||
MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
RETURN_FAIL_WHEN_SERVICE_NULL(service);
|
||||
UpgradeInfo upgradeInfo;
|
||||
@@ -148,7 +177,7 @@ static int32_t DownloadVersionStub(UpdateServiceStub::UpdateServiceStubPtr servi
|
||||
return INT_CALL_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t PauseDownloadStub(UpdateServiceStub::UpdateServiceStubPtr service,
|
||||
int32_t UpdateServiceStub::PauseDownloadStub(UpdateServiceStubPtr service,
|
||||
MessageParcel& data, MessageParcel& reply, MessageOption &option)
|
||||
{
|
||||
RETURN_FAIL_WHEN_SERVICE_NULL(service);
|
||||
@@ -166,7 +195,7 @@ static int32_t PauseDownloadStub(UpdateServiceStub::UpdateServiceStubPtr service
|
||||
return INT_CALL_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t ResumeDownloadStub(UpdateServiceStub::UpdateServiceStubPtr service,
|
||||
int32_t UpdateServiceStub::ResumeDownloadStub(UpdateServiceStubPtr service,
|
||||
MessageParcel& data, MessageParcel& reply, MessageOption &option)
|
||||
{
|
||||
RETURN_FAIL_WHEN_SERVICE_NULL(service);
|
||||
@@ -184,7 +213,7 @@ static int32_t ResumeDownloadStub(UpdateServiceStub::UpdateServiceStubPtr servic
|
||||
return INT_CALL_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t DoUpdateStub(UpdateServiceStub::UpdateServiceStubPtr service,
|
||||
int32_t UpdateServiceStub::DoUpdateStub(UpdateServiceStubPtr service,
|
||||
MessageParcel& data, MessageParcel& reply, MessageOption &option)
|
||||
{
|
||||
RETURN_FAIL_WHEN_SERVICE_NULL(service);
|
||||
@@ -202,7 +231,7 @@ static int32_t DoUpdateStub(UpdateServiceStub::UpdateServiceStubPtr service,
|
||||
return INT_CALL_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t ClearErrorStub(UpdateServiceStub::UpdateServiceStubPtr service,
|
||||
int32_t UpdateServiceStub::ClearErrorStub(UpdateServiceStubPtr service,
|
||||
MessageParcel& data, MessageParcel& reply, MessageOption &option)
|
||||
{
|
||||
RETURN_FAIL_WHEN_SERVICE_NULL(service);
|
||||
@@ -220,7 +249,7 @@ static int32_t ClearErrorStub(UpdateServiceStub::UpdateServiceStubPtr service,
|
||||
return INT_CALL_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t TerminateUpgradeStub(UpdateServiceStub::UpdateServiceStubPtr service, MessageParcel &data,
|
||||
int32_t UpdateServiceStub::TerminateUpgradeStub(UpdateServiceStubPtr service, MessageParcel &data,
|
||||
MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
RETURN_FAIL_WHEN_SERVICE_NULL(service);
|
||||
@@ -234,8 +263,8 @@ static int32_t TerminateUpgradeStub(UpdateServiceStub::UpdateServiceStubPtr serv
|
||||
return INT_CALL_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t SetUpgradePolicyStub(
|
||||
UpdateServiceStub::UpdateServiceStubPtr service, MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
int32_t UpdateServiceStub::SetUpgradePolicyStub(UpdateServiceStubPtr service,
|
||||
MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
RETURN_FAIL_WHEN_SERVICE_NULL(service);
|
||||
UpgradeInfo upgradeInfo {};
|
||||
@@ -249,7 +278,7 @@ static int32_t SetUpgradePolicyStub(
|
||||
return INT_CALL_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t GetUpgradePolicyStub(UpdateServiceStub::UpdateServiceStubPtr service,
|
||||
int32_t UpdateServiceStub::GetUpgradePolicyStub(UpdateServiceStubPtr service,
|
||||
MessageParcel& data, MessageParcel& reply, MessageOption &option)
|
||||
{
|
||||
RETURN_FAIL_WHEN_SERVICE_NULL(service);
|
||||
@@ -264,7 +293,7 @@ static int32_t GetUpgradePolicyStub(UpdateServiceStub::UpdateServiceStubPtr serv
|
||||
return INT_CALL_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t RegisterUpdateCallbackStub(UpdateServiceStub::UpdateServiceStubPtr service,
|
||||
int32_t UpdateServiceStub::RegisterUpdateCallbackStub(UpdateServiceStubPtr service,
|
||||
MessageParcel& data, MessageParcel& reply, MessageOption &option)
|
||||
{
|
||||
ENGINE_LOGI("RegisterUpdateCallbackStub");
|
||||
@@ -276,7 +305,7 @@ static int32_t RegisterUpdateCallbackStub(UpdateServiceStub::UpdateServiceStubPt
|
||||
return service->RegisterUpdateCallback(upgradeInfo, iface_cast<IUpdateCallback>(remote));
|
||||
}
|
||||
|
||||
static int32_t UnregisterUpdateCallbackStub(UpdateServiceStub::UpdateServiceStubPtr service,
|
||||
int32_t UpdateServiceStub::UnregisterUpdateCallbackStub(UpdateServiceStubPtr service,
|
||||
MessageParcel& data, MessageParcel& reply, MessageOption &option)
|
||||
{
|
||||
RETURN_FAIL_WHEN_SERVICE_NULL(service);
|
||||
@@ -285,7 +314,7 @@ static int32_t UnregisterUpdateCallbackStub(UpdateServiceStub::UpdateServiceStub
|
||||
return service->UnregisterUpdateCallback(upgradeInfo);
|
||||
}
|
||||
|
||||
static int32_t CancelStub(UpdateServiceStub::UpdateServiceStubPtr service,
|
||||
int32_t UpdateServiceStub::CancelStub(UpdateServiceStubPtr service,
|
||||
MessageParcel& data, MessageParcel& reply, MessageOption &option)
|
||||
{
|
||||
RETURN_FAIL_WHEN_SERVICE_NULL(service);
|
||||
@@ -298,7 +327,7 @@ static int32_t CancelStub(UpdateServiceStub::UpdateServiceStubPtr service,
|
||||
return INT_CALL_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t FactoryResetStub(UpdateServiceStub::UpdateServiceStubPtr service,
|
||||
int32_t UpdateServiceStub::FactoryResetStub(UpdateServiceStubPtr service,
|
||||
MessageParcel& data, MessageParcel& reply, MessageOption &option)
|
||||
{
|
||||
RETURN_FAIL_WHEN_SERVICE_NULL(service);
|
||||
@@ -310,7 +339,7 @@ static int32_t FactoryResetStub(UpdateServiceStub::UpdateServiceStubPtr service,
|
||||
return INT_CALL_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t ApplyNewVersionStub(UpdateServiceStub::UpdateServiceStubPtr service,
|
||||
int32_t UpdateServiceStub::ApplyNewVersionStub(UpdateServiceStubPtr service,
|
||||
MessageParcel& data, MessageParcel& reply, MessageOption &option)
|
||||
{
|
||||
RETURN_FAIL_WHEN_SERVICE_NULL(service);
|
||||
@@ -325,7 +354,7 @@ static int32_t ApplyNewVersionStub(UpdateServiceStub::UpdateServiceStubPtr servi
|
||||
return INT_CALL_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t VerifyUpgradePackageStub(UpdateServiceStub::UpdateServiceStubPtr service,
|
||||
int32_t UpdateServiceStub::VerifyUpgradePackageStub(UpdateServiceStubPtr service,
|
||||
MessageParcel& data, MessageParcel& reply, MessageOption &option)
|
||||
{
|
||||
RETURN_FAIL_WHEN_SERVICE_NULL(service);
|
||||
@@ -338,7 +367,7 @@ static int32_t VerifyUpgradePackageStub(UpdateServiceStub::UpdateServiceStubPtr
|
||||
return INT_CALL_SUCCESS;
|
||||
}
|
||||
|
||||
static bool IsCallerValid()
|
||||
bool UpdateServiceStub::IsCallerValid()
|
||||
{
|
||||
OHOS::Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID();
|
||||
auto callerTokenType = OHOS::Security::AccessToken::AccessTokenKit::GetTokenType(callerToken);
|
||||
@@ -359,11 +388,11 @@ static bool IsCallerValid()
|
||||
}
|
||||
}
|
||||
|
||||
static bool IsPermissionGranted(uint32_t code)
|
||||
bool UpdateServiceStub::IsPermissionGranted(uint32_t code)
|
||||
{
|
||||
Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID();
|
||||
string permission = "ohos.permission.UPDATE_SYSTEM";
|
||||
if (code == IUpdateService::FACTORY_RESET) {
|
||||
if (code == CAST_UINT(UpdaterSaInterfaceCode::FACTORY_RESET)) {
|
||||
permission = "ohos.permission.FACTORY_RESET";
|
||||
}
|
||||
int verifyResult = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, permission);
|
||||
@@ -381,32 +410,10 @@ int32_t UpdateServiceStub::OnRemoteRequest(uint32_t code,
|
||||
ENGINE_LOGI("UpdateServiceStub ReadInterfaceToken fail");
|
||||
return CALL_RESULT_TO_IPC_RESULT(INT_CALL_IPC_ERR);
|
||||
}
|
||||
static std::map<uint32_t, UpdateServiceStub::RequestFuncType> requestFuncMap = {
|
||||
{IUpdateService::CHECK_VERSION, CheckNewVersionStub},
|
||||
{IUpdateService::DOWNLOAD, DownloadVersionStub},
|
||||
{IUpdateService::PAUSE_DOWNLOAD, PauseDownloadStub},
|
||||
{IUpdateService::RESUME_DOWNLOAD, ResumeDownloadStub},
|
||||
{IUpdateService::UPGRADE, DoUpdateStub},
|
||||
{IUpdateService::CLEAR_ERROR, ClearErrorStub},
|
||||
{IUpdateService::TERMINATE_UPGRADE, TerminateUpgradeStub},
|
||||
{IUpdateService::SET_POLICY, SetUpgradePolicyStub},
|
||||
{IUpdateService::GET_POLICY, GetUpgradePolicyStub},
|
||||
{IUpdateService::GET_NEW_VERSION, GetNewVersionStub},
|
||||
{IUpdateService::GET_NEW_VERSION_DESCRIPTION, GetNewVersionDescriptionStub},
|
||||
{IUpdateService::GET_CURRENT_VERSION, GetCurrentVersionStub},
|
||||
{IUpdateService::GET_CURRENT_VERSION_DESCRIPTION, GetCurrentVersionDescriptionStub},
|
||||
{IUpdateService::GET_TASK_INFO, GetTaskInfoStub},
|
||||
{IUpdateService::REGISTER_CALLBACK, RegisterUpdateCallbackStub},
|
||||
{IUpdateService::UNREGISTER_CALLBACK, UnregisterUpdateCallbackStub},
|
||||
{IUpdateService::CANCEL, CancelStub},
|
||||
{IUpdateService::FACTORY_RESET, FactoryResetStub},
|
||||
{IUpdateService::APPLY_NEW_VERSION, ApplyNewVersionStub},
|
||||
{IUpdateService::VERIFY_UPGRADE_PACKAGE, VerifyUpgradePackageStub},
|
||||
};
|
||||
|
||||
ENGINE_LOGI("UpdateServiceStub func code %{public}u", code);
|
||||
auto iter = requestFuncMap.find(code);
|
||||
if (iter == requestFuncMap.end()) {
|
||||
auto iter = requestFuncMap_.find(code);
|
||||
if (iter == requestFuncMap_.end()) {
|
||||
ENGINE_LOGE("UpdateServiceStub OnRemoteRequest code %{public}u not found", code);
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
@@ -422,7 +429,7 @@ int32_t UpdateServiceStub::OnRemoteRequest(uint32_t code,
|
||||
UpdateSystemEvent::EVENT_PERMISSION_VERIFY_FAILED);
|
||||
return CALL_RESULT_TO_IPC_RESULT(INT_APP_NOT_GRANTED);
|
||||
}
|
||||
return CALL_RESULT_TO_IPC_RESULT(iter->second(this, data, reply, option));
|
||||
return CALL_RESULT_TO_IPC_RESULT((this->*(iter->second))(this, data, reply, option));
|
||||
}
|
||||
} // namespace UpdateEngine
|
||||
} // namespace OHOS
|
||||
|
||||
Reference in New Issue
Block a user