• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 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 "service_center_status_callback_stub.h"
17 
18 #include "app_log_wrapper.h"
19 #include "bundle_memory_guard.h"
20 #include "free_install_params.h"
21 #include "message_parcel.h"
22 #include "string_ex.h"
23 
24 namespace OHOS {
25 namespace AppExecFwk {
26 namespace {
27 const std::u16string SEEVICE_CENTER_CALLBACK_TOKEN = u"abilitydispatcherhm.openapi.hapinstall.IHapInstallCallback";
28 }
29 
ServiceCenterStatusCallbackStub()30 ServiceCenterStatusCallbackStub::ServiceCenterStatusCallbackStub()
31 {
32     APP_LOGI("ServiceCenterStatusCallbackStub is created");
33 }
34 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)35 int32_t ServiceCenterStatusCallbackStub::OnRemoteRequest(
36     uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
37 {
38     BundleMemoryGuard memoryGuard;
39     if (data.ReadInterfaceToken() != SEEVICE_CENTER_CALLBACK_TOKEN) {
40         APP_LOGE("verify interface token failed");
41         return -1;
42     }
43 
44     auto result = data.ReadString16();
45     APP_LOGD("OnRemoteRequest:code:%{public}d, result:%{public}s", code, Str16ToStr8(result).c_str());
46     return OnInstallFinished(Str16ToStr8(result));
47 }
48 }  // namespace AppExecFwk
49 }  // namespace OHOS
50