• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_power_state_callback_proxy.h"
17 #include "power_state_machine_info.h"
18 
19 namespace OHOS {
20 namespace DeviceUsageStats {
OnPowerStateChanged(PowerMgr::PowerState state)21 void BundleActivePowerStateCallbackProxy::OnPowerStateChanged(PowerMgr::PowerState state)
22 {
23     sptr<IRemoteObject> remote = Remote();
24     if (remote == nullptr) {
25         return;
26     }
27     MessageParcel data;
28     data.WriteInt32((int32_t)state);
29     MessageParcel reply;
30     MessageOption option;
31     if (!data.WriteInterfaceToken(BundleActivePowerStateCallbackProxy::GetDescriptor())) {
32         return;
33     }
34     int32_t ret = remote->SendRequest(IPowerStateCallback::POWER_STATE_CHANGED, data, reply, option);
35     if (ret != ERR_OK) {
36         BUNDLE_ACTIVE_LOGE("BundleActivePowerStateCallbackProxy::PowerStateCallback failed!");
37     }
38 }
39 }  // namespace DeviceUsageStats
40 }  // namespace OHOS
41 
42