Java、JS API差异报告(API 6 -> API 5)
头像 Tiechui.Wang 2021-07-02 11:43:00    发布
3154 浏览 26 点赞 17 收藏

版本信息:

微信图片_20210701104648.jpg


版本介绍:

本次发布HarmonyOS SDK 2.2 Beta 1,相较上一版本,API变更说明请参见【Java API差异报告(API 6 -> API 5)】和【JS API 差异报告(API 6 -> API 5)】。

● JS API差异报告(API 6 -> API 5)

手机、平板、智惹屏、智能穿戴

组件

通用

组件名称变更类型变更说明
通用事件新增新增事件绑定冒泡模式和捕获模式
通用样式新增新增hover伪类用于监控组件是否处于鼠标悬浮状态
资源限定与访问新增新增MCC和MNC、横竖屏、深色模式、设备类型
通用属性新增新增data-*进行相应的数据存储和读取
通用属性新增新增dir设置元素布局模式
通用样式新增min-width/min-height/max-width/max-height支持百分比
通用样式新增left$TABLE_COLtop$TABLE_COLright|bottom支持百分比
通用样式新增新增align-self设置自身在父元素交叉轴上的对齐方式
通用样式新增新增start|end配合position样式确定元素的偏移位置
通用样式新增新增z-index设置同一父节点其子节点的渲染顺序
通用样式新增新增image-fill为svg图片填充颜色
通用样式新增新增clip-path设置组件的裁剪区域
通用样式新增新增mask-image设置组件遮罩
通用样式新增新增mask-size设置遮罩尺寸
通用样式新增新增mask-position设置遮罩位置
通用事件新增BaseEvent新增deviceId属性表示触发该事件的设备ID信息
通用事件新增TouchInfo新增force属性表示接触力信息
通用事件新增SwipeEvent新增distance属性表示在滑动方向上的滑动距离
通用方法新增新增getBoundingClientRect方法 获取元素的大小及其相对于窗口的位置
通用方法新增动画接口新增direction参数设置动画的播放模式
通用方法新增动画接口fill参数新增backwards和both模式
通用方法新增动画曲线支持steps曲线
通用方法新增动画对象支持动画开始事件
动画样式新增transform-origin支持string类型赋值
动画样式新增支持简写属性animation
动画样式新增新增animtion-direction参数设置动画的播放模式
动画样式新增animation-fill-mode参数新增backwards和both模式
动画样式新增新增animation-play-state指定动画的当前状态
动画样式新增新增transition样式设置组件的过渡效果
动画样式新增支持全量W3C标准transform能力
动画样式新增keyframes新增background-position的支持
动画样式新增keyframes新增多段式配置能力
媒体查询新增新增dark-mode表示当前系统是否为深色模式
长度类型新增新增fp字体尺寸单位

容器组件

组件名称变更类型变更说明
badge新增新增label属性设置新事件提醒的文本值
div新增新增overflow、align-items、scrollbar-color、scrollbar-width、overscroll-effect样式/reachStart、reachEnd、reachTop、reachBottom事件/getScrollOffset、scrollBy方法
list新增新增scrollbaroffset、scrollbar-color、scrollbar-width样式
refresh新增新增timeoffset属性设置更新时间距离父组件顶部的距离
form新增新增form表单容器组件

基础组件

组件名称变更类型变更说明
chart新增新增animationduration属性设置占比类圆形图表展开动画时长
image新增src属性新增对Base64字符串的支持
image-animator新增新增支持设置每帧时长和启用图片预加载
input新增新增autofocus、selectedstart、selectedend、softkeyboardenabled、showpasswordicon属性/caret-color样式/selectchange事件/delete方法
option新增新增action属性
search新增新增caret-color样式
textarea新增新增word-break、caret-color样式/新增autofocus、selectedstart、selectedend、softkeyboardenabled属性/新增selectchange事件
richtext新增新增richtext富文本组件
web新增新增web网页内容展示组件
xcomponent新增新增xcomponent插件组件

