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 Gets the number of all OS accounts created on a device.
168      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
169      * @param osAccountsCount - Returns the number of created OS accounts.
170      * @return error code, see account_error_no.h
171      */
172     static ErrCode GetCreatedOsAccountsCount(unsigned int &osAccountsCount);
173 
174     /**
175      * @brief Gets the local ID of the current OS account.
176      * @param id - Indicates the local ID of the current OS account.
177      * @return error code, see account_error_no.h
178      */
179     static ErrCode GetOsAccountLocalIdFromProcess(int &id);
180 
181     /**
182      * @brief Checks whether current process belongs to the main account.
183      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
184      * @param isMainOsAccount - Indicates whether the current process belongs to the main OS account.
185      * @return error code, see account_error_no.h
186      */
187     static ErrCode IsMainOsAccount(bool &isMainOsAccount);
188 
189     /**
190      * @brief Gets the local ID of an OS account from the process UID
191      * @param uid - Indicates the process UID.
192      * @param id - Indicates the local ID of the OS account associated with the specified UID.
193      * @return error code, see account_error_no.h
194      */
195     static ErrCode GetOsAccountLocalIdFromUid(const int uid, int &id);
196 
197     /**
198      * @brief Gets the bundle ID associated with the specified UID.
199      * @param uid - Indicates the target uid.
200      * @param bundleId - Indicates the bundle ID associated with the specified UID.
201      * @return error code, see account_error_no.h
202      */
203     static ErrCode GetBundleIdFromUid(const int uid, int &bundleId);
204 
205     /**
206      * @brief Gets the local ID of the OS account associated with the specified domain account.
207      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
208      * @param domainInfo - Indicates the domain account info.
209      * @param id - Indicates the local ID of the OS account associated with the specified domain account.
210      * @return error code, see account_error_no.h
211      */
212     static ErrCode GetOsAccountLocalIdFromDomain(const DomainAccountInfo &domainInfo, int &id);
213 
214     /**
215      * @brief Queries the maximum number of OS accounts that can be created on a device.
216      * @param maxOsAccountNumber - Returns the maximum number of OS accounts that can be created.
217      * @return error code, see account_error_no.h
218      */
219     static ErrCode QueryMaxOsAccountNumber(uint32_t &maxOsAccountNumber);
220 
221     /**
222      * @brief Queries the maximum number of OS accounts that can be logged in.
223      * @param maxNum - Returns the maximum number of OS accounts that can be created.
224      * @return error code, see account_error_no.h
225      */
226     static ErrCode QueryMaxLoggedInOsAccountNumber(uint32_t &maxNum);
227 
228     /**
229      * @brief Gets all constraints of an account based on its ID.
230      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
231      * @param localId - Indicates the local ID of the OS account.
232      * @param constraints - Indicates a list of constraints.
233      * @return error code, see account_error_no.h
234      */
235     static ErrCode GetOsAccountAllConstraints(const int id, std::vector<std::string> &constraints);
236 
237     /**
238      * @brief Queries the list of all the OS accounts that have been created in the system.
239      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
240      * @param osAccountInfos - Indicates a list of OS accounts.
241      * @return error code, see account_error_no.h
242      */
243     static ErrCode QueryAllCreatedOsAccounts(std::vector<OsAccountInfo> &osAccountInfos);
244 
245     /**
246      * @brief Gets information about the current OS account.
247      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
248      * @param osAccountInfo - Indicates the information about the current OS account.
249      * @return error code, see account_error_no.h
250      */
251     static ErrCode QueryCurrentOsAccount(OsAccountInfo &osAccountInfo);
252 
253     /**
254      * @brief Queries OS account information based on the local ID.
255      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
256      * @param localId - Indicates the local ID of the OS account.
257      * @param osAccountInfo - Indicates the OS account information.
258      * @return error code, see account_error_no.h
259      */
260     static ErrCode QueryOsAccountById(const int id, OsAccountInfo &osAccountInfo);
261 
262     /**
263      * @brief Gets the type of this OS account from the current process.
264      * @param type - Indicates the OS account type.
265      * @return error code, see account_error_no.h
266      */
267     static ErrCode GetOsAccountTypeFromProcess(OsAccountType &type);
268 
269     /**
270      * @brief Gets the type of this OS account from the current process.
271      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
272      * @param id - Indicates the local ID of the OS account.
273      * @param type - Indicates the OS account type.
274      * @return error code, see account_error_no.h
275      */
276     static ErrCode GetOsAccountType(const int id, OsAccountType& type);
277 
278     /**
279      * @brief Gets the profile photo of an OS account based on its local ID.
280      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
281      * @param id - Indicates the local ID of the OS account.
282      * @param photo - Indicates the profile photo.
283      * @return error code, see account_error_no.h
284      */
285     static ErrCode GetOsAccountProfilePhoto(const int id, std::string &photo);
286 
287     /**
288      * @brief Checks whether the function of supporting multiple OS accounts is enabled.
289      * @param isMultiOsAccountEnable - Indicates whether multiple OS account feature is enabled.
290      * @return error code, see account_error_no.h
291      */
292     static ErrCode IsMultiOsAccountEnable(bool &isMultiOsAccountEnable);
293 
294     /**
295      * @brief Sets the local name for an OS account based on its local ID.
296      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
297      * @param localId - Indicates the local ID of the OS account.
298      * @param localName - Indicates the local name to set for the OS account.
299      * @return error code, see account_error_no.h
300      */
301     static ErrCode SetOsAccountName(const int id, const std::string &localName);
302 
303     /**
304      * @brief Sets constraints for an OS account based on its local ID.
305      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
306      * @param localId - Indicates the local ID of the OS account.
307      * @param constraints - Indicates the constraints to set for the OS account. The value can be:
308      *        <ul>
309      *        <li>{@code constraint.wifi.set} - Indicates the constraint on configuring the Wi-Fi access point.
310      *        </li>
311      *        <li>{@code constraint.sms.use} - Indicates the constraint on sending and receiving short messages.
312      *        </li>
313      *        <li>{@code constraint.calls.outgoing} - Indicates the constraint on making calls.</li>
314      *        <li>{@code constraint.unknown.sources.install} - Indicates the constraint on installing applications
315      *        from unknown sources.</li>
316      *        </ul>
317      * @param enable - Specifies whether to enable the constraint.
318      * @return error code, see account_error_no.h
319      */
320     static ErrCode SetOsAccountConstraints(
321         const int id, const std::vector<std::string> &constraints, const bool enable);
322 
323     /**
324      * @brief Sets the profile photo for an OS account based on its local ID.
325      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
326      * @param localId - Indicates the local ID of the OS account.
327      * @param photo - Indicates the profile photo to set for the OS account.
328      * @return error code, see account_error_no.h
329      */
330     static ErrCode SetOsAccountProfilePhoto(const int id, const std::string &photo);
331 
332     /**
333      * @brief Gets the distributed virtual device ID (DVID).
334      * <p>
335      * If the same OHOS account has logged in to multiple devices, these devices constitute a super device
336      * through the distributed networking. On the connected devices, you can call this method to obtain the DVIDs.
337      * The same application running on different devices obtains the same DVID, whereas different applications
338      * obtain different DVIDs.
339      * <p>
340      *
341      * @permission ohos.permission.DISTRIBUTED_DATASYNC or ohos.permission.MANAGE_LOCAL_ACCOUNTS
342      * @param deviceId - Indicates the DVID if obtained; returns an empty string if no OHOS account has logged in.
343      * @return error code, see account_error_no.h
344      */
345     static ErrCode GetDistributedVirtualDeviceId(std::string &deviceId);
346 
347     /**
348      * @brief Activates a specified OS account.
349      * <p>
350      * If multiple OS accounts are available, you can call this method to enable a specific OS account
351      * to run in the foreground. Then, the OS account originally running in the foreground will be
352      * switched to the background.
353      * </p>
354      *
355      * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
356      * @param id - Indicates the local ID of the OS account.
357      * @return error code, see account_error_no.h
358      */
359     static ErrCode ActivateOsAccount(const int id);
360 
361     /**
362      * @brief Deactivates a specified OS account.
363      * <p>
364      * You can call this method to disable a specific OS account.
365      * </p>
366      *
367      * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
368      * @param id - Indicates the local ID of the OS account.
369      * @return error code, see account_error_no.h
370      */
371     static ErrCode DeactivateOsAccount(const int id);
372 
373     /**
374      * @brief Deactivates all OS account.
375      * <p>
376      * You can call this method to disable all OS account.
377      * </p>
378      *
379      * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
380      * @return error code, see account_error_no.h
381      */
382     static ErrCode DeactivateAllOsAccounts();
383 
384     /**
385      * @brief Starts the specified OS account.
386      * @param id - Indicates the local ID of the OS account.
387      * @return error code, see account_error_no.h
388      */
389     static ErrCode StartOsAccount(const int id);
390 
391     /**
392      * @brief Gets localId according to serial number.
393      * @param serialNumber - Indicates serial number.
394      * @param id - Indicates the local ID of the OS account.
395      * @return error code, see account_error_no.h
396      */
397     static ErrCode GetOsAccountLocalIdBySerialNumber(const int64_t serialNumber, int &id);
398 
399     /**
400      * @brief Gets serial number according to localId.
401      * @param localId - Indicates the local ID of the OS account.
402      * @param serialNumber - Indicates the serial number.
403      * @return error code, see account_error_no.h
404      */
405     static ErrCode GetSerialNumberByOsAccountLocalId(const int &id, int64_t &serialNumber);
406 
407     /**
408      * @brief Subscribes the event of an OS account by the subscriber.
409      * @param subscriber subscriber information
410      * @return error code, see account_error_no.h
411      */
412     static ErrCode SubscribeOsAccount(const std::shared_ptr<OsAccountSubscriber> &subscriber);
413 
414     /**
415      * @brief Unsubscribes the event of an OS account by the subscriber.
416      * @param subscriber subscriber information
417      * @return error code, see account_error_no.h
418      */
419     static ErrCode UnsubscribeOsAccount(const std::shared_ptr<OsAccountSubscriber> &subscriber);
420 
421     /**
422      * @brief Gets the OS account switch mode.
423      * @return switch mode
424      */
425     static OS_ACCOUNT_SWITCH_MOD GetOsAccountSwitchMod();
426 
427     /**
428      * @brief Checks whether the current OS account is verified.
429      * @param isVerified - Indicates whether the current OS account is verified.
430      * @return error code, see account_error_no.h
431      */
432     static ErrCode IsCurrentOsAccountVerified(bool &isVerified);
433 
434     /**
435      * @brief Checks whether the specified OS account is created completely.
436      * @param id - Indicates the local ID of the specified OS account.
437      * @param isOsAccountCompleted - Indicates whether the current OS account is created completely.
438      * @return error code, see account_error_no.h
439      */
440     static ErrCode IsOsAccountCompleted(const int id, bool &isOsAccountCompleted);
441 
442     /**
443      * @brief Sets the current OS account to be verified.
444      * @param isVerified - Indicates whether the current OS account is verified.
445      * @return error code, see account_error_no.h
446      */
447     static ErrCode SetCurrentOsAccountIsVerified(const bool isVerified);
448 
449     /**
450      * @brief Sets the specified OS account to be verified.
451      * @param id - Indicates the local ID of the specified OS account.
452      * @param isVerified - Indicates whether the current OS account is verified.
453      * @return error code, see account_error_no.h
454      */
455     static ErrCode SetOsAccountIsVerified(const int id, const bool isVerified);
456 
457     /**
458      * @brief Gets the number of the created OS account from database.
459      * @param storeID - Indicates the store ID.
460      * @param id - Indicates the number of the created OS account.
461      * @return error code, see account_error_no.h
462      */
463     static ErrCode GetCreatedOsAccountNumFromDatabase(const std::string& storeID, int &createdOsAccountNum);
464 
465     /**
466      * @brief Get serial number from database.
467      * @param storeID - Indicates the store ID.
468      * @param serialNumber - Indicates the serial number.
469      * @return error code, see account_error_no.h
470      */
471     static ErrCode GetSerialNumberFromDatabase(const std::string& storeID, int64_t &serialNumber);
472 
473     /**
474      * @brief Gets the max ID of the OS account to be created.
475      * @param storeID - Indicates the store ID.
476      * @param id - Indicates the max ID of the OS account to be created.
477      * @return error code, see account_error_no.h
478      */
479     static ErrCode GetMaxAllowCreateIdFromDatabase(const std::string& storeID, int &id);
480 
481     /**
482      * @brief Sets the specified OS account from database.
483      * @param storeID - Indicates the store ID.
484      * @param id - Indicates the local ID of the specified OS account.
485      * @param osAccountInfo - Indicates the OS account information.
486      * @return error code, see account_error_no.h
487      */
488     static ErrCode GetOsAccountFromDatabase(const std::string& storeID, const int id, OsAccountInfo &osAccountInfo);
489 
490     /**
491      * @brief Get a list of OS accounts from database.
492      * @param storeID - Indicates the store ID.
493      * @param osAccountList - Indicates a list of OS accounts.
494      * @return error code, see account_error_no.h
495      */
496     static ErrCode GetOsAccountListFromDatabase(const std::string& storeID, std::vector<OsAccountInfo> &osAccountList);
497 
498     /**
499      * @brief Gets the local IDs of all activated OS accounts.
500      * @param ids - Indicates the local IDs of all activated OS accounts.
501      * @return error code, see account_error_no.h
502      */
503     static ErrCode QueryActiveOsAccountIds(std::vector<int32_t>& ids);
504 
505     /**
506      * @brief Gets a list of constraint source types for the specified os account.
507      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
508      * @param localId - Indicates the local ID of the OS account.
509      * @param constraint - Indicates the constraint to query the source type.
510      * @param constraintSourceTypeInfos - Indicates the list of constraint source types for the specified os account.
511      * @return error code, see account_error_no.h
512      */
513     static ErrCode QueryOsAccountConstraintSourceTypes(const int32_t id, const std::string constraint,
514         std::vector<ConstraintSourceTypeInfo> &constraintSourceTypeInfos);
515 
516     /**
517      * @brief Sets the global constraints for all OS accounts.
518      * @param constraints - Indicates the local IDs of all activated OS accounts.
519      * @param isEnabled - Indicates whether the constraints are enabled.
520      * @param enforcerId - Indicates the local ID of the OS account who enforce the operation.
521      * @param isDeviceOwner - Indicates whether the enforcer is device owner.
522      * @return error code, see account_error_no.h
523      */
524     static ErrCode SetGlobalOsAccountConstraints(const std::vector<std::string> &constraints,
525         const bool isEnabled, const int32_t enforcerId = 0, const bool isDeviceOwner = false);
526 
527     /**
528      * @brief Sets the constraints for the specified OS accounts.
529      * @param constraints - Indicates the local IDs of all activated OS accounts.
530      * @param enable - Indicates whether the constraints are enabled.
531      * @param targetId - Indicates the local ID of the target OS account.
532      * @param enforcerId - Indicates the local ID of the OS account who enforce the operation.
533      * @param isDeviceOwner - Indicates whether the enforcer is device owner.
534      * @return error code, see account_error_no.h
535      */
536     static ErrCode SetSpecificOsAccountConstraints(const std::vector<std::string> &constraints,
537         const bool enable, const int32_t targetId, const int32_t enforcerId, const bool isDeviceOwner);
538 
539     /**
540      * @brief Sets the default activated OS account.
541      * @param id - Indicates the local IDs of the default activated OS accounts.
542      * @return error code, see account_error_no.h
543      */
544     static ErrCode SetDefaultActivatedOsAccount(const int32_t id);
545 
546     /**
547      * @brief Gets the default activated OS account.
548      * @param id - Indicates the local IDs of the default activated OS accounts.
549      * @return error code, see account_error_no.h
550      */
551     static ErrCode GetDefaultActivatedOsAccount(int32_t &id);
552 
553     /**
554      * @brief Gets the currend user short name.
555      * @param shortName - Indicates the current user short name of the OS account.
556      * @return error code, see account_error_no.h
557      */
558     static ErrCode GetOsAccountShortName(std::string &shortName);
559 
560     /**
561      * @brief Gets the currend user local name.
562      * @param shortName - Indicates the current user local name of the OS account.
563      * @return error code, see account_error_no.h
564      */
565     static ErrCode GetOsAccountName(std::string &name);
566 
567     /**
568      * @brief Gets the user short name, based on account id.
569      * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
570      * @param id - Indicates the local ID of the OS account.
571      * @param shortName - Indicates the current user short name of the OS account.
572      * @return error code, see account_error_no.h
573      */
574     static ErrCode GetOsAccountShortName(const int32_t id, std::string &shortName);
575 
576     /**
577      * @brief Checks whether the current accoount is foreground.
578      * @param isForeground - Indicates whether the specified localId is Foreground.
579      * @return error code, see account_error_no.h
580      */
581     static ErrCode IsOsAccountForeground(bool &isForeground);
582 
583     /**
584      * @brief Checks whether the specified accoount is foreground.
585      * @param localId - Indicates the local Id of the OS account.
586      * @param isForeground - Indicates whether the specified localId is foreground.
587      * @return error code, see account_error_no.h
588      */
589     static ErrCode IsOsAccountForeground(const int32_t localId, bool &isForeground);
590 
591     /**
592      * @brief Checks whether the specified accoount is foreground in specified display.
593      * @param localId - Indicates the local id of the OS account.
594      * @param displayId - Indicates the id of the display.
595      * @param isForeground - Indicates whether the specified localId is foreground.
596      * @return error code, see account_error_no.h
597      */
598 
599     static ErrCode IsOsAccountForeground(const int32_t localId, const uint64_t displayId, bool &isForeground);
600 
601     /**
602      * @brief Gets the id from default display.
603      * @param localId - Indicates the corresponding localId of default display.
604      * @return error code, see account_error_no.h
605      */
606     static ErrCode GetForegroundOsAccountLocalId(int32_t &localId);
607 
608     /**
609      * @brief Gets the id from specified display.
610      * @param displayId - Indicates the id of the specified display.
611      * @param localId - Indicates the corresponding localId of specified display.
612      * @return error code, see account_error_no.h
613      */
614     static ErrCode GetForegroundOsAccountLocalId(const uint64_t displayId, int32_t &localId);
615 
616     /**
617      * @brief Gets the foreground accounts.
618      * @param accounts - Indicates the foreground accounts.
619      * @return error code, see account_error_no.h
620      */
621     static ErrCode GetForegroundOsAccounts(std::vector<ForegroundOsAccount> &accounts);
622 
623     /**
624      * @brief Gets the foreground localId list.
625      * @param localIds - Indicates the foreground localId list.
626      * @return error code, see account_error_no.h
627      */
628     static ErrCode GetBackgroundOsAccountLocalIds(std::vector<int32_t> &localIds);
629 
630     /**
631      * @brief Sets the target OS account to be removed or not.
632      *
633      * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
634      * @param localId - Indicates the target OS account.
635      * @param toBeRemoved - Indicates whether the target OS account to be removed.
636      * @return error code, see account_error_no.h
637      */
638     static ErrCode SetOsAccountToBeRemoved(int32_t localId, bool toBeRemoved);
639 };
640 }  // namespace AccountSA
641 }  // namespace OHOS
642 #endif  // OS_ACCOUNT_INTERFACES_INNERKITS_OS_ACCOUNT_MANAGER_H
643