1 /*
2 * Copyright (c) 2022-2024 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
16 #include "system_ability_token_callback_stub.h"
17
18 #include "hilog_tag_wrapper.h"
19
20 namespace OHOS {
21 namespace AAFwk {
22 namespace {
23 const std::u16string SYSTEM_ABILITY_TOKEN_CALLBACK_INTERFACE_TOKEN = u"ohos.aafwk.ISystemAbilityTokenCallback";
24 }
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)25 int32_t SystemAbilityTokenCallbackStub::OnRemoteRequest(uint32_t code,
26 MessageParcel &data, MessageParcel &reply, MessageOption &option)
27 {
28 if (data.ReadInterfaceToken() != SYSTEM_ABILITY_TOKEN_CALLBACK_INTERFACE_TOKEN) {
29 TAG_LOGE(AAFwkTag::ABILITYMGR, "OnRemoteRequest::ReadInterfaceToken error");
30 return ERR_PERMISSION_DENIED;
31 }
32 switch (code) {
33 case SEND_RESULT: {
34 std::shared_ptr<AAFwk::Want> want(data.ReadParcelable<AAFwk::Want>());
35 if (want == nullptr) {
36 TAG_LOGE(AAFwkTag::ABILITYMGR, "SEND_RESULT want readParcelable failed!");
37 return ERR_NULL_OBJECT;
38 }
39 int32_t callerUid = data.ReadInt32();
40 int32_t requestCode = data.ReadInt32();
41 uint32_t accessToken = data.ReadUint32();
42 int32_t resultCode = data.ReadInt32();
43 return SendResult(*want, callerUid, requestCode, accessToken, resultCode);
44 }
45 default: {
46 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
47 }
48 }
49 }
50 } // namespace AAFwk
51 } // namespace OHOS
52