1 /*
2  * Copyright (c) 2021-2024 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 #ifndef SERVICES_DTBSCHEDMGR_INCLUDE_DTBSCHEDMGR_LOG_H_
17 #define SERVICES_DTBSCHEDMGR_INCLUDE_DTBSCHEDMGR_LOG_H_
18 
19 #include "errors.h"
20 #include "hilog/log.h"
21 #include "inttypes.h"
22 
23 namespace OHOS {
24 namespace DistributedSchedule {
25 #undef LOG_DOMAIN
26 #define LOG_DOMAIN 0xD004170
27 
28 #undef LOG_TAG
29 #define LOG_TAG "DSched_Service"
30 
31 #ifdef HILOGD
32 #undef HILOGD
33 #endif
34 
35 #ifdef HILOGF
36 #undef HILOGF
37 #endif
38 
39 #ifdef HILOGE
40 #undef HILOGE
41 #endif
42 
43 #ifdef HILOGW
44 #undef HILOGW
45 #endif
46 
47 #ifdef HILOGI
48 #undef HILOGI
49 #endif
50 
51 #define HILOGF(fmt, ...) HILOG_FATAL(LOG_CORE, "%{public}s::%{public}s " fmt, TAG.c_str(), __FUNCTION__, ##__VA_ARGS__)
52 #define HILOGE(fmt, ...) HILOG_ERROR(LOG_CORE, "%{public}s::%{public}s " fmt, TAG.c_str(), __FUNCTION__, ##__VA_ARGS__)
53 #define HILOGW(fmt, ...) HILOG_WARN(LOG_CORE, "%{public}s::%{public}s " fmt, TAG.c_str(), __FUNCTION__, ##__VA_ARGS__)
54 #define HILOGI(fmt, ...) HILOG_INFO(LOG_CORE, "%{public}s::%{public}s " fmt, TAG.c_str(), __FUNCTION__, ##__VA_ARGS__)
55 #define HILOGD(fmt, ...) HILOG_DEBUG(LOG_CORE, "%{public}s::%{public}s " fmt, TAG.c_str(), __FUNCTION__, ##__VA_ARGS__)
56 
57 enum {
58     /**
59      * Module type: Distributed schedule Service side
60      */
61     DMS_MODULE_TYPE_SERVICE = 0,
62 };
63 
64 // offset of dms error, only be used in this file.
65 constexpr ErrCode DMS_SERVICE_ERR_OFFSET = ErrCodeOffset(SUBSYS_DISTRIBUTEDSCHEDULE, DMS_MODULE_TYPE_SERVICE);
66 
67 enum DmsInterfaceSdkErr {
68     /**
69      * Result(16300501) for the distributed sched work abnormally.
70      */
71     ERR_DMS_WORK_ABNORMALLY = 16300501,
72     /**
73      * Result(16300503) throw to js for the application is not installed on the remote end and installation-free is
74      * not supported.
75      */
76     ERR_REMOTE_UNINSTALLED_AND_UNFREEINSTALL = 16300503,
77     /**
78      * Result(16300504) throw to js for the application is not installed on the remote end but installation-free is
79      * supported, try again with freeInstall flag.
80      */
81     ERR_CONTINUE_WITHOUT_FREEINSTALL_FLAG = 16300504,
82     /**
83      * Result(16300506) throw to js for the local continuation task is already in progress.
84      */
85     ERR_CONTINUE_ALREADY_IN_PROGRESS = 16300506,
86     /**
87      * Result(16300507) throw to js for Failed to get the missionInfo of the specified bundle name.
88      */
89     ERR_GET_MISSION_INFO_OF_BUNDLE_NAME = 16300507,
90     /**
91      * Result(16300508) throw to js for bind error due to the remote device hotspot enable, try again after disable
92      * the remote device hotspot.
93      */
94     ERR_BIND_REMOTE_HOTSPOT_ENABLE_STATE = 16300508,
95     /**
96      * Result(16300509) throw to js for the remote device has been linked with other devices, try again when
97      * the remote device is idle.
98      */
99     ERR_BIND_REMOTE_IN_BUSY_LINK = 16300509,
100 };
101 
102 enum {
103     /**
104      * Result(29360128) for invalid parameters.
105      */
106     INVALID_PARAMETERS_ERR = DMS_SERVICE_ERR_OFFSET,
107      /**
108      * Result(29360129) for no response when RPC call.
109      */
110     RPC_CALL_NORESPONSE_ERR = 29360129,
111     /**
112      * Result(29360130) for not find connect callback.
113      */
114     NO_CONNECT_CALLBACK_ERR = 29360130,
115     /**
116      * Result(29360131) for remote invalid parameters.
117      */
118     INVALID_REMOTE_PARAMETERS_ERR = 29360131,
119     /**
120      * Result(29360132) for remote device fail to bind ability.
121      */
122     REMOTE_DEVICE_BIND_ABILITY_ERR = 29360132,
123     /**
124      * Result(29360133) for remote device fail to unbind ability.
125      */
126     REMOTE_DEVICE_UNBIND_ABILITY_ERR = 29360133,
127     /**
128      * Result(29360134) for remote invalid parameters.
129      */
130     REMOTE_FAIL_GET_SHELLINFO_ERR = 29360134,
131     /**
132      * Result(29360135) for remote device fail to start ability.
133      */
134     REMOTE_DEVICE_START_ABILITY_ERR = 29360135,
135     /**
136      * Result(29360136) for remote device fail to stop ability.
137      */
138     REMOTE_DEVICE_STOP_ABILITY_ERR = 29360136,
139     /**
140      * Result(29360137) for reg repeat ability token.
141      */
142     REG_REPEAT_ABILITY_TOKEN_ERR = 29360137,
143     /**
144      * Result(29360138) for no ability token.
145      */
146     NO_ABILITY_TOKEN_ERR = 29360138,
147     /**
148      * Result(29360139) for no appthread.
149      */
150     NO_APP_THREAD_ERR = 29360139,
151     /**
152      * Result(29360140) for select device continue error.
153      */
154     SELECT_DEVICE_CONTINUE_ERR = 29360140,
155     /**
156      * Result(29360141) for dump write file error.
157      */
158     DMS_WRITE_FILE_FAILED_ERR = 29360141,
159     /**
160      * Result(29360142) for notify app the bind remote service's device is offline.
161      */
162     DEVICE_OFFLINE_ERR = 29360142,
163     /**
164      * Result(29360143) for not find hitrace id.
165      */
166     NO_HITRACE_RECORD_ERR = 29360143,
167     /**
168      * Result(29360144) for get local deviceid fail.
169      */
170     GET_LOCAL_DEVICE_ERR = 29360144,
171     /**
172      * Result(29360145) for get local deviceid fail.
173      */
174     GET_DATAABILITY_ERR = 29360145,
175     /**
176      * Result(29360146) for DistributedSched Service Publish Exception.
177      */
178     DMS_PUBLISH_EXCEPTION = 29360146,
179     /**
180      * Result(29360147) for DistributedSched Storage Exception.
181      */
182     DMS_GET_STORAGE_EXCEPTION = 29360147,
183     /**
184      * Result(29360148) for DistributedSched Service Get System Ability Manager Exception.
185      */
186     DMS_GET_SAMGR_EXCEPTION = 29360148,
187     /**
188      * Result(29360149) for DistributedSched Service IPC call noresponse error.
189      */
190     IPC_CALL_NORESPONSE_ERR = 29360149,
191     /**
192      * Result(29360150) for DistributedSched Service call bundle manager service error.
193      */
194     BUNDLE_MANAGER_SERVICE_ERR = 29360150,
195     /**
196      * Result(29360151) for DistributedSched Service call distributed manager error.
197      */
198     DISTRIBUTED_MANAGER_ERR = 29360151,
199     /**
200      * Result(29360152) for DistributedSched Service NotifyCompleteContinuation failed.
201      */
202     NOTIFYCOMPLETECONTINUATION_FAILED = 29360152,
203     /**
204      * Result(29360153) for DistributedSched Service Continue Ability Timeout Error.
205      */
206     CONTINUE_ABILITY_TIMEOUT_ERR = 29360153,
207     /**
208      * Result(29360154) for DistributedSched Service Notify Complete Continuation abilityToken null.
209      */
210     ABILITYTOKEN_NULL = 29360154,
211     /**
212      * Result(29360155) for get device list fail.
213      */
214     GET_DEVICE_LIST_ERR = 29360155,
215     /**
216      * Result(29360156) for notify ability install error.
217      */
218     NOTIFY_ABILITY_INSTALL_ERR = 29360156,
219     /**
220      * Result(29360157) for permission denied.
221      */
222     DMS_PERMISSION_DENIED = 29360157,
223     /**
224      * Result(29360158) for notify ability free install.
225      */
226     NOTIFY_ABILITY_FREE_INSTALL = 29360158,
227     /**
228      * Result(29360159) for notify app invalid uid.
229      */
230     BIND_ABILITY_UID_INVALID_ERR = 29360159,
231     /**
232      * Result(29360160) for notify app happen connect leak.
233      */
234     BIND_ABILITY_LEAK_ERR = 29360160,
235     /**
236      * Result(29360161) for can not service registry.
237      */
238     NOT_FIND_SERVICE_REGISTRY = 29360161,
239     /**
240      * Result(29360162) for can not get service.
241      */
242     NOT_FIND_SERVICE_PROXY = 29360162,
243     /**
244      * Result(29360163) for IPC Send Request to DEF fail.
245      */
246     SEND_REQUEST_DEF_FAIL = 29360163,
247     /**
248      * Result(29360164) for BMS can not find the specified ability.
249      */
250     CAN_NOT_FOUND_ABILITY_ERR = 29360164,
251     /**
252      * Result(29360165) for DMS can not register device state callback.
253      */
254     REGISTER_DEVICE_STATE_CALLBACK_ERR = 29360165,
255     /**
256      * Result(29360166) for DMS can not unregister device state callback.
257      */
258     UNREGISTER_DEVICE_STATE_CALLBACK_ERR = 29360166,
259     /**
260      * Result(29360167) for DMS can not start auxiliary device FA.
261      */
262     START_AUXILIARY_FA_ERR = 29360167,
263     /**
264      * Result(29360168) for DMS can not get dmsproxy handle.
265      */
266     GET_DMSPROXY_HANDLE_FAIL = 29360168,
267     /**
268      * Result(29360169) for dmsproxy service exception.
269      */
270     DMSPROXY_SERVICE_ERR = 29360169,
271     /**
272      * Result(29360170) for softbus service unavailable.
273      */
274     SOFTBUS_SERVICE_ERR = 29360170,
275     /**
276      * Result(29360171) for softbus register callback fail.
277      */
278     SOFTBUS_REGISTER_CALLBACK_ERR = 29360171,
279     /**
280      * Result(29360172) for get DPermission sa fail.
281      */
282     GET_DISTRIBUTED_PERMISSION_SA_ERR = 29360172,
283     /**
284      * Result(29360173) for get BMS sa fail.
285      */
286     GET_BUNDLE_MANAGER_ERR = 29360173,
287     /**
288      * Result(29360174) for get remote dms fail.
289      */
290     GET_REMOTE_DMS_FAIL = 29360174,
291     /**
292      * Result(29360175) for account access permission check failed.
293      */
294     DMS_ACCOUNT_ACCESS_PERMISSION_DENIED = 29360175,
295     /**
296      * Result(29360176) for component access permission check failed.
297      */
298     DMS_COMPONENT_ACCESS_PERMISSION_DENIED = 29360176,
299     /**
300      * Result(29360177) for distributed communication permission check failed.
301      */
302     DMS_DISTRIBUTED_COMMUNICATION_PERMISSION_DENIED = 29360177,
303     /**
304      * Result(29360178) for osd function not support.
305      */
306     MISSION_OSD_NOT_SUPPORTED = 29360178,
307     /**
308      * Result(29360179) for osd switch is off.
309      */
310     MISSION_OSD_NOT_ENABLED = 29360179,
311     /**
312      * Result(29360180) for osd switch is on.
313      */
314     MISSION_OSD_ENABLED = 29360180,
315     /**
316      * Result(29360181) for front app check failed.
317      */
318     CHECK_FRONT_APP_FAIL = 29360181,
319     /*
320      * Result(29360184) for notify mission change listener failed.
321      */
322     MISSION_NOTIFY_CHANGE_LISTENER_ERR = 29360184,
323     /**
324      * Result(29360185) for subscribe data storage change failed.
325      */
326     MISSION_SUBSCRIBE_DATA_STORAGE_ERR = 29360185,
327     /**
328      * Result(29360186) for sync snapshot failed.
329      */
330     MISSION_SYNC_SNAPSHOT_ERR = 29360186,
331     /**
332      * Result(29360187) for sync mission info list failed.
333      */
334     MISSION_SYNC_MISSION_INFO_LIST_ERR = 29360187,
335     /**
336      * Result(29360188) for distributed  communication permission check failed.
337      */
338     REMOTE_DISTRIBUTED_COMMUNICATION_PERMISSION_DENIED = 29360188,
339     /*
340      * Result(29360191) for blur snapshot failed.
341      */
342     MISSION_BLUR_SNAPSHOT_ERR = 29360191,
343     /*
344      * Result(29360192) for take foreground snapshot failed.
345      */
346     MISSION_TAKE_FOREGROUND_SNAPSHOT_ERR = 29360192,
347     /*
348      * Result(29360193) for ccm switch not support.
349      */
350     MISSION_OSD_CCM_NOT_SUPPORTED = 29360193,
351     /*
352      * Result(29360194) for wifi switch is off.
353      */
354     MISSION_OSD_WIFI_OFF = 29360194,
355     /*
356      * Result(29360195) for child mode is on.
357      */
358     MISSION_OSD_CHILDMODE_ON = 29360195,
359     /*
360      * Result(29360196) for cloud switch is off.
361      */
362     MISSION_OSD_CLOUD_SWITCH_OFF = 29360196,
363     /*
364      * Result(29360197) for continue ability rejected.
365      */
366     CONTINUE_ABILITY_REJECTED = 29360197,
367     /*
368      * Result(29360198) for continue save data failed.
369      */
370     CONTINUE_SAVE_DATA_FAILED = 29360198,
371     /*
372      * Result(29360199) for onContinue failed.
373      */
374     CONTINUE_ON_CONTINUE_FAILED = 29360199,
375     /*
376      * Result(29360200) for continue get content failed.
377      */
378     CONTINUE_GET_CONTENT_FAILED = 29360200,
379     /*
380      * Result(29360201) for call permission check failed.
381      */
382     CALL_PERMISSION_DENIED = 29360201,
383     /*
384      * Result(29360202) for continue remote not install and support free install.
385      */
386     CONTINUE_REMOTE_UNINSTALLED_SUPPORT_FREEINSTALL = 29360202,
387     /*
388      * Result(29360203) for continue remote not install and not support free install.
389      */
390     CONTINUE_REMOTE_UNINSTALLED_UNSUPPORT_FREEINSTALL = 29360203,
391     /*
392      * Result(29360204) for continue remote version not match.
393      */
394     CONTINUE_REMOTE_VERSION_MISMATCH = 29360204,
395     /*
396      * Result(29360205) for continue freeinstall failed.
397      */
398     CONTINUE_FREE_INSTALL_FAILED = 29360205,
399     /*
400      * Result(29360206) for continue remote cannot install.
401      */
402     CONTINUE_REMOTE_UNINSTALLED_CANNOT_FREEINSTALL = 29360206,
403     /*
404      * Result(29360207) for app registered exceed max times.
405      */
406     REGISTER_EXCEED_MAX_TIMES = 29360207,
407     /*
408      * Result(29360208) for token has not registered.
409      */
410     TOKEN_HAS_NOT_REGISTERED = 29360208,
411     /*
412      * Result(29360209) for callback has registered.
413      */
414     CALLBACK_HAS_REGISTERED = 29360209,
415     /*
416      * Result(29360210) for callback has not registered.
417      */
418     CALLBACK_HAS_NOT_REGISTERED = 29360210,
419     /*
420      * Result(29360211) for connect ability failed.
421      */
422     CONNECT_ABILITY_FAILED = 29360211,
423     /*
424      * Result(29360212) for disconnect ability failed.
425      */
426     DISCONNECT_ABILITY_FAILED = 29360212,
427     /*
428      * Result(29360213) for panel name not configured.
429      */
430     PANEL_NAME_NOT_CONFIGURED = 29360213,
431     /*
432      * Result(29360214) for unknown callback type.
433      */
434     UNKNOWN_CALLBACK_TYPE = 29360214,
435     /*
436      * Result(29360215) for invalid connect status.
437      */
438     INVALID_CONNECT_STATUS = 29360215,
439     /*
440      * Result(29360216) for invalid continuation mode.
441      */
442     INVALID_CONTINUATION_MODE = 29360216,
443     /**
444      * Result(29360217) for dms version is empty.
445      */
446     DMS_VERSION_EMPTY = 29360217,
447     /**
448      * Result(29360218) for DistributedSched Service parse dms version error.
449      */
450     DMS_VERSION_PARSE_EXCEPTION = 29360218,
451     /*
452      * Result(29360219) for background permission check failed.
453      */
454     DMS_BACKGROUND_PERMISSION_DENIED = 29360219,
455     /*
456      * Result(29360220) for start control permission check failed.
457      */
458     DMS_START_CONTROL_PERMISSION_DENIED = 29360220,
459     /**
460      * Result(29360221) for failed to get the missionInfo of the specified missionId.
461      */
462     NO_MISSION_INFO_FOR_MISSION_ID = 29360221,
463     /**
464      * Result(29360222) for the operation device must be the device where the application to be continued
465      * is located or the target device to be continued.
466      */
467     OPERATION_DEVICE_NOT_INITIATOR_OR_TARGET = 29360222,
468     /**
469      * Result(29360223) for the local continuation task is already in progress.
470      */
471     CONTINUE_ALREADY_IN_PROGRESS = 29360223,
472     /**
473      * Result(29360224) for the mission for continuing is not alive, try again after restart mission.
474      */
475     MISSION_FOR_CONTINUING_IS_NOT_ALIVE = 29360224,
476     /**
477      * Result(29360225) for sending event failed during continuation.
478      */
479     CONTINUE_SEND_EVENT_FAILED = 29360225,
480     /**
481      * Result(29360226) for state machine receving invalid state code.
482      */
483     CONTINUE_STATE_MACHINE_INVALID_STATE = 29360226,
484     /**
485      * Result(29360227) for session shutdown during continuation.
486      */
487     CONTINUE_SESSION_SHUTDOWN = 29360227,
488     /**
489      * Result(29360228) for calling ContinueAbility failed during continuation.
490      */
491     CONTINUE_CALL_CONTINUE_ABILITY_FAILED = 29360228,
492     /**
493      * Result(29360229) for calling StartAbility failed during continuation.
494      */
495     CONTINUE_CALL_START_ABILITY_FAILED = 29360229,
496     /**
497      * Result(29360230) for sink Ability abnormal termination during continuation.
498      */
499     CONTINUE_SINK_ABILITY_TERMINATED = 29360230,
500     /**
501      * Result(29360231) for all connect manager reject connect apply.
502      */
503     DMS_CONNECT_APPLY_REJECT_FAILED = 29360231,
504     /**
505      * Result(29360232) for all connect manager deal connect apply timeout.
506      */
507     DMS_CONNECT_APPLY_TIMEOUT_FAILED = 29360232,
508     /**
509      * Result(29360233) for mission continue state is not active.
510      */
511     MISSION_NOT_CONTINUE_ACTIVE = 29360233,
512     /**
513      * Result(29360234) for mission is not focused.
514      */
515     MISSION_NOT_FOCUSED = 29360234,
516     /**
517      * Result(29360235) for bundle is not continuable.
518      */
519     BUNDLE_NOT_CONTINUABLE = 29360235,
520     /**
521      * Result(29360238) for get window failed from scb.
522      */
523     DMS_GET_WINDOW_FAILED_FROM_SCB = 29360238,
524 };
525 } // namespace DistributedSchedule
526 } // namespace OHOS
527 #endif // SERVICES_DTBSCHEDMGR_INCLUDE_DTBSCHEDMGR_LOG_H_
528