媒体组件

组件名称变更类型变更说明
video新增新增loop、starttime、speed、direction属性/stop方法
camera新增新增camera照相机组件

画布组件

组件名称变更类型变更说明
canvas新增新增抗锯齿能力和toDataURL能力
CanvasRenderingContext2D对象新增新增ellipse()接口、Path2D能力、绘制线性渐变和径向渐变能力、图像平整度设置能力。

栅格组件

组件名称变更类型变更说明
grid-container新增新增gridtemplate属性

基本功能

全局

接口名称变更类型变更说明
getApp() => object新增-
scrollTo( ScrollPageParam param) => void新增-
onShow() => void新增-
onHide() => void新增-
onConfigurationUpdated( Configuration  configuration ) => void新增-

@ohos.ability.featureAbility

接口名称变更类型变更说明
featureAbility.getContext新增获取上下文
featureAbility.getWant新增获取程序启动时的参数
featureAbility.startAbility新增启动ability

@ohos.window

接口名称变更类型变更说明
window.getTopWindow新增新增获取当前窗口的接口
window.setSystemBarProperties新增新增设置页面导航条颜色的接口
window.getProperties新增新增获取当前窗口属性的接口
window.setBackgroundColor新增新增动态设置窗口的背景色的接口
window.setKeepScreenOn新增新增设置屏幕是否常量的接口
window.setFullScreen新增新增设置是否全屏状态的接口
window.setBrightness新增新增设置屏幕亮度的接口
window.on新增新增开启监听键盘高度变化的接口
window.off新增新增关闭监听键盘高度变化的接口

@ohos.pasteboard

接口名称变更类型变更说明
getSystemPasteboard新增获取系统剪切板
createPlainTextData新增创建文本类型的PasteData对象
getPrimaryText新增获取文本数据
setPasteData新增写入系统剪切板内容
getPasteData新增读取系统剪切板内容

Context

接口名称变更类型变更说明
context.getCacheDir新增获取缓存目录
context.getFilesDir新增获取文件目录
context.getExternalCacheDir新增获取外部缓存目录

网络访问

@ohos.net.http

接口名称变更类型变更说明
request(url: string, callback: AsyncCallback<HttpResponse>):
void; request(url: string, options: HttpRequestOptions, callback:
AsyncCallback<HttpResponse>): void; request(url: string, options?:
HttpRequestOptions): Promise<HttpResponse>;
新增新增发起http网络请求
destroy(): void;新增新增中断请求任务
on(type: “headerReceive”, callback: AsyncCallback<Object>): void;新增新增打开监听HTTP Response Header 事件
off(type: “headerReceive”, callback?: AsyncCallback<Object>): void;新增新增取消监听HTTP Response Header 事件

@ohos.net.websocket

接口名称变更类型变更说明
connect(url: string, callback: AsyncCallback<boolean>): void;
connect(url: string, options: WebSocketRequestOptions, callback:
AsyncCallback<boolean>): void; connect(url: string, options?:
WebSocketRequestOptions): Promise<boolean>;
新增新增建立一个websocket连接
send(data: string, callback: AsyncCallback<boolean>): void; send(data: string): Promise<boolean>;新增新增通过websocket连接发送数据
close(options: WebSocketCloseOptions): void; close(options:
WebSocketCloseOptions, callback: AsyncCallback<boolean>): void;
close(options?: WebSocketCloseOptions): Promise<boolean>;
新增新增关闭websocket连接
on(type: ‘open’, callback: AsyncCallback<Object>): void;
on(type: ‘message’, callback: AsyncCallback<string>): void;
on(type: ‘close’, callback: AsyncCallback<{ code: number, reason:
string }>): void; on(type: ‘error’, callback: ErrorCallback): void;
新增新增打开监听websocket连接的打开事件、接收到服务器消息事件、关闭事件和错误事件
off(type: ‘open’, callback?: AsyncCallback<Object>): void;
off(type: ‘message’, callback: AsyncCallback<string>): void;
off(type: ‘close’, callback?: AsyncCallback<{ code: number, reason:
string }>): void; off(type: ‘error’, callback?: ErrorCallback): void;
新增新增关闭监听websocket连接的打开事件、接收到服务器消息事件、关闭事件和错误事件

