• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /**
17  * @addtogroup OsAccount
18  * @{
19  *
20  * @brief Provides os account management.
21  *
22  * Provides abilities for you to manage and perform operations on your OS accounts.
23  *
24  * @since 7.0
25  * @version 7.0
26  */
27 
28 /**
29  * @file os_account_manager.h
30  *
31  * @brief Declares os account manager interfaces.
32  *
33  * @since 7.0
34  * @version 7.0
35  */
36 
37 #ifndef OS_ACCOUNT_INTERFACES_INNERKITS_OS_ACCOUNT_MANAGER_H
38 #define OS_ACCOUNT_INTERFACES_INNERKITS_OS_ACCOUNT_MANAGER_H
39 
40 #include <string>
41 #include <vector>
42 #include "domain_account_callback.h"
43 #include "os_account_info.h"
44 #include "os_account_subscriber.h"
45 #include "account_error_no.h"
46 namespace OHOS {
47 namespace AccountSA {
48 class OsAccountManager {
49 public:
50     /**
51      * @brief Creates an OS account using the local name and account type.
52      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
53      * @param localName - Indicates the local name of the OS account to create.
54      * @param type - Indicates the type of the OS account to create.
55      * @param osAccountInfo - Indicates the information about the created OS account.
56      * @return error code, see account_error_no.h
57      */
58     static ErrCode CreateOsAccount(const std::string &name, const OsAccountType &type, OsAccountInfo &osAccountInfo);
59 
60     /**
61      * @brief Creates an OS account using the local name, short name and account type.
62      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
63      * @param localName - Indicates the local name of the OS account to create.
64      * @param shortName - Indicates the short name of the OS account to create.
65      * @param type - Indicates the type of the OS account to create.
66      * @param osAccountInfo - Indicates the information about the created OS account.
67      * @return error code, see account_error_no.h
68      */
69     static ErrCode CreateOsAccount(const std::string& localName, const std::string& shortName,
70         const OsAccountType& type, OsAccountInfo& osAccountInfo);
71 
72     /**
73      * @brief Creates an OS account using the local name, short name, account type and other options.
74      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
75      * @param localName - Indicates the local name of the OS account to create.
76      * @param shortName - Indicates the short name of the OS account to create.
77      * @param type - Indicates the type of the OS account to create.
78      * @param options - Indicates the options of the OS account to create.
79      *                - Include disallowedHapList - Indicates the disallowed install hap list.
80      * @param osAccountInfo - Indicates the information about the created OS account.
81      * @return error code, see account_error_no.h
82      */
83     static ErrCode CreateOsAccount(const std::string& localName, const std::string& shortName,
84         const OsAccountType& type, const CreateOsAccountOptions& options, OsAccountInfo& osAccountInfo);
85 
86     /**
87      * @brief Creates an OS account using full user info
88      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
89      * @param osAccountInfo - Indicates the information about the created OS account.
90      * @return error code, see account_error_no.h
91      */
92     static ErrCode CreateOsAccountWithFullInfo(OsAccountInfo &osAccountInfo,
93         const CreateOsAccountOptions& options = {});
94 
95     /**
96      * @brief Updates an OS account using full user info
97      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
98      * @param osAccountInfo - Indicates the information about the created OS account.
99      * @return error code, see account_error_no.h
100      */
101     static ErrCode UpdateOsAccountWithFullInfo(OsAccountInfo &osAccountInfo);
102 
103     /**
104      * @brief Creates an OS account using the account type and domain account info.
105      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
106      * @param type - Indicates the type of the OS account to create.
107      * @param domainInfo - Indicates the domain account info.
108      * @param callback - Indicates the callback for getting the information of the created OS account.
109      * @return error code, see account_error_no.h
110      */
111     static ErrCode CreateOsAccountForDomain(const OsAccountType &type, const DomainAccountInfo &domainInfo,
112         const std::shared_ptr<DomainAccountCallback> &callback, const CreateOsAccountForDomainOptions& options = {});
113 
114     /**
115      * @brief Removes an OS account based on its local ID.
116      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
117      * @param id - Indicates the local ID of the OS account.
118      * @return error code, see account_error_no.h
119      */
120     static ErrCode RemoveOsAccount(const int id);
121 
122     /**
123      * @brief Checks whether the specified OS account exists.
124      * @param id - Indicates the local ID of the OS account.
125      * @param isOsAccountExists - Indicates whether the specified OS account exists.
126      * @return error code, see account_error_no.h
127      */
128     static ErrCode IsOsAccountExists(const int id, bool &isOsAccountExists);
129 
130     /**
131      * @brief Checks whether an OS account is activated based on its local ID.
132      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
133      * @param id - Indicates the local ID of the OS account.
134      * @param isOsAccountActived - Indicates whether the OS account is activated.
135      * @return error code, see account_error_no.h
136      */
137     static ErrCode IsOsAccountActived(const int id, bool &isOsAccountActived);
138 
139     /**
140      * @brief Checks whether the specified constraint is enabled for the specified OS account.
141      * @param id - Indicates the local ID of the OS account.
142      * @param constriaint - Indicates the constraint.
143      * @param isConstraintEnable - Indicates whether the specified constraint is enabled.
144      * @return error code, see account_error_no.h
145      */
146     static ErrCode IsOsAccountConstraintEnable(const int id, const std::string &constraint, bool &isConstraintEnable);
147 
148     /**
149      * @brief Checks whether the specified constraint is enabled for the specified OS account.
150      * @param id - Indicates the local ID of the OS account.
151      * @param constriaint - Indicates the constraint.
152      * @param isEnabled - Indicates whether the specified constraint is enabled.
153      * @return error code, see account_error_no.h
154      */
155     static ErrCode CheckOsAccountConstraintEnabled(
156         const int id, const std::string &constraint, bool &isEnabled);
157 
158     /**
159      * @brief Checks whether the specified OS account is verified.
160      * @param id - Indicates the local ID of the OS account.
161      * @param isVerified - Indicates whether the current OS account is verified.
162      * @return error code, see account_error_no.h
163      */
164     static ErrCode IsOsAccountVerified(const int id, bool &isVerified);
165 
166     /**
167      * @brief Checks whether the specified OS account is deactivating.
168      * @param id - Indicates the local ID of the OS account.
169      * @param isDeactivating - Indicates whether the current OS account is deactivating.
170      * @return error code, see account_error_no.h
171      */
172     static ErrCode IsOsAccountDeactivating(const int id, bool &isDeactivating);
173 
174     /**
175      * @brief Gets the number of all OS accounts created on a device.
176      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
177      * @param osAccountsCount - Returns the number of created OS accounts.
178      * @return error code, see account_error_no.h
179      */
180     static ErrCode GetCreatedOsAccountsCount(unsigned int &osAccountsCount);
181 
182     /**
183      * @brief Gets the local ID of the current OS account.
184      * @param id - Indicates the local ID of the current OS account.
185      * @return error code, see account_error_no.h
186      */
187     static ErrCode GetOsAccountLocalIdFromProcess(int &id);
188 
189     /**
190      * @brief Checks whether current process belongs to the main account.
191      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
192      * @param isMainOsAccount - Indicates whether the current process belongs to the main OS account.
193      * @return error code, see account_error_no.h
194      */
195     static ErrCode IsMainOsAccount(bool &isMainOsAccount);
196 
197     /**
198      * @brief Gets the local ID of an OS account from the process UID
199      * @param uid - Indicates the process UID.
200      * @param id - Indicates the local ID of the OS account associated with the specified UID.
201      * @return error code, see account_error_no.h
202      */
203     static ErrCode GetOsAccountLocalIdFromUid(const int uid, int &id);
204 
205     /**
206      * @brief Gets the bundle ID associated with the specified UID.
207      * @param uid - Indicates the target uid.
208      * @param bundleId - Indicates the bundle ID associated with the specified UID.
209      * @return error code, see account_error_no.h
210      */
211     static ErrCode GetBundleIdFromUid(const int uid, int &bundleId);
212 
213     /**
214      * @brief Gets the local ID of the OS account associated with the specified domain account.
215      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
216      * @param domainInfo - Indicates the domain account info.
217      * @param id - Indicates the local ID of the OS account associated with the specified domain account.
218      * @return error code, see account_error_no.h
219      */
220     static ErrCode GetOsAccountLocalIdFromDomain(const DomainAccountInfo &domainInfo, int &id);
221 
222     /**
223      * @brief Queries the maximum number of OS accounts that can be created on a device.
224      * @param maxOsAccountNumber - Returns the maximum number of OS accounts that can be created.
225      * @return error code, see account_error_no.h
226      */
227     static ErrCode QueryMaxOsAccountNumber(uint32_t &maxOsAccountNumber);
228 
229     /**
230      * @brief Queries the maximum number of OS accounts that can be logged in.
231      * @param maxNum - Returns the maximum number of OS accounts that can be created.
232      * @return error code, see account_error_no.h
233      */
234     static ErrCode QueryMaxLoggedInOsAccountNumber(uint32_t &maxNum);
235 
236     /**
237      * @brief Gets all constraints of an account based on its ID.
238      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
239      * @param localId - Indicates the local ID of the OS account.
240      * @param constraints - Indicates a list of constraints.
241      * @return error code, see account_error_no.h
242      */
243     static ErrCode GetOsAccountAllConstraints(const int id, std::vector<std::string> &constraints);
244 
245     /**
246      * @brief Queries the list of all the OS accounts that have been created in the system.
247      * @selinux The caller needs to configure selinux permissions: allow Caller_SA_Name accountmgr:fd {use}.
248      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
249      * @param osAccountInfos - Indicates a list of OS accounts.
250      * @return error code, see account_error_no.h
251      */
252     static ErrCode QueryAllCreatedOsAccounts(std::vector<OsAccountInfo> &osAccountInfos);
253 
254     /**
255      * @brief Gets information about the current OS account.
256      * @selinux The caller needs to configure selinux permissions: allow Caller_SA_Name accountmgr:fd {use}.
257      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
258      * @param osAccountInfo - Indicates the information about the current OS account.
259      * @return error code, see account_error_no.h
260      */
261     static ErrCode QueryCurrentOsAccount(OsAccountInfo &osAccountInfo);
262 
263     /**
264      * @brief Queries OS account information based on the local ID.
265      * @selinux The caller needs to configure selinux permissions: allow Caller_SA_Name accountmgr:fd {use}.
266      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
267      * @param localId - Indicates the local ID of the OS account.
268      * @param osAccountInfo - Indicates the OS account information.
269      * @return error code, see account_error_no.h
270      */
271     static ErrCode QueryOsAccountById(const int id, OsAccountInfo &osAccountInfo);
272 
273     /**
274      * @brief Gets the type of this OS account from the current process.
275      * @param type - Indicates the OS account type.
276      * @return error code, see account_error_no.h
277      */
278     static ErrCode GetOsAccountTypeFromProcess(OsAccountType &type);
279 
280     /**
281      * @brief Gets the type of this OS account from the current process.
282      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
283      * @param id - Indicates the local ID of the OS account.
284      * @param type - Indicates the OS account type.
285      * @return error code, see account_error_no.h
286      */
287     static ErrCode GetOsAccountType(const int id, OsAccountType& type);
288 
289     /**
290      * @brief Gets the profile photo of an OS account based on its local ID.
291      * @selinux The caller needs to configure selinux permissions: allow Caller_SA_Name accountmgr:fd {use}.
292      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
293      * @param id - Indicates the local ID of the OS account.
294      * @param photo - Indicates the profile photo.
295      * @return error code, see account_error_no.h
296      */
297     static ErrCode GetOsAccountProfilePhoto(const int id, std::string &photo);
298 
299     /**
300      * @brief Checks whether the function of supporting multiple OS accounts is enabled.
301      * @param isMultiOsAccountEnable - Indicates whether multiple OS account feature is enabled.
302      * @return error code, see account_error_no.h
303      */
304     static ErrCode IsMultiOsAccountEnable(bool &isMultiOsAccountEnable);
305 
306     /**
307      * @brief Sets the local name for an OS account based on its local ID.
308      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
309      * @param localId - Indicates the local ID of the OS account.
310      * @param localName - Indicates the local name to set for the OS account.
311      * @return error code, see account_error_no.h
312      */
313     static ErrCode SetOsAccountName(const int id, const std::string &localName);
314 
315     /**
316      * @brief Sets constraints for an OS account based on its local ID.
317      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
318      * @param localId - Indicates the local ID of the OS account.
319      * @param constraints - Indicates the constraints to set for the OS account. The value can be:
320      *        <ul>
321      *        <li>{@code constraint.wifi.set} - Indicates the constraint on configuring the Wi-Fi access point.
322      *        </li>
323      *        <li>{@code constraint.sms.use} - Indicates the constraint on sending and receiving short messages.
324      *        </li>
325      *        <li>{@code constraint.calls.outgoing} - Indicates the constraint on making calls.</li>
326      *        <li>{@code constraint.unknown.sources.install} - Indicates the constraint on installing applications
327      *        from unknown sources.</li>
328      *        </ul>
329      * @param enable - Specifies whether to enable the constraint.
330      * @return error code, see account_error_no.h
331      */
332     static ErrCode SetOsAccountConstraints(
333         const int id, const std::vector<std::string> &constraints, const bool enable);
334 
335     /**
336      * @brief Sets the profile photo for an OS account based on its local ID.
337      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
338      * @param localId - Indicates the local ID of the OS account.
339      * @param photo - Indicates the profile photo to set for the OS account.
340      * @return error code, see account_error_no.h
341      */
342     static ErrCode SetOsAccountProfilePhoto(const int id, const std::string &photo);
343 
344     /**
345      * @brief Gets the distributed virtual device ID (DVID).
346      * <p>
347      * If the same OHOS account has logged in to multiple devices, these devices constitute a super device
348      * through the distributed networking. On the connected devices, you can call this method to obtain the DVIDs.
349      * The same application running on different devices obtains the same DVID, whereas different applications
350      * obtain different DVIDs.
351      * <p>
352      *
353      * @permission ohos.permission.DISTRIBUTED_DATASYNC or ohos.permission.MANAGE_LOCAL_ACCOUNTS
354      * @param dvid - Indicates the DVID if obtained; returns an empty string if no OHOS account has logged in.
355      * @return error code, see account_error_no.h
356      */
357     static ErrCode GetDistributedVirtualDeviceId(std::string &dvid);
358 
359     /**
360      * @brief Gets the distributed virtual device ID (DVID).
361      * <p>
362      * If the same OHOS account has logged in to multiple devices, these devices constitute a super device
363      * through the distributed networking. On the connected devices, you can call this method to obtain the DVIDs.
364      * The same application running on different devices obtains the same DVID, whereas different applications
365      * obtain different DVIDs.
366      * <p>
367      *
368      * @permission ohos.permission.GET_DISTRIBUTED_ACCOUNTS or ohos.permission.MANAGE_LOCAL_ACCOUNTS or
369      * ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS
370      * @param bundleName - Indicates the target bundle name.
371      * @param localId - Indicates the local ID of the OS account.
372      * @param dvid - Indicates the DVID if obtained; returns an empty string if no OHOS account has logged in.
373      * @return error code, see account_error_no.h
374      * @SystemAPI
375      */
376     static ErrCode QueryDistributedVirtualDeviceId(const std::string &bundleName, int32_t localId, std::string &dvid);
377 
378     /**
379      * @brief Activates a specified OS account.
380      * <p>
381      * If multiple OS accounts are available, you can call this method to enable a specific OS account
382      * to run in the foreground. Then, the OS account originally running in the foreground will be
383      * switched to the background.
384      * </p>
385      *
386      * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
387      * @param id - Indicates the local ID of the OS account.
388      * @return error code, see account_error_no.h
389      */
390     static ErrCode ActivateOsAccount(const int id);
391 
392     /**
393      * @brief Deactivates a specified OS account.
394      * <p>
395      * You can call this method to disable a specific OS account.
396      * </p>
397      *
398      * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
399      * @param id - Indicates the local ID of the OS account.
400      * @return error code, see account_error_no.h
401      */
402     static ErrCode DeactivateOsAccount(const int id);
403 
404     /**
405      * @brief Deactivates all OS account.
406      * <p>
407      * You can call this method to disable all OS account.
408      * </p>
409      *
410      * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
411      * @return error code, see account_error_no.h
412      */
413     static ErrCode DeactivateAllOsAccounts();
414 
415     /**
416      * @brief Starts the specified OS account.
417      * @param id - Indicates the local ID of the OS account.
418      * @return error code, see account_error_no.h
419      */
420     static ErrCode StartOsAccount(const int id);
421 
422     /**
423      * @brief Gets localId according to serial number.
424      * @param serialNumber - Indicates serial number.
425      * @param id - Indicates the local ID of the OS account.
426      * @return error code, see account_error_no.h
427      */
428     static ErrCode GetOsAccountLocalIdBySerialNumber(const int64_t serialNumber, int &id);
429 
430     /**
431      * @brief Gets serial number according to localId.
432      * @param localId - Indicates the local ID of the OS account.
433      * @param serialNumber - Indicates the serial number.
434      * @return error code, see account_error_no.h
435      */
436     static ErrCode GetSerialNumberByOsAccountLocalId(const int &id, int64_t &serialNumber);
437 
438     /**
439      * @brief Subscribes the event of an OS account by the subscriber.
440      * @param subscriber subscriber information
441      * @return error code, see account_error_no.h
442      */
443     static ErrCode SubscribeOsAccount(const std::shared_ptr<OsAccountSubscriber> &subscriber);
444 
445     /**
446      * @brief Unsubscribes the event of an OS account by the subscriber.
447      * @param subscriber subscriber information
448      * @return error code, see account_error_no.h
449      */
450     static ErrCode UnsubscribeOsAccount(const std::shared_ptr<OsAccountSubscriber> &subscriber);
451 
452     /**
453      * @brief Gets the OS account switch mode.
454      * @return switch mode
455      */
456     static OS_ACCOUNT_SWITCH_MOD GetOsAccountSwitchMod();
457 
458     /**
459      * @brief Checks whether the current OS account is verified.
460      * @param isVerified - Indicates whether the current OS account is verified.
461      * @return error code, see account_error_no.h
462      */
463     static ErrCode IsCurrentOsAccountVerified(bool &isVerified);
464 
465     /**
466      * @brief Checks whether the specified OS account is created completely.
467      * @param id - Indicates the local ID of the specified OS account.
468      * @param isOsAccountCompleted - Indicates whether the current OS account is created completely.
469      * @return error code, see account_error_no.h
470      */
471     static ErrCode IsOsAccountCompleted(const int id, bool &isOsAccountCompleted);
472 
473     /**
474      * @brief Sets the current OS account to be verified.
475      * @param isVerified - Indicates whether the current OS account is verified.
476      * @return error code, see account_error_no.h
477      */
478     static ErrCode SetCurrentOsAccountIsVerified(const bool isVerified);
479 
480     /**
481      * @brief Sets the specified OS account to be verified.
482      * @param id - Indicates the local ID of the specified OS account.
483      * @param isVerified - Indicates whether the current OS account is verified.
484      * @return error code, see account_error_no.h
485      */
486     static ErrCode SetOsAccountIsVerified(const int id, const bool isVerified);
487 
488     /**
489      * @brief Gets the number of the created OS account from database.
490      * @param storeID - Indicates the store ID.
491      * @param id - Indicates the number of the created OS account.
492      * @return error code, see account_error_no.h
493      */
494     static ErrCode GetCreatedOsAccountNumFromDatabase(const std::string& storeID, int &createdOsAccountNum);
495 
496     /**
497      * @brief Get serial number from database.
498      * @param storeID - Indicates the store ID.
499      * @param serialNumber - Indicates the serial number.
500      * @return error code, see account_error_no.h
501      */
502     static ErrCode GetSerialNumberFromDatabase(const std::string& storeID, int64_t &serialNumber);
503 
504     /**
505      * @brief Gets the max ID of the OS account to be created.
506      * @param storeID - Indicates the store ID.
507      * @param id - Indicates the max ID of the OS account to be created.
508      * @return error code, see account_error_no.h
509      */
510     static ErrCode GetMaxAllowCreateIdFromDatabase(const std::string& storeID, int &id);
511 
512     /**
513      * @brief Sets the specified OS account from database.
514      * @selinux The caller needs to configure selinux permissions: allow Caller_SA_Name accountmgr:fd {use}.
515      * @param storeID - Indicates the store ID.
516      * @param id - Indicates the local ID of the specified OS account.
517      * @param osAccountInfo - Indicates the OS account information.
518      * @return error code, see account_error_no.h
519      */
520     static ErrCode GetOsAccountFromDatabase(const std::string& storeID, const int id, OsAccountInfo &osAccountInfo);
521 
522     /**
523      * @brief Get a list of OS accounts from database.
524      * @selinux The caller needs to configure selinux permissions: allow Caller_SA_Name accountmgr:fd {use}.
525      * @param storeID - Indicates the store ID.
526      * @param osAccountList - Indicates a list of OS accounts.
527      * @return error code, see account_error_no.h
528      */
529     static ErrCode GetOsAccountListFromDatabase(const std::string& storeID, std::vector<OsAccountInfo> &osAccountList);
530 
531     /**
532      * @brief Gets the local IDs of all activated OS accounts.
533      * @param ids - Indicates the local IDs of all activated OS accounts.
534      * @return error code, see account_error_no.h
535      */
536     static ErrCode QueryActiveOsAccountIds(std::vector<int32_t>& ids);
537 
538     /**
539      * @brief Gets a list of constraint source types for the specified os account.
540      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
541      * @param localId - Indicates the local ID of the OS account.
542      * @param constraint - Indicates the constraint to query the source type.
543      * @param constraintSourceTypeInfos - Indicates the list of constraint source types for the specified os account.
544      * @return error code, see account_error_no.h
545      */
546     static ErrCode QueryOsAccountConstraintSourceTypes(const int32_t id, const std::string constraint,
547         std::vector<ConstraintSourceTypeInfo> &constraintSourceTypeInfos);
548 
549     /**
550      * @brief Sets the global constraints for all OS accounts.
551      * @param constraints - Indicates the local IDs of all activated OS accounts.
552      * @param isEnabled - Indicates whether the constraints are enabled.
553      * @param enforcerId - Indicates the local ID of the OS account who enforce the operation.
554      * @param isDeviceOwner - Indicates whether the enforcer is device owner.
555      * @return error code, see account_error_no.h
556      */
557     static ErrCode SetGlobalOsAccountConstraints(const std::vector<std::string> &constraints,
558         const bool isEnabled, const int32_t enforcerId = 0, const bool isDeviceOwner = false);
559 
560     /**
561      * @brief Sets the constraints for the specified OS accounts.
562      * @param constraints - Indicates the local IDs of all activated OS accounts.
563      * @param enable - Indicates whether the constraints are enabled.
564      * @param targetId - Indicates the local ID of the target OS account.
565      * @param enforcerId - Indicates the local ID of the OS account who enforce the operation.
566      * @param isDeviceOwner - Indicates whether the enforcer is device owner.
567      * @return error code, see account_error_no.h
568      */
569     static ErrCode SetSpecificOsAccountConstraints(const std::vector<std::string> &constraints,
570         const bool enable, const int32_t targetId, const int32_t enforcerId, const bool isDeviceOwner);
571 
572     /**
573      * @brief Sets the default activated OS account.
574      * @param id - Indicates the local IDs of the default activated OS accounts.
575      * @return error code, see account_error_no.h
576      */
577     static ErrCode SetDefaultActivatedOsAccount(const int32_t id);
578 
579     /**
580      * @brief Gets the default activated OS account.
581      * @param id - Indicates the local IDs of the default activated OS accounts.
582      * @return error code, see account_error_no.h
583      */
584     static ErrCode GetDefaultActivatedOsAccount(int32_t &id);
585 
586     /**
587      * @brief Gets the currend user short name.
588      * @param shortName - Indicates the current user short name of the OS account.
589      * @return error code, see account_error_no.h
590      */
591     static ErrCode GetOsAccountShortName(std::string &shortName);
592 
593     /**
594      * @brief Gets the currend user local name.
595      * @param shortName - Indicates the current user local name of the OS account.
596      * @return error code, see account_error_no.h
597      */
598     static ErrCode GetOsAccountName(std::string &name);
599 
600     /**
601      * @brief Gets the user short name, based on account id.
602      * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
603      * @param id - Indicates the local ID of the OS account.
604      * @param shortName - Indicates the current user short name of the OS account.
605      * @return error code, see account_error_no.h
606      */
607     static ErrCode GetOsAccountShortName(const int32_t id, std::string &shortName);
608 
609     /**
610      * @brief Checks whether the current accoount is foreground.
611      * @param isForeground - Indicates whether the specified localId is Foreground.
612      * @return error code, see account_error_no.h
613      */
614     static ErrCode IsOsAccountForeground(bool &isForeground);
615 
616     /**
617      * @brief Checks whether the specified accoount is foreground.
618      * @param localId - Indicates the local Id of the OS account.
619      * @param isForeground - Indicates whether the specified localId is foreground.
620      * @return error code, see account_error_no.h
621      */
622     static ErrCode IsOsAccountForeground(const int32_t localId, bool &isForeground);
623 
624     /**
625      * @brief Checks whether the specified accoount is foreground in specified display.
626      * @param localId - Indicates the local id of the OS account.
627      * @param displayId - Indicates the id of the display.
628      * @param isForeground - Indicates whether the specified localId is foreground.
629      * @return error code, see account_error_no.h
630      */
631 
632     static ErrCode IsOsAccountForeground(const int32_t localId, const uint64_t displayId, bool &isForeground);
633 
634     /**
635      * @brief Gets the id from default display.
636      * @param localId - Indicates the corresponding localId of default display.
637      * @return error code, see account_error_no.h
638      */
639     static ErrCode GetForegroundOsAccountLocalId(int32_t &localId);
640 
641     /**
642      * @brief Gets the id from specified display.
643      * @param displayId - Indicates the id of the specified display.
644      * @param localId - Indicates the corresponding localId of specified display.
645      * @return error code, see account_error_no.h
646      */
647     static ErrCode GetForegroundOsAccountLocalId(const uint64_t displayId, int32_t &localId);
648 
649     /**
650      * @brief Gets the foreground accounts.
651      * @param accounts - Indicates the foreground accounts.
652      * @return error code, see account_error_no.h
653      */
654     static ErrCode GetForegroundOsAccounts(std::vector<ForegroundOsAccount> &accounts);
655 
656     /**
657      * @brief Gets the foreground localId list.
658      * @param localIds - Indicates the foreground localId list.
659      * @return error code, see account_error_no.h
660      */
661     static ErrCode GetBackgroundOsAccountLocalIds(std::vector<int32_t> &localIds);
662 
663     /**
664      * @brief Sets the target OS account to be removed or not.
665      *
666      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
667      * @param localId - Indicates the target OS account.
668      * @param toBeRemoved - Indicates whether the target OS account to be removed.
669      * @return error code, see account_error_no.h
670      */
671     static ErrCode SetOsAccountToBeRemoved(int32_t localId, bool toBeRemoved);
672 
673     /**
674      * @brief Get domain account info by a given os account id
675      *
676      * @permission ohos.permission.GET_DOMAIN_ACCOUNTS and ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
677      * @param localId - Indicates the target OS account.
678      * @param domainInfo - Returns the domain account information.
679      * @return error code, see account_error_no.h
680      */
681     static ErrCode GetOsAccountDomainInfo(const int32_t localId, DomainAccountInfo &domainInfo);
682 };
683 }  // namespace AccountSA
684 }  // namespace OHOS
685 #endif  // OS_ACCOUNT_INTERFACES_INNERKITS_OS_ACCOUNT_MANAGER_H
686