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 #include "hiview_shutdown_callback_stub.h"
16
17 #include <message_parcel.h>
18
19 namespace OHOS {
20 namespace HiviewDFX {
21 namespace {
22 constexpr int ERR_DEFAULT = -1;
23 }
24
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)25 int HiViewShutdownCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
26 MessageOption &option)
27 {
28 std::u16string descripter = HiViewShutdownCallbackStub::GetDescriptor();
29 std::u16string remoteDescripter = data.ReadInterfaceToken();
30 if (descripter != remoteDescripter) {
31 return ERR_DEFAULT;
32 }
33
34 switch (code) {
35 case static_cast<uint32_t>(PowerMgr::IShutdownCallback::POWER_SHUTDOWN_CHANGED): {
36 ShutdownStub();
37 return ERR_OK;
38 }
39 default: {
40 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
41 }
42 }
43 }
44
ShutdownStub()45 void HiViewShutdownCallbackStub::ShutdownStub()
46 {
47 ShutdownCallback();
48 }
49 } // namespace HiviewDFX
50 } // namespace OHOS
51