文件数据

@ohos.fileio

接口名称变更类型变更说明
fileio.stat新增基于路径获取文件状态信息(异步)
fileio.statSync新增基于路径获取文件状态信息(同步)
fileio.opendir新增打开目录(异步)
fileio.opendirSync新增打开目录(异步)
fileio.access新增获取文件存在和读写状态(异步)
fileio.accessSync新增获取文件存在和读写状态(同步)
fileio.closeSync新增关闭文件(同步)
fileio.copyFile新增复制文件(异步)
fileio.copyFileSync新增复制文件(同步)
fileio.mkdir新增创建目录(同步)
fileio.mkdirSync新增创建目录(异步)
fileio.openSync新增打开文件(同步)
fileio.read新增读文件(异步)
fileio.readSync新增读文件(同步)
fileio.rmdirSync新增删除目录(同步)
fileio.unlink新增删除文件(异步)
fileio.unlinkSync新增删除文件(同步)
fileio.write新增写文件(异步)
fileio.writeSync新增写文件(同步)
fileio.hash新增哈希文件(异步)
fileio.Dir.read新增读取下一个目录项(异步)
fileio.Dir.readSync新增读取下一个目录项(同步)
fileio.Dir.closeSync新增关闭目录(同步)
fileio.Dirent.name新增获取目录项名称
fileio.Dirent.isBlockDevice新增判断目录项是否是块设备
fileio.Dirent.isCharacterDevice新增判断目录项是否是字符设备
fileio.Dirent.isDirectory新增判断目录项是否是目录
fileio.Dirent.isFIFO新增判断目录项是否是FIFO
fileio.Dirent.isFile新增判断目录项是否是普通文件
fileio.Dirent.isSocket新增判断目录项是否是SOCKET
fileio.Dirent.isSymbolicLink新增判断目录项是否是符号链接
fileio.Stat.dev新增读取文件的dev
fileio.Stat.ino新增读取文件的INO
fileio.Stat.mode新增读取文件的mode
fileio.Stat.nlink新增读取文件的nlink
fileio.Stat.uid新增读取文件的uid
fileio.Stat.gid新增读取文件的gid
fileio.Stat.rdev新增读取文件的rdev
fileio.Stat.size新增读取文件的size
fileio.Stat.blocks新增读取文件的blocks
fileio.Stat.atime新增读取文件的atime
fileio.Stat.mtime新增读取文件的mtime
fileio.Stat.ctime新增读取文件的ctime
fileio.Stat.isBlockDevice新增判断文件是否是BlockDevice
fileio.Stat.isCharacterDevice新增判断文件是否是CharacterDevice
fileio.Stat.isDirectory新增判断文件是否是Directory
fileio.Stat.isFIFO新增判断文件是否是FIFO
fileio.Stat.isFile新增判断文件是否是File
fileio.Stat.isSocket新增判断文件是否是Socket
fileio.Stat.isSymbolicLink新增判断文件是否是SymbolicLink

@ohos.document

接口名称变更类型变更说明
document.choose新增通过文件管理picker选取文件,返回文件uri
document.show新增通过入参uri,拉起对应应用打开文件

@ohos.data.storage

