public class AccountAbility extends Object
This class provides basic account-related functions, including querying and updating the distributed information of an OS account in a distributed system, creating, removing, and starting an OS account, updating OS account information, and querying information about the current OS account or all OS accounts. The distributed information refers to the account information that is used on a distributed network. It affects the availability of the distributed network and the distributed database.
SystemCapability.Account#OS_ACCOUNT| 限定符和类型 | 方法 | 说明 |
|---|---|---|
static AccountAbility |
getAccountAbility() |
Obtains the
AccountAbility instance. |
int |
getAllCreatedOsAccounts() |
Obtains the number of all OS accounts created on a device.
|
String |
getDistributedVirtualDeviceId() |
Obtains the distributed virtual device ID (DVID).
|
List<String> |
getOsAccountAllConstraints(int localId) |
Obtains all constraints of an OS account based on its local ID.
|
int |
getOsAccountLocalIdFromProcess() |
Obtains the local ID of an OS account from the current process UID.
|
int |
getOsAccountLocalIdFromUid(int uid) |
Queries the local ID of an OS account from the process UID.
|
OsAccountType |
getOsAccountTypeFromProcess() |
Obtains the type of this OS account from the current process.
|
boolean |
isMultiOSAccountEnable() |
Checks whether the function of supporting multiple OS accounts is enabled.
|
boolean |
isOsAccountActive(int localId) |
Checks whether an OS account is active based on its local ID.
|
boolean |
isOsAccountConstraintEnable(int localId,
String constraint) |
Checks whether a constraint has been enabled for an OS account based on its local ID.
|
boolean |
isOsAccountKingKong() |
Checks whether this OS account is a King Kong user.
|
boolean |
isOsAccountVerified() |
Checks whether this OS account has been verified.
|
boolean |
isOsAccountVerified(int localId) |
Checks whether an OS account has been verified based on its local ID.
|
OsAccount |
queryCurrentOsAccount() |
Queries information about the current OS account.
|
DistributedInfo |
queryOsAccountDistributedInfo() |
Queries the distributed information of the current OS account.
|
public DistributedInfo queryOsAccountDistributedInfo()
Your application needs to request the ohos.permission.MANAGE_LOCAL_ACCOUNTS or
ohos.security.SystemPermission.DISTRIBUTED_DATASYNC permission.
null if the query fails.public boolean isMultiOSAccountEnable()
true if this function is enabled; returns false otherwise.public int getOsAccountLocalIdFromUid(int uid)
uid - Indicates the process UID.public OsAccount queryCurrentOsAccount()
Your application needs to request the ohos.permission.MANAGE_LOCAL_ACCOUNTS permission.
null if the query fails.public boolean isOsAccountConstraintEnable(int localId,
String constraint)
Your application needs to request the ohos.permission.MANAGE_LOCAL_ACCOUNTS permission.
localId - Indicates the local ID of the OS account.constraint - Indicates the constraint to check. The value can be:
constraint.wifi.set - Indicates the constraint on configuring the Wi-Fi access point.constraint.sms.use - Indicates the constraint on sending and receiving short messages.constraint.calls.outgoing - Indicates the constraint on making calls.constraint.unknown.sources.install - Indicates the constraint on installing applications
from unknown sources.true if the constraint has been enabled for the OS account;
returns false otherwise.public List<String> getOsAccountAllConstraints(int localId)
Your application needs to request the ohos.permission.MANAGE_LOCAL_ACCOUNTS permission.
localId - Indicates the local ID of the OS account.public int getAllCreatedOsAccounts()
Your application needs to request the ohos.permission.MANAGE_LOCAL_ACCOUNTS permission.
public int getOsAccountLocalIdFromProcess()
public boolean isOsAccountActive(int localId)
Your application needs to request the ohos.permission.MANAGE_LOCAL_ACCOUNTS or
ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS permission.
localId - Indicates the local ID of the OS account.true if the OS account is active; returns false otherwise.public boolean isOsAccountKingKong()
true if this OS account is a King Kong user; returns false otherwise.public boolean isOsAccountVerified()
true if the OS account has been verified successfully; returns false otherwise.public boolean isOsAccountVerified(int localId)
Your application needs to request the ohos.permission.MANAGE_LOCAL_ACCOUNTS or
ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS permission.
localId - Indicates the local ID of the OS account.true if the OS account has been verified successfully; returns false otherwise.public OsAccountType getOsAccountTypeFromProcess()
OsAccountType#ADMIN,
OsAccountType#NORMAL, and OsAccountType#GUEST.public String getDistributedVirtualDeviceId()
If the same OHOS account has logged in to multiple devices, these devices constitute a super device through the distributed networking. On the networked devices, you can call this method to obtain the DVIDs. The same application running on different devices obtains the same DVID, whereas different applications obtain different DVIDs.
Permissions: SystemPermission.DISTRIBUTED_DATASYNC
public static AccountAbility getAccountAbility()
AccountAbility instance.AccountAbility instance.