1 /*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #include "sec_comp_load_callback.h"
16
17 #include "i_sec_comp_service.h"
18 #include "sec_comp_client.h"
19 #include "sec_comp_log.h"
20
21 namespace OHOS {
22 namespace Security {
23 namespace SecurityComponent {
24 namespace {
25 static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, SECURITY_DOMAIN_SECURITY_COMPONENT, "SecCompClient"};
26 } // namespace
SecCompLoadCallback()27 SecCompLoadCallback::SecCompLoadCallback() {}
28
OnLoadSystemAbilitySuccess(int32_t systemAbilityId,const sptr<IRemoteObject> & remoteObject)29 void SecCompLoadCallback::OnLoadSystemAbilitySuccess(
30 int32_t systemAbilityId, const sptr<IRemoteObject>& remoteObject)
31 {
32 if (systemAbilityId != SA_ID_SECURITY_COMPONENT_SERVICE) {
33 SC_LOG_ERROR(LABEL, "start systemabilityId is not security_component!");
34 return;
35 }
36
37 if (remoteObject == nullptr) {
38 SC_LOG_ERROR(LABEL, "remoteObject is null.");
39 SecCompClient::GetInstance().FinishStartSAFail();
40 return;
41 }
42
43 SC_LOG_INFO(LABEL, "Start systemAbilityId: %{public}d success!", systemAbilityId);
44
45 SecCompClient::GetInstance().FinishStartSASuccess(remoteObject);
46 }
47
OnLoadSystemAbilityFail(int32_t systemAbilityId)48 void SecCompLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId)
49 {
50 if (systemAbilityId != SA_ID_SECURITY_COMPONENT_SERVICE) {
51 SC_LOG_ERROR(LABEL, "start systemabilityId is not security_component!");
52 return;
53 }
54
55 SC_LOG_ERROR(LABEL, "Start systemAbilityId: %{public}d failed.", systemAbilityId);
56
57 SecCompClient::GetInstance().FinishStartSAFail();
58 }
59 } // namespace SecurityComponent
60 } // namespace Security
61 } // namespace OHOS
62