接口名称变更类型变更说明
getStorageSync(path: string)新增创建或获取一个Storage实例
getStorage(path: string, callback: AsyncCallback<Storage>)新增创建或获取一个Storage实例
getStorage(path: string)新增创建或获取一个Storage实例
deleteStorageSync(path: string)新增删除一个Storage实例
deleteStorage(path: string, callback: AsyncCallback<void>)新增删除一个Storage实例
deleteStorage(path: string)新增删除一个Storage实例
removeStorageFromCacheSync(path: string)新增从缓存中移除指定的Storage实例
removeStorageFromCache(path: string, callback: AsyncCallback<void>)新增从缓存中移除指定的Storage实例
removeStorageFromCache(path: string)新增从缓存中移除指定的Storage实例
storage.getSync(key: string, defValue: ValueType)新增获取指定key的值
storage.get(key: string, defValue: ValueType, callback: AsyncCallback<ValueType>)新增获取指定key的值
storage.get(key: string, defValue: ValueType)新增获取指定key的值
storage.hasSync(key: string)新增检查指定key是否存在
storage.has(key: string, callback: AsyncCallback<boolean>)新增检查指定key是否存在
storage.has(key: string)新增检查指定key是否存在
storage.putSync(key: string, value: ValueType)新增添加一个指定的key-value到Storage实例中
storage.put(key: string, value: ValueType, callback: AsyncCallback<void>)新增添加一个指定的key-value到Storage实例中
storage.put(key: string, value: ValueType)新增添加一个指定的key-value到Storage实例中
storage.deleteSync(key: string)新增从Storage实例中删除一个指定的key-value对象
storage.delete(key: string, callback: AsyncCallback<void>)新增从Storage实例中删除一个指定的key-value对象
storage.delete(key: string)新增从Storage实例中删除一个指定的key-value对象
storage.clearSync()新增从Storage实例中清空所有的数据
storage.clear(callback: AsyncCallback<void>)新增从Storage实例中清空所有的数据
storage.clear()新增从Storage实例中清空所有的数据
storage.flushSync()新增将Storage实例持久化到文件中
storage.flush(callback: AsyncCallback<void>)新增将Storage实例持久化到文件中
storage.flush()新增将Storage实例持久化到文件中
storage.on(type: ‘change’, callback: Callback<StorageObserver>)新增添加数据变动的监听,当Storage实例持久化时,该回调方法会被执行
storage.off(type: ‘change’, callback: Callback<StorageObserver>)新增取消数据变动的监听

系统能力

@ohos.deviceInfo

接口名称变更类型变更说明
deviceInfo.deviceType新增新增设备类型
deviceInfo.manufacture新增新增设备厂家名称
deviceInfo.brand新增新增设备品牌名称
deviceInfo.marketName新增新增外部产品系列
deviceInfo.productSeries新增新增产品系列
deviceInfo.productModel新增新增认证型号
deviceInfo.softwareModel新增新增内部软件子型号
deviceInfo.hardwareModel新增新增硬件版本号
deviceInfo.hardwareProfile新增新增硬件Profile
deviceInfo.serial新增新增设备序列号
deviceInfo.bootloaderVersion新增新增Bootloader版本号
deviceInfo.abiList新增新增应用二进制接口(Abi)列表
deviceInfo.securityPatchTag新增新增安全补丁级别
deviceInfo.displayVersion新增新增产品版本
deviceInfo.incrementalVersion新增新增差异版本号
deviceInfo.osReleaseType新增新增系统的发布类型
deviceInfo.osFullName新增新增系统版本
deviceInfo.majorVersion新增新增Major版本号
deviceInfo.seniorVersion新增新增Senior版本号
deviceInfo.featureVersion新增新增Feature版本号
deviceInfo.buildVersion新增新增Build版本号
deviceInfo.sdkApiVersion新增新增系统软件API版本
deviceInfo.firstApiVersion新增新增首个版本系统软件API版本
deviceInfo.versionId新增新增版本ID
deviceInfo.buildType新增新增构建类型
deviceInfo.buildUser新增新增构建用户
deviceInfo.buildHost新增新增构建主机
deviceInfo.buildTime新增新增构建时间
deviceInfo.buildRootHash新增新增构建版本Hash

@system.sensor

