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 "free_install_status_callback_stub.h"
17 #include "fms_log_wrapper.h"
18 #include "ipc_types.h"
19 #include "message_parcel.h"
20
21 namespace OHOS {
22 namespace AppExecFwk {
FreeInstallStatusCallBackStub()23 FreeInstallStatusCallBackStub::FreeInstallStatusCallBackStub()
24 {}
25
OnInstallFinishedInner(MessageParcel & data,MessageParcel & reply)26 int32_t FreeInstallStatusCallBackStub::OnInstallFinishedInner(MessageParcel &data, MessageParcel &reply)
27 {
28 auto resultCode = data.ReadInt32();
29 std::unique_ptr<AAFwk::Want> want(data.ReadParcelable<AAFwk::Want>());
30 if (want == nullptr) {
31 HILOG_ERROR("null want");
32 return ERR_INVALID_VALUE;
33 }
34
35 auto userId = data.ReadInt32();
36 OnInstallFinished(resultCode, *want, userId);
37 return NO_ERROR;
38 }
39
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)40 int32_t FreeInstallStatusCallBackStub::OnRemoteRequest(
41 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
42 {
43 HILOG_INFO("code:%{public}d", code);
44 std::u16string descriptor = FreeInstallStatusCallBackStub::GetDescriptor();
45 std::u16string remoteDescriptor = data.ReadInterfaceToken();
46 if (descriptor != remoteDescriptor) {
47 HILOG_ERROR("LocalDescriptor not equal to remote,descriptor:%{public}s,remoteDescriptor:%{public}s",
48 Str16ToStr8(descriptor).c_str(), Str16ToStr8(remoteDescriptor).c_str());
49 return ERR_INVALID_STATE;
50 }
51
52 if (code == IFreeInstallStatusCallBackCmd::ON_FREE_INSTALL_DONE) {
53 return OnInstallFinishedInner(data, reply);
54 }
55
56 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
57 }
58 } // namespace AppExecFwk
59 } // namespace OHOS
60