• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import type common from '@ohos.app.ability.common';
17import update from '@ohos.update';
18import type { Features, ChangelogType, CountDownDialogType } from '../const/update_const';
19
20/**
21 * 升级控制接口
22 *
23 * @since 2022-12-01
24 */
25export interface IUpgradeControl {
26  /**
27   * 升级UX
28   */
29  page: IPage,
30
31  /**
32   * 升级提醒
33   */
34  notify: INotify
35}
36
37/**
38 * 更新日志
39 *
40 * @since 2022-12-01
41 */
42export interface ChangelogInfo {
43  /**
44   * 版本号
45   */
46  version?: string;
47
48  /**
49   * 版本大小
50   */
51  size?: string;
52
53  /**
54   * 更新日志
55   */
56  content: string;
57
58  /**
59   * 更新日志类型
60   */
61  displayType?: ChangelogType;
62
63  /**
64   * 更新日志--概述
65   */
66  headFeatures?: Features;
67
68  /**
69   * 更新日志--更新注意事项
70   */
71  endFeatures?: Features;
72
73  /**
74   * 更新日志--具体内容
75   */
76  contentFeatures?: Array<Features>;
77}
78
79/**
80 * 倒计时弹框信息
81 *
82 * @since 2022-12-01
83 */
84export interface CountDownDialogInfo {
85  /**
86   * 弹框消息体
87   */
88  dialogText: Resource;
89
90  /**
91   * 弹框类型
92   */
93  dialogType: CountDownDialogType;
94}
95
96/**
97 * 界面数据
98 *
99 * @since 2022-12-01
100 */
101export interface VersionPageInfo {
102  /**
103   * 版本号
104   */
105  version: string;
106
107  /**
108   * 版本大小
109   */
110  size?: number;
111
112  /**
113   * 生效模式
114   */
115  effectiveMode?: update.EffectiveMode;
116  /**
117   * 升级模式
118   */
119  otaMode?:update.OtaMode;
120  /**
121   * 更新日志
122   */
123  changelog: ChangelogInfo;
124
125  /**
126   * 倒计时弹框显示内容
127   */
128  countDownDialogInfo?: CountDownDialogInfo;
129}
130
131/**
132 * ux页面显示内容
133 *
134 * @since 2022-12-01
135 */
136export interface IPage {
137  /**
138   * 取新版本数据
139   *
140   * @param versionComponents 升级包
141   * @param componentDescriptions 更新日志
142   * @return Promise<VersionPageInfo> 具体的新版本数据
143   */
144  getNewVersionPageInfo(versionComponents: Array<update.VersionComponent>,
145    componentDescriptions?: Array<update.ComponentDescription>): Promise<VersionPageInfo>;
146
147  /**
148   * 取当前版本数据
149   *
150   * @param versionComponents 升级包
151   * @param componentDescriptions 更新日志
152   * @return VersionPageInfo 具体的当前版本数据
153   */
154  getCurrentVersionPageInfo(versionComponents: Array<update.VersionComponent>,
155    componentDescriptions: Array<update.ComponentDescription>): VersionPageInfo;
156}
157
158/**
159 * 提醒
160 *
161 * @since 2022-12-01
162 */
163export interface INotify {
164  /**
165   * 下载进度通知
166   *
167   * @param version 版本号
168   * @param progress 进度
169   * @param context 上下文
170   */
171  showDownloading(version: string, progress: number, context: common.Context): Promise<void>;
172
173  /**
174   * 升级失败通知
175   *
176   * @param versionName 版本号
177   * @param context 上下文
178   */
179  showUpgradeFailed(versionName: string, context: common.Context): Promise<void>;
180
181  /**
182   * 升级成功通知
183   *
184   * @param versionName 版本号
185   * @param context 上下文
186   */
187  showUpgradeSuccess(versionName: string, context: common.Context): Promise<void>;
188
189  /**
190   * 安装中通知
191   *
192   * @param version 版本号
193   * @param progress 进度
194   * @param context 上下文
195   */
196  showInstalling(version: string, progress: number, context: common.Context): Promise<void>
197
198  /**
199   * 取消所有通知
200   */
201  cancelAll(): Promise<void>;
202
203  /**
204   * 检查notification服务是否启动
205   */
206   isServiceReady(): Promise<void>;
207}
208
209