openharmony 鸿蒙 changelogs-ability

2023-06-24 浏览 (414)

Ability Framework Changelog

cl.ability.1 AreaMode APIs Changed

Duplicate AreaMode APIs are deleted.

Change Impact

JS APIs in API version 9 are affected. Your application needs to adapt these APIs so that it can properly implement features in the SDK environment of the new version.

Key API/Component Changes

ModuleClassMethod/Attribute/Enum/ConstantChange Type
@ohos.app.ability.common.d.tscommon.AreaModeDeleted
application/Context.d.tsAreaModeDeleted

Adaptation Guide

Use AreaMode in @ohos.app.ability.contextConstant.d.ts.

import contextConstant from '@ohos.app.ability.contextConstant';
let area: contextConstant.AreaMode = contextConstant.AreaMode.EL1;

cl.ability.2 killProcessesBySelf Renamed

The killProcessesBySelf API is renamed killAllProcesses.

Change Impact

JS APIs in API version 9 are affected. Your application needs to adapt these APIs so that it can properly implement features in the SDK environment of the new version.

Key API/Component Changes

ModuleClassMethod/Attribute/Enum/ConstantChange Type
application/ApplicationContextApplicationContextkillProcessesBySelf(): Promise<void>;Deleted
application/ApplicationContextApplicationContextkillProcessesBySelf(callback: AsyncCallback<void>);Deleted
application/ApplicationContextApplicationContextkillAllProcesses(): Promise<void>;Added
application/ApplicationContextApplicationContextkillAllProcesses(callback: AsyncCallback<void>);Added

Adaptation Guide

The following code snippet shows how to call killProcessesBySelf in an application.

Code before the change:

let context: common.UIAbilityContext = globalThis.abilityContext;
let appContext = context.getApplicationContext();
appContext.killProcessesBySelf()

Code after the change:

let context: common.UIAbilityContext = globalThis.abilityContext;
let appContext = context.getApplicationContext();
appContext.killAllProcesses()

cl.ability.3 getProcessRunningInformation Renamed

The getProcessRunningInformation API is renamed getRunningProcessInformation.

Change Impact

JS APIs in API version 9 are affected. Your application needs to adapt these APIs so that it can properly implement features in the SDK environment of the new version.

Key API/Component Changes

ModuleClassMethod/Attribute/Enum/ConstantChange Type
@ohos.app.ability.appManager.d.tsappManagerfunction getProcessRunningInformation(): Promise<Array<ProcessRunningInformation>>;Deleted
@ohos.app.ability.appManager.d.tsappManagerfunction getProcessRunningInformation(callback: AsyncCallback<Array<ProcessRunningInformation>>): void;Deleted
@ohos.app.ability.appManager.d.tsappManagerfunction getRunningProcessInformation(): Promise<Array<ProcessInformation>>;Added
@ohos.app.ability.appManager.d.tsappManagerfunction getRunningProcessInformation(callback: AsyncCallback<Array<ProcessInformation>>): void;Added
application/ApplicationContext.d.tsApplicationContextgetProcessRunningInformation(): Promise<Array<ProcessRunningInformation>>;Deleted
application/ApplicationContext.d.tsApplicationContextgetProcessRunningInformation(callback: AsyncCallback<Array<ProcessRunningInformation>>): void;Deleted
application/ApplicationContext.d.tsApplicationContextgetRunningProcessInformation(): Promise<Array<ProcessInformation>>;Added
application/ApplicationContext.d.tsApplicationContextgetRunningProcessInformation(callback: AsyncCallback<Array<ProcessInformation>>): void;Added

Adaptation Guide

The following code snippet shows how to call getProcessRunningInformation in an application.

Code before the change:

let context: common.UIAbilityContext = globalThis.abilityContext;
let appContext = context.getApplicationContext();
appContext.getProcessRunningInformation()

Code after the change:

let context: common.UIAbilityContext = globalThis.abilityContext;
let appContext = context.getApplicationContext();
appContext.getRunningProcessInformation()

cl.ability.4 WantConstant.Flags API Changed

