• 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 "quick_fix_callback_stub.h"
17 
18 #include "hilog_wrapper.h"
19 
20 namespace OHOS {
21 namespace AppExecFwk {
QuickFixCallbackStub()22 QuickFixCallbackStub::QuickFixCallbackStub()
23 {
24     requestFuncMap_[ON_NOTIFY_LOAD_PATCH] = &QuickFixCallbackStub::HandleOnLoadPatchDoneInner;
25     requestFuncMap_[ON_NOTIFY_UNLOAD_PATCH] = &QuickFixCallbackStub::HandleOnUnloadPatchDoneInner;
26     requestFuncMap_[ON_NOTIFY_RELOAD_PAGE] = &QuickFixCallbackStub::HandleOnReloadPageDoneInner;
27 }
28 
~QuickFixCallbackStub()29 QuickFixCallbackStub::~QuickFixCallbackStub()
30 {
31     requestFuncMap_.clear();
32 }
33 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)34 int QuickFixCallbackStub::OnRemoteRequest(
35     uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
36 {
37     if (data.ReadInterfaceToken() != IQuickFixCallback::GetDescriptor()) {
38         HILOG_ERROR("local descriptor is not equal to remote.");
39         return ERR_INVALID_STATE;
40     }
41 
42     auto itFunc = requestFuncMap_.find(code);
43     if (itFunc != requestFuncMap_.end()) {
44         auto requestFunc = itFunc->second;
45         if (requestFunc != nullptr) {
46             return (this->*requestFunc)(data, reply);
47         }
48     }
49 
50     HILOG_WARN("default case, need check value of code.");
51     return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
52 }
53 
HandleOnLoadPatchDoneInner(MessageParcel & data,MessageParcel & reply)54 int32_t QuickFixCallbackStub::HandleOnLoadPatchDoneInner(MessageParcel &data, MessageParcel &reply)
55 {
56     int32_t resultCode = data.ReadInt32();
57     int32_t recordId = data.ReadInt32();
58     OnLoadPatchDone(resultCode, recordId);
59     return ERR_OK;
60 }
61 
HandleOnUnloadPatchDoneInner(MessageParcel & data,MessageParcel & reply)62 int32_t QuickFixCallbackStub::HandleOnUnloadPatchDoneInner(MessageParcel &data, MessageParcel &reply)
63 {
64     int32_t resultCode = data.ReadInt32();
65     int32_t recordId = data.ReadInt32();
66     OnUnloadPatchDone(resultCode, recordId);
67     return ERR_OK;
68 }
69 
HandleOnReloadPageDoneInner(MessageParcel & data,MessageParcel & reply)70 int32_t QuickFixCallbackStub::HandleOnReloadPageDoneInner(MessageParcel &data, MessageParcel &reply)
71 {
72     int32_t resultCode = data.ReadInt32();
73     int32_t recordId = data.ReadInt32();
74     OnReloadPageDone(resultCode, recordId);
75     return ERR_OK;
76 }
77 } // namespace AAFwk
78 } // namespace OHOS
79