• 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 #ifndef FOUNDATION_APPEXECFWK_SERVICES_FORMMGR_INCLUDE_FORM_UTIL_H
17 #define FOUNDATION_APPEXECFWK_SERVICES_FORMMGR_INCLUDE_FORM_UTIL_H
18 
19 #include "want.h"
20 
21 namespace OHOS {
22 namespace AppExecFwk {
23 using Want = OHOS::AAFwk::Want;
24 /**
25  * @class FormUtil
26  * form utils.
27  */
28 class FormUtil {
29 public:
30     /**
31      * @brief create want for form.
32      * @param formName The name of the form.
33      * @param specificationId specification id.
34      * @param isTemporaryForm temporary form or not.
35      * @param want The want of the form.
36      */
37     static void CreateFormWant(const std::string &formName, const int32_t specificationId, const bool isTemporaryForm,
38     Want &want);
39     /**
40      * @brief create default want for form.
41      * @param want The want of the form..
42      * @param uri The uri.
43      * @param userId user id.
44      */
45     static void CreateDefaultFormWant(Want &want, const std::string &uri, const int32_t userId);
46 
47     /**
48      * @brief create udid for form.
49      * @return udid.
50      */
51     static std::string GenerateUdid();
52 
53     /**
54      * @brief create form id for form.
55      * @param udidHash udid hash
56      * @return new form id.
57      */
58     static int64_t GenerateFormId(int64_t udidHash);
59 
60     /**
61      * @brief padding form id.
62      * @param formId The id of the form.
63      * @param udidHash udid hash.
64      * @return new form id.
65      */
66     static int64_t PaddingUDIDHash(uint64_t formId, uint64_t udidHash);
67 
68     /**
69      * @brief create udid hash.
70      * @param udidHash udid hash.
71      * @return Returns true on success, false on failure.
72      */
73     static bool GenerateUdidHash(int64_t &udidHash);
74     /**
75      * @brief Get current system nanosecond.
76      * @return Current system nanosecond.
77      */
78     static int64_t GetCurrentNanosecond();
79     /**
80      * @brief Get current system millisecond.
81      * @return Current system millisecond.
82      */
83     static int64_t GetCurrentMillisecond();
84     /**
85      * @brief Get millisecond from tm.
86      * @param tmAtTime tm time.
87      * @return Millisecond.
88      */
89     static int64_t GetMillisecondFromTm(struct tm &tmAtTime);
90 
91     /**
92      * @brief split string.
93      * @param in string.
94      * @param delim delimiter.
95      * @return string list.
96      */
97     static std::vector<std::string> StringSplit(const std::string &in, const std::string &delim);
98 
99     /**
100      * @brief get current active account id.
101      * @return int current active account id.
102      */
103     static int GetCurrentAccountId();
104 };
105 }  // namespace AppExecFwk
106 }  // namespace OHOS
107 #endif  // FOUNDATION_APPEXECFWK_SERVICES_FORMMGR_INCLUDE_FORM_UTIL_H