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_active_log.h"
17 #include "app_group_callback_stub.h"
18 #include "iapp_group_callback_ipc_interface_code.h"
19 
20 namespace OHOS {
21 namespace DeviceUsageStats {
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)22 int32_t AppGroupCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel &reply,
23     MessageOption &option)
24 {
25     std::u16string descriptor = AppGroupCallbackStub::GetDescriptor();
26     std::u16string remoteDescriptor = data.ReadInterfaceToken();
27     if (descriptor != remoteDescriptor) {
28         BUNDLE_ACTIVE_LOGE("RegisterAppGroupCallBack OnRemoteRequest cannot get power mgr service");
29         return -1;
30     }
31     switch (code) {
32         case static_cast<uint32_t>(IAppGroupCallBackInterfaceCode::ON_BUNDLE_GROUP_CHANGED): {
33             std::shared_ptr<AppGroupCallbackInfo> groupInfo(
34                 data.ReadParcelable<AppGroupCallbackInfo>());
35             if (!groupInfo) {
36                 BUNDLE_ACTIVE_LOGE("RegisterAppGroupCallBack ReadParcelable<AbilityStateData> failed");
37                 return -1;
38             }
39             OnAppGroupChanged(*(groupInfo.get()));
40             groupInfo = nullptr;
41             break;
42         }
43         default:
44             return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
45     }
46     return ERR_OK;
47 }
48 
OnAppGroupChanged(const AppGroupCallbackInfo & appGroupCallbackInfo)49 void AppGroupCallbackStub::OnAppGroupChanged(const AppGroupCallbackInfo &appGroupCallbackInfo)
50 {
51 }
52 }  // namespace DeviceUsageStats
53 }  // namespace OHOS
54 
55