|
|
@@ -13,8 +13,7 @@ import { GlobalWidgetManager } from '../common/widget/GlobalWidgetManager';
|
|
|
import { WidgetSizeAdapter, SizeChangeListener } from '../common/widget/WidgetSizeAdapter';
|
|
|
import { PreferencesUtil } from '../common/utils/PreferencesUtil';
|
|
|
|
|
|
-const TAG = 'Heanup';
|
|
|
-
|
|
|
+const TAG = 'Heanup EntryFormAbility';
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -38,7 +37,8 @@ function copyWidgetData(target: ExtendedWidgetData, overrides: Partial<ExtendedW
|
|
|
coverImage: overrides.coverImage !== undefined ? overrides.coverImage : target.coverImage,
|
|
|
currentTime: overrides.currentTime !== undefined ? overrides.currentTime : target.currentTime,
|
|
|
totalTime: overrides.totalTime !== undefined ? overrides.totalTime : target.totalTime,
|
|
|
- progressPercentage: overrides.progressPercentage !== undefined ? overrides.progressPercentage : target.progressPercentage,
|
|
|
+ progressPercentage: overrides.progressPercentage !== undefined ? overrides.progressPercentage :
|
|
|
+ target.progressPercentage,
|
|
|
hasNext: overrides.hasNext !== undefined ? overrides.hasNext : target.hasNext,
|
|
|
hasPrevious: overrides.hasPrevious !== undefined ? overrides.hasPrevious : target.hasPrevious,
|
|
|
showProgress: overrides.showProgress !== undefined ? overrides.showProgress : target.showProgress,
|
|
|
@@ -62,42 +62,223 @@ implements SizeChangeListener {
|
|
|
private layoutManager: FormLayoutManager = FormLayoutManager.getInstance();
|
|
|
private sizeAdapter: WidgetSizeAdapter = WidgetSizeAdapter.getInstance();
|
|
|
private globalWidgetManager: GlobalWidgetManager = GlobalWidgetManager.getInstance();
|
|
|
-
|
|
|
// 使用实例变量而不是静态变量,确保每个进程都能正确设置监听器
|
|
|
private globalListenerSetup: boolean = false;
|
|
|
-
|
|
|
// 防抖机制:避免短时间内重复更新
|
|
|
private lastUpdateTime: number = 0;
|
|
|
- private updateDebounceDelay: number = 100; // 100ms防抖延迟
|
|
|
+ private updateDebounceDelay: number = 100;
|
|
|
+ // 100ms防抖延迟
|
|
|
|
|
|
// 进程启动时间,用于检测进程重启
|
|
|
private processStartTime: number = Date.now();
|
|
|
- private lastHealthCheck: number = 0;
|
|
|
-
|
|
|
// 图片下载缓存
|
|
|
private downloadingImages: Map<string, Promise<string | null>> = new Map();
|
|
|
- private imageCache: Map<string, string> = new Map(); // url -> fileName映射
|
|
|
+ private imageCache: Map<string, string> = new Map();
|
|
|
+
|
|
|
+ // url -> fileName映射
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 卡片创建时调用
|
|
|
+ */
|
|
|
+ onAddForm(want: Want): formBindingData.FormBindingData {
|
|
|
+
|
|
|
+
|
|
|
+ // 检查参数有效性
|
|
|
+ if (!want || !want.parameters) {
|
|
|
+ hilog.error(0x0000, TAG, 'FormAbility onAddForm want or want.parameters is undefined');
|
|
|
+ return formBindingData.createFormBindingData('');
|
|
|
+ }
|
|
|
+
|
|
|
+ // 初始化服务
|
|
|
+ try {
|
|
|
+
|
|
|
+ this.initializeServices();
|
|
|
+
|
|
|
+ } catch (error) {
|
|
|
+ hilog.error(0x0000, TAG, `Heanup EntryFormAbility failed to initialize services: ${error}`);
|
|
|
+ }
|
|
|
+
|
|
|
+ const formId = want.parameters?.['ohos.extra.param.key.form_identity'] as string;
|
|
|
+ const formName = want.parameters?.['ohos.extra.param.key.form_name'] as string;
|
|
|
+ const formDimension = want.parameters?.['ohos.extra.param.key.form_dimension'] as string;
|
|
|
+ const tempFlag = want.parameters?.['ohos.extra.param.key.form_temporary'] as boolean;
|
|
|
+
|
|
|
+
|
|
|
+ // 持久化保存 Form ID(异步执行,不阻塞返回)
|
|
|
+ this.saveFormIdToPersistence(formId).then(() => {
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+ // 检测卡片尺寸并注册到全局管理器
|
|
|
+ const widgetSize = this.sizeAdapter.detectSizeFromWant(want);
|
|
|
+ try {
|
|
|
+ this.globalWidgetManager.registerWidget(formId, widgetSize);
|
|
|
+
|
|
|
+ } catch (error) {
|
|
|
+ hilog.error(0x0000, TAG, `Failed to register widget: ${error}`);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 注册各种监听器
|
|
|
+ this.sizeAdapter.registerSizeChangeListener(formId, this);
|
|
|
+
|
|
|
+ // 初始化卡片数据
|
|
|
+ this.initializeWidget(formId, widgetSize);
|
|
|
+
|
|
|
+ // 验证监听器设置状态
|
|
|
+ setTimeout(() => {
|
|
|
+ const avSessionListener = AvSessionWidgetListener.getInstance();
|
|
|
+ const listenerCount = avSessionListener.getListenerCount();
|
|
|
+
|
|
|
+
|
|
|
+ if (listenerCount === 0) {
|
|
|
+ hilog.warn(0x0000, TAG, `⚠️ No listeners found! Form process may not receive data updates!`);
|
|
|
+ } else {
|
|
|
+
|
|
|
+ }
|
|
|
+ }, 2000);
|
|
|
+
|
|
|
+ // 获取当前播放状态而不是初始数据
|
|
|
+ this.playerControlService.getCurrentPlayState().then((currentState: WidgetData) => {
|
|
|
+ const adaptedData = this.layoutManager.adaptDataForSize(currentState, widgetSize);
|
|
|
+ const formData = formBindingData.createFormBindingData(adaptedData);
|
|
|
+ // 立即更新卡片以显示当前状态
|
|
|
+ formProvider.updateForm(formId, formData);
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ // 返回初始数据作为临时显示
|
|
|
+ const initialData = this.widgetDataManager?.getInitialWidgetData() || this.getDefaultWidgetData();
|
|
|
+ const adaptedData = this.layoutManager.adaptDataForSize(initialData, widgetSize);
|
|
|
+
|
|
|
+ return formBindingData.createFormBindingData(adaptedData);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 卡片更新时调用
|
|
|
+ */
|
|
|
+ onUpdateForm(formId: string): void {
|
|
|
+
|
|
|
+
|
|
|
+ // 确保服务已初始化
|
|
|
+ if (!this.globalListenerSetup) {
|
|
|
+
|
|
|
+ this.initializeServices();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 确保widget已注册到GlobalWidgetManager
|
|
|
+ if (!this.globalWidgetManager.hasWidget(formId)) {
|
|
|
+
|
|
|
+ this.globalWidgetManager.registerWidget(formId, 'medium' as WidgetSize);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 只更新指定的卡片,避免重复更新
|
|
|
+ this.updateWidgetData(formId);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 卡片删除时调用
|
|
|
+ */
|
|
|
+ onRemoveForm(formId: string): void {
|
|
|
+
|
|
|
+
|
|
|
+ // 从持久化存储中移除 Form ID(异步执行)
|
|
|
+ this.removeFormIdFromPersistence(formId).then(() => {
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ // 注销各种监听器
|
|
|
+ this.sizeAdapter.unregisterSizeChangeListener(formId);
|
|
|
+
|
|
|
+ // 从全局管理器中注销卡片
|
|
|
+ this.globalWidgetManager.unregisterWidget(formId);
|
|
|
+
|
|
|
+ // 清理卡片相关数据和配置
|
|
|
+ this.widgetDataManager?.removeWidgetData(formId);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 卡片可见性变化时调用
|
|
|
+ */
|
|
|
+ onVisibilityChange(newStatus: Record<string, number>): void {
|
|
|
+
|
|
|
+
|
|
|
+ const formIds = Object.keys(newStatus);
|
|
|
+ for (let i = 0; i < formIds.length; i++) {
|
|
|
+ const formId = formIds[i];
|
|
|
+ const isVisible = newStatus[formId] === 1;
|
|
|
+
|
|
|
+
|
|
|
+ if (isVisible) {
|
|
|
+ // 卡片变为可见时,更新数据
|
|
|
+ this.updateWidgetData(formId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 卡片配置更新时调用
|
|
|
+ */
|
|
|
+ onConfigurationUpdate(newConfig: Object): void {
|
|
|
+
|
|
|
+
|
|
|
+ // 更新所有卡片以适应新配置
|
|
|
+ this.widgetDataManager?.updateAllWidgets();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 实现SizeChangeListener接口
|
|
|
+ * 处理卡片尺寸变化事件
|
|
|
+ */
|
|
|
+ onSizeChanged(formId: string, oldSize: WidgetSize, newSize: WidgetSize): void {
|
|
|
+
|
|
|
+
|
|
|
+ // 更新全局管理器中的尺寸记录
|
|
|
+ this.globalWidgetManager.updateWidgetSize(formId, newSize);
|
|
|
+
|
|
|
+ // 立即更新卡片数据以适应新尺寸
|
|
|
+ this.updateWidgetData(formId);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理卡片尺寸变化(系统调用)
|
|
|
+ * @param newStatus 新的尺寸状态
|
|
|
+ */
|
|
|
+ onAcquireFormState(want: Want): number {
|
|
|
+
|
|
|
+
|
|
|
+ const formId = want.parameters?.['ohos.extra.param.key.form_identity'] as string;
|
|
|
+
|
|
|
+ if (formId) {
|
|
|
+ // 检测新的尺寸
|
|
|
+ const newSize = this.sizeAdapter.detectSizeFromWant(want);
|
|
|
+ const oldSize = this.globalWidgetManager.getWidgetSize(formId);
|
|
|
+
|
|
|
+ if (oldSize && this.sizeAdapter.validateSizeChange(oldSize, newSize)) {
|
|
|
+ // 处理尺寸变化
|
|
|
+ this.handleFormSizeChange(formId, oldSize, newSize);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 返回卡片状态 - 使用数字常量代替枚举
|
|
|
+ return 1; // READY状态
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 初始化服务
|
|
|
*/
|
|
|
private initializeServices(): void {
|
|
|
- hilog.info(0x0000, TAG, 'Heanup EntryFormAbility initializeServices called');
|
|
|
|
|
|
if (!this.widgetDataManager) {
|
|
|
this.widgetDataManager = new WidgetDataManager();
|
|
|
- hilog.info(0x0000, TAG, 'Heanup EntryFormAbility WidgetDataManager initialized');
|
|
|
}
|
|
|
|
|
|
// 设置全局状态监听器(每个进程实例设置一次)
|
|
|
- hilog.info(0x0000, TAG, `Heanup EntryFormAbility checking global listener setup: ${this.globalListenerSetup}`);
|
|
|
if (!this.globalListenerSetup) {
|
|
|
- hilog.info(0x0000, TAG, 'Heanup EntryFormAbility setting up global listener...');
|
|
|
this.setupGlobalStateListener();
|
|
|
this.globalListenerSetup = true;
|
|
|
- hilog.info(0x0000, TAG, 'Heanup EntryFormAbility global listener setup flag set to true');
|
|
|
- } else {
|
|
|
- hilog.info(0x0000, TAG, 'Heanup EntryFormAbility global listener already setup, skipping');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -106,89 +287,29 @@ implements SizeChangeListener {
|
|
|
*/
|
|
|
private setupGlobalStateListener(): void {
|
|
|
try {
|
|
|
- hilog.info(0x0000, TAG, `Heanup EntryFormAbility [Process:${this.processStartTime}] getting AvSessionWidgetListener instance...`);
|
|
|
const avSessionListener = AvSessionWidgetListener.getInstance();
|
|
|
-
|
|
|
- // 检查当前监听器数量
|
|
|
- const currentListenerCount = avSessionListener.getListenerCount();
|
|
|
- hilog.info(0x0000, TAG, `Heanup EntryFormAbility [Process:${this.processStartTime}] current listener count before adding: ${currentListenerCount}`);
|
|
|
-
|
|
|
- hilog.info(0x0000, TAG, `Heanup EntryFormAbility [Process:${this.processStartTime}] adding state listener...`);
|
|
|
-
|
|
|
avSessionListener.addStateListener((data: WidgetData) => {
|
|
|
- const now = Date.now();
|
|
|
- hilog.info(0x0000, TAG, `Heanup EntryFormAbility [Process:${this.processStartTime}] global listener received state update: isPlaying=${data.playState.isPlaying}, title=${data.currentSong.title}, age=${now - this.processStartTime}ms`);
|
|
|
-
|
|
|
- // 更新健康检查时间
|
|
|
- this.lastHealthCheck = now;
|
|
|
-
|
|
|
- // 总是尝试更新,让updateAllWidgetsWithData自己检查
|
|
|
this.updateAllWidgetsWithData(data);
|
|
|
});
|
|
|
-
|
|
|
- // 验证监听器是否成功注册
|
|
|
- const listenerCount = avSessionListener.getListenerCount();
|
|
|
- hilog.info(0x0000, TAG, `Heanup EntryFormAbility [Process:${this.processStartTime}] listener registered successfully, total listeners: ${listenerCount}`);
|
|
|
-
|
|
|
- // 启动健康检查定时器
|
|
|
- this.startHealthCheck();
|
|
|
-
|
|
|
- hilog.info(0x0000, TAG, `Heanup EntryFormAbility [Process:${this.processStartTime}] global state listener setup successfully`);
|
|
|
} catch (error) {
|
|
|
- hilog.error(0x0000, TAG, `Heanup EntryFormAbility [Process:${this.processStartTime}] failed to setup global listener: ${error}`);
|
|
|
+ hilog.error(0x0000, TAG,
|
|
|
+ `Heanup EntryFormAbility [Process:${this.processStartTime}] failed to setup global listener: ${error}`);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 启动健康检查,定期检测监听器是否还在工作
|
|
|
- */
|
|
|
- private startHealthCheck(): void {
|
|
|
- setInterval(() => {
|
|
|
- const now = Date.now();
|
|
|
- const timeSinceLastUpdate = now - this.lastHealthCheck;
|
|
|
-
|
|
|
- // 如果超过30秒没有收到任何状态更新,可能监听器失效了
|
|
|
- if (timeSinceLastUpdate > 30000) {
|
|
|
- hilog.warn(0x0000, TAG, `Heanup EntryFormAbility [Process:${this.processStartTime}] health check failed: ${timeSinceLastUpdate}ms since last update`);
|
|
|
-
|
|
|
- // 尝试强制重连和重新请求当前状态
|
|
|
- this.playerControlService.forceReconnect().then(() => {
|
|
|
- return this.playerControlService.getCurrentPlayState();
|
|
|
- }).then((currentState) => {
|
|
|
- hilog.info(0x0000, TAG, `Heanup EntryFormAbility [Process:${this.processStartTime}] health check recovery: got current state`);
|
|
|
- this.updateAllWidgetsWithData(currentState);
|
|
|
- }).catch(() => {
|
|
|
- hilog.error(0x0000, TAG, `Heanup EntryFormAbility [Process:${this.processStartTime}] health check recovery failed:`);
|
|
|
- });
|
|
|
- } else {
|
|
|
- hilog.info(0x0000, TAG, `Heanup EntryFormAbility [Process:${this.processStartTime}] health check OK: ${timeSinceLastUpdate}ms since last update`);
|
|
|
- }
|
|
|
- }, 15000); // 每15秒检查一次
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 使用指定数据更新所有卡片
|
|
|
*/
|
|
|
private updateAllWidgetsWithData(data: WidgetData): void {
|
|
|
- hilog.info(0x0000, TAG, `Heanup EntryFormAbility updateAllWidgetsWithData called with isPlaying=${data.playState.isPlaying}, title=${data.currentSong.title}`);
|
|
|
-
|
|
|
// 防抖机制:避免短时间内重复更新
|
|
|
const now = Date.now();
|
|
|
if (now - this.lastUpdateTime < this.updateDebounceDelay) {
|
|
|
- hilog.info(0x0000, TAG, `Heanup EntryFormAbility update debounced, skipping (${now - this.lastUpdateTime}ms since last update)`);
|
|
|
return;
|
|
|
}
|
|
|
this.lastUpdateTime = now;
|
|
|
|
|
|
const activeWidgets = this.globalWidgetManager.getActiveWidgets();
|
|
|
- hilog.info(0x0000, TAG, `Heanup EntryFormAbility active widgets count: ${activeWidgets.size}`);
|
|
|
|
|
|
- // 打印所有活跃的widget ID
|
|
|
- if (activeWidgets.size > 0) {
|
|
|
- activeWidgets.forEach((size: WidgetSize, formId: string) => {
|
|
|
- hilog.info(0x0000, TAG, `Heanup EntryFormAbility found active widget: ${formId}, size: ${size}`);
|
|
|
- });
|
|
|
- }
|
|
|
|
|
|
if (activeWidgets.size === 0) {
|
|
|
hilog.warn(0x0000, TAG, 'Heanup EntryFormAbility no widgets to update in this process, skipping');
|
|
|
@@ -196,11 +317,10 @@ implements SizeChangeListener {
|
|
|
}
|
|
|
|
|
|
activeWidgets.forEach((size: WidgetSize, formId: string) => {
|
|
|
- hilog.info(0x0000, TAG, `Heanup EntryFormAbility updating widget: ${formId}`);
|
|
|
this.updateSingleWidget(formId, size, data);
|
|
|
});
|
|
|
|
|
|
- hilog.info(0x0000, TAG, `Heanup EntryFormAbility batch update completed for ${activeWidgets.size} widgets`);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -233,7 +353,6 @@ implements SizeChangeListener {
|
|
|
formImages: formattedData.formImages
|
|
|
};
|
|
|
|
|
|
- hilog.info(0x0000, TAG, `Heanup widget ${formId} calling formProvider.updateForm with isPlaying=${adaptedData.isPlaying}, hasNext=${adaptedData.hasNext}, hasPrevious=${adaptedData.hasPrevious}, coverImage=${adaptedData.coverImage || 'empty'}`);
|
|
|
|
|
|
// 使用统一的图片处理方法
|
|
|
this.updateWidgetWithImage(formId, adaptedData, retryCount);
|
|
|
@@ -255,7 +374,7 @@ implements SizeChangeListener {
|
|
|
private updateWidgetDirectly(formId: string, adaptedData: ExtendedWidgetData, retryCount: number = 0): void {
|
|
|
const formData = formBindingData.createFormBindingData(adaptedData);
|
|
|
formProvider.updateForm(formId, formData).then(() => {
|
|
|
- hilog.info(0x0000, TAG, `Heanup widget ${formId} updated successfully: isPlaying=${adaptedData.isPlaying}, title=${adaptedData.songTitle}, hasNext=${adaptedData.hasNext}, hasPrevious=${adaptedData.hasPrevious}`);
|
|
|
+
|
|
|
}).catch(() => {
|
|
|
hilog.error(0x0000, TAG, `Heanup widget ${formId} update failed, retry count: ${retryCount}`);
|
|
|
|
|
|
@@ -271,7 +390,8 @@ implements SizeChangeListener {
|
|
|
/**
|
|
|
* 统一处理图片更新
|
|
|
*/
|
|
|
- private async updateWidgetWithImage(formId: string, adaptedData: ExtendedWidgetData, retryCount: number = 0): Promise<void> {
|
|
|
+ private async updateWidgetWithImage(formId: string, adaptedData: ExtendedWidgetData,
|
|
|
+ retryCount: number = 0): Promise<void> {
|
|
|
try {
|
|
|
if (!adaptedData.coverImage || adaptedData.coverImage.trim() === '') {
|
|
|
// 没有封面图片,直接更新
|
|
|
@@ -279,7 +399,6 @@ implements SizeChangeListener {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- hilog.info(0x0000, TAG, `Heanup widget ${formId} processing image: ${adaptedData.coverImage}`);
|
|
|
|
|
|
if (this.isNetworkUrl(adaptedData.coverImage)) {
|
|
|
// 处理网络图片
|
|
|
@@ -289,7 +408,7 @@ implements SizeChangeListener {
|
|
|
await this.updateWidgetWithLocalImage(formId, adaptedData, retryCount);
|
|
|
} else {
|
|
|
// 其他情况,可能是相对路径或其他格式,直接使用
|
|
|
- hilog.info(0x0000, TAG, `Heanup widget ${formId} using image path as-is: ${adaptedData.coverImage}`);
|
|
|
+
|
|
|
this.updateWidgetDirectly(formId, adaptedData, retryCount);
|
|
|
}
|
|
|
} catch (error) {
|
|
|
@@ -303,16 +422,17 @@ implements SizeChangeListener {
|
|
|
/**
|
|
|
* 处理本地文件URI图片
|
|
|
*/
|
|
|
- private async updateWidgetWithLocalImage(formId: string, adaptedData: ExtendedWidgetData, retryCount: number = 0): Promise<void> {
|
|
|
+ private async updateWidgetWithLocalImage(formId: string, adaptedData: ExtendedWidgetData,
|
|
|
+ retryCount: number = 0): Promise<void> {
|
|
|
try {
|
|
|
const localFileUri: string = adaptedData.coverImage;
|
|
|
- hilog.info(0x0000, TAG, `Heanup widget ${formId} processing local image: ${localFileUri}`);
|
|
|
+
|
|
|
|
|
|
// 先用无图片的数据快速更新一次,确保界面响应性
|
|
|
- const dataWithoutImage: ExtendedWidgetData = copyWidgetData(adaptedData, {
|
|
|
+ const dataWithoutImage: ExtendedWidgetData = copyWidgetData(adaptedData, {
|
|
|
coverImage: '',
|
|
|
imgName: '',
|
|
|
- formImages: undefined
|
|
|
+ formImages: undefined
|
|
|
});
|
|
|
this.updateWidgetDirectly(formId, dataWithoutImage, 0);
|
|
|
|
|
|
@@ -328,15 +448,15 @@ implements SizeChangeListener {
|
|
|
|
|
|
// 按照官方文档要求,imgName 必须与 formImages 中的 key 相同
|
|
|
const dataWithImage: ExtendedWidgetData = copyWidgetData(adaptedData, {
|
|
|
- coverImage: '', // 清空原路径
|
|
|
- imgName: fileName, // 设置图片名称用于 memory:// 协议
|
|
|
+ coverImage: '', // 清空原路径
|
|
|
+ imgName: fileName, // 设置图片名称用于 memory:// 协议
|
|
|
formImages: imageMap // 必填字段,不可缺省
|
|
|
});
|
|
|
|
|
|
const formDataWithImage = formBindingData.createFormBindingData(dataWithImage);
|
|
|
await formProvider.updateForm(formId, formDataWithImage);
|
|
|
|
|
|
- hilog.info(0x0000, TAG, `Heanup widget ${formId} updated with local image: ${fileName}, fd: ${fileDescriptor}`);
|
|
|
+
|
|
|
} catch (fdError) {
|
|
|
hilog.error(0x0000, TAG, `Heanup widget ${formId} failed to get file descriptor: ${fdError}`);
|
|
|
// 文件描述符获取失败,使用默认图片
|
|
|
@@ -351,10 +471,10 @@ implements SizeChangeListener {
|
|
|
hilog.error(0x0000, TAG, `Heanup widget ${formId} local image update error: ${error}`);
|
|
|
|
|
|
// 失败后回退到无图片模式
|
|
|
- const dataWithoutImage: ExtendedWidgetData = copyWidgetData(adaptedData, {
|
|
|
+ const dataWithoutImage: ExtendedWidgetData = copyWidgetData(adaptedData, {
|
|
|
coverImage: '',
|
|
|
imgName: '',
|
|
|
- formImages: undefined
|
|
|
+ formImages: undefined
|
|
|
});
|
|
|
this.updateWidgetDirectly(formId, dataWithoutImage, retryCount);
|
|
|
}
|
|
|
@@ -363,10 +483,11 @@ implements SizeChangeListener {
|
|
|
/**
|
|
|
* 使用网络图片更新卡片
|
|
|
*/
|
|
|
- private async updateWidgetWithNetworkImage(formId: string, adaptedData: ExtendedWidgetData, retryCount: number = 0): Promise<void> {
|
|
|
+ private async updateWidgetWithNetworkImage(formId: string, adaptedData: ExtendedWidgetData,
|
|
|
+ retryCount: number = 0): Promise<void> {
|
|
|
try {
|
|
|
const imageUrl: string = adaptedData.coverImage;
|
|
|
- hilog.info(0x0000, TAG, `Heanup widget ${formId} downloading network image: ${imageUrl}`);
|
|
|
+
|
|
|
|
|
|
// 先用无图片的数据快速更新一次
|
|
|
const dataWithoutImage: ExtendedWidgetData = copyWidgetData(adaptedData, { coverImage: '' });
|
|
|
@@ -381,15 +502,15 @@ implements SizeChangeListener {
|
|
|
imageMap[fileName] = await this.getImageFileDescriptor(fileName);
|
|
|
|
|
|
const dataWithImage: ExtendedWidgetData = copyWidgetData(adaptedData, {
|
|
|
- coverImage: '', // 清空URL
|
|
|
- imgName: fileName, // 设置图片名称用于memory://协议
|
|
|
+ coverImage: '', // 清空URL
|
|
|
+ imgName: fileName, // 设置图片名称用于memory://协议
|
|
|
formImages: imageMap
|
|
|
});
|
|
|
|
|
|
const formDataWithImage = formBindingData.createFormBindingData(dataWithImage);
|
|
|
await formProvider.updateForm(formId, formDataWithImage);
|
|
|
|
|
|
- hilog.info(0x0000, TAG, `Heanup widget ${formId} updated with network image: ${fileName}`);
|
|
|
+
|
|
|
} else {
|
|
|
hilog.warn(0x0000, TAG, `Heanup widget ${formId} failed to download image, using default`);
|
|
|
// 图片下载失败,使用默认图片
|
|
|
@@ -423,13 +544,13 @@ implements SizeChangeListener {
|
|
|
*/
|
|
|
private async processLocalImageFile(fileUri: string): Promise<string | null> {
|
|
|
try {
|
|
|
- hilog.info(0x0000, TAG, `Processing local image file: ${fileUri}`);
|
|
|
+
|
|
|
|
|
|
// 检查缓存
|
|
|
if (this.imageCache.has(fileUri)) {
|
|
|
const fileName = this.imageCache.get(fileUri)!;
|
|
|
- hilog.info(0x0000, TAG, `Using cached local image: ${fileName} for ${fileUri}`);
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
// 验证缓存文件是否仍然存在 - 使用 FormExtensionAbility 的 tempDir
|
|
|
const formTempDir = this.context.getApplicationContext().tempDir;
|
|
|
const tempFilePath = `${formTempDir}/${fileName}`;
|
|
|
@@ -444,7 +565,7 @@ implements SizeChangeListener {
|
|
|
|
|
|
// 检查是否正在处理
|
|
|
if (this.downloadingImages.has(fileUri)) {
|
|
|
- hilog.info(0x0000, TAG, `Local image already processing, waiting: ${fileUri}`);
|
|
|
+
|
|
|
const existingPromise = this.downloadingImages.get(fileUri);
|
|
|
if (existingPromise) {
|
|
|
return await existingPromise;
|
|
|
@@ -462,7 +583,7 @@ implements SizeChangeListener {
|
|
|
|
|
|
if (fileName) {
|
|
|
this.imageCache.set(fileUri, fileName);
|
|
|
- hilog.info(0x0000, TAG, `Local image processed successfully: ${fileName}`);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
return fileName;
|
|
|
@@ -478,11 +599,11 @@ implements SizeChangeListener {
|
|
|
*/
|
|
|
private async performLocalImageCopy(fileUri: string): Promise<string | null> {
|
|
|
try {
|
|
|
- hilog.info(0x0000, TAG, `Copying local image file: ${fileUri}`);
|
|
|
+
|
|
|
|
|
|
// 转换 file:// URI 为实际文件路径
|
|
|
const realPath = fileUri.replace('file://', '');
|
|
|
-
|
|
|
+
|
|
|
// 检查源文件是否存在
|
|
|
if (!fileIo.accessSync(realPath)) {
|
|
|
hilog.error(0x0000, TAG, `Source image file does not exist: ${realPath}`);
|
|
|
@@ -492,17 +613,16 @@ implements SizeChangeListener {
|
|
|
// 生成目标文件名(包含时间戳和随机数,确保每次都不同)
|
|
|
const fileExtension = this.getFileExtension(realPath) || 'jpg';
|
|
|
const fileName = `widget_local_${Date.now()}_${Math.random().toString(36).substr(2, 9)}.${fileExtension}`;
|
|
|
-
|
|
|
+
|
|
|
// 使用 FormExtensionAbility 的 tempDir(官方文档要求)
|
|
|
const formTempDir = this.context.getApplicationContext().tempDir;
|
|
|
const tempFilePath = `${formTempDir}/${fileName}`;
|
|
|
|
|
|
- hilog.info(0x0000, TAG, `Using FormExtensionAbility tempDir: ${formTempDir}`);
|
|
|
|
|
|
// 复制文件到临时目录
|
|
|
fileIo.copyFileSync(realPath, tempFilePath);
|
|
|
|
|
|
- hilog.info(0x0000, TAG, `Local image copied successfully: ${realPath} -> ${tempFilePath}`);
|
|
|
+
|
|
|
return fileName;
|
|
|
|
|
|
} catch (error) {
|
|
|
@@ -530,13 +650,13 @@ implements SizeChangeListener {
|
|
|
// 检查缓存
|
|
|
if (this.imageCache.has(imageUrl)) {
|
|
|
const fileName = this.imageCache.get(imageUrl)!;
|
|
|
- hilog.info(0x0000, TAG, `Using cached image: ${fileName} for ${imageUrl}`);
|
|
|
+
|
|
|
return fileName;
|
|
|
}
|
|
|
|
|
|
// 检查是否正在下载
|
|
|
if (this.downloadingImages.has(imageUrl)) {
|
|
|
- hilog.info(0x0000, TAG, `Image already downloading, waiting: ${imageUrl}`);
|
|
|
+
|
|
|
const existingPromise = this.downloadingImages.get(imageUrl);
|
|
|
if (existingPromise) {
|
|
|
return await existingPromise;
|
|
|
@@ -583,19 +703,18 @@ implements SizeChangeListener {
|
|
|
if (response.responseCode === http.ResponseCode.OK && response.result) {
|
|
|
// 生成文件名(确保每次都不同,符合官方文档要求)
|
|
|
const fileName = `widget_cover_${Date.now()}_${Math.random().toString(36).substr(2, 9)}.jpg`;
|
|
|
-
|
|
|
+
|
|
|
// 使用 FormExtensionAbility 的 tempDir(官方文档要求)
|
|
|
const formTempDir = this.context.getApplicationContext().tempDir;
|
|
|
const filePath = `${formTempDir}/${fileName}`;
|
|
|
|
|
|
- hilog.info(0x0000, TAG, `Using FormExtensionAbility tempDir for download: ${formTempDir}`);
|
|
|
|
|
|
// 保存文件
|
|
|
const file = fileIo.openSync(filePath, fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE);
|
|
|
await fileIo.write(file.fd, response.result as ArrayBuffer);
|
|
|
fileIo.closeSync(file);
|
|
|
-
|
|
|
- hilog.info(0x0000, TAG, `Network image downloaded successfully: ${fileName}`);
|
|
|
+
|
|
|
+
|
|
|
httpRequest.destroy();
|
|
|
return fileName;
|
|
|
} else {
|
|
|
@@ -617,13 +736,13 @@ implements SizeChangeListener {
|
|
|
// 使用 FormExtensionAbility 的 tempDir(官方文档要求)
|
|
|
const formTempDir = this.context.getApplicationContext().tempDir;
|
|
|
const filePath = `${formTempDir}/${fileName}`;
|
|
|
-
|
|
|
- hilog.info(0x0000, TAG, `Opening file for descriptor: ${filePath}`);
|
|
|
+
|
|
|
+
|
|
|
const file = fileIo.openSync(filePath, fileIo.OpenMode.READ_ONLY);
|
|
|
-
|
|
|
+
|
|
|
// 注意:文件描述符会被系统自动管理,不需要手动关闭
|
|
|
// 系统会在卡片更新完成后自动关闭文件描述符
|
|
|
- hilog.info(0x0000, TAG, `Got file descriptor for ${fileName}: ${file.fd}`);
|
|
|
+
|
|
|
return file.fd;
|
|
|
} catch (error) {
|
|
|
hilog.error(0x0000, TAG, `Failed to get file descriptor for ${fileName}: ${error}`);
|
|
|
@@ -631,86 +750,6 @@ implements SizeChangeListener {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 卡片创建时调用
|
|
|
- */
|
|
|
- onAddForm(want: Want): formBindingData.FormBindingData {
|
|
|
- hilog.info(0x0000, TAG, 'Heanup EntryFormAbility onAddForm called');
|
|
|
-
|
|
|
- // 检查参数有效性
|
|
|
- if (!want || !want.parameters) {
|
|
|
- hilog.error(0x0000, TAG, 'FormAbility onAddForm want or want.parameters is undefined');
|
|
|
- return formBindingData.createFormBindingData('');
|
|
|
- }
|
|
|
-
|
|
|
- // 初始化服务
|
|
|
- try {
|
|
|
- hilog.info(0x0000, TAG, 'Heanup EntryFormAbility initializing services...');
|
|
|
- this.initializeServices();
|
|
|
- hilog.info(0x0000, TAG, 'Heanup EntryFormAbility services initialized successfully');
|
|
|
- } catch (error) {
|
|
|
- hilog.error(0x0000, TAG, `Heanup EntryFormAbility failed to initialize services: ${error}`);
|
|
|
- }
|
|
|
-
|
|
|
- const formId = want.parameters?.['ohos.extra.param.key.form_identity'] as string;
|
|
|
- const formName = want.parameters?.['ohos.extra.param.key.form_name'] as string;
|
|
|
- const formDimension = want.parameters?.['ohos.extra.param.key.form_dimension'] as string;
|
|
|
- const tempFlag = want.parameters?.['ohos.extra.param.key.form_temporary'] as boolean;
|
|
|
-
|
|
|
- hilog.info(0x0000, TAG, `Form added: ${formId}, name: ${formName}, dimension: ${formDimension}, temp: ${tempFlag}`);
|
|
|
-
|
|
|
- // 持久化保存 Form ID(异步执行,不阻塞返回)
|
|
|
- this.saveFormIdToPersistence(formId).then(() => {
|
|
|
- hilog.info(0x0000, TAG, `💾 Form ID persistence completed for: ${formId}`);
|
|
|
- })
|
|
|
-
|
|
|
- // 检测卡片尺寸并注册到全局管理器
|
|
|
- const widgetSize = this.sizeAdapter.detectSizeFromWant(want);
|
|
|
- try {
|
|
|
- this.globalWidgetManager.registerWidget(formId, widgetSize);
|
|
|
- hilog.info(0x0000, TAG, `Widget registered successfully: ${formId}, size: ${widgetSize}`);
|
|
|
- } catch (error) {
|
|
|
- hilog.error(0x0000, TAG, `Failed to register widget: ${error}`);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- hilog.info(0x0000, TAG, `Detected widget size: ${widgetSize} for form: ${formId}`);
|
|
|
-
|
|
|
- // 注册各种监听器
|
|
|
- this.sizeAdapter.registerSizeChangeListener(formId, this);
|
|
|
-
|
|
|
- // 初始化卡片数据
|
|
|
- this.initializeWidget(formId, widgetSize);
|
|
|
-
|
|
|
- // 验证监听器设置状态
|
|
|
- setTimeout(() => {
|
|
|
- const avSessionListener = AvSessionWidgetListener.getInstance();
|
|
|
- const listenerCount = avSessionListener.getListenerCount();
|
|
|
- hilog.info(0x0000, TAG, `📊 Form process listener status check: ${listenerCount} listeners registered in AvSessionWidgetListener`);
|
|
|
-
|
|
|
- if (listenerCount === 0) {
|
|
|
- hilog.warn(0x0000, TAG, `⚠️ No listeners found! Form process may not receive data updates!`);
|
|
|
- } else {
|
|
|
- hilog.info(0x0000, TAG, `✅ Form process has ${listenerCount} listeners, should receive data updates`);
|
|
|
- }
|
|
|
- }, 2000);
|
|
|
-
|
|
|
- // 获取当前播放状态而不是初始数据
|
|
|
- this.playerControlService.getCurrentPlayState().then((currentState: WidgetData) => {
|
|
|
- const adaptedData = this.layoutManager.adaptDataForSize(currentState, widgetSize);
|
|
|
- const formData = formBindingData.createFormBindingData(adaptedData);
|
|
|
- // 立即更新卡片以显示当前状态
|
|
|
- formProvider.updateForm(formId, formData);
|
|
|
- hilog.info(0x0000, TAG, `Widget ${formId} initialized with current state`);
|
|
|
- });
|
|
|
-
|
|
|
- // 返回初始数据作为临时显示
|
|
|
- const initialData = this.widgetDataManager?.getInitialWidgetData() || this.getDefaultWidgetData();
|
|
|
- const adaptedData = this.layoutManager.adaptDataForSize(initialData, widgetSize);
|
|
|
-
|
|
|
- return formBindingData.createFormBindingData(adaptedData);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 获取默认卡片数据
|
|
|
*/
|
|
|
@@ -751,135 +790,12 @@ implements SizeChangeListener {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 卡片更新时调用
|
|
|
- */
|
|
|
- onUpdateForm(formId: string): void {
|
|
|
- hilog.info(0x0000, TAG, `Heanup EntryFormAbility onUpdateForm called: ${formId}`);
|
|
|
-
|
|
|
- // 确保服务已初始化
|
|
|
- if (!this.globalListenerSetup) {
|
|
|
- hilog.info(0x0000, TAG, 'Heanup EntryFormAbility services not initialized, initializing now...');
|
|
|
- this.initializeServices();
|
|
|
- }
|
|
|
-
|
|
|
- // 确保widget已注册到GlobalWidgetManager
|
|
|
- if (!this.globalWidgetManager.hasWidget(formId)) {
|
|
|
- hilog.info(0x0000, TAG, `Heanup EntryFormAbility widget ${formId} not registered in onUpdateForm, registering as MEDIUM size`);
|
|
|
- this.globalWidgetManager.registerWidget(formId, 'medium' as WidgetSize);
|
|
|
- }
|
|
|
-
|
|
|
- // 只更新指定的卡片,避免重复更新
|
|
|
- this.updateWidgetData(formId);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 卡片删除时调用
|
|
|
- */
|
|
|
- onRemoveForm(formId: string): void {
|
|
|
- hilog.info(0x0000, TAG, `onRemoveForm called: ${formId}`);
|
|
|
-
|
|
|
- // 从持久化存储中移除 Form ID(异步执行)
|
|
|
- this.removeFormIdFromPersistence(formId).then(() => {
|
|
|
- hilog.info(0x0000, TAG, `🗑️ Form ID removal completed for: ${formId}`);
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
- // 注销各种监听器
|
|
|
- this.sizeAdapter.unregisterSizeChangeListener(formId);
|
|
|
-
|
|
|
- // 从全局管理器中注销卡片
|
|
|
- this.globalWidgetManager.unregisterWidget(formId);
|
|
|
-
|
|
|
- // 清理卡片相关数据和配置
|
|
|
- this.widgetDataManager?.removeWidgetData(formId);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 卡片可见性变化时调用
|
|
|
- */
|
|
|
- onVisibilityChange(newStatus: Record<string, number>): void {
|
|
|
- hilog.info(0x0000, TAG, 'onVisibilityChange called');
|
|
|
-
|
|
|
- const formIds = Object.keys(newStatus);
|
|
|
- for (let i = 0; i < formIds.length; i++) {
|
|
|
- const formId = formIds[i];
|
|
|
- const isVisible = newStatus[formId] === 1;
|
|
|
- hilog.info(0x0000, TAG, `Form ${formId} visibility: ${isVisible}`);
|
|
|
-
|
|
|
- if (isVisible) {
|
|
|
- // 卡片变为可见时,更新数据
|
|
|
- this.updateWidgetData(formId);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 处理卡片事件(用户交互)
|
|
|
- * 注意:由于改用call方式,此方法不再被调用,保留用于兼容性
|
|
|
- */
|
|
|
- onFormEvent(formId: string, message: string): void {
|
|
|
- hilog.info(0x0000, TAG, `onFormEvent called but ignored (using call method): ${formId}`);
|
|
|
- // 由于改用call方式,此方法不再处理事件
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 卡片配置更新时调用
|
|
|
- */
|
|
|
- onConfigurationUpdate(newConfig: Object): void {
|
|
|
- hilog.info(0x0000, TAG, 'onConfigurationUpdate called');
|
|
|
-
|
|
|
- // 更新所有卡片以适应新配置
|
|
|
- this.widgetDataManager?.updateAllWidgets();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 实现SizeChangeListener接口
|
|
|
- * 处理卡片尺寸变化事件
|
|
|
- */
|
|
|
- onSizeChanged(formId: string, oldSize: WidgetSize, newSize: WidgetSize): void {
|
|
|
- hilog.info(0x0000, TAG, `Size changed for form ${formId}: ${oldSize} -> ${newSize}`);
|
|
|
-
|
|
|
- // 更新全局管理器中的尺寸记录
|
|
|
- this.globalWidgetManager.updateWidgetSize(formId, newSize);
|
|
|
-
|
|
|
- // 立即更新卡片数据以适应新尺寸
|
|
|
- this.updateWidgetData(formId);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 处理卡片尺寸变化(系统调用)
|
|
|
- * @param newStatus 新的尺寸状态
|
|
|
- */
|
|
|
- onAcquireFormState(want: Want): number {
|
|
|
- hilog.info(0x0000, TAG, 'onAcquireFormState called');
|
|
|
-
|
|
|
- const formId = want.parameters?.['ohos.extra.param.key.form_identity'] as string;
|
|
|
-
|
|
|
- if (formId) {
|
|
|
- // 检测新的尺寸
|
|
|
- const newSize = this.sizeAdapter.detectSizeFromWant(want);
|
|
|
- const oldSize = this.globalWidgetManager.getWidgetSize(formId);
|
|
|
-
|
|
|
- if (oldSize && this.sizeAdapter.validateSizeChange(oldSize, newSize)) {
|
|
|
- // 处理尺寸变化
|
|
|
- this.handleFormSizeChange(formId, oldSize, newSize);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 返回卡片状态 - 使用数字常量代替枚举
|
|
|
- return 1; // READY状态
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 初始化卡片
|
|
|
*/
|
|
|
private async initializeWidget(formId: string, widgetSize: WidgetSize): Promise<void> {
|
|
|
try {
|
|
|
- hilog.info(0x0000, TAG, `Heanup widget initializing: ${formId} with size: ${widgetSize}`);
|
|
|
+
|
|
|
|
|
|
// 获取当前播放状态
|
|
|
const currentState = await this.playerControlService.getCurrentPlayState();
|
|
|
@@ -892,7 +808,7 @@ implements SizeChangeListener {
|
|
|
// 立即更新一次卡片数据
|
|
|
await this.updateWidgetData(formId);
|
|
|
|
|
|
- hilog.info(0x0000, TAG, `Heanup widget ${formId} initialized successfully with size: ${widgetSize}`);
|
|
|
+
|
|
|
} catch (error) {
|
|
|
hilog.error(0x0000, TAG, `Failed to initialize widget ${formId}: ${error}`);
|
|
|
}
|
|
|
@@ -913,20 +829,19 @@ implements SizeChangeListener {
|
|
|
const formData = formBindingData.createFormBindingData(adaptedData);
|
|
|
await formProvider.updateForm(formId, formData);
|
|
|
|
|
|
- hilog.info(0x0000, TAG, `Heanup widget ${formId} updated successfully with size: ${currentSize}, isPlaying=${adaptedData.isPlaying}`);
|
|
|
+
|
|
|
} catch (error) {
|
|
|
hilog.error(0x0000, TAG, `Failed to update widget ${formId}: ${error}`);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 处理表单尺寸变化
|
|
|
*/
|
|
|
private async handleFormSizeChange(formId: string, oldSize: WidgetSize, newSize: WidgetSize): Promise<void> {
|
|
|
try {
|
|
|
- hilog.info(0x0000, TAG, `Handling form size change: ${formId} from ${oldSize} to ${newSize}`);
|
|
|
+
|
|
|
|
|
|
// 获取当前播放状态
|
|
|
const currentState = await this.playerControlService.getCurrentPlayState();
|
|
|
@@ -937,25 +852,23 @@ implements SizeChangeListener {
|
|
|
// 更新卡片数据
|
|
|
await this.widgetDataManager?.updateWidget(formId, adaptedData);
|
|
|
|
|
|
- hilog.info(0x0000, TAG, `Form size change handled successfully for: ${formId}`);
|
|
|
+
|
|
|
} catch (error) {
|
|
|
hilog.error(0x0000, TAG, `Failed to handle form size change: ${error}`);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 保存 Form ID 到持久化存储
|
|
|
*/
|
|
|
private async saveFormIdToPersistence(formId: string): Promise<void> {
|
|
|
try {
|
|
|
- hilog.info(0x0000, TAG, `💾 Saving Form ID to persistence: ${formId}`);
|
|
|
+
|
|
|
const preferencesUtil = PreferencesUtil.getInstance();
|
|
|
const prefs = await preferencesUtil.getPreferences(this.context);
|
|
|
await preferencesUtil.addFormId(prefs, formId);
|
|
|
- hilog.info(0x0000, TAG, `✅ Form ID saved successfully: ${formId}`);
|
|
|
+
|
|
|
} catch (error) {
|
|
|
hilog.error(0x0000, TAG, `❌ Failed to save Form ID: ${error}`);
|
|
|
}
|
|
|
@@ -966,11 +879,11 @@ implements SizeChangeListener {
|
|
|
*/
|
|
|
private async removeFormIdFromPersistence(formId: string): Promise<void> {
|
|
|
try {
|
|
|
- hilog.info(0x0000, TAG, `🗑️ Removing Form ID from persistence: ${formId}`);
|
|
|
+
|
|
|
const preferencesUtil = PreferencesUtil.getInstance();
|
|
|
const prefs = await preferencesUtil.getPreferences(this.context);
|
|
|
await preferencesUtil.removeFormId(prefs, formId);
|
|
|
- hilog.info(0x0000, TAG, `✅ Form ID removed successfully: ${formId}`);
|
|
|
+
|
|
|
} catch (error) {
|
|
|
hilog.error(0x0000, TAG, `❌ Failed to remove Form ID: ${error}`);
|
|
|
}
|