WantConstant.Flags has multiple invalid flag definitions. These invalid flags are deleted.

Change Impact

JS APIs in API version 9 are affected. Your application needs to adapt these APIs so that it can properly implement features in the SDK environment of the new version.

Key API/Component Changes

ModuleClassMethod/Attribute/Enum/ConstantChange Type
@ohos.app.ability.wantConstant.d.tswantConstant.FlagsFLAG_ABILITY_FORWARD_RESULTDeleted
@ohos.app.ability.wantConstant.d.tswantConstant.FlagsFLAG_ABILITY_CONTINUATIONDeleted
@ohos.app.ability.wantConstant.d.tswantConstant.FlagsFLAG_NOT_OHOS_COMPONENTDeleted
@ohos.app.ability.wantConstant.d.tswantConstant.FlagsFLAG_ABILITY_FORM_ENABLEDDeleted
@ohos.app.ability.wantConstant.d.tswantConstant.FlagsFLAG_AUTH_PERSISTABLE_URI_PERMISSIONDeleted
@ohos.app.ability.wantConstant.d.tswantConstant.FlagsFLAG_AUTH_PREFIX_URI_PERMISSIONDeleted
@ohos.app.ability.wantConstant.d.tswantConstant.FlagsFLAG_ABILITYSLICE_MULTI_DEVICEDeleted
@ohos.app.ability.wantConstant.d.tswantConstant.FlagsFLAG_START_FOREGROUND_ABILITYDeleted
@ohos.app.ability.wantConstant.d.tswantConstant.FlagsFLAG_ABILITY_CONTINUATION_REVERSIBLEDeleted
@ohos.app.ability.wantConstant.d.tswantConstant.FlagsFLAG_INSTALL_WITH_BACKGROUND_MODEDeleted
@ohos.app.ability.wantConstant.d.tswantConstant.FlagsFLAG_ABILITY_CLEAR_MISSIONDeleted
@ohos.app.ability.wantConstant.d.tswantConstant.FlagsFLAG_ABILITY_NEW_MISSIONDeleted
@ohos.app.ability.wantConstant.d.tswantConstant.FlagsFLAG_ABILITY_MISSION_TOPDeleted

cl.ability.5 WantConstant.Action API Changed

WantConstant.Action has multiple invalid action definitions. These invalid actions are deleted.

Change Impact

JS APIs in API version 9 are affected. Your application needs to adapt these APIs so that it can properly implement features in the SDK environment of the new version.

Key API/Component Changes

ModuleClassMethod/Attribute/Enum/ConstantChange Type
@ohos.app.ability.wantConstant.d.tswantConstant.ActionACTION_APP_ACCOUNT_AUTHDeleted
@ohos.app.ability.wantConstant.d.tswantConstant.ActionACTION_MARKET_DOWNLOADDeleted
@ohos.app.ability.wantConstant.d.tswantConstant.ActionACTION_MARKET_CROWDTESTDeleted
@ohos.app.ability.wantConstant.d.tswantConstant.ActionDLP_PARAMS_SANDBOXDeleted
@ohos.app.ability.wantConstant.d.tswantConstant.ActionDLP_PARAMS_BUNDLE_NAMEDeleted
@ohos.app.ability.wantConstant.d.tswantConstant.ActionDLP_PARAMS_MODULE_NAMEDeleted
@ohos.app.ability.wantConstant.d.tswantConstant.ActionDLP_PARAMS_ABILITY_NAMEDeleted

cl.ability.6 Caller APIs Changed

Caller APIs use the Parcelable and MessageSequence objects provided by RPC in API version 9 to replace the deprecated Sequenceable and MessageParcel object.

Change Impact

JS APIs in API version 9 are affected. Your application needs to adapt these APIs so that it can properly implement features in the SDK environment of the new version.

Key API/Component Changes

