• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 <map>
17 #include <fstream>
18 #include "iam_common_defines.h"
19 #include "iam_logger.h"
20 #include "directory_ex.h"
21 #include "user_auth_common_defines.h"
22 #include "config_policy_utils.h"
23 #include "widget_json.h"
24 
25 #define LOG_TAG "USER_AUTH_SA"
26 
27 namespace OHOS {
28 namespace UserIam {
29 namespace UserAuth {
30 
31 const std::string AUTH_TYPE_PIN = "pin";
32 const std::string AUTH_TYPE_FACE = "face";
33 const std::string AUTH_TYPE_FINGER_PRINT = "fingerprint";
34 const std::string AUTH_TYPE_ALL = "all";
35 const std::string AUTH_TYPE_PRIVATE_PIN = "privatePin";
36 
37 const std::string WINDOW_MODE_DIALOG = "DIALOG_BOX";
38 const std::string WINDOW_MODE_FULLSCREEN = "FULLSCREEN";
39 const std::string WINDOW_MODE_NONE_INTERRUPTION_DIALOG_BOX = "NONE_INTERRUPTION_DIALOG_BOX";
40 
41 const std::string PIN_SUB_TYPE_SIX = "PIN_SIX";
42 const std::string PIN_SUB_TYPE_NUM = "PIN_NUMBER";
43 const std::string PIN_SUB_TYPE_MIX = "PIN_MIXED";
44 const std::string PIN_SUB_TYPE_FOUR = "PIN_FOUR";
45 const std::string PIN_SUB_TYPE_PATTERN = "PIN_PATTERN";
46 const std::string PIN_SUB_TYPE_MAX = "PIN_MAX";
47 
48 const std::string JSON_AUTH_TYPE = "type";
49 const std::string JSON_WIDGET_CTX_ID = "widgetContextId";
50 const std::string JSON_WIDGET_CTX_ID_STR = "widgetContextIdStr";
51 const std::string JSON_AUTH_EVENT = "event";
52 const std::string JSON_AUTH_VERSION = "version";
53 const std::string JSON_AUTH_PAYLOAD = "payload";
54 const std::string JSON_AUTH_END_AFTER_FIRST_FAIL = "endAfterFirstFail";
55 const std::string JSON_AUTH_INTENT = "authIntent";
56 const std::string JSON_AUTH_TIP_CODE = "tipCode";
57 const std::string JSON_ORIENTATION = "orientation";
58 const std::string JSON_NEED_ROTATE = "needRotate";
59 const std::string JSON_ALREADY_LOAD = "alreadyLoad";
60 const std::string JSON_LOCKOUT_DURATION = "lockoutDuration";
61 const std::string JSON_REMAIN_ATTEMPTS = "remainAttempts";
62 const std::string JSON_AUTH_RESULT = "result";
63 const std::string JSON_SENSOR_INFO = "sensorInfo";
64 const std::string JSON_AUTH_TIP_TYPE = "tipType";
65 const std::string JSON_AUTH_TIP_INFO = "tipInfo";
66 const std::string JSON_AUTH_TITLE = "title";
67 const std::string JSON_AUTH_CMD = "cmd";
68 const std::string JSON_AUTH_PIN_SUB_TYPE = "pinSubType";
69 const std::string JSON_AUTH_WINDOW_MODE = "windowModeType";
70 const std::string JSON_AUTH_NAVI_BTN_TEXT = "navigationButtonText";
71 const std::string JSON_WIDGET_IS_RELOAD = "isReload";
72 const std::string JSON_WIDGET_ROTATE_AUTH_TYPE = "rotateAuthType";
73 const std::string JSON_WIDGET_CALLING_PROCESS_NAME = "callingProcessName";
74 const std::string JSON_WIDGET_CALLING_APP_ID = "callingAppID";
75 const std::string JSON_WIDGET_USER_ID = "userId";
76 const std::string JSON_WIDGET_SKIP_LOCKED_BIOMETRIC_AUTH = "skipLockedBiometricAuth";
77 
78 const std::string JSON_UI_EXTENSION_TYPE = "ability.want.params.uiExtensionType";
79 const std::string JSON_UI_EXT_NODE_ANGLE = "ability.want.params.uiExtNodeAngle";
80 const std::string JSON_USER_IAM_CMD_DATA = "useriamCmdData";
81 const std::string JSON_SYS_DIALOG_ZORDER = "sysDialogZOrder";
82 const std::string JSON_IS_ENABLE_ROTATE = "isEnableRotate";
83 
84 const std::string JSON_CHALLENGE = "challenge";
85 const std::string JSON_CALLER_BUNDLE_NAME = "callingBundleName";
86 const std::string JSON_CMD_EXTRA_INFO = "extraInfo";
87 
88 constexpr const char *AUTH_WIDGE_CONFIG_SUFFIX = "etc/auth_widget/auth_widget_config.json";
89 const std::string SHWO_WITH_LEVEL_2_WINDOW = "show_with_level_2_window";
90 const std::string FOLLOW_CALLER_WINDOW_WHEN_FOLDED = "follow_caller_window_when_folded";
91 const std::string SCENEBOARD_BUNDLE_NAME = "sceneboard_bundle_name";
92 const std::string SCENEBOARD_ABILITY_NAME = "sceneboard_ability_name";
93 
94 const uint32_t DISABLE_ROTATE = 0;
95 const uint32_t MAX_ERR_BUF_LEN = 256;
96 
97 namespace {
GetJsonPayload(nlohmann::json & jsonPayload,const WidgetCommand::Cmd & cmd)98 void GetJsonPayload(nlohmann::json &jsonPayload, const WidgetCommand::Cmd &cmd)
99 {
100     jsonPayload[JSON_AUTH_TYPE] = cmd.type;
101     if (cmd.lockoutDuration != -1) {
102         jsonPayload[JSON_LOCKOUT_DURATION] = cmd.lockoutDuration;
103     }
104     if (cmd.remainAttempts != -1) {
105         jsonPayload[JSON_REMAIN_ATTEMPTS] = cmd.remainAttempts;
106     }
107     if (cmd.event == CMD_NOTIFY_AUTH_RESULT || cmd.result == PIN_EXPIRED) {
108         jsonPayload[JSON_AUTH_RESULT] = cmd.result;
109     }
110     if (cmd.event == CMD_NOTIFY_AUTH_TIP) {
111         jsonPayload[JSON_AUTH_TIP_TYPE] = cmd.tipType;
112         jsonPayload[JSON_AUTH_TIP_INFO] = cmd.tipInfo;
113     }
114     if (!cmd.sensorInfo.empty()) {
115         jsonPayload[JSON_SENSOR_INFO] = cmd.sensorInfo;
116     }
117     auto jsonCmdExtraInfo = nlohmann::json({{JSON_CHALLENGE, cmd.extraInfo.challenge},
118         {JSON_CALLER_BUNDLE_NAME, cmd.extraInfo.callingBundleName}});
119     jsonPayload[JSON_CMD_EXTRA_INFO] = jsonCmdExtraInfo;
120 }
121 
GetJsonCmd(nlohmann::json & jsonCommand,const WidgetCommand & command)122 void GetJsonCmd(nlohmann::json &jsonCommand, const WidgetCommand &command)
123 {
124     std::vector<nlohmann::json> jsonCmdList;
125     for (auto &cmd : command.cmdList) {
126         auto jsonCmd = nlohmann::json({{JSON_AUTH_EVENT, cmd.event},
127             {JSON_AUTH_VERSION, cmd.version}
128         });
129         nlohmann::json jsonPayload;
130         GetJsonPayload(jsonPayload, cmd);
131         jsonCmd[JSON_AUTH_PAYLOAD] = jsonPayload;
132         jsonCmdList.push_back(jsonCmd);
133     }
134 
135     jsonCommand = nlohmann::json({{JSON_WIDGET_CTX_ID, command.widgetContextId},
136         {JSON_AUTH_TYPE, command.typeList},
137         {JSON_AUTH_TITLE, command.title},
138         {JSON_AUTH_CMD, jsonCmdList},
139         {JSON_WIDGET_CTX_ID_STR, command.widgetContextIdStr}
140     });
141     if (command.pinSubType != "") {
142         jsonCommand[JSON_AUTH_PIN_SUB_TYPE] = command.pinSubType;
143     }
144     if (command.windowModeType != "") {
145         jsonCommand[JSON_AUTH_WINDOW_MODE] = command.windowModeType;
146     }
147     if (command.navigationButtonText != "") {
148         jsonCommand[JSON_AUTH_NAVI_BTN_TEXT] = command.navigationButtonText;
149     }
150     jsonCommand[JSON_WIDGET_IS_RELOAD] = command.isReload;
151     jsonCommand[JSON_WIDGET_ROTATE_AUTH_TYPE] = command.rotateAuthType;
152     jsonCommand[JSON_WIDGET_CALLING_APP_ID] = command.callingAppID;
153     jsonCommand[JSON_WIDGET_CALLING_PROCESS_NAME] = command.callingProcessName;
154     jsonCommand[JSON_WIDGET_USER_ID] = command.userId;
155     jsonCommand[JSON_WIDGET_SKIP_LOCKED_BIOMETRIC_AUTH] = command.skipLockedBiometricAuth;
156 }
157 
ReadFileIntoJson(const std::string & filePath,nlohmann::json & jsonBuf)158 bool ReadFileIntoJson(const std::string &filePath, nlohmann::json &jsonBuf)
159 {
160     IAM_LOGI("ReadFileIntoJson entry");
161     std::string realPath;
162     if (!PathToRealPath(filePath, realPath)) {
163         IAM_LOGE("Path to realPath failed");
164         return false;
165     }
166 
167     char errBuf[MAX_ERR_BUF_LEN];
168     errBuf[0] = '\0';
169     std::fstream in;
170     in.open(realPath, std::ios_base::in);
171     if (!in.is_open()) {
172         strerror_r(errno, errBuf, sizeof(errBuf));
173         IAM_LOGE("file open failed due to %{public}s, errno:%{public}d", errBuf, errno);
174         return false;
175     }
176 
177     in.seekg(0, std::ios::end);
178     int64_t size = in.tellg();
179     if (size <= 0) {
180         IAM_LOGE("file empty, errno:%{public}d", errno);
181         in.close();
182         return false;
183     }
184 
185     in.seekg(0, std::ios::beg);
186     jsonBuf = nlohmann::json::parse(in, nullptr, false);
187     in.close();
188     if (jsonBuf.is_discarded()) {
189         IAM_LOGE("bad profile file");
190         return false;
191     }
192 
193     return true;
194 }
195 
GetStringArrayFromJson(const nlohmann::json & jsonObject,std::vector<std::string> & exemptedBundleInfos,const std::string & key)196 bool GetStringArrayFromJson(const nlohmann::json &jsonObject,
197     std::vector<std::string> &exemptedBundleInfos,
198     const std::string &key)
199 {
200     if (jsonObject.is_null()) {
201         IAM_LOGE("jsonObject is null");
202         return false;
203     }
204     if (jsonObject.is_array() && !jsonObject.is_discarded()) {
205         for (const auto &object : jsonObject) {
206             if (!object.is_object()) {
207                 IAM_LOGE("is not object");
208                 return false;
209             }
210             const auto &objectEnd = object.end();
211             if (object.find(key) != objectEnd) {
212                 exemptedBundleInfos = object.at(key).get<std::vector<std::string>>();
213                 break;
214             }
215         }
216         return true;
217     }
218     IAM_LOGE("getStringArrayFromJson error");
219     return false;
220 }
221 
GetStringFromJson(const nlohmann::json & jsonObject,std::string & exemptedBundleInfo,const std::string & key)222 bool GetStringFromJson(const nlohmann::json &jsonObject, std::string &exemptedBundleInfo,
223     const std::string &key)
224 {
225     if (jsonObject.is_null()) {
226         IAM_LOGE("jsonObject is null");
227         return false;
228     }
229     if (jsonObject.is_array() && !jsonObject.is_discarded()) {
230         for (const auto &object : jsonObject) {
231             if (!object.is_object()) {
232                 IAM_LOGE("is not object");
233                 return false;
234             }
235             const auto &objectEnd = object.end();
236             if (object.find(key) != objectEnd) {
237                 exemptedBundleInfo = object.at(key).get<std::string>();
238                 return true;
239             }
240         }
241     }
242     IAM_LOGE("getStringFromJson error");
243     return false;
244 }
245 }
246 
247 // utils
Str2AuthType(const std::string & strAuthType)248 AuthType Str2AuthType(const std::string &strAuthType)
249 {
250     AuthType authType = AuthType::ALL;
251     if (strAuthType.compare(AUTH_TYPE_ALL) == 0) {
252         authType = AuthType::ALL;
253     } else if (strAuthType.compare(AUTH_TYPE_PIN) == 0) {
254         authType = AuthType::PIN;
255     } else if (strAuthType.compare(AUTH_TYPE_FACE) == 0) {
256         authType = AuthType::FACE;
257     } else if (strAuthType.compare(AUTH_TYPE_FINGER_PRINT) == 0) {
258         authType = AuthType::FINGERPRINT;
259     } else if (strAuthType.compare(AUTH_TYPE_PRIVATE_PIN) == 0) {
260         authType = AuthType::PRIVATE_PIN;
261     } else {
262         IAM_LOGE("strAuthType: %{public}s", strAuthType.c_str());
263     }
264     return authType;
265 }
266 
AuthType2Str(const AuthType & authType)267 std::string AuthType2Str(const AuthType &authType)
268 {
269     std::string strAuthType = "";
270     switch (authType) {
271         case AuthType::ALL: {
272             strAuthType = AUTH_TYPE_ALL;
273             break;
274         }
275         case AuthType::PIN: {
276             strAuthType = AUTH_TYPE_PIN;
277             break;
278         }
279         case AuthType::FACE: {
280             strAuthType = AUTH_TYPE_FACE;
281             break;
282         }
283         case AuthType::FINGERPRINT: {
284             strAuthType = AUTH_TYPE_FINGER_PRINT;
285             break;
286         }
287         case AuthType::PRIVATE_PIN: {
288             strAuthType = AUTH_TYPE_PRIVATE_PIN;
289             break;
290         }
291         default: {
292             IAM_LOGE("authType: %{public}u", authType);
293         }
294     }
295     return strAuthType;
296 }
297 
WinModeType2Str(const WindowModeType & winModeType)298 std::string WinModeType2Str(const WindowModeType &winModeType)
299 {
300     std::string strWinModeType = "";
301     switch (winModeType) {
302         case WindowModeType::DIALOG_BOX: {
303             strWinModeType = WINDOW_MODE_DIALOG;
304             break;
305         }
306         case WindowModeType::FULLSCREEN: {
307             strWinModeType = WINDOW_MODE_FULLSCREEN;
308             break;
309         }
310         case WindowModeType::NONE_INTERRUPTION_DIALOG_BOX: {
311             strWinModeType = WINDOW_MODE_NONE_INTERRUPTION_DIALOG_BOX;
312             break;
313         }
314         default: {
315             IAM_LOGE("winModeType: %{public}u", winModeType);
316         }
317     }
318     return strWinModeType;
319 }
320 
AuthTypeList() const321 std::vector<AuthType> WidgetNotice::AuthTypeList() const
322 {
323     std::vector<AuthType> authTypeList;
324     for (const auto &type : typeList) {
325         authTypeList.emplace_back(Str2AuthType(type));
326     }
327     return authTypeList;
328 }
329 
PinSubType2Str(const PinSubType & subType)330 std::string PinSubType2Str(const PinSubType &subType)
331 {
332     std::string strPinSubType = "";
333     switch (subType) {
334         case PinSubType::PIN_SIX: {
335             strPinSubType = PIN_SUB_TYPE_SIX;
336             break;
337         }
338         case PinSubType::PIN_NUMBER: {
339             strPinSubType = PIN_SUB_TYPE_NUM;
340             break;
341         }
342         case PinSubType::PIN_MIXED: {
343             strPinSubType = PIN_SUB_TYPE_MIX;
344             break;
345         }
346         case PinSubType::PIN_FOUR: {
347             strPinSubType = PIN_SUB_TYPE_FOUR;
348             break;
349         }
350         case PinSubType::PIN_PATTERN: {
351             strPinSubType = PIN_SUB_TYPE_PATTERN;
352             break;
353         }
354         case PinSubType::PIN_MAX: {
355             strPinSubType = PIN_SUB_TYPE_MAX;
356             break;
357         }
358         default: {
359             IAM_LOGE("subType: %{public}u", subType);
360         }
361     }
362     return strPinSubType;
363 }
364 
to_json(nlohmann::json & jsonNotice,const WidgetNotice & notice)365 void to_json(nlohmann::json &jsonNotice, const WidgetNotice &notice)
366 {
367     auto type = nlohmann::json({{JSON_AUTH_TYPE, notice.typeList},
368         {JSON_AUTH_END_AFTER_FIRST_FAIL, notice.endAfterFirstFail},
369         {JSON_AUTH_INTENT, notice.authIntent},
370         {JSON_AUTH_TIP_CODE, notice.tipCode}});
371     jsonNotice = nlohmann::json({{JSON_WIDGET_CTX_ID, notice.widgetContextId},
372         {JSON_AUTH_EVENT, notice.event},
373         {JSON_ORIENTATION, notice.orientation},
374         {JSON_NEED_ROTATE, notice.needRotate},
375         {JSON_ALREADY_LOAD, notice.alreadyLoad},
376         {JSON_AUTH_VERSION, notice.version},
377         {JSON_AUTH_PAYLOAD, type}});
378 }
379 
isNumberItem(const nlohmann::json & jsonNotice,const std::string & item)380 bool isNumberItem(const nlohmann::json &jsonNotice, const std::string &item)
381 {
382     if (jsonNotice.find(item) != jsonNotice.end() && jsonNotice[item].is_number()) {
383         return true;
384     }
385     return false;
386 }
387 
from_json(const nlohmann::json & jsonNotice,WidgetNotice & notice)388 void from_json(const nlohmann::json &jsonNotice, WidgetNotice &notice)
389 {
390     if (isNumberItem(jsonNotice, JSON_WIDGET_CTX_ID)) {
391         jsonNotice.at(JSON_WIDGET_CTX_ID).get_to(notice.widgetContextId);
392     }
393     if (jsonNotice.find(JSON_AUTH_EVENT) != jsonNotice.end() && jsonNotice[JSON_AUTH_EVENT].is_string()) {
394         jsonNotice.at(JSON_AUTH_EVENT).get_to(notice.event);
395     }
396     if (isNumberItem(jsonNotice, JSON_ORIENTATION)) {
397         jsonNotice.at(JSON_ORIENTATION).get_to(notice.orientation);
398     }
399     if (isNumberItem(jsonNotice, JSON_NEED_ROTATE)) {
400         jsonNotice.at(JSON_NEED_ROTATE).get_to(notice.needRotate);
401     }
402     if (isNumberItem(jsonNotice, JSON_ALREADY_LOAD)) {
403         jsonNotice.at(JSON_ALREADY_LOAD).get_to(notice.alreadyLoad);
404     }
405     if (jsonNotice.find(JSON_AUTH_VERSION) != jsonNotice.end() && jsonNotice[JSON_AUTH_VERSION].is_string()) {
406         jsonNotice.at(JSON_AUTH_VERSION).get_to(notice.version);
407     }
408     if (jsonNotice.find(JSON_AUTH_PAYLOAD) == jsonNotice.end()) {
409         return;
410     }
411     if (jsonNotice[JSON_AUTH_PAYLOAD].find(JSON_AUTH_TYPE) != jsonNotice[JSON_AUTH_PAYLOAD].end() &&
412         jsonNotice[JSON_AUTH_PAYLOAD][JSON_AUTH_TYPE].is_array()) {
413         for (size_t index = 0; index < jsonNotice[JSON_AUTH_PAYLOAD][JSON_AUTH_TYPE].size(); index++) {
414             if (!jsonNotice[JSON_AUTH_PAYLOAD][JSON_AUTH_TYPE].at(index).is_string()) {
415                 notice.typeList.clear();
416                 break;
417             }
418             notice.typeList.emplace_back(jsonNotice[JSON_AUTH_PAYLOAD][JSON_AUTH_TYPE].at(index).get<std::string>());
419         }
420     }
421     if ((jsonNotice[JSON_AUTH_PAYLOAD].find(JSON_AUTH_END_AFTER_FIRST_FAIL) !=
422             jsonNotice[JSON_AUTH_PAYLOAD].end()) &&
423         jsonNotice[JSON_AUTH_PAYLOAD][JSON_AUTH_END_AFTER_FIRST_FAIL].is_boolean()) {
424         jsonNotice[JSON_AUTH_PAYLOAD].at(JSON_AUTH_END_AFTER_FIRST_FAIL).get_to(notice.endAfterFirstFail);
425     }
426     if (isNumberItem(jsonNotice[JSON_AUTH_PAYLOAD], JSON_AUTH_INTENT)) {
427         jsonNotice[JSON_AUTH_PAYLOAD].at(JSON_AUTH_INTENT).get_to(notice.authIntent);
428     }
429     if (isNumberItem(jsonNotice[JSON_AUTH_PAYLOAD], JSON_AUTH_TIP_CODE)) {
430         jsonNotice[JSON_AUTH_PAYLOAD].at(JSON_AUTH_TIP_CODE).get_to(notice.tipCode);
431     }
432 }
433 
GetConfigRealPath()434 std::string GetConfigRealPath()
435 {
436     char buf[MAX_PATH_LEN] = { 0 };
437     char *configPath = GetOneCfgFile(AUTH_WIDGE_CONFIG_SUFFIX, buf, MAX_PATH_LEN);
438     if (configPath == nullptr || configPath[0] == '\0' || strlen(configPath) > MAX_PATH_LEN) {
439         IAM_LOGE("get configPath error");
440         return AUTH_WIDGE_CONFIG_SUFFIX;
441     }
442     return configPath;
443 }
444 
LoadConfigJsonBuffer(nlohmann::json & jsonBuf)445 void LoadConfigJsonBuffer(nlohmann::json &jsonBuf)
446 {
447     IAM_LOGI("LoadConfig start");
448     std::string configPath = GetConfigRealPath();
449     if (!ReadFileIntoJson(configPath, jsonBuf)) {
450         IAM_LOGE("ReadFileIntoJson failed");
451     }
452 }
453 
GetSceneboardBundleName(nlohmann::json & jsonBuf,std::string & processName)454 bool GetSceneboardBundleName(nlohmann::json &jsonBuf, std::string &processName)
455 {
456     IAM_LOGI("enter");
457     if (!GetStringFromJson(jsonBuf, processName, SCENEBOARD_BUNDLE_NAME)) {
458         IAM_LOGE("GetStringFromJson failed");
459         return false;
460     }
461     return true;
462 }
463 
GetSceneboardAbilityName(nlohmann::json & jsonBuf,std::string & processName)464 bool GetSceneboardAbilityName(nlohmann::json &jsonBuf, std::string &processName)
465 {
466     IAM_LOGI("enter");
467     if (!GetStringFromJson(jsonBuf, processName, SCENEBOARD_ABILITY_NAME)) {
468         IAM_LOGE("GetStringFromJson failed");
469         return false;
470     }
471     return true;
472 }
473 
GetProcessName(nlohmann::json & jsonBuf,std::vector<std::string> & processName)474 bool GetProcessName(nlohmann::json &jsonBuf, std::vector<std::string> &processName)
475 {
476     IAM_LOGI("enter");
477     if (!GetStringArrayFromJson(jsonBuf, processName, SHWO_WITH_LEVEL_2_WINDOW)) {
478         IAM_LOGE("GetStringArrayFromJson failed");
479         return false;
480     }
481     return true;
482 }
483 
GetFollowCallerList(nlohmann::json & jsonBuf,std::vector<std::string> & processName)484 bool GetFollowCallerList(nlohmann::json &jsonBuf, std::vector<std::string> &processName)
485 {
486     IAM_LOGI("enter");
487     if (!GetStringArrayFromJson(jsonBuf, processName, FOLLOW_CALLER_WINDOW_WHEN_FOLDED)) {
488         IAM_LOGE("GetStringArrayFromJson failed");
489         return false;
490     }
491     return true;
492 }
493 
to_json(nlohmann::json & jsonCommand,const WidgetCommand & command)494 void to_json(nlohmann::json &jsonCommand, const WidgetCommand &command)
495 {
496     GetJsonCmd(jsonCommand, command);
497 }
498 
499 // WidgetCmdParameters
to_json(nlohmann::json & jsWidgetCmdParam,const WidgetCmdParameters & widgetCmdParameters)500 void to_json(nlohmann::json &jsWidgetCmdParam, const WidgetCmdParameters &widgetCmdParameters)
501 {
502     nlohmann::json jsonCommand;
503     GetJsonCmd(jsonCommand, widgetCmdParameters.useriamCmdData);
504 
505     jsWidgetCmdParam = nlohmann::json({{JSON_UI_EXTENSION_TYPE, widgetCmdParameters.uiExtensionType},
506         {JSON_SYS_DIALOG_ZORDER, widgetCmdParameters.sysDialogZOrder},
507         {JSON_UI_EXT_NODE_ANGLE, widgetCmdParameters.uiExtNodeAngle},
508         {JSON_IS_ENABLE_ROTATE, DISABLE_ROTATE},
509         {JSON_USER_IAM_CMD_DATA, jsonCommand}
510     });
511 }
512 } // namespace UserAuth
513 } // namespace UserIam
514 } // namespace OHOS