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 "bundle_tool_callback_stub.h"
17 
18 #include "app_log_wrapper.h"
19 #include "message_parcel.h"
20 #include "string_ex.h"
21 
22 namespace OHOS {
23 namespace AppExecFwk {
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)24 int32_t BundleToolCallbackStub::OnRemoteRequest(
25     uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
26 {
27     APP_LOGI("bundle mgr callback onReceived message, the message code is %{public}u", code);
28     std::unique_lock<std::mutex> lock(mutex_);
29     std::u16string descriptor = BundleToolCallbackStub::GetDescriptor();
30     std::u16string token = data.ReadInterfaceToken();
31     if (descriptor != token) {
32         APP_LOGE("failed to verify parameters");
33         return OBJECT_NULL;
34     }
35     int32_t resultCode = data.ReadInt32();
36     uint32_t versionCode = data.ReadUint32();
37     int32_t missionId = data.ReadInt32();
38     APP_LOGI("BundleToolCallbackStub: resultCode:%{public}d, versionCode:%{public}d, missionId:%{public}d",
39         resultCode, versionCode, missionId);
40     dataReady_ = true;
41     cv_.notify_all();
42     return ERR_OK;
43 }
44 }  // namespace AppExecFwk
45 }  // namespace OHOS