ModuleClassMethod/Attribute/Enum/ConstantChange Type
api/@ohos.app.ability.UIAbility.d.tsCalleeCallback(indata: rpc.MessageParcel): rpc.Sequenceable;Changed to (indata: rpc.MessageSequence): rpc.Parcelable;.
api/@ohos.app.ability.UIAbility.d.tsCallercall(method: string, data: rpc.Sequenceable): Promise;Changed to call(method: string, data: rpc.Parcelable): Promise;.
api/@ohos.app.ability.UIAbility.d.tsCallercallWithResult(method: string, data: rpc.Sequenceable): Promise<rpc.MessageParcel>;Changed to callWithResult(method: string, data: rpc.Parcelable): Promise<rpc.MessageSequence>;.

Adaptation Guide

The following illustrates how to call the caller APIs in your application.

Code before the change:

  class MyMessageAble{
      name:""
      str:""
      num: 1
      constructor(name, str) {
        this.name = name;
        this.str = str;
      }
      marshalling(messageParcel) {
          messageParcel.writeInt(this.num);
          messageParcel.writeString(this.str);
          console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']');
          return true;
      }
      unmarshalling(messageParcel) {
          this.num = messageParcel.readInt();
          this.str = messageParcel.readString();
          console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']');
          return true;
      }
  };
  let method = 'call_Function';
  function funcCallBack(pdata) {
      console.log('Callee funcCallBack is called ' + pdata);
      let msg = new MyMessageAble("test", "");
      pdata.readSequenceable(msg);
      return new MyMessageAble("test1", "Callee test");
  }
  export default class MainUIAbility extends UIAbility {
    onCreate(want, launchParam) {
      console.log('Callee onCreate is called');
      try {
        this.callee.on(method, funcCallBack);
      } catch (error) {
        console.log('Callee.on catch error, error.code: ' + error.code +
          ' error.message: ' + error.message);
      }
    }
  }

Code after the change:

  class MyMessageAble{
      name:""
      str:""
      num: 1
      constructor(name, str) {
        this.name = name;
        this.str = str;
      }
      marshalling(messageSequence) {
          messageSequence.writeInt(this.num);
          messageSequence.writeString(this.str);
          console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']');
          return true;
      }
      unmarshalling(messageSequence) {
          this.num = messageSequence.readInt();
          this.str = messageSequence.readString();
          console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']');
          return true;
      }
  };
  let method = 'call_Function';
  function funcCallBack(pdata) {
      console.log('Callee funcCallBack is called ' + pdata);
      let msg = new MyMessageAble("test", "");
      pdata.readParcelable(msg);
      return new MyMessageAble("test1", "Callee test");
  }
  export default class MainUIAbility extends UIAbility {
    onCreate(want, launchParam) {
      console.log('Callee onCreate is called');
      try {
        this.callee.on(method, funcCallBack);
      } catch (error) {
        console.log('Callee.on catch error, error.code: ' + error.code +
          ' error.message: ' + error.message);
      }
    }
  }

cl.ability.7 WantConstant.Flags API Changed

The wantConstant API had two similar enums. Now the two enums are combined into one.

Change Impact

JS APIs in API version 9 are affected. Your application needs to adapt these APIs so that it can properly implement features in the SDK environment of the new version.

Key API/Component Changes

ModuleClassMethod/Attribute/Enum/ConstantChange Type
@ohos.app.ability.wantConstant.d.tswantConstant.ParameterABILITY_BACK_TO_OTHER_MISSION_STACKDeleted
@ohos.app.ability.wantConstant.d.tswantConstant.ParamsABILITY_BACK_TO_OTHER_MISSION_STACKAdded

Adaptation Guide

Use ABILITY_BACK_TO_OTHER_MISSION_STACK in @ohos.app.ability.wantConstant.d.ts.

import wantConstant from '@ohos.app.ability.wantConstant';
let backToOtherMissionStack: wantConstant.Params = wantParam.Params.ABILITY_BACK_TO_OTHER_MISSION_STACK;

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Resource Scheduler Subsystem Changelog

harmony 鸿蒙Telephony Subsystem Changelog

harmony 鸿蒙Web Subsystem Changelog

harmony 鸿蒙ArkUI Subsystem Changelog

harmony 鸿蒙Bundle Manager Subsystem Changelog

harmony 鸿蒙Util Subsystem Changelog

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/4001c09d9f7b43d38c61a16e705b513a