• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 主题框架changeLog
2
3## cl.theme.1 API9接口支持异常处理
4
5下列模块内部接口使用业务逻辑返回值表示错误信息,不符合OpenHarmony接口错误码规范。在API9进行变更。
6 - 壁纸管理服务:@ohos.wallpaper.d.ts
7
8 - 锁屏管理服务:@ohos.screenLock.d.ts
9
10以上模块中的接口变更为:
11同步接口:通过抛出异常的方式返回错误信息。
12异步接口:参数检查错误同步抛出,业务逻辑错误通过AsyncCallback或Promise的error对象抛出。
13
14**变更影响**
15
16基于此前版本开发的应用,需适配接口的错误信息返回方式,否则会影响原有业务逻辑。
17
18**关键接口/组件变更**
19
20以下标记为壁纸管理服务接口废除:
21   - getColors(wallpaperType: WallpaperType, callback: AsyncCallback<Array<RgbaColor>>): void;
22   - getColors(wallpaperType: WallpaperType): Promise<Array<RgbaColor>>;
23   - getId(wallpaperType: WallpaperType, callback: AsyncCallback<number>): void;
24   - getId(wallpaperType: WallpaperType): Promise<number>;
25   - getMinHeight(callback: AsyncCallback<number>): void;
26   - getMinHeight(): Promise<number>;
27   - getMinWidth(callback: AsyncCallback<number>): void;
28   - getMinWidth(): Promise<number>;
29   - isChangePermitted(callback: AsyncCallback<boolean>): void;
30   - isChangePermitted(): Promise<boolean>;
31   - isOperationAllowed(callback: AsyncCallback<boolean>): void;
32   - isOperationAllowed(): Promise<boolean>;
33   - reset(wallpaperType: WallpaperType, callback: AsyncCallback<void>): void;
34   - reset(wallpaperType: WallpaperType): Promise<void>;
35   - setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback<void>): void;
36   - setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise<void>;
37   - getFile(wallpaperType: WallpaperType, callback: AsyncCallback<number>): void;
38   - getFile(wallpaperType: WallpaperType): Promise<number>;
39   - getPixelMap(wallpaperType: WallpaperType, callback: AsyncCallback<image.PixelMap>): void;
40   - getPixelMap(wallpaperType: WallpaperType): Promise<image.PixelMap>;
41
42壁纸管理服务替代接口如下:
43   - getColorsSync(wallpaperType: WallpaperType): Array<RgbaColor>;
44   - getIdSync(wallpaperType: WallpaperType): number;
45   - getMinHeightSync(): number;
46   - getMinWidthSync(): number;
47   - isChangeAllowed(): boolean;
48   - isUserChangeAllowed(): boolean;
49   - restore(wallpaperType: WallpaperType, callback: AsyncCallback<void>): void;
50   - restore(wallpaperType: WallpaperType): Promise<void>;
51   - setImage(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback<void>): void;
52   - setImage(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise<void>;
53   - getFileSync(wallpaperType: WallpaperType): number;
54   - getImage(wallpaperType: WallpaperType, callback: AsyncCallback<image.PixelMap>): void;
55   - getImage(wallpaperType: WallpaperType): Promise<image.PixelMap>;
56
57以下标记为壁纸管理服务接口变更:
58   - on(type: 'colorChange', callback: (colors: Array<RgbaColor>, wallpaperType: WallpaperType) => void): void
59   - off(type: 'colorChange', callback?: (colors: Array<RgbaColor>, wallpaperType: WallpaperType) => void): void
60
61以下标记为锁屏管理服务接口废除:
62   - isScreenLocked(callback: AsyncCallback<boolean>): void;
63   - isScreenLocked(): Promise<boolean>;
64   - isSecureMode(callback: AsyncCallback<boolean>): void;
65   - isSecureMode(): Promise<boolean>;
66   - unlockScreen(callback: AsyncCallback<void>): void;
67   - unlockScreen(): Promise<void>;
68
69锁屏管理服务替代接口如下:
70   - isLocked(): boolean;
71   - isSecure(): boolean;
72   - unlock(callback: AsyncCallback<boolean>): void;
73   - unlock():Promise<boolean>;
74
75以下标记为锁屏管理服务接口删除:
76   - lockScreen(callback: AsyncCallback<void>): void;
77   - lockScreen(): Promise<void>;
78
79以下标记为锁屏管理服务接口新增:
80   - lock(callback: AsyncCallback<boolean>): void;
81   - lock():Promise<boolean>;
82
83以下标记为锁屏管理服务接口变更:
84   - onSystemEvent(callback: Callback<SystemEvent>): boolean;
85   - sendScreenLockEvent(event: String, parameter: number, callback: AsyncCallback<boolean>): void;
86   - sendScreenLockEvent(event: String, parameter: number): Promise<boolean>;
87
88**壁纸管理服务适配指导**
89
90异步接口以getImage为例,示例代码如下:
91
92```ts
93import pointer from '@ohos.wallpaper';
94try {
95    wallpaper.getImage(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
96        console.log(`success to getImage: ${JSON.stringify(data)}`);
97    }).catch((error) => {
98        console.error(`failed to getImage because: ${JSON.stringify(error)}`);
99    });
100} catch (err) {
101    console.error(`failed to getImage because: ${JSON.stringify(err)}`);
102}
103
104```
105
106同步接口以getFileSync为例,示例代码如下:
107
108```ts
109import pointer from '@ohos.wallpaper';
110try {
111    let file = wallpaper.getFileSync(wallpaper.WallpaperType.WALLPAPER_SYSTEM);
112} catch (err) {
113    console.error(`failed to getFileSync because: ${err.message}`);
114}
115```
116
117**锁屏管理服务适配指导**
118
119异步接口以lock为例,示例代码如下:
120
121```ts
122import screenLock from '@ohos.screenlock';
123try {
124  screenLock.lock((err, data) => {
125    if (err) {
126        console.error(`Failed to lock the screen, because: ${err.message}`);
127        return;
128    }
129    console.info(`lock the screen successfully. result: ${data}`);
130  });
131} catch (err) {
132    console.error(`Failed to lock the screen, because: ${err.message}`);
133}
134
135```
136
137同步接口以onSystemEvent为例,示例代码如下:
138
139```ts
140import screenLock from '@ohos.screenlock';
141try {
142   let isSuccess = screenLock.onSystemEvent((event) => {
143       console.log(`Register the system event which related to screenlock successfully. eventType: ${event.eventType}`)
144   });
145} catch (err) {
146   console.error(`Failed to register the system event which related to screenlock, because: ${err.message}`)
147}
148```
149