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 "isec_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 constexpr int32_t SA_ID_SECURITY_COMPONENT_SERVICE = 3506;
27 } // namespace
SecCompLoadCallback()28 SecCompLoadCallback::SecCompLoadCallback() {}
29
OnLoadSystemAbilitySuccess(int32_t systemAbilityId,const sptr<IRemoteObject> & remoteObject)30 void SecCompLoadCallback::OnLoadSystemAbilitySuccess(
31 int32_t systemAbilityId, const sptr<IRemoteObject>& remoteObject)
32 {
33 if (systemAbilityId != SA_ID_SECURITY_COMPONENT_SERVICE) {
34 SC_LOG_ERROR(LABEL, "start systemabilityId is not security_component!");
35 return;
36 }
37
38 if (remoteObject == nullptr) {
39 SC_LOG_ERROR(LABEL, "remoteObject is null.");
40 SecCompClient::GetInstance().FinishStartSAFail();
41 return;
42 }
43
44 SC_LOG_INFO(LABEL, "Start systemAbilityId: %{public}d success!", systemAbilityId);
45
46 SecCompClient::GetInstance().FinishStartSASuccess(remoteObject);
47 }
48
OnLoadSystemAbilityFail(int32_t systemAbilityId)49 void SecCompLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId)
50 {
51 if (systemAbilityId != SA_ID_SECURITY_COMPONENT_SERVICE) {
52 SC_LOG_ERROR(LABEL, "start systemabilityId is not security_component!");
53 return;
54 }
55
56 SC_LOG_ERROR(LABEL, "Start systemAbilityId: %{public}d failed.", systemAbilityId);
57
58 SecCompClient::GetInstance().FinishStartSAFail();
59 }
60 } // namespace SecurityComponent
61 } // namespace Security
62 } // namespace OHOS
63