• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_proxy.h"
17 
18 #include <gslogger.h>
19 
20 namespace OHOS {
21 namespace {
22 DEFINE_HILOG_LABEL("AnimationServiceProxy");
23 } // namespace
24 
AnimationServiceProxy(const sptr<IRemoteObject> & impl)25 AnimationServiceProxy::AnimationServiceProxy(const sptr<IRemoteObject>& impl)
26     : IRemoteProxy<IAnimationService>(impl)
27 {
28 }
29 
StartRotationAnimation(int32_t did,int32_t degree)30 GSError AnimationServiceProxy::StartRotationAnimation(int32_t did, int32_t degree)
31 {
32     MessageParcel data;
33     MessageParcel reply;
34     MessageOption option;
35 
36     auto retval = data.WriteInterfaceToken(GetDescriptor());
37     if (!retval) {
38         GSLOG2HI(ERROR) << "WriteInterfaceToken failed";
39         return GSERROR_INVALID_ARGUMENTS;
40     }
41 
42     data.WriteInt32(did);
43     data.WriteInt32(degree);
44 
45     int32_t res = Remote()->SendRequest(START_ROTATION_ANIMATION, data, reply, option);
46     if (res) {
47         GSLOG2HI(ERROR) << "SendRequest failed, retval=" << res;
48         return GSERROR_BINDER;
49     }
50 
51     GSError ret = static_cast<enum GSError>(reply.ReadInt32());
52     if (ret != GSERROR_OK) {
53         GSLOG2HI(ERROR) << "Call return failed: " << ret;
54     }
55 
56     return ret;
57 }
58 
SplitModeCreateBackground()59 GSError AnimationServiceProxy::SplitModeCreateBackground()
60 {
61     MessageParcel data;
62     MessageParcel reply;
63     MessageOption option;
64 
65     auto retval = data.WriteInterfaceToken(GetDescriptor());
66     if (!retval) {
67         GSLOG2HI(ERROR) << "WriteInterfaceToken failed";
68         return GSERROR_INVALID_ARGUMENTS;
69     }
70 
71     int32_t res = Remote()->SendRequest(SPLIT_MODE_CREATE_BACKGOUND, data, reply, option);
72     if (res) {
73         GSLOG2HI(ERROR) << "SendRequest failed, retval=" << res;
74         return GSERROR_BINDER;
75     }
76 
77     GSError ret = static_cast<enum GSError>(reply.ReadInt32());
78     if (ret != GSERROR_OK) {
79         GSLOG2HI(ERROR) << "Call return failed: " << ret;
80     }
81 
82     return ret;
83 }
84 
SplitModeCreateMiddleLine()85 GSError AnimationServiceProxy::SplitModeCreateMiddleLine()
86 {
87     MessageParcel data;
88     MessageParcel reply;
89     MessageOption option;
90 
91     auto retval = data.WriteInterfaceToken(GetDescriptor());
92     if (!retval) {
93         GSLOG2HI(ERROR) << "WriteInterfaceToken failed";
94         return GSERROR_INVALID_ARGUMENTS;
95     }
96 
97     int32_t res = Remote()->SendRequest(SPLIT_MODE_CREATE_MIDDLE_LINE, data, reply, option);
98     if (res) {
99         GSLOG2HI(ERROR) << "SendRequest failed, retval=" << res;
100         return GSERROR_BINDER;
101     }
102 
103     GSError ret = static_cast<enum GSError>(reply.ReadInt32());
104     if (ret != GSERROR_OK) {
105         GSLOG2HI(ERROR) << "Call return failed: " << ret;
106     }
107 
108     return ret;
109 }
110 
CreateLaunchPage(const std::string & filename)111 GSError AnimationServiceProxy::CreateLaunchPage(const std::string &filename)
112 {
113     MessageParcel data;
114     MessageParcel reply;
115     MessageOption option;
116 
117     auto retval = data.WriteInterfaceToken(GetDescriptor());
118     if (!retval) {
119         GSLOG2HI(ERROR) << "WriteInterfaceToken failed";
120         return GSERROR_INVALID_ARGUMENTS;
121     }
122 
123     data.WriteString(filename);
124     int32_t res = Remote()->SendRequest(CREATE_LAUNCH_PAGE, data, reply, option);
125     if (res) {
126         GSLOG2HI(ERROR) << "SendRequest failed, retval=" << res;
127         return GSERROR_BINDER;
128     }
129 
130     GSError ret = static_cast<enum GSError>(reply.ReadInt32());
131     if (ret != GSERROR_OK) {
132         GSLOG2HI(ERROR) << "Call return failed: " << ret;
133     }
134 
135     return ret;
136 }
137 
CancelLaunchPage()138 GSError AnimationServiceProxy::CancelLaunchPage()
139 {
140     MessageParcel data;
141     MessageParcel reply;
142     MessageOption option;
143 
144     auto retval = data.WriteInterfaceToken(GetDescriptor());
145     if (!retval) {
146         GSLOG2HI(ERROR) << "WriteInterfaceToken failed";
147         return GSERROR_INVALID_ARGUMENTS;
148     }
149 
150     int32_t res = Remote()->SendRequest(DESTROY_LAUNCH_PAGE, data, reply, option);
151     if (res) {
152         GSLOG2HI(ERROR) << "SendRequest failed, retval=" << res;
153         return GSERROR_BINDER;
154     }
155 
156     GSError ret = static_cast<enum GSError>(reply.ReadInt32());
157     if (ret != GSERROR_OK) {
158         GSLOG2HI(ERROR) << "Call return failed: " << ret;
159     }
160 
161     return ret;
162 }
163 } // namespace OHOS
164