接口名称变更类型变更说明
sensor.subscribeDeviceOrientation新增新增订阅设备方向传感器
sensor.unsubscribeDeviceOrientation新增新增取消订阅设备方向传感器
sensor.subscribeGyroscope新增新增订阅陀螺仪传感器
sensor.unsubscribeGyroscope新增新增取消订阅陀螺仪传感器

@ohos.batteryinfo

接口名称变更类型变更说明
batteryInfo.batterySOC新增新增电量属性
batteryInfo.chargingStatus新增新增充电状态属性
batteryInfo.healthStatus新增新增电池健康状态属性
batteryInfo.pluggedType新增新增充电器类型属性
batteryInfo.voltage新增新增电池电源属性
batteryInfo.technology新增新增电池类型属性
batteryInfo.batteryTemperature新增新增电池温度属性
batteryInfo.BatteryHealthState新增新增电池健康状态枚举
batteryInfo.BatteryPluggedType新增新增充电器类型枚举
batteryInfo.BatteryChargeState新增新增充电状态枚举

@ohos.multimedia.media

接口名称变更类型变更说明
createAudioPlayer(): AudioPlayer新增创建音频播放的实例
createAudioRecorder(): AudioRecorder新增创建音频录制的实例
play(): void新增开始播放音频资源
pause(): void新增暂停播放音频资源
stop(): void新增停止播放音频资源
seek(timeMs: number): void新增跳转到指定播放位置
setVolume(vol: number): void新增设置音量
release(): void新增释放音频资源
on(type: ‘play’ $TABLE_COL ‘pause’ $TABLE_COL ‘stop’$TABLE_COL
‘finish’  $TABLE_COL ‘volumeChange’, callback: () => void): void
新增开始监听音频播放事件
on(type:‘error’, callback: ErrorCallback): void新增开始监听音频播放错误事件
prepare(config: AudioRecorderConfig): void新增录音准备
start(): void新增录音开始
pause(): void新增录音暂停
resume(): void新增录音恢复
stop(): void新增录音停止
release(): void新增录音释放
reset(): void新增录音重置
on(type: ‘prepare’ $TABLE_COL ‘start’ $TABLE_COL ‘pause’ $TABLE_COL
‘resume’  $TABLE_COL ‘stop’ $TABLE_COL ‘release’ $TABLE_COL ‘reset’,
callback: ()  => void): void
新增开始监听音频录制事件
on(type: ‘error’, callback: ErrorCallback): void新增开始监听音频录制错误事件

@ohos.multimedia.mediaLibrary

接口名称变更类型变更说明
getMediaLibrary()新增获取媒体数据管理器
storeMediaAsset(option: MediaAssetOption, callback: AsyncCallback<string>)新增保存媒体资源
storeMediaAsset(option: MediaAssetOption)新增保存媒体资源

安全

@ohos.useriam.userauth

接口名称变更类型变更说明
userauth.getAuthenticator新增新增获取认证器对象接口
userauth.Authenticator.execuate新增新增执行认证接口

轻量级智能穿戴

组件

通用

组件名称变更类型变更说明
通用样式新增‘left’ | 'top’支持百分比

● Java API差异报告(API 6 -> API 5)

Added Packages

Added Packages
ohos.data.fileProvides basic file access capabilities.

Added Packages

Package ohos.aafwk.ability

Added Classes and Interfaces
FormStateEnumerates the states of a form.
IAbilityStartCallbackProvides a callback to be invoked when an ability is started in installation-free mode.
Changed Classes and Interfaces
AbilityAn ability is an abstraction of functionalities that a HarmonyOS application can provide.
AbilitySliceAs the fundamental unit of the Ability using the Page template, {@code AbilitySlice} provides an ability with a carrier for service logic and UI display.
AbilitySlice.FormCallbackProvides callbacks that will be invoked when a Form instance is obtained or when the {@code Form} provider is uninstalled.
IAbilityContinuationEnables an Ability to implement migration in a distributed system.

Package ohos.aafwk.ability.continuation

