• 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_stub.h"
17 #include "bundle_active_event.h"
18 
19 namespace OHOS {
20 namespace DeviceUsageStats {
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)21 int32_t BundleActivePowerStateCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel &reply,
22     MessageOption &option)
23 {
24     std::u16string descriptor = BundleActivePowerStateCallbackStub::GetDescriptor();
25     std::u16string remoteDescriptor = data.ReadInterfaceToken();
26     PowerMgr::PowerState state = static_cast<PowerMgr::PowerState>(data.ReadInt32());
27     if (descriptor != remoteDescriptor) {
28         BUNDLE_ACTIVE_LOGE("BundleActivePowerStateCallbackStub::OnRemoteRequest cannot get power mgr service");
29         return -1;
30     }
31     switch (code) {
32         case IPowerStateCallback::POWER_STATE_CHANGED: {
33             PowerStateStub(state);
34             return ERR_OK;
35         }
36         default:
37             return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
38         }
39 }
40 
PowerStateStub(PowerMgr::PowerState state)41 void BundleActivePowerStateCallbackStub::PowerStateStub(PowerMgr::PowerState state)
42 {
43     OnPowerStateChanged(state);
44 }
45 }  // namespace DeviceUsageStats
46 }  // namespace OHOS
47 
48