• 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 "time_service_proxy.h"
17 
18 #include "iremote_broker.h"
19 #include "message_option.h"
20 #include "time_common.h"
21 #include "time_service_ipc_interface_code.h"
22 
23 namespace OHOS {
24 namespace MiscServices {
25 using namespace OHOS::HiviewDFX;
26 
TimeServiceProxy(const sptr<IRemoteObject> & object)27 TimeServiceProxy::TimeServiceProxy(const sptr<IRemoteObject> &object) : IRemoteProxy<ITimeService>(object)
28 {
29 }
30 
SetTime(int64_t time,APIVersion apiVersion)31 int32_t TimeServiceProxy::SetTime(int64_t time, APIVersion apiVersion)
32 {
33     MessageParcel data, reply;
34     MessageOption option;
35     if (!data.WriteInterfaceToken(GetDescriptor())) {
36         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write descriptor");
37         return E_TIME_WRITE_PARCEL_ERROR;
38     }
39     if (!data.WriteInt64(time)) {
40         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write time");
41         return E_TIME_WRITE_PARCEL_ERROR;
42     }
43     if (!data.WriteInt8(apiVersion)) {
44         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write apiVersion");
45         return E_TIME_WRITE_PARCEL_ERROR;
46     }
47     int32_t result =
48         Remote()->SendRequest(static_cast<uint32_t>(TimeServiceIpcInterfaceCode::SET_TIME), data, reply, option);
49     if (result != ERR_NONE) {
50         TIME_HILOGE(TIME_MODULE_CLIENT, "SetTime failed, error code is: %{public}d", result);
51         return result;
52     }
53     return result;
54 }
55 
CreateTimer(const std::shared_ptr<ITimerInfo> & timerOptions,sptr<IRemoteObject> & timerCallback,uint64_t & timerId)56 int32_t TimeServiceProxy::CreateTimer(const std::shared_ptr<ITimerInfo> &timerOptions,
57     sptr<IRemoteObject> &timerCallback, uint64_t &timerId)
58 {
59     MessageParcel data, reply;
60     MessageOption option;
61     if (!data.WriteInterfaceToken(GetDescriptor())) {
62         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write descriptor");
63         return E_TIME_WRITE_PARCEL_ERROR;
64     }
65     if (!data.WriteInt32(timerOptions->type)) {
66         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write type");
67         return E_TIME_WRITE_PARCEL_ERROR;
68     }
69     if (!data.WriteBool(timerOptions->repeat)) {
70         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write repeat");
71         return E_TIME_WRITE_PARCEL_ERROR;
72     }
73     if (!data.WriteBool(timerOptions->disposable)) {
74         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write disposable");
75         return E_TIME_WRITE_PARCEL_ERROR;
76     }
77     if (!data.WriteUint64(timerOptions->interval)) {
78         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write interval");
79         return E_TIME_WRITE_PARCEL_ERROR;
80     }
81     if (!data.WriteBool(timerOptions->wantAgent != nullptr)) {
82         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write wantAgent status");
83         return E_TIME_WRITE_PARCEL_ERROR;
84     }
85     if (timerOptions->wantAgent != nullptr) {
86         if (!data.WriteParcelable(&(*timerOptions->wantAgent))) {
87             TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write wantAgent");
88             return E_TIME_WRITE_PARCEL_ERROR;
89         }
90     }
91     if (!data.WriteRemoteObject(timerCallback)) {
92         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write timerCallback");
93         return E_TIME_WRITE_PARCEL_ERROR;
94     }
95     if (!data.WriteUint64(timerId)) {
96         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write timerId");
97         return E_TIME_WRITE_PARCEL_ERROR;
98     }
99     auto ret =
100         Remote()->SendRequest(static_cast<uint32_t>(TimeServiceIpcInterfaceCode::CREATE_TIMER), data, reply, option);
101     if (ret == E_TIME_OK) {
102         timerId = reply.ReadUint64();
103         return E_TIME_OK;
104     }
105     return ret;
106 }
107 
StartTimer(uint64_t timerId,uint64_t triggerTime)108 int32_t TimeServiceProxy::StartTimer(uint64_t timerId, uint64_t triggerTime)
109 {
110     MessageParcel data, reply;
111     MessageOption option;
112     if (!data.WriteInterfaceToken(GetDescriptor())) {
113         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write descriptor");
114         return E_TIME_WRITE_PARCEL_ERROR;
115     }
116     if (!data.WriteUint64(timerId)) {
117         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write timerId");
118         return E_TIME_WRITE_PARCEL_ERROR;
119     }
120     if (!data.WriteUint64(triggerTime)) {
121         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write triggerTime");
122         return E_TIME_WRITE_PARCEL_ERROR;
123     }
124     return Remote()->SendRequest(static_cast<uint32_t>(TimeServiceIpcInterfaceCode::START_TIMER), data, reply, option);
125 }
126 
StopTimer(uint64_t timerId)127 int32_t TimeServiceProxy::StopTimer(uint64_t timerId)
128 {
129     MessageParcel data, reply;
130     MessageOption option;
131     if (!data.WriteInterfaceToken(GetDescriptor())) {
132         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write descriptor");
133         return E_TIME_WRITE_PARCEL_ERROR;
134     }
135     if (!data.WriteUint64(timerId)) {
136         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write timerId");
137         return E_TIME_WRITE_PARCEL_ERROR;
138     }
139     return Remote()->SendRequest(static_cast<uint32_t>(TimeServiceIpcInterfaceCode::STOP_TIMER), data, reply, option);
140 }
141 
DestroyTimer(uint64_t timerId,bool isAsync)142 int32_t TimeServiceProxy::DestroyTimer(uint64_t timerId, bool isAsync)
143 {
144     MessageParcel data, reply;
145     MessageOption option;
146     if (!data.WriteInterfaceToken(GetDescriptor())) {
147         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write descriptor");
148         return E_TIME_WRITE_PARCEL_ERROR;
149     }
150     if (!data.WriteUint64(timerId)) {
151         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write timerId");
152         return E_TIME_WRITE_PARCEL_ERROR;
153     }
154 
155     if (isAsync) {
156         option.SetFlags(MessageOption::TF_ASYNC);
157     }
158     return Remote()->SendRequest(
159         static_cast<uint32_t>(TimeServiceIpcInterfaceCode::DESTROY_TIMER), data, reply, option);
160 }
161 
SetTimeZone(const std::string & timeZoneId,APIVersion apiVersion)162 int32_t TimeServiceProxy::SetTimeZone(const std::string &timeZoneId, APIVersion apiVersion)
163 {
164     MessageParcel data, reply;
165     MessageOption option;
166     if (!data.WriteInterfaceToken(GetDescriptor())) {
167         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write descriptor");
168         return E_TIME_WRITE_PARCEL_ERROR;
169     }
170     if (!data.WriteString(timeZoneId)) {
171         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write timeZoneId");
172         return E_TIME_WRITE_PARCEL_ERROR;
173     }
174     if (!data.WriteInt8(apiVersion)) {
175         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write apiVersion");
176         return E_TIME_WRITE_PARCEL_ERROR;
177     }
178     int32_t result =
179         Remote()->SendRequest(static_cast<uint32_t>(TimeServiceIpcInterfaceCode::SET_TIME_ZONE), data, reply, option);
180     if (result != ERR_NONE) {
181         TIME_HILOGE(TIME_MODULE_CLIENT, "SetTimeZone failed, error code is: %{public}d", result);
182         return result;
183     }
184     return result;
185 }
186 
GetTimeZone(std::string & timeZoneId)187 int32_t TimeServiceProxy::GetTimeZone(std::string &timeZoneId)
188 {
189     MessageParcel data, reply;
190     MessageOption option;
191     if (!data.WriteInterfaceToken(GetDescriptor())) {
192         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write descriptor");
193         return E_TIME_WRITE_PARCEL_ERROR;
194     }
195     int32_t result =
196         Remote()->SendRequest(static_cast<uint32_t>(TimeServiceIpcInterfaceCode::GET_TIME_ZONE), data, reply, option);
197     if (result != ERR_NONE) {
198         TIME_HILOGE(TIME_MODULE_CLIENT, "GetTimeZone failed, error code is: %{public}d", result);
199         return result;
200     }
201     timeZoneId = reply.ReadString();
202     return result;
203 }
204 
GetWallTimeMs(int64_t & times)205 int32_t TimeServiceProxy::GetWallTimeMs(int64_t &times)
206 {
207     MessageParcel data, reply;
208     MessageOption option;
209     if (!data.WriteInterfaceToken(GetDescriptor())) {
210         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write descriptor");
211         return E_TIME_WRITE_PARCEL_ERROR;
212     }
213     int32_t result = Remote()->SendRequest(
214         static_cast<uint32_t>(TimeServiceIpcInterfaceCode::GET_WALL_TIME_MILLI), data, reply, option);
215     if (result != ERR_NONE) {
216         TIME_HILOGE(TIME_MODULE_CLIENT, "GetWallTimeMs failed, error code is: %{public}d", result);
217         return result;
218     }
219     times = reply.ReadInt64();
220     return result;
221 }
222 
GetWallTimeNs(int64_t & times)223 int32_t TimeServiceProxy::GetWallTimeNs(int64_t &times)
224 {
225     MessageParcel data, reply;
226     MessageOption option;
227     if (!data.WriteInterfaceToken(GetDescriptor())) {
228         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write descriptor");
229         return E_TIME_WRITE_PARCEL_ERROR;
230     }
231     int32_t result = Remote()->SendRequest(
232         static_cast<uint32_t>(TimeServiceIpcInterfaceCode::GET_WALL_TIME_NANO), data, reply, option);
233     if (result != ERR_NONE) {
234         TIME_HILOGE(TIME_MODULE_CLIENT, "GetWallTimeNs failed, error code is: %{public}d", result);
235         return result;
236     }
237     times = reply.ReadInt64();
238     return result;
239 }
240 
GetBootTimeMs(int64_t & times)241 int32_t TimeServiceProxy::GetBootTimeMs(int64_t &times)
242 {
243     MessageParcel data, reply;
244     MessageOption option;
245     if (!data.WriteInterfaceToken(GetDescriptor())) {
246         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write descriptor");
247         return E_TIME_WRITE_PARCEL_ERROR;
248     }
249     int32_t result = Remote()->SendRequest(
250         static_cast<uint32_t>(TimeServiceIpcInterfaceCode::GET_BOOT_TIME_MILLI), data, reply, option);
251     if (result != ERR_NONE) {
252         TIME_HILOGE(TIME_MODULE_CLIENT, "GetBootTimeMs failed, error code is: %{public}d", result);
253         return result;
254     }
255     times = reply.ReadInt64();
256     return result;
257 }
258 
GetBootTimeNs(int64_t & times)259 int32_t TimeServiceProxy::GetBootTimeNs(int64_t &times)
260 {
261     MessageParcel data, reply;
262     MessageOption option;
263     if (!data.WriteInterfaceToken(GetDescriptor())) {
264         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write parcelable");
265         return E_TIME_WRITE_PARCEL_ERROR;
266     }
267     int32_t result = Remote()->SendRequest(
268         static_cast<uint32_t>(TimeServiceIpcInterfaceCode::GET_BOOT_TIME_NANO), data, reply, option);
269     if (result != ERR_NONE) {
270         TIME_HILOGE(TIME_MODULE_CLIENT, "GetBootTimeNs failed, error code is: %{public}d", result);
271         return result;
272     }
273     times = reply.ReadInt64();
274     return result;
275 }
276 
GetMonotonicTimeMs(int64_t & times)277 int32_t TimeServiceProxy::GetMonotonicTimeMs(int64_t &times)
278 {
279     MessageParcel data, reply;
280     MessageOption option;
281     if (!data.WriteInterfaceToken(GetDescriptor())) {
282         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write descriptor");
283         return E_TIME_WRITE_PARCEL_ERROR;
284     }
285     int32_t result = Remote()->SendRequest(
286         static_cast<uint32_t>(TimeServiceIpcInterfaceCode::GET_MONO_TIME_MILLI), data, reply, option);
287     if (result != ERR_NONE) {
288         TIME_HILOGE(TIME_MODULE_CLIENT, "GetMonotonicTimeMs failed, error code is: %{public}d", result);
289         return result;
290     }
291     times = reply.ReadInt64();
292     return result;
293 }
294 
GetMonotonicTimeNs(int64_t & times)295 int32_t TimeServiceProxy::GetMonotonicTimeNs(int64_t &times)
296 {
297     MessageParcel data, reply;
298     MessageOption option;
299     if (!data.WriteInterfaceToken(GetDescriptor())) {
300         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write descriptor");
301         return E_TIME_WRITE_PARCEL_ERROR;
302     }
303     int32_t result = Remote()->SendRequest(
304         static_cast<uint32_t>(TimeServiceIpcInterfaceCode::GET_MONO_TIME_NANO), data, reply, option);
305     if (result != ERR_NONE) {
306         TIME_HILOGE(TIME_MODULE_CLIENT, "GetMonotonicTimeNs failed, error code is: %{public}d", result);
307         return result;
308     }
309     times = reply.ReadInt64();
310     return result;
311 }
312 
GetThreadTimeMs(int64_t & times)313 int32_t TimeServiceProxy::GetThreadTimeMs(int64_t &times)
314 {
315     MessageParcel data, reply;
316     MessageOption option;
317     if (!data.WriteInterfaceToken(GetDescriptor())) {
318         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write descriptor");
319         return E_TIME_WRITE_PARCEL_ERROR;
320     }
321     int32_t result = Remote()->SendRequest(
322         static_cast<uint32_t>(TimeServiceIpcInterfaceCode::GET_THREAD_TIME_MILLI), data, reply, option);
323     if (result != ERR_NONE) {
324         TIME_HILOGE(TIME_MODULE_CLIENT, "GetThreadTimeMs failed, error code is: %{public}d", result);
325         return result;
326     }
327     times = reply.ReadInt64();
328     return result;
329 }
330 
GetThreadTimeNs(int64_t & times)331 int32_t TimeServiceProxy::GetThreadTimeNs(int64_t &times)
332 {
333     MessageParcel data, reply;
334     MessageOption option;
335     if (!data.WriteInterfaceToken(GetDescriptor())) {
336         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write descriptor");
337         return E_TIME_WRITE_PARCEL_ERROR;
338     }
339     int32_t result = Remote()->SendRequest(
340         static_cast<uint32_t>(TimeServiceIpcInterfaceCode::GET_THREAD_TIME_NANO), data, reply, option);
341     if (result != ERR_NONE) {
342         TIME_HILOGE(TIME_MODULE_CLIENT, "GetThreadTimeNs failed, error code is: %{public}d", result);
343         return result;
344     }
345     times = reply.ReadInt64();
346     return result;
347 }
348 
ProxyTimer(int32_t uid,bool isProxy,bool needRetrigger)349 bool TimeServiceProxy::ProxyTimer(int32_t uid, bool isProxy, bool needRetrigger)
350 {
351     MessageParcel data, reply;
352     MessageOption option;
353     if (!data.WriteInterfaceToken(GetDescriptor())) {
354         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write descriptor");
355         return false;
356     }
357     if (!data.WriteInt32(uid)) {
358         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write uid");
359         return false;
360     }
361     if (!data.WriteBool(isProxy)) {
362         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write isProxy");
363         return false;
364     }
365     if (!data.WriteBool(needRetrigger)) {
366         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write needRetrigger");
367         return false;
368     }
369 
370     int32_t result =
371         Remote()->SendRequest(static_cast<uint32_t>(TimeServiceIpcInterfaceCode::PROXY_TIMER), data, reply, option);
372     if (result != ERR_NONE) {
373         TIME_HILOGE(TIME_MODULE_CLIENT, "ProxyTimer failed, error code is: %{public}d", result);
374         return false;
375     }
376     return true;
377 }
378 
ProxyTimer(int32_t uid,std::set<int> pidList,bool isProxy,bool needRetrigger)379 bool TimeServiceProxy::ProxyTimer(int32_t uid, std::set<int> pidList, bool isProxy, bool needRetrigger)
380 {
381     MessageParcel data, reply;
382     MessageOption option;
383     if (!data.WriteInterfaceToken(GetDescriptor())) {
384         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write descriptor");
385         return false;
386     }
387     if (!data.WriteInt32(uid)) {
388         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write uid");
389         return false;
390     }
391     if (!data.WriteInt32(pidList.size())) {
392         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write pid size");
393         return false;
394     }
395     for (std::set<int>::iterator pid = pidList.begin(); pid != pidList.end(); ++pid) {
396         if (!data.WriteInt32(*pid)) {
397             TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write pid");
398             return false;
399         }
400     }
401     if (!data.WriteBool(isProxy)) {
402         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write isProxy");
403         return false;
404     }
405     if (!data.WriteBool(needRetrigger)) {
406         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write needRetrigger");
407         return false;
408     }
409 
410     int32_t result =
411         Remote()->SendRequest(static_cast<uint32_t>(TimeServiceIpcInterfaceCode::PID_PROXY_TIMER), data, reply, option);
412     if (result != ERR_NONE) {
413         TIME_HILOGE(TIME_MODULE_CLIENT, "ProxyTimer failed, error code is: %{public}d", result);
414         return false;
415     }
416     return true;
417 }
418 
AdjustTimer(bool isAdjust,uint32_t interval)419 int32_t TimeServiceProxy::AdjustTimer(bool isAdjust, uint32_t interval)
420 {
421     MessageParcel data;
422     MessageParcel reply;
423     MessageOption option;
424     if (!data.WriteInterfaceToken(GetDescriptor())) {
425         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write descriptor");
426         return E_TIME_WRITE_PARCEL_ERROR;
427     }
428     if (!data.WriteBool(isAdjust)) {
429         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write adjust state");
430         return E_TIME_WRITE_PARCEL_ERROR;
431     }
432     if (!data.WriteUint32(interval)) {
433         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write interval");
434         return E_TIME_WRITE_PARCEL_ERROR;
435     }
436     int32_t result =
437         Remote()->SendRequest(static_cast<uint32_t>(TimeServiceIpcInterfaceCode::ADJUST_TIMER), data, reply, option);
438     if (result != ERR_NONE) {
439         TIME_HILOGE(TIME_MODULE_CLIENT, "Adjust Timer failed, error code is: %{public}d", result);
440         return result;
441     }
442     return result;
443 }
444 
SetTimerExemption(const std::unordered_set<std::string> & nameArr,bool isExemption)445 int32_t TimeServiceProxy::SetTimerExemption(const std::unordered_set<std::string> &nameArr, bool isExemption)
446 {
447     MessageParcel data;
448     MessageParcel reply;
449     MessageOption option;
450     if (!data.WriteInterfaceToken(GetDescriptor())) {
451         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write descriptor");
452         return E_TIME_WRITE_PARCEL_ERROR;
453     }
454 
455     if (nameArr.empty()) {
456         TIME_HILOGE(TIME_MODULE_CLIENT, "Nothing need cache");
457         return E_TIME_NOT_FOUND;
458     }
459 
460     uint32_t size = static_cast<uint32_t>(nameArr.size());
461     if (!data.WriteUint32(size)) {
462         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write size");
463         return E_TIME_WRITE_PARCEL_ERROR;
464     }
465 
466     for (auto name : nameArr) {
467         if (!data.WriteString(name)) {
468             TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write name");
469             return E_TIME_WRITE_PARCEL_ERROR;
470         }
471     }
472 
473     if (!data.WriteBool(isExemption)) {
474         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write is exemption");
475         return E_TIME_WRITE_PARCEL_ERROR;
476     }
477 
478     int32_t result =
479         Remote()->SendRequest(static_cast<uint32_t>(TimeServiceIpcInterfaceCode::SET_TIMER_EXEMPTION),
480             data, reply, option);
481     if (result != ERR_NONE) {
482         TIME_HILOGE(TIME_MODULE_CLIENT, "Set Timer Exemption failed, error code is: %{public}d", result);
483         return result;
484     }
485     return result;
486 }
487 
ResetAllProxy()488 bool TimeServiceProxy::ResetAllProxy()
489 {
490     MessageParcel data, reply;
491     MessageOption option;
492     if (!data.WriteInterfaceToken(GetDescriptor())) {
493         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write descriptor");
494         return false;
495     }
496     int32_t result = Remote()->SendRequest(
497         static_cast<uint32_t>(TimeServiceIpcInterfaceCode::RESET_ALL_PROXY), data, reply, option);
498     if (result != ERR_NONE) {
499         TIME_HILOGE(TIME_MODULE_CLIENT, "ProxyTimer failed, error code is: %{public}d", result);
500         return false;
501     }
502     return true;
503 }
504 
GetNtpTimeMs(int64_t & time)505 int32_t TimeServiceProxy::GetNtpTimeMs(int64_t &time)
506 {
507     MessageParcel data;
508     MessageParcel reply;
509     MessageOption option;
510     if (!data.WriteInterfaceToken(GetDescriptor())) {
511         TIME_HILOGE(TIME_MODULE_CLIENT, "Failed to write descriptor");
512         return E_TIME_WRITE_PARCEL_ERROR;
513     }
514     int32_t result = Remote()->SendRequest(
515         static_cast<uint32_t>(TimeServiceIpcInterfaceCode::GET_NTP_TIME_MILLI), data, reply, option);
516     if (result != ERR_NONE) {
517         TIME_HILOGE(TIME_MODULE_CLIENT, "GetNtpTimeMs failed, error code is: %{public}d", result);
518         return result;
519     }
520     time = reply.ReadInt64();
521     return result;
522 }
523 } // namespace MiscServices
524 } // namespace OHOS