• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 元能力子系统JS API变更Changelog
2
3## cl.ability.1 AreaMode接口变更
4AreaMode接口有多个重复,删除掉重复的AreaMode。
5
6**变更影响**
7
8影响API9版本的JS接口,应用需要进行适配才可以在新版本SDK环境正常实现功能。
9
10**关键的接口/组件变更**
11
12| 模块名                    | 类名                | 方法/属性/枚举/常量                                          | 变更类型 |
13| ------------------------- | ------------------- | ------------------------------------------------------------ | -------- |
14| @ohos.app.ability.common.d.ts | common.AreaMode |  | 删除     |
15| application/Context.d.ts | AreaMode |  | 删除     |
16
17
18**适配指导**
19
20使用@ohos.app.ability.contextConstant.d.ts中的AreaMode
21
22```ts
23import contextConstant from '@ohos.app.ability.contextConstant';
24let area: contextConstant.AreaMode = contextConstant.AreaMode.EL1;
25```
26
27
28
29## cl.ability.2 killProcessesBySelf接口变更
30
31killProcessesBySelf接口命名不合理,修改为killAllProcesses。
32
33**变更影响**
34
35影响API9版本的JS接口,应用需要进行适配才可以在新版本SDK环境正常实现功能。
36
37**关键接口/组件变更**
38
39| 模块名                         | 类名               | 方法/属性/枚举/常量                                   | 变更类型 |
40| ------------------------------ | ------------------ | ----------------------------------------------------- | -------- |
41| application/ApplicationContext | ApplicationContext | killProcessesBySelf(): Promise\<void\>;               | 删除     |
42| application/ApplicationContext | ApplicationContext | killProcessesBySelf(callback: AsyncCallback\<void\>); | 删除     |
43| application/ApplicationContext | ApplicationContext | killAllProcesses(): Promise\<void\>;                  | 新增     |
44| application/ApplicationContext | ApplicationContext | killAllProcesses(callback: AsyncCallback\<void\>);    | 新增     |
45
46
47**适配指导**
48
49应用中调用killProcessesBySelf可参考下列代码
50
51变更前代码:
52
53```ts
54let context: common.UIAbilityContext = globalThis.abilityContext;
55let appContext = context.getApplicationContext();
56appContext.killProcessesBySelf()
57```
58
59变更后代码:
60
61```ts
62let context: common.UIAbilityContext = globalThis.abilityContext;
63let appContext = context.getApplicationContext();
64appContext.killAllProcesses()
65```
66
67
68
69## cl.ability.3 getProcessRunningInformation接口变更
70
71getProcessRunningInformation接口命名不合理,修改为getRunningProcessInformation。
72
73**变更影响**
74
75影响API9版本的JS接口,应用需要进行适配才可以在新版本SDK环境正常实现功能。
76
77**关键接口/组件变更**
78
79| 模块名                              | 类名               | 方法/属性/枚举/常量                                          | 变更类型 |
80| ----------------------------------- | ------------------ | ------------------------------------------------------------ | -------- |
81| @ohos.app.ability.appManager.d.ts   | appManager         | function getProcessRunningInformation(): Promise\<Array\<ProcessRunningInformation\>\>; | 删除     |
82| @ohos.app.ability.appManager.d.ts   | appManager         | function getProcessRunningInformation(callback: AsyncCallback\<Array\<ProcessRunningInformation\>\>): void; | 删除     |
83| @ohos.app.ability.appManager.d.ts   | appManager         | function getRunningProcessInformation(): Promise\<Array\<ProcessInformation\>\>; | 新增     |
84| @ohos.app.ability.appManager.d.ts   | appManager         | function getRunningProcessInformation(callback: AsyncCallback\<Array\<ProcessInformation\>\>): void; | 新增     |
85| application/ApplicationContext.d.ts | ApplicationContext | getProcessRunningInformation(): Promise\<Array\<ProcessRunningInformation\>\>; | 删除     |
86| application/ApplicationContext.d.ts | ApplicationContext | getProcessRunningInformation(callback: AsyncCallback\<Array\<ProcessRunningInformation\>\>): void; | 删除     |
87| application/ApplicationContext.d.ts | ApplicationContext | getRunningProcessInformation(): Promise\<Array\<ProcessInformation\>\>; | 新增     |
88| application/ApplicationContext.d.ts | ApplicationContext | getRunningProcessInformation(callback: AsyncCallback\<Array\<ProcessInformation\>\>): void; | 新增     |
89
90**适配指导**
91
92应用中调用getProcessRunningInformation可参考下列代码
93
94变更前代码:
95
96```ts
97let context: common.UIAbilityContext = globalThis.abilityContext;
98let appContext = context.getApplicationContext();
99appContext.getProcessRunningInformation()
100```
101
102变更后代码:
103
104```ts
105let context: common.UIAbilityContext = globalThis.abilityContext;
106let appContext = context.getApplicationContext();
107appContext.getRunningProcessInformation()
108```
109
110
111
112## cl.ability.4 WantConstant.Flags接口变更
113WantConstant.Flags接口有多个无效Flag定义,删除掉无效的Flag。
114
115**变更影响**
116
117影响API9版本的JS接口,应用需要进行适配才可以在新版本SDK环境正常实现功能。
118
119**关键的接口/组件变更**
120
121| 模块名                    | 类名                | 方法/属性/枚举/常量                                          | 变更类型 |
122| ------------------------- | ------------------- | ------------------------------------------------------------ | -------- |
123| @ohos.app.ability.wantConstant.d.ts | wantConstant.Flags  | FLAG_ABILITY_FORWARD_RESULT | 删除     |
124| @ohos.app.ability.wantConstant.d.ts | wantConstant.Flags  | FLAG_ABILITY_CONTINUATION | 删除     |
125| @ohos.app.ability.wantConstant.d.ts | wantConstant.Flags  | FLAG_NOT_OHOS_COMPONENT | 删除     |
126| @ohos.app.ability.wantConstant.d.ts | wantConstant.Flags  | FLAG_ABILITY_FORM_ENABLED | 删除     |
127| @ohos.app.ability.wantConstant.d.ts | wantConstant.Flags  | FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 删除     |
128| @ohos.app.ability.wantConstant.d.ts | wantConstant.Flags  | FLAG_AUTH_PREFIX_URI_PERMISSION | 删除     |
129| @ohos.app.ability.wantConstant.d.ts | wantConstant.Flags  | FLAG_ABILITYSLICE_MULTI_DEVICE | 删除     |
130| @ohos.app.ability.wantConstant.d.ts | wantConstant.Flags  | FLAG_START_FOREGROUND_ABILITY | 删除     |
131| @ohos.app.ability.wantConstant.d.ts | wantConstant.Flags  | FLAG_ABILITY_CONTINUATION_REVERSIBLE | 删除     |
132| @ohos.app.ability.wantConstant.d.ts | wantConstant.Flags  | FLAG_INSTALL_WITH_BACKGROUND_MODE | 删除     |
133| @ohos.app.ability.wantConstant.d.ts | wantConstant.Flags  | FLAG_ABILITY_CLEAR_MISSION | 删除     |
134| @ohos.app.ability.wantConstant.d.ts | wantConstant.Flags  | FLAG_ABILITY_NEW_MISSION | 删除     |
135| @ohos.app.ability.wantConstant.d.ts | wantConstant.Flags  | FLAG_ABILITY_MISSION_TOP | 删除     |
136
137
138
139## cl.ability.5 WantConstant.Action接口变更
140WantConstant.Action接口有多个无效Action定义,删除掉无效的Action。
141
142**变更影响**
143
144影响API9版本的JS接口,应用需要进行适配才可以在新版本SDK环境正常实现功能。
145
146**关键的接口/组件变更**
147
148| 模块名                    | 类名                | 方法/属性/枚举/常量                                          | 变更类型 |
149| ------------------------- | ------------------- | ------------------------------------------------------------ | -------- |
150| @ohos.app.ability.wantConstant.d.ts | wantConstant.Action  | ACTION_APP_ACCOUNT_AUTH | 删除     |
151| @ohos.app.ability.wantConstant.d.ts | wantConstant.Action  | ACTION_MARKET_DOWNLOAD | 删除     |
152| @ohos.app.ability.wantConstant.d.ts | wantConstant.Action  | ACTION_MARKET_CROWDTEST | 删除     |
153| @ohos.app.ability.wantConstant.d.ts | wantConstant.Action  | DLP_PARAMS_SANDBOX | 删除     |
154| @ohos.app.ability.wantConstant.d.ts | wantConstant.Action  | DLP_PARAMS_BUNDLE_NAME | 删除     |
155| @ohos.app.ability.wantConstant.d.ts | wantConstant.Action  | DLP_PARAMS_MODULE_NAME | 删除     |
156| @ohos.app.ability.wantConstant.d.ts | wantConstant.Action  | DLP_PARAMS_ABILITY_NAME | 删除     |
157
158
159
160## cl.ability.6 Caller相关接口变更
161Caller相关接口使用RPC废弃的Sequenceable和MessageParcel对象,使用RPC在API9提供的Parcelable和MessageSequence对象替代。
162
163**变更影响**
164
165影响API9版本的JS接口,应用需要进行适配才可以在新版本SDK环境正常实现功能。
166
167**关键的接口/组件变更**
168
169| 模块名                    | 类名                | 方法/属性/枚举/常量                                          | 变更类型 |
170| ------------------------- | ------------------- | ------------------------------------------------------------ | -------- |
171| api/@ohos.app.ability.UIAbility.d.ts | CalleeCallback | (indata: rpc.MessageParcel): rpc.Sequenceable; | 变更,修改为 (indata: rpc.MessageSequence): rpc.Parcelable;     |
172| api/@ohos.app.ability.UIAbility.d.ts | Caller | call(method: string, data: rpc.Sequenceable): Promise<void>; | 变更,修改为 call(method: string, data: rpc.Parcelable): Promise<void>;     |
173| api/@ohos.app.ability.UIAbility.d.ts | Caller | callWithResult(method: string, data: rpc.Sequenceable): Promise<rpc.MessageParcel>; | 变更,修改为 callWithResult(method: string, data: rpc.Parcelable): Promise<rpc.MessageSequence>;     |
174
175**适配指导**
176
177应用中调用Caller相关接口可参考下列代码
178
179变更前代码:
180
181```ts
182  class MyMessageAble{
183      name:""
184      str:""
185      num: 1
186      constructor(name, str) {
187        this.name = name;
188        this.str = str;
189      }
190      marshalling(messageParcel) {
191          messageParcel.writeInt(this.num);
192          messageParcel.writeString(this.str);
193          console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']');
194          return true;
195      }
196      unmarshalling(messageParcel) {
197          this.num = messageParcel.readInt();
198          this.str = messageParcel.readString();
199          console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']');
200          return true;
201      }
202  };
203  let method = 'call_Function';
204  function funcCallBack(pdata) {
205      console.log('Callee funcCallBack is called ' + pdata);
206      let msg = new MyMessageAble("test", "");
207      pdata.readSequenceable(msg);
208      return new MyMessageAble("test1", "Callee test");
209  }
210  export default class MainUIAbility extends UIAbility {
211    onCreate(want, launchParam) {
212      console.log('Callee onCreate is called');
213      try {
214        this.callee.on(method, funcCallBack);
215      } catch (error) {
216        console.log('Callee.on catch error, error.code: ' + error.code +
217          ' error.message: ' + error.message);
218      }
219    }
220  }
221```
222
223变更后代码:
224
225```ts
226  class MyMessageAble{
227      name:""
228      str:""
229      num: 1
230      constructor(name, str) {
231        this.name = name;
232        this.str = str;
233      }
234      marshalling(messageSequence) {
235          messageSequence.writeInt(this.num);
236          messageSequence.writeString(this.str);
237          console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']');
238          return true;
239      }
240      unmarshalling(messageSequence) {
241          this.num = messageSequence.readInt();
242          this.str = messageSequence.readString();
243          console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']');
244          return true;
245      }
246  };
247  let method = 'call_Function';
248  function funcCallBack(pdata) {
249      console.log('Callee funcCallBack is called ' + pdata);
250      let msg = new MyMessageAble("test", "");
251      pdata.readParcelable(msg);
252      return new MyMessageAble("test1", "Callee test");
253  }
254  export default class MainUIAbility extends UIAbility {
255    onCreate(want, launchParam) {
256      console.log('Callee onCreate is called');
257      try {
258        this.callee.on(method, funcCallBack);
259      } catch (error) {
260        console.log('Callee.on catch error, error.code: ' + error.code +
261          ' error.message: ' + error.message);
262      }
263    }
264  }
265```
266
267
268
269## cl.ability.7 WantConstant.Flags接口变更
270
271wantConstant接口有两个类似的枚举,合并成一个。
272
273**变更影响**
274
275影响API9版本的JS接口,应用需要进行适配才可以在新版本SDK环境正常实现功能。
276
277**关键的接口/组件变更**
278
279| 模块名                              | 类名                   | 方法/属性/枚举/常量                 | 变更类型 |
280| ----------------------------------- | ---------------------- | ----------------------------------- | -------- |
281| @ohos.app.ability.wantConstant.d.ts | wantConstant.Parameter | ABILITY_BACK_TO_OTHER_MISSION_STACK | 删除     |
282| @ohos.app.ability.wantConstant.d.ts | wantConstant.Params    | ABILITY_BACK_TO_OTHER_MISSION_STACK | 新增     |
283
284**适配指导**
285
286使用@ohos.app.ability.wantConstant.d.ts中的ABILITY_BACK_TO_OTHER_MISSION_STACK
287
288```ts
289import wantConstant from '@ohos.app.ability.wantConstant';
290let backToOtherMissionStack: wantConstant.Params = wantParam.Params.ABILITY_BACK_TO_OTHER_MISSION_STACK;
291```