• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 #include "ans_convert_enum.h"
17 #include "ans_log_wrapper.h"
18 
19 namespace OHOS {
20 namespace NotificationNapi {
ContentTypeJSToC(const ContentType & inType,NotificationContent::Type & outType)21 bool AnsEnumUtil::ContentTypeJSToC(const ContentType &inType, NotificationContent::Type &outType)
22 {
23     switch (inType) {
24         case ContentType::NOTIFICATION_CONTENT_BASIC_TEXT:
25             outType = NotificationContent::Type::BASIC_TEXT;
26             break;
27         case ContentType::NOTIFICATION_CONTENT_LONG_TEXT:
28             outType = NotificationContent::Type::LONG_TEXT;
29             break;
30         case ContentType::NOTIFICATION_CONTENT_MULTILINE:
31             outType = NotificationContent::Type::MULTILINE;
32             break;
33         case ContentType::NOTIFICATION_CONTENT_PICTURE:
34             outType = NotificationContent::Type::PICTURE;
35             break;
36         case ContentType::NOTIFICATION_CONTENT_CONVERSATION:
37             outType = NotificationContent::Type::CONVERSATION;
38             break;
39         case ContentType::NOTIFICATION_CONTENT_LOCAL_LIVE_VIEW:
40             outType = NotificationContent::Type::LOCAL_LIVE_VIEW;
41             break;
42         case ContentType::NOTIFICATION_CONTENT_LIVE_VIEW:
43             outType = NotificationContent::Type::LIVE_VIEW;
44             break;
45         default:
46             ANS_LOGE("ContentType %{public}d is an invalid value", inType);
47             return false;
48     }
49     return true;
50 }
51 
ContentTypeCToJS(const NotificationContent::Type & inType,ContentType & outType)52 bool AnsEnumUtil::ContentTypeCToJS(const NotificationContent::Type &inType, ContentType &outType)
53 {
54     switch (inType) {
55         case NotificationContent::Type::BASIC_TEXT:
56             outType = ContentType::NOTIFICATION_CONTENT_BASIC_TEXT;
57             break;
58         case NotificationContent::Type::LONG_TEXT:
59             outType = ContentType::NOTIFICATION_CONTENT_LONG_TEXT;
60             break;
61         case NotificationContent::Type::MULTILINE:
62             outType = ContentType::NOTIFICATION_CONTENT_MULTILINE;
63             break;
64         case NotificationContent::Type::PICTURE:
65             outType = ContentType::NOTIFICATION_CONTENT_PICTURE;
66             break;
67         case NotificationContent::Type::CONVERSATION:
68             outType = ContentType::NOTIFICATION_CONTENT_CONVERSATION;
69             break;
70         case NotificationContent::Type::LOCAL_LIVE_VIEW:
71             outType = ContentType::NOTIFICATION_CONTENT_LOCAL_LIVE_VIEW;
72             break;
73         case NotificationContent::Type::LIVE_VIEW:
74             outType = ContentType::NOTIFICATION_CONTENT_LIVE_VIEW;
75             break;
76         default:
77             ANS_LOGE("ContentType %{public}d is an invalid value", inType);
78             return false;
79     }
80     return true;
81 }
82 
SlotTypeJSToC(const SlotType & inType,NotificationConstant::SlotType & outType)83 bool AnsEnumUtil::SlotTypeJSToC(const SlotType &inType, NotificationConstant::SlotType &outType)
84 {
85     switch (inType) {
86         case SlotType::SOCIAL_COMMUNICATION:
87             outType = NotificationConstant::SlotType::SOCIAL_COMMUNICATION;
88             break;
89         case SlotType::SERVICE_INFORMATION:
90             outType = NotificationConstant::SlotType::SERVICE_REMINDER;
91             break;
92         case SlotType::CONTENT_INFORMATION:
93             outType = NotificationConstant::SlotType::CONTENT_INFORMATION;
94             break;
95         case SlotType::LIVE_VIEW:
96             outType = NotificationConstant::SlotType::LIVE_VIEW;
97             break;
98         case SlotType::CUSTOMER_SERVICE:
99             outType = NotificationConstant::SlotType::CUSTOMER_SERVICE;
100             break;
101         case SlotType::EMERGENCY_INFORMATION:
102             outType = NotificationConstant::SlotType::EMERGENCY_INFORMATION;
103             break;
104         case SlotType::UNKNOWN_TYPE:
105         case SlotType::OTHER_TYPES:
106             outType = NotificationConstant::SlotType::OTHER;
107             break;
108         default:
109             ANS_LOGE("SlotType %{public}d is an invalid value", inType);
110             return false;
111     }
112     return true;
113 }
114 
SlotTypeCToJS(const NotificationConstant::SlotType & inType,SlotType & outType)115 bool AnsEnumUtil::SlotTypeCToJS(const NotificationConstant::SlotType &inType, SlotType &outType)
116 {
117     switch (inType) {
118         case NotificationConstant::SlotType::CUSTOM:
119             outType = SlotType::UNKNOWN_TYPE;
120             break;
121         case NotificationConstant::SlotType::SOCIAL_COMMUNICATION:
122             outType = SlotType::SOCIAL_COMMUNICATION;
123             break;
124         case NotificationConstant::SlotType::SERVICE_REMINDER:
125             outType = SlotType::SERVICE_INFORMATION;
126             break;
127         case NotificationConstant::SlotType::CONTENT_INFORMATION:
128             outType = SlotType::CONTENT_INFORMATION;
129             break;
130         case NotificationConstant::SlotType::LIVE_VIEW:
131             outType = SlotType::LIVE_VIEW;
132             break;
133         case NotificationConstant::SlotType::CUSTOMER_SERVICE:
134             outType = SlotType::CUSTOMER_SERVICE;
135             break;
136         case NotificationConstant::SlotType::EMERGENCY_INFORMATION:
137             outType = SlotType::EMERGENCY_INFORMATION;
138             break;
139         case NotificationConstant::SlotType::OTHER:
140             outType = SlotType::OTHER_TYPES;
141             break;
142         default:
143             ANS_LOGE("SlotType %{public}d is an invalid value", inType);
144             return false;
145     }
146     return true;
147 }
148 
149 
SlotLevelJSToC(const SlotLevel & inLevel,NotificationSlot::NotificationLevel & outLevel)150 bool AnsEnumUtil::SlotLevelJSToC(const SlotLevel &inLevel, NotificationSlot::NotificationLevel &outLevel)
151 {
152     switch (inLevel) {
153         case SlotLevel::LEVEL_NONE:
154             outLevel = NotificationSlot::NotificationLevel::LEVEL_NONE;
155             break;
156         case SlotLevel::LEVEL_MIN:
157             outLevel = NotificationSlot::NotificationLevel::LEVEL_MIN;
158             break;
159         case SlotLevel::LEVEL_LOW:
160             outLevel = NotificationSlot::NotificationLevel::LEVEL_LOW;
161             break;
162         case SlotLevel::LEVEL_DEFAULT:
163             outLevel = NotificationSlot::NotificationLevel::LEVEL_DEFAULT;
164             break;
165         case SlotLevel::LEVEL_HIGH:
166             outLevel = NotificationSlot::NotificationLevel::LEVEL_HIGH;
167             break;
168         default:
169             ANS_LOGE("SlotLevel %{public}d is an invalid value", inLevel);
170             return false;
171     }
172     return true;
173 }
174 
LiveViewStatusJSToC(const LiveViewStatus & inType,NotificationLiveViewContent::LiveViewStatus & outType)175 bool AnsEnumUtil::LiveViewStatusJSToC(
176     const LiveViewStatus &inType, NotificationLiveViewContent::LiveViewStatus &outType)
177 {
178     switch (inType) {
179         case LiveViewStatus::LIVE_VIEW_CREATE:
180             outType = NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_CREATE;
181             break;
182         case LiveViewStatus::LIVE_VIEW_INCREMENTAL_UPDATE:
183             outType = NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_INCREMENTAL_UPDATE;
184             break;
185         case LiveViewStatus::LIVE_VIEW_END:
186             outType = NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_END;
187             break;
188         case LiveViewStatus::LIVE_VIEW_FULL_UPDATE:
189             outType = NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_FULL_UPDATE;
190             break;
191         default:
192             ANS_LOGE("LiveViewStatus %{public}d is an invalid value", inType);
193             return false;
194     }
195 
196     return true;
197 }
198 
LiveViewTypesJSToC(const LiveViewTypes & inType,NotificationLocalLiveViewContent::LiveViewTypes & outType)199 bool AnsEnumUtil::LiveViewTypesJSToC(
200     const LiveViewTypes &inType, NotificationLocalLiveViewContent::LiveViewTypes &outType)
201 {
202     switch (inType) {
203         case LiveViewTypes::LIVE_VIEW_ACTIVITY:
204             outType = NotificationLocalLiveViewContent::LiveViewTypes::LIVE_VIEW_ACTIVITY;
205             break;
206         case LiveViewTypes::LIVE_VIEW_INSTANT:
207             outType = NotificationLocalLiveViewContent::LiveViewTypes::LIVE_VIEW_INSTANT;
208             break;
209         case LiveViewTypes::LIVE_VIEW_LONG_TERM:
210             outType = NotificationLocalLiveViewContent::LiveViewTypes::LIVE_VIEW_LONG_TERM;
211             break;
212         case LiveViewTypes::LIVE_VIEW_INSTANT_BANNER:
213             outType = NotificationLocalLiveViewContent::LiveViewTypes::LIVE_VIEW_INSTANT_BANNER;
214             break;
215         default:
216             ANS_LOGE("LiveViewTypes %{public}d is an invalid value", inType);
217             return false;
218     }
219 
220     return true;
221 }
222 
SlotLevelCToJS(const NotificationSlot::NotificationLevel & inLevel,SlotLevel & outLevel)223 bool AnsEnumUtil::SlotLevelCToJS(const NotificationSlot::NotificationLevel &inLevel, SlotLevel &outLevel)
224 {
225     switch (inLevel) {
226         case NotificationSlot::NotificationLevel::LEVEL_NONE:
227         case NotificationSlot::NotificationLevel::LEVEL_UNDEFINED:
228             outLevel = SlotLevel::LEVEL_NONE;
229             break;
230         case NotificationSlot::NotificationLevel::LEVEL_MIN:
231             outLevel = SlotLevel::LEVEL_MIN;
232             break;
233         case NotificationSlot::NotificationLevel::LEVEL_LOW:
234             outLevel = SlotLevel::LEVEL_LOW;
235             break;
236         case NotificationSlot::NotificationLevel::LEVEL_DEFAULT:
237             outLevel = SlotLevel::LEVEL_DEFAULT;
238             break;
239         case NotificationSlot::NotificationLevel::LEVEL_HIGH:
240             outLevel = SlotLevel::LEVEL_HIGH;
241             break;
242         default:
243             ANS_LOGE("SlotLevel %{public}d is an invalid value", inLevel);
244             return false;
245     }
246     return true;
247 }
248 
ReasonCToJS(const int & inType,int & outType)249 bool AnsEnumUtil::ReasonCToJS(const int &inType, int &outType)
250 {
251     switch (inType) {
252         case NotificationConstant::DEFAULT_REASON_DELETE:
253             outType = static_cast<int32_t>(RemoveReason::DEFAULT_REASON_DELETE);
254             break;
255         case NotificationConstant::CLICK_REASON_DELETE:
256             outType = static_cast<int32_t>(RemoveReason::CLICK_REASON_REMOVE);
257             break;
258         case NotificationConstant::CANCEL_REASON_DELETE:
259             outType = static_cast<int32_t>(RemoveReason::CANCEL_REASON_REMOVE);
260             break;
261         case NotificationConstant::CANCEL_ALL_REASON_DELETE:
262             outType = static_cast<int32_t>(RemoveReason::CANCEL_ALL_REASON_REMOVE);
263             break;
264         case NotificationConstant::ERROR_REASON_DELETE:
265             outType = static_cast<int32_t>(RemoveReason::ERROR_REASON_REMOVE);
266             break;
267         case NotificationConstant::PACKAGE_CHANGED_REASON_DELETE:
268             outType = static_cast<int32_t>(RemoveReason::PACKAGE_CHANGED_REASON_REMOVE);
269             break;
270         case NotificationConstant::USER_STOPPED_REASON_DELETE:
271             outType = static_cast<int32_t>(RemoveReason::USER_STOPPED_REASON_REMOVE);
272             break;
273         case NotificationConstant::APP_CANCEL_REASON_DELETE:
274             outType = static_cast<int32_t>(RemoveReason::APP_CANCEL_REASON_REMOVE);
275             break;
276         case NotificationConstant::APP_CANCEL_ALL_REASON_DELETE:
277             outType = static_cast<int32_t>(RemoveReason::APP_CANCEL_ALL_REASON_REMOVE);
278             break;
279         case NotificationConstant::USER_REMOVED_REASON_DELETE:
280             outType = static_cast<int32_t>(RemoveReason::USER_REMOVED_REASON_DELETE);
281             break;
282         case NotificationConstant::FLOW_CONTROL_REASON_DELETE:
283             outType = static_cast<int32_t>(RemoveReason::FLOW_CONTROL_REASON_DELETE);
284             break;
285         default:
286             ReasonCToJSExt(inType, outType);
287             break;
288     }
289     return true;
290 }
291 
ReasonCToJSExt(const int & inType,int & outType)292 void AnsEnumUtil::ReasonCToJSExt(const int &inType, int &outType)
293 {
294     switch (inType) {
295         case NotificationConstant::DISABLE_SLOT_REASON_DELETE:
296             outType = static_cast<int32_t>(RemoveReason::DISABLE_SLOT_REASON_DELETE);
297             break;
298         case NotificationConstant::DISABLE_NOTIFICATION_REASON_DELETE:
299             outType = static_cast<int32_t>(RemoveReason::DISABLE_NOTIFICATION_REASON_DELETE);
300             break;
301         case NotificationConstant::APP_CANCEL_AS_BUNELE_REASON_DELETE:
302             outType = static_cast<int32_t>(RemoveReason::APP_CANCEL_AS_BUNELE_REASON_DELETE);
303             break;
304         case NotificationConstant::APP_CANCEL_AS_BUNELE_WITH_AGENT_REASON_DELETE:
305             outType = static_cast<int32_t>(RemoveReason::APP_CANCEL_AS_BUNELE_WITH_AGENT_REASON_DELETE);
306             break;
307         case NotificationConstant::APP_CANCEL_REMINDER_REASON_DELETE:
308             outType = static_cast<int32_t>(RemoveReason::APP_CANCEL_REMINDER_REASON_DELETE);
309             break;
310         case NotificationConstant::APP_CANCEL_GROPU_REASON_DELETE:
311             outType = static_cast<int32_t>(RemoveReason::APP_CANCEL_GROPU_REASON_DELETE);
312             break;
313         case NotificationConstant::APP_REMOVE_GROUP_REASON_DELETE:
314             outType = static_cast<int32_t>(RemoveReason::APP_REMOVE_GROUP_REASON_DELETE);
315             break;
316         case NotificationConstant::APP_REMOVE_ALL_REASON_DELETE:
317             outType = static_cast<int32_t>(RemoveReason::APP_REMOVE_ALL_REASON_DELETE);
318             break;
319         case NotificationConstant::APP_REMOVE_ALL_USER_REASON_DELETE:
320             outType = static_cast<int32_t>(RemoveReason::APP_REMOVE_ALL_USER_REASON_DELETE);
321             break;
322         case NotificationConstant::TRIGGER_EIGHT_HOUR_REASON_DELETE:
323             outType = static_cast<int32_t>(RemoveReason::TRIGGER_EIGHT_HOUR_REASON_DELETE);
324             break;
325         case NotificationConstant::TRIGGER_FOUR_HOUR_REASON_DELETE:
326             outType = static_cast<int32_t>(RemoveReason::TRIGGER_FOUR_HOUR_REASON_DELETE);
327             break;
328         default:
329             ReasonCToJSSecondExt(inType, outType);
330             break;
331     }
332 }
333 
ReasonCToJSSecondExt(const int & inType,int & outType)334 void AnsEnumUtil::ReasonCToJSSecondExt(const int &inType, int &outType)
335 {
336     switch (inType) {
337         case NotificationConstant::TRIGGER_TEN_MINUTES_REASON_DELETE:
338             outType = static_cast<int32_t>(RemoveReason::TRIGGER_TEN_MINUTES_REASON_DELETE);
339             break;
340         case NotificationConstant::TRIGGER_FIFTEEN_MINUTES_REASON_DELETE:
341             outType = static_cast<int32_t>(RemoveReason::TRIGGER_FIFTEEN_MINUTES_REASON_DELETE);
342             break;
343         case NotificationConstant::TRIGGER_THIRTY_MINUTES_REASON_DELETE:
344             outType = static_cast<int32_t>(RemoveReason::TRIGGER_THIRTY_MINUTES_REASON_DELETE);
345             break;
346         case NotificationConstant::TRIGGER_START_ARCHIVE_REASON_DELETE:
347             outType = static_cast<int32_t>(RemoveReason::TRIGGER_START_ARCHIVE_REASON_DELETE);
348             break;
349         case NotificationConstant::TRIGGER_AUTO_DELETE_REASON_DELETE:
350             outType = static_cast<int32_t>(RemoveReason::TRIGGER_AUTO_DELETE_REASON_DELETE);
351             break;
352         case NotificationConstant::PACKAGE_REMOVE_REASON_DELETE:
353             outType = static_cast<int32_t>(RemoveReason::PACKAGE_REMOVE_REASON_DELETE);
354             break;
355         case NotificationConstant::SLOT_ENABLED_REASON_DELETE:
356             outType = static_cast<int32_t>(RemoveReason::SLOT_ENABLED_REASON_DELETE);
357             break;
358         case NotificationConstant::APP_CANCEL_REASON_OTHER:
359             outType = static_cast<int32_t>(RemoveReason::APP_CANCEL_REASON_OTHER);
360             break;
361         case NotificationConstant::RECOVER_LIVE_VIEW_DELETE:
362             outType = static_cast<int32_t>(RemoveReason::RECOVER_LIVE_VIEW_DELETE);
363             break;
364         case NotificationConstant::DISABLE_NOTIFICATION_FEATURE_REASON_DELETE:
365             outType = static_cast<int32_t>(RemoveReason::DISABLE_NOTIFICATION_FEATURE_REASON_DELETE);
366             break;
367         case NotificationConstant::DISTRIBUTED_COLLABORATIVE_DELETE:
368             outType = static_cast<int32_t>(RemoveReason::DISTRIBUTED_COLLABORATIVE_DELETE);
369             break;
370         default:
371             outType = static_cast<int32_t>(RemoveReason::APP_CANCEL_REASON_OTHER);
372             ANS_LOGW("Reason %{public}d is an invalid value", inType);
373             break;
374     }
375 }
376 
DoNotDisturbTypeJSToC(const DoNotDisturbType & inType,NotificationConstant::DoNotDisturbType & outType)377 bool AnsEnumUtil::DoNotDisturbTypeJSToC(const DoNotDisturbType &inType, NotificationConstant::DoNotDisturbType &outType)
378 {
379     switch (inType) {
380         case DoNotDisturbType::TYPE_NONE:
381             outType = NotificationConstant::DoNotDisturbType::NONE;
382             break;
383         case DoNotDisturbType::TYPE_ONCE:
384             outType = NotificationConstant::DoNotDisturbType::ONCE;
385             break;
386         case DoNotDisturbType::TYPE_DAILY:
387             outType = NotificationConstant::DoNotDisturbType::DAILY;
388             break;
389         case DoNotDisturbType::TYPE_CLEARLY:
390             outType = NotificationConstant::DoNotDisturbType::CLEARLY;
391             break;
392         default:
393             ANS_LOGE("DoNotDisturbType %{public}d is an invalid value", inType);
394             return false;
395     }
396     return true;
397 }
398 
DoNotDisturbTypeCToJS(const NotificationConstant::DoNotDisturbType & inType,DoNotDisturbType & outType)399 bool AnsEnumUtil::DoNotDisturbTypeCToJS(const NotificationConstant::DoNotDisturbType &inType, DoNotDisturbType &outType)
400 {
401     switch (inType) {
402         case NotificationConstant::DoNotDisturbType::NONE:
403             outType = DoNotDisturbType::TYPE_NONE;
404             break;
405         case NotificationConstant::DoNotDisturbType::ONCE:
406             outType = DoNotDisturbType::TYPE_ONCE;
407             break;
408         case NotificationConstant::DoNotDisturbType::DAILY:
409             outType = DoNotDisturbType::TYPE_DAILY;
410             break;
411         case NotificationConstant::DoNotDisturbType::CLEARLY:
412             outType = DoNotDisturbType::TYPE_CLEARLY;
413             break;
414         default:
415             ANS_LOGE("DoNotDisturbType %{public}d is an invalid value", inType);
416             return false;
417     }
418     return true;
419 }
420 
DeviceRemindTypeCToJS(const NotificationConstant::RemindType & inType,DeviceRemindType & outType)421 bool AnsEnumUtil::DeviceRemindTypeCToJS(const NotificationConstant::RemindType &inType, DeviceRemindType &outType)
422 {
423     switch (inType) {
424         case NotificationConstant::RemindType::DEVICE_IDLE_DONOT_REMIND:
425             outType = DeviceRemindType::IDLE_DONOT_REMIND;
426             break;
427         case NotificationConstant::RemindType::DEVICE_IDLE_REMIND:
428             outType = DeviceRemindType::IDLE_REMIND;
429             break;
430         case NotificationConstant::RemindType::DEVICE_ACTIVE_DONOT_REMIND:
431             outType = DeviceRemindType::ACTIVE_DONOT_REMIND;
432             break;
433         case NotificationConstant::RemindType::DEVICE_ACTIVE_REMIND:
434             outType = DeviceRemindType::ACTIVE_REMIND;
435             break;
436         default:
437             ANS_LOGE("DeviceRemindType %{public}d is an invalid value", inType);
438             return false;
439     }
440     return true;
441 }
442 
SourceTypeCToJS(const NotificationConstant::SourceType & inType,SourceType & outType)443 bool AnsEnumUtil::SourceTypeCToJS(const NotificationConstant::SourceType &inType, SourceType &outType)
444 {
445     switch (inType) {
446         case NotificationConstant::SourceType::TYPE_NORMAL:
447             outType = SourceType::TYPE_NORMAL;
448             break;
449         case NotificationConstant::SourceType::TYPE_CONTINUOUS:
450             outType = SourceType::TYPE_CONTINUOUS;
451             break;
452         case NotificationConstant::SourceType::TYPE_TIMER:
453             outType = SourceType::TYPE_TIMER;
454             break;
455         default:
456             ANS_LOGE("SourceType %{public}d is an invalid value", inType);
457             return false;
458     }
459     return true;
460 }
461 
LiveViewStatusCToJS(const NotificationLiveViewContent::LiveViewStatus & inType,LiveViewStatus & outType)462 bool AnsEnumUtil::LiveViewStatusCToJS(const NotificationLiveViewContent::LiveViewStatus &inType,
463     LiveViewStatus &outType)
464 {
465     switch (inType) {
466         case NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_CREATE:
467             outType = LiveViewStatus::LIVE_VIEW_CREATE;
468             break;
469         case NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_INCREMENTAL_UPDATE:
470             outType = LiveViewStatus::LIVE_VIEW_INCREMENTAL_UPDATE;
471             break;
472         case NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_END:
473             outType = LiveViewStatus::LIVE_VIEW_END;
474             break;
475         case NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_FULL_UPDATE:
476             outType = LiveViewStatus::LIVE_VIEW_FULL_UPDATE;
477             break;
478         default:
479             ANS_LOGE("LiveViewStatus %{public}d is an invalid value", inType);
480             return false;
481     }
482 
483     return true;
484 }
LiveViewTypesCToJS(const NotificationLocalLiveViewContent::LiveViewTypes & inType,LiveViewTypes & outType)485 bool AnsEnumUtil::LiveViewTypesCToJS(const NotificationLocalLiveViewContent::LiveViewTypes &inType,
486     LiveViewTypes &outType)
487 {
488     switch (inType) {
489         case NotificationLocalLiveViewContent::LiveViewTypes::LIVE_VIEW_ACTIVITY:
490             outType = LiveViewTypes::LIVE_VIEW_ACTIVITY;
491             break;
492         case NotificationLocalLiveViewContent::LiveViewTypes::LIVE_VIEW_INSTANT:
493             outType = LiveViewTypes::LIVE_VIEW_INSTANT;
494             break;
495         case NotificationLocalLiveViewContent::LiveViewTypes::LIVE_VIEW_LONG_TERM:
496             outType = LiveViewTypes::LIVE_VIEW_LONG_TERM;
497             break;
498         case NotificationLocalLiveViewContent::LiveViewTypes::LIVE_VIEW_INSTANT_BANNER:
499             outType = LiveViewTypes::LIVE_VIEW_INSTANT_BANNER;
500             break;
501         default:
502             ANS_LOGE("LiveViewTypes %{public}d is an invalid value", inType);
503             return false;
504     }
505 
506     return true;
507 }
508 }
509 }
510