Added Classes
ContinuationDeviceInfoDefines information about the selected device.
Changed Interfaces
IContinuationDeviceCallbackProvides callbacks for listening for device connection state changes.

Package ohos.aafwk.content

Changed Classes
IntentProvides an abstract description of an operation to be performed.

Package ohos.agp.components.webengine

Added Interfaces
ScaleChangeListenerProvides a listener that listens for scale changes.
ScaleControllerManages and observes scaling of a {@code WebView} object.
Changed Classes
WebViewRepresents a component that has the web page access capability.

Package ohos.agp.window.service

Changed Classes
WindowManager.LayoutConfigEncapsulates the layout attributes, flags, and constants used with a Window.

Package ohos.app

Changed Classes and Interfaces
AbilityContextAn abstract class that provides the application context for the
current object and obtains the application environment information.
ContextProvides the context of an object in the application and obtains application environment information.

Package ohos.bundle

Changed Classes
ApplicationInfoObtains configuration information about an application.

Package ohos.data.distributed.file

Changed Classes
DistAgentFileProvides methods for the file manager to perform operations on distributed agent files.
DistFileInherits from the {@code java.io.File} class and provides methods
for the file manager to perform basic operations on distributed files or
directories.
DistFilesProvides methods for the file manager to perform operations on distributed files or directories.
DistLinkFileProvides methods for the file manager to perform operations on distributed link files.

Package ohos.event.notification

Added Classes
ReminderHelperProvides static methods for managing reminders, including publishing
or canceling a reminder, adding or removing a notification slot, and
obtaining or canceling all reminders of the current application.
ReminderManagerDefine constant for background agent service function.
ReminderManager.AppLimitExceedsExceptionThrows this exception when the number of effective reminders of current application exceed the limit value ReminderDataManager#MAX_NUM_REMINDER_LIMIT_APP
ReminderManager.SysLimitExceedsExceptionThrows this exception when the number of effective reminders of the whole system exceed the limit value ReminderDataManager#MAX_NUM_REMINDER_LIMIT_SYSTEM
ReminderRequestBase class for letting a background agent to publish reminders on behalf of a third-party application.
ReminderRequestAlarmA ReminderRequest child class used for creating reminders for alarm clocks.
ReminderRequestCalendarA ReminderRequest child class used for creating reminders for calendar events.
ReminderRequestTimerA ReminderRequest child class used for creating reminders for countdown timers.

Package ohos.media.audio

Changed Classes
AudioManagerManages audio information, controls audio devices, adjusts the volume, and manages the audio focus.

Package ohos.miscservices.download

Changed Classes
DownloadConfig.BuilderProvides {@code Builder} objects of download configuration,
including methods to set parameters used to create a download session.

Package ohos.rpc

Changed Classes
MessageParcelInherits from the Parcel class and provides methods for managing {@code MessageParcel} objects.
RemoteProxyImplements IRemoteObject proxy objects.

Package ohos.utils

Changed Classes
IntentConstantsDefines the ohos.aafwk.content.Intent-related constants
used in the system, including the actions, entities, and flags
contained in the intents passed to methods for starting an ability.


©本站发布的所有内容,包括但不限于文字、图片、音频、视频、图表、标志、标识、广告、商标、商号、域名、软件、程序等,除特别标明外,均来源于网络或用户投稿,版权归原作者或原出处所有。我们致力于保护原作者版权,若涉及版权问题,请及时联系我们进行处理。
分类
其它
地址:北京市朝阳区北三环东路三元桥曙光西里甲1号第三置业A座1508室 商务内容合作QQ:2291221 电话:13391790444或(010)62178877
版权所有:电脑商情信息服务集团 北京赢邦策略咨询有限责任公司
声明:本媒体部分图片、文章来源于网络,版权归原作者所有,我司致力于保护作者版权,如有侵权,请与我司联系删除
京ICP备:2022009079号-2
京公网安备:11010502051901号
ICP证:京B2-20230255