提交 f01789dd 编写于 作者: H handyohos

bugfix: update system parameter api documentation

update system parameter api documentation
Signed-off-by: Nhandyohos <zhangxiaotian@huawei.com>
Change-Id: Ie5563d2f53a1b7e9de3d9b4b543ceefdc5d8ee42
上级 75b7de10
# 系统属性
# 系统参数
系统参数(SystemParameter)是为各系统服务提供的简单易用的键值对访问接口,各个系统服务可以定义系统参数来描述该服务的状态信息,或者通过系统参数来改变系统服务的行为。其基本操作原语为get和set,通过get可以查询系统参数的值,通过set可以修改系统参数的值。
详细的系统参数设计原理及定义可参考
[系统参数](../../../device-dev/subsystems/subsys-boot-init-sysparam.md)
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> - 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> - 此接口为系统接口,三方应用不支持调用。
> - 由于系统参数都是各个系统服务的内部信息和控制参数,每个系统参数都有各自不同的DAC和MAC访问控制权限,三方应用不能使用此类接口。
## 导入模块
......@@ -15,7 +20,7 @@ import parameter from '@ohos.systemparameter'
getSync(key: string, def?: string): string
获取系统属性Key对应的值。
获取系统参数Key对应的值。
**系统能力:** SystemCapability.Startup.SystemInfo
......@@ -23,20 +28,20 @@ getSync(key: string, def?: string): string
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| key | string | 是 | 待查询的系统属性Key。 |
| key | string | 是 | 待查询的系统参数Key。 |
| def | string | 否 | 默认值。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| string | 系统属性值,若key不存在,返回默认值。若未指定默认值,返回空字符串。 |
| string | 系统参数值,若key不存在,返回默认值。若未指定默认值,返回空字符串。 |
**示例:**
```ts
try {
var info = parameter.getSync("test.parameter.key");
var info = parameter.getSync("const.ohos.apiversion");
console.log(JSON.stringify(info));
}catch(e){
console.log("getSync unexpected error: " + e);
......@@ -48,7 +53,7 @@ try {
get(key: string, callback: AsyncCallback&lt;string&gt;): void
获取系统属性Key对应的值。
获取系统参数Key对应的值。
**系统能力:** SystemCapability.Startup.SystemInfo
......@@ -56,14 +61,14 @@ get(key: string, callback: AsyncCallback&lt;string&gt;): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| key | string | 是 | 待查询的系统属性Key。 |
| key | string | 是 | 待查询的系统参数Key。 |
| callback | AsyncCallback&lt;string&gt; | 是 | 回调函数。 |
**示例:**
```ts
try {
parameter.get("test.parameter.key", function (err, data) {
parameter.get("const.ohos.apiversion", function (err, data) {
if (err == undefined) {
console.log("get test.parameter.key value success:" + data)
} else {
......@@ -79,7 +84,7 @@ try {
get(key: string, def: string, callback: AsyncCallback&lt;string&gt;): void
获取系统属性Key对应的值。
获取系统参数Key对应的值。
**系统能力:** SystemCapability.Startup.SystemInfo
......@@ -87,7 +92,7 @@ get(key: string, def: string, callback: AsyncCallback&lt;string&gt;): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| key | string | 是 | 待查询的系统属性Key。 |
| key | string | 是 | 待查询的系统参数Key。 |
| def | string | 是 | 默认值。 |
| callback | AsyncCallback&lt;string&gt; | 是 | 回调函数。 |
......@@ -95,7 +100,7 @@ get(key: string, def: string, callback: AsyncCallback&lt;string&gt;): void
```ts
try {
parameter.get("test.parameter.key", "default", function (err, data) {
parameter.get("const.ohos.apiversion", "default", function (err, data) {
if (err == undefined) {
console.log("get test.parameter.key value success:" + data)
} else {
......@@ -112,7 +117,7 @@ try {
get(key: string, def?: string): Promise&lt;string&gt;
获取系统属性Key对应的值。
获取系统参数Key对应的值。
**系统能力:** SystemCapability.Startup.SystemInfo
......@@ -120,7 +125,7 @@ get(key: string, def?: string): Promise&lt;string&gt;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| key | string | 是 | 待查询的系统属性Key。 |
| key | string | 是 | 待查询的系统参数Key。 |
| def | string | 否 | 默认值。 |
**返回值:**
......@@ -133,7 +138,7 @@ get(key: string, def?: string): Promise&lt;string&gt;
```ts
try {
var p = parameter.get("test.parameter.key");
var p = parameter.get("const.ohos.apiversion");
p.then(function (value) {
console.log("get test.parameter.key success: " + value);
}).catch(function (err) {
......@@ -149,7 +154,7 @@ try {
setSync(key: string, value: string): void
设置系统属性Key对应的值。
设置系统参数Key对应的值。
**系统能力:** SystemCapability.Startup.SystemInfo
......@@ -157,8 +162,8 @@ setSync(key: string, value: string): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| key | string | 是 | 待设置的系统属性Key。 |
| value | string | 是 | 待设置的系统属性值。 |
| key | string | 是 | 待设置的系统参数Key。 |
| value | string | 是 | 待设置的系统参数值。 |
**示例:**
......@@ -175,7 +180,7 @@ try {
set(key: string, value: string, callback: AsyncCallback&lt;void&gt;): void
设置系统属性Key对应的值。
设置系统参数Key对应的值。
**系统能力:** SystemCapability.Startup.SystemInfo
......@@ -183,8 +188,8 @@ set(key: string, value: string, callback: AsyncCallback&lt;void&gt;): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| key | string | 是 | 待设置的系统属性Key。 |
| value | string | 是 | 待设置的系统属性值。 |
| key | string | 是 | 待设置的系统参数Key。 |
| value | string | 是 | 待设置的系统参数值。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
**示例:**
......@@ -207,7 +212,7 @@ try {
set(key: string, value: string): Promise&lt;void&gt;
设置系统属性Key对应的值。
设置系统参数Key对应的值。
**系统能力:** SystemCapability.Startup.SystemInfo
......@@ -215,8 +220,8 @@ set(key: string, value: string): Promise&lt;void&gt;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| key | string | 是 | 待设置的系统属性Key。 |
| value| string | 是 | 待设置的系统属性值。 |
| key | string | 是 | 待设置的系统参数Key。 |
| value| string | 是 | 待设置的系统参数值。 |
**返回值:**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册