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