• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "ability_info_callback_stub.h"
17 #include "appexecfwk_errors.h"
18 #include "hilog_tag_wrapper.h"
19 #include "ipc_types.h"
20 #include "iremote_object.h"
21 
22 namespace OHOS {
23 namespace AppExecFwk {
AbilityInfoCallbackStub()24 AbilityInfoCallbackStub::AbilityInfoCallbackStub() {}
25 
~AbilityInfoCallbackStub()26 AbilityInfoCallbackStub::~AbilityInfoCallbackStub() {}
27 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)28 int AbilityInfoCallbackStub::OnRemoteRequest(
29     uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
30 {
31     TAG_LOGI(AAFwkTag::APPMGR, "code: %{public}u, flags: %{public}d", code,
32         option.GetFlags());
33     std::u16string descriptor = AbilityInfoCallbackStub::GetDescriptor();
34     std::u16string remoteDescriptor = data.ReadInterfaceToken();
35     if (descriptor != remoteDescriptor) {
36         TAG_LOGE(AAFwkTag::APPMGR, "invalid descriptor");
37         return ERR_INVALID_STATE;
38     }
39 
40     if (code == static_cast<uint32_t>(IAbilityInfoCallback::Notify_ABILITY_TOKEN)) {
41         return HandleNotifyAbilityToken(data, reply);
42     }
43 
44     TAG_LOGI(AAFwkTag::APPMGR, "end");
45     return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
46 }
47 
NotifyAbilityToken(const sptr<IRemoteObject> token,const Want & want)48 void AbilityInfoCallbackStub::NotifyAbilityToken(const sptr<IRemoteObject> token, const Want &want)
49 {
50 }
51 
HandleNotifyAbilityToken(MessageParcel & data,MessageParcel & reply)52 int32_t AbilityInfoCallbackStub::HandleNotifyAbilityToken(MessageParcel &data, MessageParcel &reply)
53 {
54     TAG_LOGI(AAFwkTag::APPMGR, "called");
55     sptr<IRemoteObject> token = data.ReadRemoteObject();
56     Want *want = data.ReadParcelable<Want>();
57 
58     if (!want) {
59         TAG_LOGE(AAFwkTag::APPMGR, "ReadParcelable<Want> failed");
60         return ERR_APPEXECFWK_PARCEL_ERROR;
61     }
62     NotifyAbilityToken(token, *want);
63     delete want;
64     return NO_ERROR;
65 }
66 }  // namespace AppExecFwk
67 }  // namespace OHOS
68