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", 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", 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", 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_LOGD("SlotType %{public}d", 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", 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", 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", 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_LOGD("SlotLevel %{public}d", 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 case NotificationConstant::USER_LOGOUT_REASON_DELETE:
286 outType = static_cast<int32_t>(RemoveReason::USER_LOGOUT_REASON_DELETE);
287 break;
288 case NotificationConstant::DISTRIBUTED_COLLABORATIVE_CLICK_DELETE:
289 outType = static_cast<int32_t>(RemoveReason::DISTRIBUTED_COLLABORATIVE_CLICK_DELETE);
290 break;
291 case NotificationConstant::DISTRIBUTED_ENABLE_CLOSE_DELETE:
292 outType = static_cast<int32_t>(RemoveReason::DISTRIBUTED_ENABLE_CLOSE_DELETE);
293 break;
294 case NotificationConstant::DISTRIBUTED_RELEASE_DELETE:
295 outType = static_cast<int32_t>(RemoveReason::DISTRIBUTED_RELEASE_DELETE);
296 break;
297 default:
298 ReasonCToJSExt(inType, outType);
299 break;
300 }
301 return true;
302 }
303
ReasonCToJSExt(const int & inType,int & outType)304 void AnsEnumUtil::ReasonCToJSExt(const int &inType, int &outType)
305 {
306 switch (inType) {
307 case NotificationConstant::DISABLE_SLOT_REASON_DELETE:
308 outType = static_cast<int32_t>(RemoveReason::DISABLE_SLOT_REASON_DELETE);
309 break;
310 case NotificationConstant::DISABLE_NOTIFICATION_REASON_DELETE:
311 outType = static_cast<int32_t>(RemoveReason::DISABLE_NOTIFICATION_REASON_DELETE);
312 break;
313 case NotificationConstant::APP_CANCEL_AS_BUNELE_REASON_DELETE:
314 outType = static_cast<int32_t>(RemoveReason::APP_CANCEL_AS_BUNELE_REASON_DELETE);
315 break;
316 case NotificationConstant::APP_CANCEL_AS_BUNELE_WITH_AGENT_REASON_DELETE:
317 outType = static_cast<int32_t>(RemoveReason::APP_CANCEL_AS_BUNELE_WITH_AGENT_REASON_DELETE);
318 break;
319 case NotificationConstant::APP_CANCEL_REMINDER_REASON_DELETE:
320 outType = static_cast<int32_t>(RemoveReason::APP_CANCEL_REMINDER_REASON_DELETE);
321 break;
322 case NotificationConstant::APP_CANCEL_GROPU_REASON_DELETE:
323 outType = static_cast<int32_t>(RemoveReason::APP_CANCEL_GROPU_REASON_DELETE);
324 break;
325 case NotificationConstant::APP_REMOVE_GROUP_REASON_DELETE:
326 outType = static_cast<int32_t>(RemoveReason::APP_REMOVE_GROUP_REASON_DELETE);
327 break;
328 case NotificationConstant::APP_REMOVE_ALL_REASON_DELETE:
329 outType = static_cast<int32_t>(RemoveReason::APP_REMOVE_ALL_REASON_DELETE);
330 break;
331 case NotificationConstant::APP_REMOVE_ALL_USER_REASON_DELETE:
332 outType = static_cast<int32_t>(RemoveReason::APP_REMOVE_ALL_USER_REASON_DELETE);
333 break;
334 case NotificationConstant::TRIGGER_EIGHT_HOUR_REASON_DELETE:
335 outType = static_cast<int32_t>(RemoveReason::TRIGGER_EIGHT_HOUR_REASON_DELETE);
336 break;
337 case NotificationConstant::TRIGGER_FOUR_HOUR_REASON_DELETE:
338 outType = static_cast<int32_t>(RemoveReason::TRIGGER_FOUR_HOUR_REASON_DELETE);
339 break;
340 default:
341 ReasonCToJSSecondExt(inType, outType);
342 break;
343 }
344 }
345
ReasonCToJSSecondExt(const int & inType,int & outType)346 void AnsEnumUtil::ReasonCToJSSecondExt(const int &inType, int &outType)
347 {
348 switch (inType) {
349 case NotificationConstant::TRIGGER_TEN_MINUTES_REASON_DELETE:
350 outType = static_cast<int32_t>(RemoveReason::TRIGGER_TEN_MINUTES_REASON_DELETE);
351 break;
352 case NotificationConstant::TRIGGER_FIFTEEN_MINUTES_REASON_DELETE:
353 outType = static_cast<int32_t>(RemoveReason::TRIGGER_FIFTEEN_MINUTES_REASON_DELETE);
354 break;
355 case NotificationConstant::TRIGGER_THIRTY_MINUTES_REASON_DELETE:
356 outType = static_cast<int32_t>(RemoveReason::TRIGGER_THIRTY_MINUTES_REASON_DELETE);
357 break;
358 case NotificationConstant::TRIGGER_START_ARCHIVE_REASON_DELETE:
359 outType = static_cast<int32_t>(RemoveReason::TRIGGER_START_ARCHIVE_REASON_DELETE);
360 break;
361 case NotificationConstant::TRIGGER_AUTO_DELETE_REASON_DELETE:
362 outType = static_cast<int32_t>(RemoveReason::TRIGGER_AUTO_DELETE_REASON_DELETE);
363 break;
364 case NotificationConstant::PACKAGE_REMOVE_REASON_DELETE:
365 outType = static_cast<int32_t>(RemoveReason::PACKAGE_REMOVE_REASON_DELETE);
366 break;
367 case NotificationConstant::SLOT_ENABLED_REASON_DELETE:
368 outType = static_cast<int32_t>(RemoveReason::SLOT_ENABLED_REASON_DELETE);
369 break;
370 case NotificationConstant::APP_CANCEL_REASON_OTHER:
371 outType = static_cast<int32_t>(RemoveReason::APP_CANCEL_REASON_OTHER);
372 break;
373 case NotificationConstant::RECOVER_LIVE_VIEW_DELETE:
374 outType = static_cast<int32_t>(RemoveReason::RECOVER_LIVE_VIEW_DELETE);
375 break;
376 case NotificationConstant::DISABLE_NOTIFICATION_FEATURE_REASON_DELETE:
377 outType = static_cast<int32_t>(RemoveReason::DISABLE_NOTIFICATION_FEATURE_REASON_DELETE);
378 break;
379 case NotificationConstant::DISTRIBUTED_COLLABORATIVE_DELETE:
380 outType = static_cast<int32_t>(RemoveReason::DISTRIBUTED_COLLABORATIVE_DELETE);
381 break;
382 default:
383 outType = static_cast<int32_t>(RemoveReason::APP_CANCEL_REASON_OTHER);
384 ANS_LOGD("Reason %{public}d", inType);
385 break;
386 }
387 }
388
DoNotDisturbTypeJSToC(const DoNotDisturbType & inType,NotificationConstant::DoNotDisturbType & outType)389 bool AnsEnumUtil::DoNotDisturbTypeJSToC(const DoNotDisturbType &inType, NotificationConstant::DoNotDisturbType &outType)
390 {
391 switch (inType) {
392 case DoNotDisturbType::TYPE_NONE:
393 outType = NotificationConstant::DoNotDisturbType::NONE;
394 break;
395 case DoNotDisturbType::TYPE_ONCE:
396 outType = NotificationConstant::DoNotDisturbType::ONCE;
397 break;
398 case DoNotDisturbType::TYPE_DAILY:
399 outType = NotificationConstant::DoNotDisturbType::DAILY;
400 break;
401 case DoNotDisturbType::TYPE_CLEARLY:
402 outType = NotificationConstant::DoNotDisturbType::CLEARLY;
403 break;
404 default:
405 ANS_LOGD("DoNotDisturbType %{public}d", inType);
406 return false;
407 }
408 return true;
409 }
410
DoNotDisturbTypeCToJS(const NotificationConstant::DoNotDisturbType & inType,DoNotDisturbType & outType)411 bool AnsEnumUtil::DoNotDisturbTypeCToJS(const NotificationConstant::DoNotDisturbType &inType, DoNotDisturbType &outType)
412 {
413 switch (inType) {
414 case NotificationConstant::DoNotDisturbType::NONE:
415 outType = DoNotDisturbType::TYPE_NONE;
416 break;
417 case NotificationConstant::DoNotDisturbType::ONCE:
418 outType = DoNotDisturbType::TYPE_ONCE;
419 break;
420 case NotificationConstant::DoNotDisturbType::DAILY:
421 outType = DoNotDisturbType::TYPE_DAILY;
422 break;
423 case NotificationConstant::DoNotDisturbType::CLEARLY:
424 outType = DoNotDisturbType::TYPE_CLEARLY;
425 break;
426 default:
427 ANS_LOGD("DoNotDisturbType %{public}d", inType);
428 return false;
429 }
430 return true;
431 }
432
DeviceRemindTypeCToJS(const NotificationConstant::RemindType & inType,DeviceRemindType & outType)433 bool AnsEnumUtil::DeviceRemindTypeCToJS(const NotificationConstant::RemindType &inType, DeviceRemindType &outType)
434 {
435 switch (inType) {
436 case NotificationConstant::RemindType::DEVICE_IDLE_DONOT_REMIND:
437 outType = DeviceRemindType::IDLE_DONOT_REMIND;
438 break;
439 case NotificationConstant::RemindType::DEVICE_IDLE_REMIND:
440 outType = DeviceRemindType::IDLE_REMIND;
441 break;
442 case NotificationConstant::RemindType::DEVICE_ACTIVE_DONOT_REMIND:
443 outType = DeviceRemindType::ACTIVE_DONOT_REMIND;
444 break;
445 case NotificationConstant::RemindType::DEVICE_ACTIVE_REMIND:
446 outType = DeviceRemindType::ACTIVE_REMIND;
447 break;
448 default:
449 ANS_LOGD("DeviceRemindType %{public}d", inType);
450 return false;
451 }
452 return true;
453 }
454
SourceTypeCToJS(const NotificationConstant::SourceType & inType,SourceType & outType)455 bool AnsEnumUtil::SourceTypeCToJS(const NotificationConstant::SourceType &inType, SourceType &outType)
456 {
457 switch (inType) {
458 case NotificationConstant::SourceType::TYPE_NORMAL:
459 outType = SourceType::TYPE_NORMAL;
460 break;
461 case NotificationConstant::SourceType::TYPE_CONTINUOUS:
462 outType = SourceType::TYPE_CONTINUOUS;
463 break;
464 case NotificationConstant::SourceType::TYPE_TIMER:
465 outType = SourceType::TYPE_TIMER;
466 break;
467 default:
468 ANS_LOGD("SourceType %{public}d", inType);
469 return false;
470 }
471 return true;
472 }
473
LiveViewStatusCToJS(const NotificationLiveViewContent::LiveViewStatus & inType,LiveViewStatus & outType)474 bool AnsEnumUtil::LiveViewStatusCToJS(const NotificationLiveViewContent::LiveViewStatus &inType,
475 LiveViewStatus &outType)
476 {
477 switch (inType) {
478 case NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_CREATE:
479 outType = LiveViewStatus::LIVE_VIEW_CREATE;
480 break;
481 case NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_INCREMENTAL_UPDATE:
482 outType = LiveViewStatus::LIVE_VIEW_INCREMENTAL_UPDATE;
483 break;
484 case NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_END:
485 outType = LiveViewStatus::LIVE_VIEW_END;
486 break;
487 case NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_FULL_UPDATE:
488 outType = LiveViewStatus::LIVE_VIEW_FULL_UPDATE;
489 break;
490 default:
491 ANS_LOGD("LiveViewStatus %{public}d", inType);
492 return false;
493 }
494
495 return true;
496 }
LiveViewTypesCToJS(const NotificationLocalLiveViewContent::LiveViewTypes & inType,LiveViewTypes & outType)497 bool AnsEnumUtil::LiveViewTypesCToJS(const NotificationLocalLiveViewContent::LiveViewTypes &inType,
498 LiveViewTypes &outType)
499 {
500 switch (inType) {
501 case NotificationLocalLiveViewContent::LiveViewTypes::LIVE_VIEW_ACTIVITY:
502 outType = LiveViewTypes::LIVE_VIEW_ACTIVITY;
503 break;
504 case NotificationLocalLiveViewContent::LiveViewTypes::LIVE_VIEW_INSTANT:
505 outType = LiveViewTypes::LIVE_VIEW_INSTANT;
506 break;
507 case NotificationLocalLiveViewContent::LiveViewTypes::LIVE_VIEW_LONG_TERM:
508 outType = LiveViewTypes::LIVE_VIEW_LONG_TERM;
509 break;
510 case NotificationLocalLiveViewContent::LiveViewTypes::LIVE_VIEW_INSTANT_BANNER:
511 outType = LiveViewTypes::LIVE_VIEW_INSTANT_BANNER;
512 break;
513 default:
514 ANS_LOGD("LiveViewTypes %{public}d", inType);
515 return false;
516 }
517
518 return true;
519 }
520 }
521 }
522