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 "animation_service_stub.h"
17
18 #include <gslogger.h>
19
20 namespace OHOS {
21 namespace {
22 DEFINE_HILOG_LABEL("AnimationServiceStub");
23 } // namespace
24
AnimationServiceStub()25 AnimationServiceStub::AnimationServiceStub()
26 {
27 memberFuncMap_[START_ROTATION_ANIMATION] = &AnimationServiceStub::StartRotationAnimationRemote;
28 memberFuncMap_[SPLIT_MODE_CREATE_BACKGOUND] = &AnimationServiceStub::SplitModeCreateBackgroundRemote;
29 memberFuncMap_[SPLIT_MODE_CREATE_MIDDLE_LINE] = &AnimationServiceStub::SplitModeCreateMiddleLineRemote;
30 memberFuncMap_[CREATE_LAUNCH_PAGE] = &AnimationServiceStub::CreateLaunchPageRemote;
31 memberFuncMap_[DESTROY_LAUNCH_PAGE] = &AnimationServiceStub::CancelLaunchPageRemote;
32 }
33
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)34 int32_t AnimationServiceStub::OnRemoteRequest(uint32_t code,
35 MessageParcel &data, MessageParcel &reply, MessageOption &option)
36 {
37 auto remoteDescriptor = data.ReadInterfaceToken();
38 if (GetDescriptor() != remoteDescriptor) {
39 GSLOG2HI(ERROR) << "Wrong Descriptor";
40 return ERR_INVALID_STATE;
41 }
42
43 auto it = memberFuncMap_.find(code);
44 if (it == memberFuncMap_.end()) {
45 GSLOG2HI(ERROR) << "Cannot process " << code;
46 return ERR_INVALID_STATE;
47 }
48
49 return (this->*(it->second))(data, reply, option);
50 }
51
StartRotationAnimationRemote(MessageParcel & data,MessageParcel & reply,MessageOption & options)52 int32_t AnimationServiceStub::StartRotationAnimationRemote(MessageParcel& data,
53 MessageParcel& reply, MessageOption& options)
54 {
55 auto did = data.ReadInt32();
56 auto degree = data.ReadInt32();
57 auto gret = StartRotationAnimation(did, degree);
58 reply.WriteInt32(gret);
59 return 0;
60 }
61
SplitModeCreateBackgroundRemote(MessageParcel & data,MessageParcel & reply,MessageOption & options)62 int32_t AnimationServiceStub::SplitModeCreateBackgroundRemote(MessageParcel& data,
63 MessageParcel& reply, MessageOption& options)
64 {
65 reply.WriteInt32(SplitModeCreateBackground());
66 return 0;
67 }
68
SplitModeCreateMiddleLineRemote(MessageParcel & data,MessageParcel & reply,MessageOption & options)69 int32_t AnimationServiceStub::SplitModeCreateMiddleLineRemote(MessageParcel& data,
70 MessageParcel& reply, MessageOption& options)
71 {
72 reply.WriteInt32(SplitModeCreateMiddleLine());
73 return 0;
74 }
75
CreateLaunchPageRemote(MessageParcel & data,MessageParcel & reply,MessageOption & options)76 int32_t AnimationServiceStub::CreateLaunchPageRemote(MessageParcel& data,
77 MessageParcel& reply, MessageOption& options)
78 {
79 auto filename = data.ReadString();
80 auto gret = CreateLaunchPage(filename);
81 reply.WriteInt32(gret);
82 return 0;
83 }
84
CancelLaunchPageRemote(MessageParcel & data,MessageParcel & reply,MessageOption & options)85 int32_t AnimationServiceStub::CancelLaunchPageRemote(MessageParcel& data,
86 MessageParcel& reply, MessageOption& options)
87 {
88 reply.WriteInt32(CancelLaunchPage());
89 return 0;
90 }
91 } // namespace OHOS
92