1 /*
2 * Copyright (c) 2021 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 "clean_cache_callback_host.h"
17
18 #include "ipc_types.h"
19
20 #include "app_log_wrapper.h"
21
22 namespace OHOS {
23 namespace AppExecFwk {
CleanCacheCallbackHost()24 CleanCacheCallbackHost::CleanCacheCallbackHost()
25 {
26 APP_LOGI("create clean cache callback host instance");
27 }
28
~CleanCacheCallbackHost()29 CleanCacheCallbackHost::~CleanCacheCallbackHost()
30 {
31 APP_LOGI("destroyclean cache callback host instance");
32 }
33
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)34 int CleanCacheCallbackHost::OnRemoteRequest(
35 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
36 {
37 APP_LOGD("clean cache callback host onReceived message, the message code is %{public}u", code);
38 std::u16string descripter = CleanCacheCallbackHost::GetDescriptor();
39 std::u16string remoteDescripter = data.ReadInterfaceToken();
40 if (descripter != remoteDescripter) {
41 APP_LOGE("fail to write reply message in clean cache host due to the reply is nullptr");
42 return OBJECT_NULL;
43 }
44
45 switch (code) {
46 case static_cast<uint32_t>(ICleanCacheCallback::Message::ON_CLEAN_CACHE_CALLBACK): {
47 bool succeed = data.ReadBool();
48 OnCleanCacheFinished(succeed);
49 break;
50 }
51 default:
52 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
53 }
54 return NO_ERROR;
55 }
56 } // namespace AppExecFwk
57 } // namespace OHOS
58