From e1e0662e68775da05a0aeb48d1b31958487329cf Mon Sep 17 00:00:00 2001
From: rex <1491721419@qq.com>
Date: Fri, 5 Sep 2025 20:25:20 +0800
Subject: [PATCH 1/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0Copyright&=E8=A7=A3?=
=?UTF-8?q?=E5=86=B3=E4=BB=A3=E7=A0=81=E8=AD=A6=E5=91=8A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
AppFreeze/build-profile.json5 | 2 +-
.../main/ets/entryability/EntryAbility.ets | 14 +++++
.../entrybackupability/EntryBackupAbility.ets | 14 +++++
.../main/ets/entryability/EntryAbility.ets | 14 +++++
.../entrybackupability/EntryBackupAbility.ets | 14 +++++
.../entry/src/main/ets/pages/Index.ets | 14 +++++
.../entry/src/main/ets/segment/A.ets | 14 +++++
.../entry/src/main/ets/segment/segment.ets | 14 +++++
.../entry/src/main/ets/segment/segment2.ets | 14 +++++
.../entry/src/main/ets/segment/segment3.ets | 14 +++++
.../entry/src/main/ets/segment/segment4.ets | 14 +++++
.../entry/src/main/ets/segment/segment5.ets | 14 +++++
.../entry/src/main/ets/segment/segment6.ets | 14 +++++
ArkUI/Proper_Use_Layout/README.md | 2 +-
.../main/ets/entryability/EntryAbility.ets | 2 +-
.../src/main/ets/view/InTabComponent.ets | 6 +-
.../src/main/ets/view/SwitchTabComponent.ets | 5 +-
.../main/ets/entryability/EntryAbility.ets | 14 +++++
.../entrybackupability/EntryBackupAbility.ets | 14 +++++
CppCrash/entry/src/main/ets/pages/Index.ets | 14 +++++
.../entry/src/main/ets/pages/PageOne.ets | 1 -
.../entry/src/main/ets/pages/PageThree.ets | 1 -
.../entry/src/main/ets/pages/PageTwo.ets | 1 -
.../entry/src/main/ets/view/TestCode.ets | 14 +++++
MemoryDetection/README.md | 56 +++++++++----------
.../main/ets/entryability/EntryAbility.ets | 14 +++++
.../entrybackupability/EntryBackupAbility.ets | 14 +++++
NonSameLayerRendering/README.md | 4 --
.../main/ets/entryability/EntryAbility.ets | 14 +++++
.../entrybackupability/EntryBackupAbility.ets | 14 +++++
.../main/ets/entryability/EntryAbility.ets | 14 +++++
.../entrybackupability/EntryBackupAbility.ets | 14 +++++
.../pages/ApplicationAssetProtectionAfter.ets | 1 -
.../entry/src/main/module.json5 | 10 ++++
.../entry/src/main/ets/pages/EdgeBlur.ets | 2 +-
.../src/main/ets/pages/LoopScrolling.ets | 2 +-
.../src/main/ets/pages/PullUpLoading.ets | 4 +-
37 files changed, 357 insertions(+), 50 deletions(-)
diff --git a/AppFreeze/build-profile.json5 b/AppFreeze/build-profile.json5
index cb0e86db..9e87e7e6 100644
--- a/AppFreeze/build-profile.json5
+++ b/AppFreeze/build-profile.json5
@@ -6,7 +6,7 @@
"name": "default",
"signingConfig": "default",
"targetSdkVersion": "5.0.5(17)",
- "compatibleSdkVersion": "5.0.0(17)",
+ "compatibleSdkVersion": "5.0.5(17)",
"runtimeOS": "HarmonyOS",
"buildOption": {
"strictMode": {
diff --git a/AppFreeze/entry/src/main/ets/entryability/EntryAbility.ets b/AppFreeze/entry/src/main/ets/entryability/EntryAbility.ets
index 508880af..843c7f0c 100644
--- a/AppFreeze/entry/src/main/ets/entryability/EntryAbility.ets
+++ b/AppFreeze/entry/src/main/ets/entryability/EntryAbility.ets
@@ -1,3 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { window } from '@kit.ArkUI';
diff --git a/AppFreeze/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/AppFreeze/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
index 8e4de992..4ce6449f 100644
--- a/AppFreeze/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
+++ b/AppFreeze/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -1,3 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
import { hilog } from '@kit.PerformanceAnalysisKit';
import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
diff --git a/ArkTS_high_performance_segment/entry/src/main/ets/entryability/EntryAbility.ets b/ArkTS_high_performance_segment/entry/src/main/ets/entryability/EntryAbility.ets
index 508880af..843c7f0c 100644
--- a/ArkTS_high_performance_segment/entry/src/main/ets/entryability/EntryAbility.ets
+++ b/ArkTS_high_performance_segment/entry/src/main/ets/entryability/EntryAbility.ets
@@ -1,3 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { window } from '@kit.ArkUI';
diff --git a/ArkTS_high_performance_segment/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ArkTS_high_performance_segment/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
index 78678995..bbc0b862 100644
--- a/ArkTS_high_performance_segment/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
+++ b/ArkTS_high_performance_segment/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -1,3 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
import { hilog } from '@kit.PerformanceAnalysisKit';
import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
diff --git a/ArkTS_high_performance_segment/entry/src/main/ets/pages/Index.ets b/ArkTS_high_performance_segment/entry/src/main/ets/pages/Index.ets
index 8e2d24ad..64ca9978 100644
--- a/ArkTS_high_performance_segment/entry/src/main/ets/pages/Index.ets
+++ b/ArkTS_high_performance_segment/entry/src/main/ets/pages/Index.ets
@@ -1,3 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
@Entry
@Component
struct Index {
diff --git a/ArkTS_high_performance_segment/entry/src/main/ets/segment/A.ets b/ArkTS_high_performance_segment/entry/src/main/ets/segment/A.ets
index e1f6c343..87301080 100644
--- a/ArkTS_high_performance_segment/entry/src/main/ets/segment/A.ets
+++ b/ArkTS_high_performance_segment/entry/src/main/ets/segment/A.ets
@@ -1,3 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
@Component
export struct A {
build() {
diff --git a/ArkTS_high_performance_segment/entry/src/main/ets/segment/segment.ets b/ArkTS_high_performance_segment/entry/src/main/ets/segment/segment.ets
index 1f745f66..5fda0050 100644
--- a/ArkTS_high_performance_segment/entry/src/main/ets/segment/segment.ets
+++ b/ArkTS_high_performance_segment/entry/src/main/ets/segment/segment.ets
@@ -1,3 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
// [Start Counter_example1]
// The variable does not change in the subsequent process. It is recommended to declare it as a constant
let PRICE = 10000;
diff --git a/ArkTS_high_performance_segment/entry/src/main/ets/segment/segment2.ets b/ArkTS_high_performance_segment/entry/src/main/ets/segment/segment2.ets
index cd096f2d..474b1aa1 100644
--- a/ArkTS_high_performance_segment/entry/src/main/ets/segment/segment2.ets
+++ b/ArkTS_high_performance_segment/entry/src/main/ets/segment/segment2.ets
@@ -1,3 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
// [Start Case4]
// app.ets
import { getObject, TestA } from './segment';
diff --git a/ArkTS_high_performance_segment/entry/src/main/ets/segment/segment3.ets b/ArkTS_high_performance_segment/entry/src/main/ets/segment/segment3.ets
index f5d371a8..02c43687 100644
--- a/ArkTS_high_performance_segment/entry/src/main/ets/segment/segment3.ets
+++ b/ArkTS_high_performance_segment/entry/src/main/ets/segment/segment3.ets
@@ -1,3 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
// [Start Case8]
import HashMap from '@ohos.util.HashMap';
diff --git a/ArkTS_high_performance_segment/entry/src/main/ets/segment/segment4.ets b/ArkTS_high_performance_segment/entry/src/main/ets/segment/segment4.ets
index f9dc5032..1c4b952c 100644
--- a/ArkTS_high_performance_segment/entry/src/main/ets/segment/segment4.ets
+++ b/ArkTS_high_performance_segment/entry/src/main/ets/segment/segment4.ets
@@ -1,3 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
// [Start Case10]
// A is any ets file that can be imported
import { A } from "./A"
diff --git a/ArkTS_high_performance_segment/entry/src/main/ets/segment/segment5.ets b/ArkTS_high_performance_segment/entry/src/main/ets/segment/segment5.ets
index 30828c87..1d373672 100644
--- a/ArkTS_high_performance_segment/entry/src/main/ets/segment/segment5.ets
+++ b/ArkTS_high_performance_segment/entry/src/main/ets/segment/segment5.ets
@@ -1,3 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
// [Start Case11]
import lazy { A } from "./A"
diff --git a/ArkTS_high_performance_segment/entry/src/main/ets/segment/segment6.ets b/ArkTS_high_performance_segment/entry/src/main/ets/segment/segment6.ets
index a04b9687..a5415675 100644
--- a/ArkTS_high_performance_segment/entry/src/main/ets/segment/segment6.ets
+++ b/ArkTS_high_performance_segment/entry/src/main/ets/segment/segment6.ets
@@ -1,3 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
// Attention: This is the counterexample file
// [Start export_multi_levels]
diff --git a/ArkUI/Proper_Use_Layout/README.md b/ArkUI/Proper_Use_Layout/README.md
index 375ce803..f9a43a70 100644
--- a/ArkUI/Proper_Use_Layout/README.md
+++ b/ArkUI/Proper_Use_Layout/README.md
@@ -4,7 +4,7 @@
## 预览效果
-
+
## 工程目录
```
diff --git a/ArkUI/Proper_Use_Layout/entry/src/main/ets/entryability/EntryAbility.ets b/ArkUI/Proper_Use_Layout/entry/src/main/ets/entryability/EntryAbility.ets
index 664be58f..9f670d7c 100644
--- a/ArkUI/Proper_Use_Layout/entry/src/main/ets/entryability/EntryAbility.ets
+++ b/ArkUI/Proper_Use_Layout/entry/src/main/ets/entryability/EntryAbility.ets
@@ -20,7 +20,7 @@ import { window } from '@kit.ArkUI';
const DOMAIN = 0x0000;
export default class EntryAbility extends UIAbility {
- onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ onCreate(_want: Want, _launchParam: AbilityConstant.LaunchParam): void {
this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate');
}
diff --git a/ArkUI/PureTabsExt/entry/src/main/ets/view/InTabComponent.ets b/ArkUI/PureTabsExt/entry/src/main/ets/view/InTabComponent.ets
index 95476169..32104c57 100644
--- a/ArkUI/PureTabsExt/entry/src/main/ets/view/InTabComponent.ets
+++ b/ArkUI/PureTabsExt/entry/src/main/ets/view/InTabComponent.ets
@@ -55,7 +55,7 @@ export default struct InTabComponent {
systemLanguage = newConfig.language;
}
},
- onMemoryLevel: (level: AbilityConstant.MemoryLevel): void => {
+ onMemoryLevel: (_level: AbilityConstant.MemoryLevel): void => {
// do nothing
}
});
@@ -113,10 +113,10 @@ export default struct InTabComponent {
Tabs({controller: this.subController}){
// [StartExclude tabs_fading_edge]
// [StartExclude tabs_bar_translate]
- ForEach(this.tabItems, (item: string, index: number) => {
+ ForEach(this.tabItems, (item: string, _index: number) => {
TabContent(){
List({ space: 10 }) {
- ForEach(this.contents, (item: number, index: number) => {
+ ForEach(this.contents, (_item: number, _index: number) => {
this.contentBuilder()
})
}
diff --git a/ArkUI/PureTabsExt/entry/src/main/ets/view/SwitchTabComponent.ets b/ArkUI/PureTabsExt/entry/src/main/ets/view/SwitchTabComponent.ets
index 03adf3c6..c107dfe5 100644
--- a/ArkUI/PureTabsExt/entry/src/main/ets/view/SwitchTabComponent.ets
+++ b/ArkUI/PureTabsExt/entry/src/main/ets/view/SwitchTabComponent.ets
@@ -13,7 +13,6 @@
* limitations under the License.
*/
import { AbilityConstant, Configuration } from "@kit.AbilityKit";
-import { Constants } from "../common/constant/Constants";
// [Start custom_switch_tab]
@Component
@@ -49,7 +48,7 @@ export default struct SwitchTabComponent {
systemLanguage = newConfig.language;
}
},
- onMemoryLevel: (level: AbilityConstant.MemoryLevel): void => {
+ onMemoryLevel: (_level: AbilityConstant.MemoryLevel): void => {
// do nothing
}
});
@@ -94,7 +93,7 @@ export default struct SwitchTabComponent {
index: $$this.currentIndex // use $$ for two-way data binding
}) {
// [StartExclude custom_switch_tab]
- ForEach(this.tabItems, (item: string, index: number) => {
+ ForEach(this.tabItems, (item: string, _index: number) => {
TabContent() {
Column() {
Text(`${item}`)
diff --git a/CppCrash/entry/src/main/ets/entryability/EntryAbility.ets b/CppCrash/entry/src/main/ets/entryability/EntryAbility.ets
index 508880af..843c7f0c 100644
--- a/CppCrash/entry/src/main/ets/entryability/EntryAbility.ets
+++ b/CppCrash/entry/src/main/ets/entryability/EntryAbility.ets
@@ -1,3 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { window } from '@kit.ArkUI';
diff --git a/CppCrash/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/CppCrash/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
index 8e4de992..4ce6449f 100644
--- a/CppCrash/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
+++ b/CppCrash/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -1,3 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
import { hilog } from '@kit.PerformanceAnalysisKit';
import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
diff --git a/CppCrash/entry/src/main/ets/pages/Index.ets b/CppCrash/entry/src/main/ets/pages/Index.ets
index 8e2d24ad..64ca9978 100644
--- a/CppCrash/entry/src/main/ets/pages/Index.ets
+++ b/CppCrash/entry/src/main/ets/pages/Index.ets
@@ -1,3 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
@Entry
@Component
struct Index {
diff --git a/DealStrideSolution/entry/src/main/ets/pages/PageOne.ets b/DealStrideSolution/entry/src/main/ets/pages/PageOne.ets
index a2145ff3..33487bfd 100644
--- a/DealStrideSolution/entry/src/main/ets/pages/PageOne.ets
+++ b/DealStrideSolution/entry/src/main/ets/pages/PageOne.ets
@@ -16,7 +16,6 @@
import { image } from '@kit.ImageKit';
import CameraService from '../utils/CameraServiceOne';
import { CommonConstants } from '../common/CommonConstants';
-import { promptAction } from '@kit.ArkUI';
@Builder
export function PageOneBuilder() {
diff --git a/DealStrideSolution/entry/src/main/ets/pages/PageThree.ets b/DealStrideSolution/entry/src/main/ets/pages/PageThree.ets
index 361dfdfb..93e095a5 100644
--- a/DealStrideSolution/entry/src/main/ets/pages/PageThree.ets
+++ b/DealStrideSolution/entry/src/main/ets/pages/PageThree.ets
@@ -16,7 +16,6 @@
import { image } from '@kit.ImageKit';
import CameraService from '../utils/CameraServiceThree';
import { CommonConstants } from '../common/CommonConstants';
-import { promptAction } from '@kit.ArkUI';
@Builder
export function PageThreeBuilder() {
diff --git a/DealStrideSolution/entry/src/main/ets/pages/PageTwo.ets b/DealStrideSolution/entry/src/main/ets/pages/PageTwo.ets
index 93c0fad3..1ec6c5be 100644
--- a/DealStrideSolution/entry/src/main/ets/pages/PageTwo.ets
+++ b/DealStrideSolution/entry/src/main/ets/pages/PageTwo.ets
@@ -16,7 +16,6 @@
import { image } from '@kit.ImageKit';
import CameraService from '../utils/CameraServiceTwo';
import { CommonConstants } from '../common/CommonConstants';
-import { promptAction } from '@kit.ArkUI';
@Builder
export function PageTwoBuilder() {
diff --git a/FramedRendering/entry/src/main/ets/view/TestCode.ets b/FramedRendering/entry/src/main/ets/view/TestCode.ets
index 5b4e2bf9..206421b0 100644
--- a/FramedRendering/entry/src/main/ets/view/TestCode.ets
+++ b/FramedRendering/entry/src/main/ets/view/TestCode.ets
@@ -1,3 +1,17 @@
+/*
+* Copyright (c) 2024 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
import { ProductDetailModel } from "../model/BasicDataSource";
import { ProductDetailSource } from "../model/ProductDetailSource";
diff --git a/MemoryDetection/README.md b/MemoryDetection/README.md
index 827f428a..5ce35372 100644
--- a/MemoryDetection/README.md
+++ b/MemoryDetection/README.md
@@ -11,32 +11,30 @@
### 工程目录
```
-.
-└── entry
- └── src
- ├── main
- ├── cpp
- │ ├── CMakeLists.txt
- │ ├── address_problems.cpp C++ 样例代码
- │ ├── address_sanitizer_case1.cpp C++ 样例代码
- │ ├── address_sanitizer_case2.cpp C++ 样例代码
- │ ├── address_sanitizer_case3.cpp C++ 样例代码
- │ ├── address_sanitizer_case4.cpp C++ 样例代码
- │ ├── napi_init.cpp C++ 样例代码
- │ ├── resource_leak.cpp C++ 样例代码
- │ ├── task_demo1.cpp C++ 样例代码
- │ └── task_demo2.cpp C++ 样例代码
- └── ets
- └── pages
- ├── FdLeakDetection.ets ArkTS样例代码
- ├── GwpAsan.cpp C++ 样例代码
- ├── Index.ets ArkTS样例代码
- ├── MemoryLeakDetection.ets ArkTS样例代码
- ├── SetAsan.cpp C++ 样例代码
- ├── address_overflow_case.cpp C++ 样例代码
- ├── addressproblems.cpp C++ 样例代码
- ├── resource_leak_case.ets C++ 样例代码
- └── setHwAsan.cpp C++ 样例代码
+├──entry/src
+│ └──main
+│ │ ├──cpp
+│ │ ├──CMakeLists.txt
+│ │ ├──address_problems.cpp // C++ 样例代码
+│ │ ├──address_sanitizer_case1.cpp // C++ 样例代码
+│ │ ├──address_sanitizer_case2.cpp // C++ 样例代码
+│ │ ├──address_sanitizer_case3.cpp // C++ 样例代码
+│ │ ├──address_sanitizer_case4.cpp // C++ 样例代码
+│ │ ├──napi_init.cpp // C++ 样例代码
+│ │ ├──resource_leak.cpp // C++ 样例代码
+│ │ ├──task_demo1.cpp // C++ 样例代码
+│ │ ├──task_demo2.cpp // C++ 样例代码
+│ │ └──ets
+│ └──pages
+│ ├──FdLeakDetection.ets // ArkTS样例代码
+│ ├──GwpAsan.cpp // C++ 样例代码
+│ ├──Index.ets // ArkTS样例代码
+│ ├──MemoryLeakDetection.ets // ArkTS样例代码
+│ ├──SetAsan.cpp // C++ 样例代码
+│ ├──address_overflow_case.cpp // C++ 样例代码
+│ ├──addressproblems.cpp // C++ 样例代码
+│ ├── resource_leak_case.ets // C++ 样例代码
+│ └── setHwAsan.cpp // C++ 样例代码
```
### 具体实现
@@ -55,8 +53,8 @@
1. 本示例仅支持标准系统上运行,支持设备:华为手机、华为PC/2in1设备、华为平板。
-2. HarmonyOS系统:HarmonyOS NEXT 5.1.1 Release及以上。
+2. HarmonyOS系统:HarmonyOS NEXT 5.0.5 Release及以上。
-3. DevEco Studio版本:DevEco Studio NEXT 5.1.1 Release及以上。
+3. DevEco Studio版本:DevEco Studio NEXT 5.0.5 Release及以上。
-4. HarmonyOS SDK版本:HarmonyOS NEXT 5.1.1 Release SDK及以上。
\ No newline at end of file
+4. HarmonyOS SDK版本:HarmonyOS NEXT 5.0.5 Release SDK及以上。
\ No newline at end of file
diff --git a/MemoryDetection/entry/src/main/ets/entryability/EntryAbility.ets b/MemoryDetection/entry/src/main/ets/entryability/EntryAbility.ets
index 1098e966..5839b852 100644
--- a/MemoryDetection/entry/src/main/ets/entryability/EntryAbility.ets
+++ b/MemoryDetection/entry/src/main/ets/entryability/EntryAbility.ets
@@ -1,3 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { window } from '@kit.ArkUI';
diff --git a/MemoryDetection/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/MemoryDetection/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
index 8e4de992..4ce6449f 100644
--- a/MemoryDetection/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
+++ b/MemoryDetection/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -1,3 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
import { hilog } from '@kit.PerformanceAnalysisKit';
import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
diff --git a/NonSameLayerRendering/README.md b/NonSameLayerRendering/README.md
index d66c1b0c..f738be94 100644
--- a/NonSameLayerRendering/README.md
+++ b/NonSameLayerRendering/README.md
@@ -6,10 +6,6 @@
本工程配套官网[同层渲染原生组件](https://developer.huawei.com/consumer/cn/doc/best-practices/bpta-render-web-using-same-layer-render),
文章介绍如何在Web组件上使用原生组件同层渲染。
-### 预览效果
-
-
-
### 使用说明
1. 打开应用,抓取Trace图分析。
diff --git a/PerformanceAnalysis/ArkTSMemAnalysis/entry/src/main/ets/entryability/EntryAbility.ets b/PerformanceAnalysis/ArkTSMemAnalysis/entry/src/main/ets/entryability/EntryAbility.ets
index 508880af..843c7f0c 100644
--- a/PerformanceAnalysis/ArkTSMemAnalysis/entry/src/main/ets/entryability/EntryAbility.ets
+++ b/PerformanceAnalysis/ArkTSMemAnalysis/entry/src/main/ets/entryability/EntryAbility.ets
@@ -1,3 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { window } from '@kit.ArkUI';
diff --git a/PerformanceAnalysis/ArkTSMemAnalysis/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/PerformanceAnalysis/ArkTSMemAnalysis/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
index 8e4de992..4ce6449f 100644
--- a/PerformanceAnalysis/ArkTSMemAnalysis/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
+++ b/PerformanceAnalysis/ArkTSMemAnalysis/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -1,3 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
import { hilog } from '@kit.PerformanceAnalysisKit';
import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
diff --git a/PerformanceAnalysis/CrossThreadSerializationDelay/entry/src/main/ets/entryability/EntryAbility.ets b/PerformanceAnalysis/CrossThreadSerializationDelay/entry/src/main/ets/entryability/EntryAbility.ets
index 508880af..2dae1b50 100644
--- a/PerformanceAnalysis/CrossThreadSerializationDelay/entry/src/main/ets/entryability/EntryAbility.ets
+++ b/PerformanceAnalysis/CrossThreadSerializationDelay/entry/src/main/ets/entryability/EntryAbility.ets
@@ -1,3 +1,17 @@
+/*
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { window } from '@kit.ArkUI';
diff --git a/PerformanceAnalysis/CrossThreadSerializationDelay/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/PerformanceAnalysis/CrossThreadSerializationDelay/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
index 8e4de992..9926cd4d 100644
--- a/PerformanceAnalysis/CrossThreadSerializationDelay/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
+++ b/PerformanceAnalysis/CrossThreadSerializationDelay/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -1,3 +1,17 @@
+/*
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
import { hilog } from '@kit.PerformanceAnalysisKit';
import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
diff --git a/Privacy/privacy/src/main/ets/pages/ApplicationAssetProtectionAfter.ets b/Privacy/privacy/src/main/ets/pages/ApplicationAssetProtectionAfter.ets
index ce56ce0e..f050279c 100644
--- a/Privacy/privacy/src/main/ets/pages/ApplicationAssetProtectionAfter.ets
+++ b/Privacy/privacy/src/main/ets/pages/ApplicationAssetProtectionAfter.ets
@@ -29,5 +29,4 @@ function getAgeInfo() {
}
}
-console['log']('' + getAgeInfo());
// [End application_asset_protection_after]
\ No newline at end of file
diff --git a/SegmentedPhotograph/entry/src/main/module.json5 b/SegmentedPhotograph/entry/src/main/module.json5
index 8fdc7bed..526d8067 100644
--- a/SegmentedPhotograph/entry/src/main/module.json5
+++ b/SegmentedPhotograph/entry/src/main/module.json5
@@ -42,6 +42,16 @@
],
"when": "always"
}
+ },
+ {
+ "name": "ohos.permission.READ_IMAGEVIDEO",
+ "reason": "$string:reason",
+ "usedScene": {
+ "abilities": [
+ "EntryAbility"
+ ],
+ "when": "always"
+ }
}
]
}
diff --git a/SimpleChatList/entry/src/main/ets/pages/EdgeBlur.ets b/SimpleChatList/entry/src/main/ets/pages/EdgeBlur.ets
index 8eef2133..6949f780 100644
--- a/SimpleChatList/entry/src/main/ets/pages/EdgeBlur.ets
+++ b/SimpleChatList/entry/src/main/ets/pages/EdgeBlur.ets
@@ -52,7 +52,7 @@ struct EdgeBlur {
.listDirection(Axis.Vertical)
.scrollBar(BarState.Off)
// [Start DisableScrolling]
- .onScrollFrameBegin((offset: number, state: ScrollState) => {
+ .onScrollFrameBegin((_offset: number, _state: ScrollState) => {
return { offsetRemain: 0 } // If the return value is set to 0, it means that there will be no scrolling.
})
// [End DisableScrolling]
diff --git a/SimpleChatList/entry/src/main/ets/pages/LoopScrolling.ets b/SimpleChatList/entry/src/main/ets/pages/LoopScrolling.ets
index b356a46e..49982ca9 100644
--- a/SimpleChatList/entry/src/main/ets/pages/LoopScrolling.ets
+++ b/SimpleChatList/entry/src/main/ets/pages/LoopScrolling.ets
@@ -138,7 +138,7 @@ struct LoopScrolling {
.scrollSnapAlign(ScrollSnapAlign.START)
.friction(2)
// [Start LoopScrolling]
- .onScrollFrameBegin((offset: number, state: ScrollState) => {
+ .onScrollFrameBegin((offset: number, _state: ScrollState) => {
let currentOffset = this.scroller.currentOffset().xOffset;
let newOffset = currentOffset + offset;
let totalWeight = 220 * 10; // The total width of LIST.
diff --git a/SimpleChatList/entry/src/main/ets/pages/PullUpLoading.ets b/SimpleChatList/entry/src/main/ets/pages/PullUpLoading.ets
index 84b3f16d..6e70731c 100644
--- a/SimpleChatList/entry/src/main/ets/pages/PullUpLoading.ets
+++ b/SimpleChatList/entry/src/main/ets/pages/PullUpLoading.ets
@@ -64,7 +64,7 @@ struct PullUpLoading {
.height(64)
}
.width('90%')
- .onScrollIndex((start: number, end: number) => {
+ .onScrollIndex((_start: number, end: number) => {
if (end > this.arr.length) {
setTimeout(() => {
for (let i = 0; i < 5; i++) {
@@ -74,7 +74,7 @@ struct PullUpLoading {
}
})
// [End PullUpLoading]
- .onAreaChange((oldValue: Area, newValue: Area) => {
+ .onAreaChange((_oldValue: Area, newValue: Area) => {
this.refreshOffset = newValue.position.y as number;
})
.scrollBar(BarState.Off)
--
Gitee
From 7fa9762946a9e2a2caf8428d74b778bb11832033 Mon Sep 17 00:00:00 2001
From: rex <1491721419@qq.com>
Date: Fri, 12 Sep 2025 20:21:23 +0800
Subject: [PATCH 2/4] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=BB=A3=E7=A0=81?=
=?UTF-8?q?=E6=9C=AA=E6=8D=95=E8=8E=B7=E8=AD=A6=E5=91=8A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../main/ets/entryability/EntryAbility.ets | 8 +-
HDRVivid/AVCodecVideo/README.md | 6 +-
.../main/ets/entryability/EntryAbility.ets | 23 +-
.../entry/src/main/ets/pages/Index.ets | 158 ++++---
.../entry/src/main/ets/pages/Recorder.ets | 384 +++++++++++-------
.../main/ets/entryability/EntryAbility.ets | 8 +-
HpDemo/entry/src/main/ets/pages/Index.ets | 28 +-
.../main/ets/entryability/EntryAbility.ets | 27 +-
.../InsightIntentExecutorImpl.ets | 7 +-
.../entry/src/main/ets/pages/MainPage.ets | 10 +-
.../ets/utils/audioplayer/BackgroundUtil.ets | 28 +-
.../ets/utils/audioplayer/MediaService.ets | 79 ++--
.../main/ets/utils/audioplayer/MediaTools.ets | 11 +-
13 files changed, 507 insertions(+), 270 deletions(-)
diff --git a/FileUploadAndDownloadSlow/entry/src/main/ets/entryability/EntryAbility.ets b/FileUploadAndDownloadSlow/entry/src/main/ets/entryability/EntryAbility.ets
index 508880af..59f6b0bb 100644
--- a/FileUploadAndDownloadSlow/entry/src/main/ets/entryability/EntryAbility.ets
+++ b/FileUploadAndDownloadSlow/entry/src/main/ets/entryability/EntryAbility.ets
@@ -1,12 +1,18 @@
import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { window } from '@kit.ArkUI';
+import { BusinessError } from '@kit.BasicServicesKit';
const DOMAIN = 0x0000;
export default class EntryAbility extends UIAbility {
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
- this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
+ try {
+ this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
+ } catch (err) {
+ let error = err as BusinessError;
+ hilog.error(DOMAIN, 'testTag', `Failed to set colorMode. code=${error.code}, message=${error.message}`);
+ }
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate');
}
diff --git a/HDRVivid/AVCodecVideo/README.md b/HDRVivid/AVCodecVideo/README.md
index 6085a6d1..9ae5cbce 100644
--- a/HDRVivid/AVCodecVideo/README.md
+++ b/HDRVivid/AVCodecVideo/README.md
@@ -157,8 +157,8 @@
* 本示例仅支持标准系统上运行,支持设备:华为手机。
-* HarmonyOS系统:HarmonyOS 5.0.5 Release及以上。
+* HarmonyOS系统:HarmonyOS 5.1.0 Release及以上。
-* DevEco Studio版本:DevEco Studio 5.0.5 Release及以上。
+* DevEco Studio版本:DevEco Studio 5.1.0 Release及以上。
-* HarmonyOS SDK版本:HarmonyOS 5.0.5 Release SDK及以上。
\ No newline at end of file
+* HarmonyOS SDK版本:HarmonyOS 5.1.0 Release SDK及以上。
\ No newline at end of file
diff --git a/HDRVivid/AVCodecVideo/entry/src/main/ets/entryability/EntryAbility.ets b/HDRVivid/AVCodecVideo/entry/src/main/ets/entryability/EntryAbility.ets
index b8d65e75..760d140b 100644
--- a/HDRVivid/AVCodecVideo/entry/src/main/ets/entryability/EntryAbility.ets
+++ b/HDRVivid/AVCodecVideo/entry/src/main/ets/entryability/EntryAbility.ets
@@ -43,15 +43,30 @@ export default class EntryAbility extends UIAbility {
} catch (err) {
Logger.error('Entry', 'requestPre() data: ' + JSON.stringify(err));
}
-
- windowStage.getMainWindowSync().setWindowKeepScreenOn(true);
+ try {
+ windowStage.getMainWindowSync().setWindowKeepScreenOn(true)
+ .then(() => {
+ hilog.info(0x000, 'testTag', 'setWindowKeepScreenOn success');
+ })
+ .catch((error: BusinessError) => {
+ hilog.error(0x000, 'testTag', `setWindowKeepScreenOn failed. code ${error.code}, message ${error.message}`);
+ })
+ } catch (error) {
+ let err = error as BusinessError;
+ hilog.error(0x000, 'testTag', `getMainWindowSync failed. code=${err.code}, message=${err.message}`);
+ }
windowStage.loadContent('pages/Index', (err) => {
if (err.code) {
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
- let uiContext: UIContext | undefined = windowStage.getMainWindowSync().getUIContext();
- AppStorage.setOrCreate('uiContext', uiContext);
+ try {
+ let uiContext: UIContext | undefined = windowStage.getMainWindowSync().getUIContext();
+ AppStorage.setOrCreate('uiContext', uiContext);
+ } catch (error) {
+ let err = error as BusinessError;
+ hilog.error(0x000, 'testTag', `getMainWindowSync failed. code=${err.code}, message=${err.message}`);
+ }
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
});
}
diff --git a/HDRVivid/AVCodecVideo/entry/src/main/ets/pages/Index.ets b/HDRVivid/AVCodecVideo/entry/src/main/ets/pages/Index.ets
index 51d22500..cf75f11f 100644
--- a/HDRVivid/AVCodecVideo/entry/src/main/ets/pages/Index.ets
+++ b/HDRVivid/AVCodecVideo/entry/src/main/ets/pages/Index.ets
@@ -24,6 +24,7 @@ import DateTimeUtil from '../common/utils/DateTimeUtils';
import { CommonConstants as Const } from '../common/CommonConstants';
import { CameraDataModel } from '../model/CameraDateModel';
import { videoProfileCheck } from '../common/utils/CameraCheck';
+import { BusinessError } from '@kit.BasicServicesKit';
const TAG: string = Const.INDEX_TAG;
const DATETIME: DateTimeUtil = new DateTimeUtil();
@@ -35,8 +36,18 @@ struct Player {
@State isShow: boolean = false;
private cameraData: CameraDataModel = new CameraDataModel();
private selectFilePath: string | null = null;
- private display = display.getDefaultDisplaySync();
- private heightPx = (this.display.width * Const.DEFAULT_HEIGHT / Const.DEFAULT_WIDTH) + Const.PX;
+ private display: display.Display | null = null;
+ private heightPx = '';
+
+ aboutToAppear() {
+ try {
+ this.display = display.getDefaultDisplaySync();
+ this.heightPx = (this.display.width * Const.DEFAULT_HEIGHT / Const.DEFAULT_WIDTH) + Const.PX;
+ } catch (error) {
+ let err = error as BusinessError;
+ Logger.error(`getDefaultDisplaySync failed. code=${err.code}, message=${err.message}`);
+ }
+ }
selectFile() {
let photoPicker = new photoAccessHelper.PhotoViewPicker();
@@ -51,50 +62,73 @@ struct Player {
message: $r('app.string.alert'),
duration: Const.DURATION,
bottom: Const.BOTTOM
- });
+ })
+ .catch((err: BusinessError) => {
+ Logger.error(`promptAction openToast failed. code=${err.code}, message=${err.message}`);
+ })
} else {
this.play();
Logger.info(TAG, 'documentViewPicker.select to file succeed and URI is:' + this.selectFilePath);
}
- });
+ })
+ .catch((err: BusinessError) => {
+ Logger.error(`photoPicker select failed. code=${err.code}, message=${err.message}`);
+ })
}
play() {
- let inputFile = fileIo.openSync(this.selectFilePath, fileIo.OpenMode.READ_ONLY);
- if (!inputFile) {
- Logger.error(TAG, 'player inputFile is null');
- }
- let inputFileState = fileIo.statSync(inputFile.fd);
- if (inputFileState.size <= 0) {
- Logger.error(TAG, 'player inputFile size is 0');
+ try {
+ let inputFile = fileIo.openSync(this.selectFilePath, fileIo.OpenMode.READ_ONLY);
+ if (!inputFile) {
+ Logger.error(TAG, 'player inputFile is null');
+ }
+ let inputFileState = fileIo.statSync(inputFile.fd);
+ if (inputFileState.size <= 0) {
+ Logger.error(TAG, 'player inputFile size is 0');
+ }
+ this.buttonEnabled = false;
+ player.playNative(inputFile.fd, Const.DEFAULT_VALUE, inputFileState.size, () => {
+ Logger.info(TAG, 'player JSCallback');
+ this.buttonEnabled = true;
+ fileIo.close(inputFile)
+ .catch((err: BusinessError) => {
+ Logger.error(`fileIo close failed. code=${err.code}, message=${err.message}`);
+ })
+ })
+ } catch (err) {
+ let error = err as BusinessError;
+ Logger.error(`fileIo failed. code=${error.code}, message=${error.message}`);
}
- this.buttonEnabled = false;
- player.playNative(inputFile.fd, Const.DEFAULT_VALUE, inputFileState.size, () => {
- Logger.info(TAG, 'player JSCallback');
- this.buttonEnabled = true;
- fileIo.close(inputFile);
- })
}
async checkIsProfileSupport(): Promise {
let context = this.getUIContext()?.getHostContext();
- let cameraManager: camera.CameraManager = camera.getCameraManager(context);
- if (!cameraManager) {
- Logger.error(TAG, 'camera.getCameraManager error!');
- }
+ let cameraManager: camera.CameraManager;
+ try {
+ cameraManager = camera.getCameraManager(context)
+ if (!cameraManager) {
+ Logger.error(TAG, 'camera.getCameraManager error!');
+ }
- let videoProfile: undefined | camera.VideoProfile = videoProfileCheck(cameraManager, this.cameraData);
- if (!videoProfile) {
- Logger.error(TAG, 'videoProfile is not found');
- promptAction.openToast({
- message: $r('app.string.alert_setting'),
- duration: Const.DURATION,
- bottom: Const.BOTTOM,
- backgroundColor: Color.White,
- backgroundBlurStyle: BlurStyle.NONE
- })
- this.cameraData = new CameraDataModel();
- return;
+ let videoProfile: undefined | camera.VideoProfile = videoProfileCheck(cameraManager, this.cameraData);
+ if (!videoProfile) {
+ Logger.error(TAG, 'videoProfile is not found');
+ promptAction.openToast({
+ message: $r('app.string.alert_setting'),
+ duration: Const.DURATION,
+ bottom: Const.BOTTOM,
+ backgroundColor: Color.White,
+ backgroundBlurStyle: BlurStyle.NONE
+ })
+ .catch((err: BusinessError) => {
+ Logger.error(`promptAction openToast failed. code=${err.code}, message=${err.message}`);
+ })
+ this.cameraData = new CameraDataModel();
+ return;
+ }
+ } catch (err) {
+ let error = err as BusinessError;
+ Logger.error(`getCameraManager failed. code=${error.code}, message=${error.message}`);
}
}
@@ -197,27 +231,39 @@ struct Player {
.onClick(async () => {
let context = this.getUIContext()?.getHostContext();
let helper = photoAccessHelper.getPhotoAccessHelper(context);
- let uri = await helper.createAsset(photoAccessHelper.PhotoType.VIDEO, 'mp4', {
- title: `AVCodecVideo_${DATETIME.getDate()}_${DATETIME.getTime()}`
- });
- let file = await fileIo.open(uri, fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE);
- this.cameraData.outputfd = file.fd;
- if (this.cameraData.outputfd !== null) {
- recorder.initNative(this.cameraData.outputfd, this.cameraData.videoCodecMime, this.cameraData.cameraWidth,
- this.cameraData.cameraHeight, this.cameraData.frameRate, this.cameraData.isHDRVivid,
- this.cameraData.bitRate).then((data) => {
- if (data.surfaceId !== null) {
- this.cameraData.surfaceId = data.surfaceId;
- let uiContext = this.getUIContext();
- let router = uiContext.getRouter();
- router.pushUrl({
- url: 'pages/Recorder',
- params: this.cameraData
- });
- }
- })
- } else {
- Logger.error(TAG, 'get outputfd failed!');
+ try {
+ let uri = await helper.createAsset(photoAccessHelper.PhotoType.VIDEO, 'mp4', {
+ title: `AVCodecVideo_${DATETIME.getDate()}_${DATETIME.getTime()}`
+ });
+ let file = await fileIo.open(uri, fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE);
+ this.cameraData.outputfd = file.fd;
+ if (this.cameraData.outputfd !== null) {
+ recorder.initNative(this.cameraData.outputfd, this.cameraData.videoCodecMime,
+ this.cameraData.cameraWidth,
+ this.cameraData.cameraHeight, this.cameraData.frameRate, this.cameraData.isHDRVivid,
+ this.cameraData.bitRate).then((data) => {
+ if (data.surfaceId !== null) {
+ this.cameraData.surfaceId = data.surfaceId;
+ let uiContext = this.getUIContext();
+ let router = uiContext.getRouter();
+ router.pushUrl({
+ url: 'pages/Recorder',
+ params: this.cameraData
+ })
+ .then(() => {
+ Logger.info(`router pushUrl success`);
+ })
+ .catch((error: BusinessError) => {
+ Logger.error(`router pushUrl failed. code=${error.code}, message=${error.message}`);
+ })
+ }
+ })
+ } else {
+ Logger.error(TAG, 'get outputfd failed!');
+ }
+ } catch (err) {
+ let error = err as BusinessError;
+ Logger.error(`fileIo open failed. code=${error.code}, message=${error.message}`);
}
})
.width('48%')
@@ -230,7 +276,7 @@ struct Player {
.height('52vp')
}
.justifyContent(FlexAlign.End)
- .padding({left: '16vp', right: '16vp'})
+ .padding({ left: '16vp', right: '16vp' })
.width('100%')
.height('100%')
}
@@ -301,7 +347,7 @@ struct Player {
'bottom': { 'anchor': '__container__', 'align': VerticalAlign.Bottom },
'left': { 'anchor': '__container__', 'align': HorizontalAlign.Start }
})
- .padding({left: '16vp', right: '16vp', bottom:'16vp'})
+ .padding({ left: '16vp', right: '16vp', bottom: '16vp' })
.width($r('app.string.full_width'))
.height($r('app.float.index_column_height'))
.justifyContent(FlexAlign.End)
diff --git a/HDRVivid/AVCodecVideo/entry/src/main/ets/pages/Recorder.ets b/HDRVivid/AVCodecVideo/entry/src/main/ets/pages/Recorder.ets
index 7aabb90c..362b906b 100644
--- a/HDRVivid/AVCodecVideo/entry/src/main/ets/pages/Recorder.ets
+++ b/HDRVivid/AVCodecVideo/entry/src/main/ets/pages/Recorder.ets
@@ -47,18 +47,53 @@ async function releaseCamera(): Promise {
});
}
// Stop the Session.
- videoSession.stop();
+ videoSession.stop()
+ .then(() => {
+ Logger.info(TAG, `videoSession stop success`);
+ })
+ .catch((error: BusinessError) => {
+ Logger.error(TAG, `videoSession stop. code=${error.code}, message=${error.message}`);
+ })
// Close file fd.
- fileIo.close(params.outputfd);
+ fileIo.close(params.outputfd)
+ .then(() => {
+ Logger.info(TAG, `fileIo close success`);
+ })
+ .catch((error: BusinessError) => {
+ Logger.error(TAG, `fileIo close. code=${error.code}, message=${error.message}`);
+ })
// Close camera input stream.
- cameraInput.close();
+ cameraInput.close()
+ .then(() => {
+ Logger.info(TAG, `cameraInput close success`);
+ })
+ .catch((error: BusinessError) => {
+ Logger.error(TAG, `cameraInput close. code=${error.code}, message=${error.message}`);
+ })
// Release preview output stream.
- XComponentPreviewOutput.release();
+ XComponentPreviewOutput.release()
+ .then(() => {
+ Logger.info(TAG, `XComponentPreviewOutput release success`);
+ })
+ .catch((error: BusinessError) => {
+ Logger.error(TAG, `XComponentPreviewOutput release. code=${error.code}, message=${error.message}`);
+ })
// Release the video output stream.
- encoderVideoOutput.release();
- Logger.info(TAG, 'encoderVideoOutput release');
+ encoderVideoOutput.release()
+ .then(() => {
+ Logger.info(TAG, 'encoderVideoOutput release success');
+ })
+ .catch((error: BusinessError) => {
+ Logger.error(TAG, `encoderVideoOutput release. code=${error.code}, message=${error.message}`);
+ })
// Release session.
- videoSession.release();
+ videoSession.release()
+ .then(() => {
+ Logger.info(TAG, 'videoSession release');
+ })
+ .catch((error: BusinessError) => {
+ Logger.error(TAG, `videoSession release. code=${error.code}, message=${error.message}`);
+ })
}
// [Start set_video_color]
@@ -79,11 +114,16 @@ function setVideoStabilizationMode(session: camera.VideoSession): boolean {
// Check whether video anti-shake is supported
let isSupported: boolean = isVideoStabilizationModeSupported(session, mode);
if (isSupported) {
- console.info(`setVideoStabilizationMode: ${mode}`);
- // Setting video anti-shake
- session.setVideoStabilizationMode(mode);
- let activeVideoStabilizationMode = session.getActiveVideoStabilizationMode();
- console.info(`activeVideoStabilizationMode: ${activeVideoStabilizationMode}`);
+ Logger.info(TAG, `setVideoStabilizationMode: ${mode}`);
+ try {
+ // Setting video anti-shake
+ session.setVideoStabilizationMode(mode);
+ let activeVideoStabilizationMode = session.getActiveVideoStabilizationMode();
+ Logger.info(TAG, `activeVideoStabilizationMode: ${activeVideoStabilizationMode}`);
+ } catch (err) {
+ let error = err as BusinessError;
+ Logger.error(`fileIo open failed. code=${error.code}, message=${error.message}`);
+ }
} else {
console.info(`videoStabilizationMode: ${mode} is not support`);
}
@@ -103,18 +143,25 @@ function getSupportedColorSpaces(session: camera.VideoSession): Array = getSupportedColorSpaces(session);
let isSupportedColorSpaces = colorSpaces.indexOf(colorSpace) >= 0;
if (isSupportedColorSpaces) {
console.info(`setColorSpace: ${colorSpace}`);
- session.setColorSpace(colorSpace);
- let activeColorSpace:colorSpaceManager.ColorSpace = session.getActiveColorSpace();
- console.info(`activeColorSpace: ${activeColorSpace}`);
+ try {
+ session.setColorSpace(colorSpace);
+ let activeColorSpace: colorSpaceManager.ColorSpace = session.getActiveColorSpace();
+ console.info(`activeColorSpace: ${activeColorSpace}`);
+ } catch (err) {
+ let error = err as BusinessError;
+ Logger.error(`fileIo open failed. code=${error.code}, message=${error.message}`);
+ }
} else {
console.info(`colorSpace: ${colorSpace} is not support`);
}
}
+
// [End set_video_color]
@Entry
@@ -129,15 +176,26 @@ struct Recorder {
private cameraWidth: number = Const.DEFAULT_WIDTH;
private cameraHeight: number = Const.DEFAULT_HEIGHT;
private XComponentController: XComponentController = new XComponentController();
- private display = display.getDefaultDisplaySync();
- private heightPx = (this.display.width * this.cameraWidth / this.cameraHeight) + Const.PX;
- private widthPx = this.display.width + Const.PX;
+ private display: display.Display | null = null;
+ private heightPx: string = '';
+ private widthPx: string = '';
private timer: number = Const.DEFAULT_VALUE;
private seconds: number = Const.DEFAULT_VALUE;
private isReleased: boolean = false;
private isBack: boolean = false;
private range: number[] = [];
+ aboutToAppear(): void {
+ try {
+ this.display = display.getDefaultDisplaySync();
+ this.heightPx = (this.display.width * this.cameraWidth / this.cameraHeight) + Const.PX;
+ this.widthPx = this.display.width + Const.PX;
+ } catch (err) {
+ let error = err as BusinessError;
+ Logger.error(`getDefaultDisplaySync failed. code=${error.code}, message=${error.message}`);
+ }
+ }
+
onBackPress() {
this.isBack = true;
}
@@ -178,158 +236,164 @@ struct Recorder {
releaseCamera();
// Create the CameraManager object.
let context = this.getUIContext()?.getHostContext();
- let cameraManager = camera.getCameraManager(context);
- if (!cameraManager) {
- Logger.error(TAG, 'camera.getCameraManager error');
- return;
- }
+ try {
- // Get supported camera devices.
- let cameraDevices: Array = cameraManager.getSupportedCameras();
- if (cameraDevices !== undefined && cameraDevices.length <= 0) {
- Logger.error(TAG, 'cameraManager.getSupportedCameras error!');
- return;
- }
- // Gets supported mode types
- let sceneModes: Array = cameraManager.getSupportedSceneModes(cameraDevices[0]);
- let isSupportVideoMode: boolean = sceneModes.indexOf(camera.SceneMode.NORMAL_VIDEO) >= 0;
- if (!isSupportVideoMode) {
- Logger.error('video mode not support');
- return;
- }
+ let cameraManager = camera.getCameraManager(context);
+ if (!cameraManager) {
+ Logger.error(TAG, 'camera.getCameraManager error');
+ return;
+ }
- // [Start create_video_output3]
- let videoProfile: undefined | camera.VideoProfile = videoProfileCheck(cameraManager, params);
- if (!videoProfile) {
- Logger.error(TAG, 'videoProfile is not found!');
- return;
- }
+ // Get supported camera devices.
+ let cameraDevices: Array = cameraManager.getSupportedCameras();
+ if (cameraDevices !== undefined && cameraDevices.length <= 0) {
+ Logger.error(TAG, 'cameraManager.getSupportedCameras error!');
+ return;
+ }
- // [StartExclude create_video_output3]
- //The preview stream of XComponent.
- // [Start camera_conversation]
- let XComponentPreviewProfile: camera.Profile | undefined = previewProfileCameraCheck(cameraManager, params)
- if (XComponentPreviewProfile === undefined) {
- Logger.error(TAG, 'XComponentPreviewProfile is not found');
- return;
- }
- // [StartExclude camera_conversation]
- // [EndExclude create_video_output3]
-
- // Create a video output instance
- encoderVideoOutput = cameraManager.createVideoOutput(videoProfile, params.surfaceId);
- if (encoderVideoOutput === undefined) {
- Logger.error(TAG, 'encoderVideoOutput is undefined');
- return;
- }
- Logger.info(TAG, 'encoderVideoOutput success');
- // [End create_video_output3]
-
- // Create a preview stream output object
- XComponentPreviewOutput = cameraManager.createPreviewOutput(XComponentPreviewProfile, this.XComponentSurfaceId);
- if (XComponentPreviewOutput === undefined) {
- Logger.error(TAG, 'XComponentPreviewOutput is undefined');
- return;
- }
+ // Gets supported mode types
+ let sceneModes: Array = cameraManager.getSupportedSceneModes(cameraDevices[0]);
+ let isSupportVideoMode: boolean = sceneModes.indexOf(camera.SceneMode.NORMAL_VIDEO) >= 0;
+ if (!isSupportVideoMode) {
+ Logger.error('video mode not support');
+ return;
+ }
- // Create the cameraInput object.
- try {
- cameraInput = cameraManager.createCameraInput(cameraDevices[0]);
- } catch (error) {
- let err = error as BusinessError;
- Logger.error(TAG, `Failed to createCameraInput. error: ${JSON.stringify(err)}`);
- }
- if (cameraInput === undefined) {
- Logger.error(TAG, 'cameraInput is undefined');
- return;
- }
+ // [Start create_video_output3]
+ let videoProfile: undefined | camera.VideoProfile = videoProfileCheck(cameraManager, params);
+ if (!videoProfile) {
+ Logger.error(TAG, 'videoProfile is not found!');
+ return;
+ }
- // Turn on the camera.
- try {
- await cameraInput.open();
- } catch (error) {
- let err = error as BusinessError;
- Logger.error(TAG, `Failed to open cameraInput. error: ${JSON.stringify(err)}`);
- }
- // [EndExclude camera_conversation]
+ // [StartExclude create_video_output3]
+ //The preview stream of XComponent.
+ // [Start camera_conversation]
+ let XComponentPreviewProfile: camera.Profile | undefined = previewProfileCameraCheck(cameraManager, params)
+ if (XComponentPreviewProfile === undefined) {
+ Logger.error(TAG, 'XComponentPreviewProfile is not found');
+ return;
+ }
+ // [StartExclude camera_conversation]
+ // [EndExclude create_video_output3]
- // Create a session flow
- try {
- videoSession = cameraManager.createSession(camera.SceneMode.NORMAL_VIDEO) as camera.VideoSession;
- } catch (error) {
- let err = error as BusinessError;
- Logger.error(TAG, `Failed to create the session instance. error: ${JSON.stringify(err)}`);
- }
- // [StartExclude camera_conversation]
- if (videoSession === undefined) {
- Logger.error(TAG, 'videoSession is undefined');
- return;
- }
- // [EndExclude camera_conversation]
+ // Create a video output instance
+ encoderVideoOutput = cameraManager.createVideoOutput(videoProfile, params.surfaceId);
+ if (encoderVideoOutput === undefined) {
+ Logger.error(TAG, 'encoderVideoOutput is undefined');
+ return;
+ }
+ Logger.info(TAG, 'encoderVideoOutput success');
+ // [End create_video_output3]
- // Start a configuration session
- try {
- videoSession.beginConfig();
- } catch (error) {
- // [StartExclude camera_conversation]
- let err = error as BusinessError;
- Logger.error(TAG, `Failed to beginConfig. error: ${JSON.stringify(err)}`);
- // [EndExclude camera_conversation]
- }
- // [StartExclude camera_conversation]
- try {
- videoSession.addInput(cameraInput);
- } catch (error) {
- // DocsDot
- let err = error as BusinessError;
- Logger.error(TAG, `Failed to add cameraInput. error: ${JSON.stringify(err)}`);
- // DocsDot
- }
- // [EndExclude camera_conversation]
- // Add an XComponent preview stream to a session
- try {
- videoSession.addOutput(XComponentPreviewOutput);
- } catch (error) {
- // [StartExclude camera_conversation]
- let err = error as BusinessError;
- Logger.error(TAG, `Failed to add XcomponentPreviewOutput. error: ${JSON.stringify(err)}`);
+ // Create a preview stream output object
+ XComponentPreviewOutput = cameraManager.createPreviewOutput(XComponentPreviewProfile, this.XComponentSurfaceId);
+ if (XComponentPreviewOutput === undefined) {
+ Logger.error(TAG, 'XComponentPreviewOutput is undefined');
+ return;
+ }
+
+ // Create the cameraInput object.
+ try {
+ cameraInput = cameraManager.createCameraInput(cameraDevices[0]);
+ } catch (error) {
+ let err = error as BusinessError;
+ Logger.error(TAG, `Failed to createCameraInput. error: ${JSON.stringify(err)}`);
+ }
+ if (cameraInput === undefined) {
+ Logger.error(TAG, 'cameraInput is undefined');
+ return;
+ }
+
+ // Turn on the camera.
+ try {
+ await cameraInput.open();
+ } catch (error) {
+ let err = error as BusinessError;
+ Logger.error(TAG, `Failed to open cameraInput. error: ${JSON.stringify(err)}`);
+ }
// [EndExclude camera_conversation]
- }
- try {
- videoSession.addOutput(encoderVideoOutput);
- } catch (error) {
+ // Create a session flow
+ try {
+ videoSession = cameraManager.createSession(camera.SceneMode.NORMAL_VIDEO) as camera.VideoSession;
+ } catch (error) {
+ let err = error as BusinessError;
+ Logger.error(TAG, `Failed to create the session instance. error: ${JSON.stringify(err)}`);
+ }
// [StartExclude camera_conversation]
- let err = error as BusinessError;
- Logger.error(TAG, `Failed to add encoderVideoOutput. error: ${JSON.stringify(err)}`);
+ if (videoSession === undefined) {
+ Logger.error(TAG, 'videoSession is undefined');
+ return;
+ }
// [EndExclude camera_conversation]
- }
- try {
- await videoSession.commitConfig();
- } catch (error) {
+ // Start a configuration session
+ try {
+ videoSession.beginConfig();
+ } catch (error) {
+ // [StartExclude camera_conversation]
+ let err = error as BusinessError;
+ Logger.error(TAG, `Failed to beginConfig. error: ${JSON.stringify(err)}`);
+ // [EndExclude camera_conversation]
+ }
// [StartExclude camera_conversation]
- let err = error as BusinessError;
- Logger.error(TAG, `videoSession commitConfig error: ${JSON.stringify(err)}`);
+ try {
+ videoSession.addInput(cameraInput);
+ } catch (error) {
+ // DocsDot
+ let err = error as BusinessError;
+ Logger.error(TAG, `Failed to add cameraInput. error: ${JSON.stringify(err)}`);
+ // DocsDot
+ }
// [EndExclude camera_conversation]
- }
+ // Add an XComponent preview stream to a session
+ try {
+ videoSession.addOutput(XComponentPreviewOutput);
+ } catch (error) {
+ // [StartExclude camera_conversation]
+ let err = error as BusinessError;
+ Logger.error(TAG, `Failed to add XcomponentPreviewOutput. error: ${JSON.stringify(err)}`);
+ // [EndExclude camera_conversation]
+ }
- // Setting video anti-shake
- if (setVideoStabilizationMode(videoSession)) {
- // Set the color space
- setColorSpaceBeforeCommitConfig(videoSession, true);
- }
+ try {
+ videoSession.addOutput(encoderVideoOutput);
+ } catch (error) {
+ // [StartExclude camera_conversation]
+ let err = error as BusinessError;
+ Logger.error(TAG, `Failed to add encoderVideoOutput. error: ${JSON.stringify(err)}`);
+ // [EndExclude camera_conversation]
+ }
- try {
- await videoSession.start();
- } catch (error) {
- // [StartExclude camera_conversation]
- let err = error as BusinessError;
- Logger.error(TAG, `videoSession start error: ${JSON.stringify(err)}`);
- // [EndExclude camera_conversation]
- }
+ try {
+ await videoSession.commitConfig();
+ } catch (error) {
+ // [StartExclude camera_conversation]
+ let err = error as BusinessError;
+ Logger.error(TAG, `videoSession commitConfig error: ${JSON.stringify(err)}`);
+ // [EndExclude camera_conversation]
+ }
+
+ // Setting video anti-shake
+ if (setVideoStabilizationMode(videoSession)) {
+ // Set the color space
+ setColorSpaceBeforeCommitConfig(videoSession, true);
+ }
+ try {
+ await videoSession.start();
+ } catch (error) {
+ // [StartExclude camera_conversation]
+ let err = error as BusinessError;
+ Logger.error(TAG, `videoSession start error: ${JSON.stringify(err)}`);
+ // [EndExclude camera_conversation]
+ }
+ } catch (err) {
+ let error = err as BusinessError;
+ Logger.error(`error.code=${error.code}, error.message=${error.message}`);
+ }
// Start the video output stream
encoderVideoOutput.start((err: BusinessError) => {
// [StartExclude camera_conversation]
@@ -371,12 +435,22 @@ struct Recorder {
if (currentFov < this.range[0]) {
currentFov = this.range[0];
}
- videoSession.setZoomRatio(currentFov);
+ try {
+ videoSession.setZoomRatio(currentFov);
+ } catch (err) {
+ let error = err as BusinessError;
+ Logger.error(`setZoomRatio failed. code=${error.code}, message=${error.message}`);
+ }
}
})
.onActionEnd((event: GestureEvent) => {
if (videoSession) {
- this.fov = videoSession.getZoomRatio();
+ try {
+ this.fov = videoSession.getZoomRatio();
+ } catch (err) {
+ let error = err as BusinessError;
+ Logger.error(`getZoomRatio failed. code=${error.code}, message=${error.message}`);
+ }
}
})
)
diff --git a/HpDemo/entry/src/main/ets/entryability/EntryAbility.ets b/HpDemo/entry/src/main/ets/entryability/EntryAbility.ets
index d3ee54d2..29169f01 100644
--- a/HpDemo/entry/src/main/ets/entryability/EntryAbility.ets
+++ b/HpDemo/entry/src/main/ets/entryability/EntryAbility.ets
@@ -16,12 +16,18 @@
import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { window } from '@kit.ArkUI';
+import { BusinessError } from '@kit.BasicServicesKit';
const DOMAIN = 0x0000;
export default class EntryAbility extends UIAbility {
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
- this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
+ try {
+ this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
+ } catch (err) {
+ let error = err as BusinessError;
+ hilog.error(DOMAIN, 'testTag', `Failed to set colorMode. code=${error.code}, message=${error.message}`);
+ }
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate');
}
diff --git a/HpDemo/entry/src/main/ets/pages/Index.ets b/HpDemo/entry/src/main/ets/pages/Index.ets
index 123f355d..5fff919f 100644
--- a/HpDemo/entry/src/main/ets/pages/Index.ets
+++ b/HpDemo/entry/src/main/ets/pages/Index.ets
@@ -16,14 +16,28 @@
import { display, window } from '@kit.ArkUI';
import { common } from '@kit.AbilityKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
+import { BusinessError } from '@kit.BasicServicesKit';
@Entry
@Component
struct Index {
+ @State availableHeightVal1: string = '';
+ @State availableHeightVal2: string = '';
+
+ aboutToAppear(): void {
+ try {
+ this.availableHeightVal1 = display.getDisplayByIdSync(0).availableHeight.toString();
+ this.availableHeightVal2 = display.getDisplayByIdSync(999).availableHeight.toString();
+ } catch (err) {
+ let error = err as BusinessError;
+ hilog.error(0x000, 'testTag', `get availableHeight failed. code=${error.code}, message=${error.message}`);
+ }
+ }
+
build() {
Column() {
- Text(display.getDisplayByIdSync(0).availableHeight.toString())
- Text(display.getDisplayByIdSync(999).availableHeight.toString())
+ Text(this.availableHeightVal1)
+ Text(this.availableHeightVal2)
Button('remove')
.onClick(async () => {
try {
@@ -39,8 +53,14 @@ struct Index {
let rectWidth = Number(display.getDisplayByIdSync(0).availableWidth);
let foldCreaseRegion = display.getCurrentFoldCreaseRegion().creaseRects[0].height;
let rectHeight = Number(display.getDisplayByIdSync(0).availableHeight) +
- Number(display.getDisplayByIdSync(999).availableHeight) + Number(foldCreaseRegion);
- mainWindow.resizeAsync(rectWidth, rectHeight);
+ Number(display.getDisplayByIdSync(999).availableHeight) + Number(foldCreaseRegion);
+ mainWindow.resizeAsync(rectWidth, rectHeight)
+ .then(() => {
+ hilog.info(0x000, 'testTag', `resizeAsync succeed.`);
+ })
+ .catch((error: BusinessError) => {
+ hilog.error(0x000, 'testTag', `resizeAsync falied. code=${error.code}, message=${error.message}`);
+ })
// [End resizeWindow]
} catch (exception) {
hilog.error(0x0000, 'test',
diff --git a/XiaoyiAgentDemo/entry/src/main/ets/entryability/EntryAbility.ets b/XiaoyiAgentDemo/entry/src/main/ets/entryability/EntryAbility.ets
index d7b59612..bd7ee037 100644
--- a/XiaoyiAgentDemo/entry/src/main/ets/entryability/EntryAbility.ets
+++ b/XiaoyiAgentDemo/entry/src/main/ets/entryability/EntryAbility.ets
@@ -23,7 +23,6 @@ const DOMAIN = 0x0000;
let uiContext: UIContext | null = null;
export default class EntryAbility extends UIAbility {
-
onCreate(): void {
AppStorage.setOrCreate('context', this.context);
hilog.info(DOMAIN, 'testTag', '[EntryAbility] onCreate completed');
@@ -43,9 +42,14 @@ export default class EntryAbility extends UIAbility {
return;
}
windowStage.getMainWindow((err: BusinessError, data) => {
- let windowClass = data;
- uiContext = windowClass.getUIContext();
- AppStorage.set('uiContext', uiContext);
+ try {
+ let windowClass = data;
+ uiContext = windowClass.getUIContext();
+ AppStorage.set('uiContext', uiContext);
+ } catch (error) {
+ let err = error as BusinessError;
+ hilog.error(0x000, 'testTag', `getUIContext failed. code=${err.code}, message=${err.message}`);
+ }
})
hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.');
@@ -71,10 +75,19 @@ export default class EntryAbility extends UIAbility {
onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void {
hilog.info(DOMAIN, 'testTag', 'Received URI:', want.uri);
const uri = want.uri;
+ let pathname = '';
if (uri) {
- const urlObj = url.URL.parseURL(uri);
- let pathname = urlObj.pathname;
- uiContext?.getRouter().pushUrl({ url: 'pages' + pathname });
+ try {
+ const urlObj = url.URL.parseURL(uri);
+ pathname = urlObj.pathname;
+ } catch (error) {
+ let err = error as BusinessError;
+ hilog.error(0x000, 'testTag', `getUIContext failed. code=${err.code}, message=${err.message}`);
+ }
+ uiContext?.getRouter().pushUrl({ url: 'pages' + pathname })
+ .catch((error: BusinessError) => {
+ hilog.error(0x000, 'testTag', `pushUrl failed. code=${error.code}, message=${error.message}`);
+ })
}
}
// [End onNewWant]
diff --git a/XiaoyiAgentDemo/entry/src/main/ets/entryability/InsightIntentExecutorImpl.ets b/XiaoyiAgentDemo/entry/src/main/ets/entryability/InsightIntentExecutorImpl.ets
index 1d7a599d..6f7a6304 100644
--- a/XiaoyiAgentDemo/entry/src/main/ets/entryability/InsightIntentExecutorImpl.ets
+++ b/XiaoyiAgentDemo/entry/src/main/ets/entryability/InsightIntentExecutorImpl.ets
@@ -20,6 +20,7 @@ import { window } from '@kit.ArkUI';
import AudioPlayHandler from './intentHandlers/AudioPlayHandler';
import TextGetHandler from './intentHandlers/TextGetHandler';
import PageNavigateHandler from './intentHandlers/PageNavigateHandler';
+import { hilog } from '@kit.PerformanceAnalysisKit';
export default class InsightIntentExecutorImpl extends InsightIntentExecutor {
// Instruction implementation class.
@@ -81,7 +82,10 @@ export default class InsightIntentExecutorImpl extends InsightIntentExecutor {
case 'OpenSecondPage':
return this.pageHandler.execute();
default:
- pageLoader.loadContent('pages/MainPage');
+ pageLoader.loadContent('pages/MainPage')
+ .catch((error: BusinessError) => {
+ hilog.error(0x000, 'testTag', `loadContent failed. code=${error.code}, message=${error.message}`);
+ })
break;
}
return Promise.resolve({
@@ -92,4 +96,5 @@ export default class InsightIntentExecutorImpl extends InsightIntentExecutor {
} as insightIntent.ExecuteResult)
}
}
+
// [End executorImpl]
\ No newline at end of file
diff --git a/XiaoyiAgentDemo/entry/src/main/ets/pages/MainPage.ets b/XiaoyiAgentDemo/entry/src/main/ets/pages/MainPage.ets
index 0b948905..c50b9c1d 100644
--- a/XiaoyiAgentDemo/entry/src/main/ets/pages/MainPage.ets
+++ b/XiaoyiAgentDemo/entry/src/main/ets/pages/MainPage.ets
@@ -12,6 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+import { BusinessError } from '@kit.BasicServicesKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
@Entry
@Component
@@ -20,7 +22,13 @@ struct HelloWorldPage {
// Jump to the second page
private navigateToSecond() {
- this.getUIContext().getRouter().pushUrl({ url: 'pages/SecondPage' });
+ this.getUIContext().getRouter().pushUrl({ url: 'pages/SecondPage' })
+ .then(() => {
+ hilog.info(0x000, 'testTag', `pushUrl success`);
+ })
+ .catch((error: BusinessError) => {
+ hilog.error(0x000, 'testTag', `pushUrl failed. code=${error.code}, message=${error.message}`);
+ })
}
build() {
diff --git a/XiaoyiAgentDemo/entry/src/main/ets/utils/audioplayer/BackgroundUtil.ets b/XiaoyiAgentDemo/entry/src/main/ets/utils/audioplayer/BackgroundUtil.ets
index d0a8ab36..dee283da 100644
--- a/XiaoyiAgentDemo/entry/src/main/ets/utils/audioplayer/BackgroundUtil.ets
+++ b/XiaoyiAgentDemo/entry/src/main/ets/utils/audioplayer/BackgroundUtil.ets
@@ -41,19 +41,23 @@ export class BackgroundUtil {
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
};
- wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj: Object) => {
- try {
- backgroundTaskManager.startBackgroundRunning(context,
- backgroundTaskManager.BackgroundMode.AUDIO_PLAYBACK, wantAgentObj).then(() => {
- Logger.info('this avPlayer: ', 'startBackgroundRunning succeeded');
- }).catch((error: BusinessError) => {
- Logger.error('this avPlayer: ', `startBackgroundRunning failed Cause: code ${error.code}`);
- });
- } catch (error) {
- Logger.error('this avPlayer: ', `startBackgroundRunning failed. code ${(error as BusinessError).code}
+ wantAgent.getWantAgent(wantAgentInfo)
+ .then((wantAgentObj: Object) => {
+ try {
+ backgroundTaskManager.startBackgroundRunning(context,
+ backgroundTaskManager.BackgroundMode.AUDIO_PLAYBACK, wantAgentObj).then(() => {
+ Logger.info('this avPlayer: ', 'startBackgroundRunning succeeded');
+ }).catch((error: BusinessError) => {
+ Logger.error('this avPlayer: ', `startBackgroundRunning failed Cause: code ${error.code}`);
+ });
+ } catch (error) {
+ Logger.error('this avPlayer: ', `startBackgroundRunning failed. code ${(error as BusinessError).code}
message ${(error as BusinessError).message}`);
- }
- });
+ }
+ })
+ .catch((error: BusinessError) => {
+ Logger.error('this avPlayer: ', `getWantAgent failed. code=${error.code}, message=${error.message}`);
+ })
}
/**
diff --git a/XiaoyiAgentDemo/entry/src/main/ets/utils/audioplayer/MediaService.ets b/XiaoyiAgentDemo/entry/src/main/ets/utils/audioplayer/MediaService.ets
index 47982f3b..128739d7 100644
--- a/XiaoyiAgentDemo/entry/src/main/ets/utils/audioplayer/MediaService.ets
+++ b/XiaoyiAgentDemo/entry/src/main/ets/utils/audioplayer/MediaService.ets
@@ -128,22 +128,18 @@ export class MediaService {
break;
}
};
-
private avSessionPlayCall = () => {
Logger.info(TAG, `avSessionPlayCall on play , do play task`);
this.play();
};
-
private avSessionPauseCall = () => {
Logger.info(TAG, `avSessionPauseCall on pause , do pause task`);
this.pause();
};
-
private avSessionPlayNextCall = () => {
Logger.info(TAG, `avSessionPlayNextCall on playNext , do playNext task`);
this.playNext();
};
-
private avSessionPlayPreviousCall = () => {
Logger.info(TAG, `avSessionPlayPreviousCall on playPrevious , do playPrevious task`);
this.playPrevious();
@@ -174,7 +170,7 @@ export class MediaService {
this.songChangedBack(this.changedData);
}
}
-
+
public static getInstance(): MediaService {
if (!MediaService.instance) {
MediaService.instance = new MediaService();
@@ -206,11 +202,21 @@ export class MediaService {
this.avPlayer.on('stateChange', this.avPlayerStateChangeCall)
}
}
-
+
private async createSession(): Promise {
- this.session = await avSession.createAVSession(this.context, 'SESSION_NAME', 'audio');
- this.session.activate();
- Logger.info(TAG, `session create done : sessionId : ${this.session.sessionId}`);
+ try {
+ this.session = await avSession.createAVSession(this.context, 'SESSION_NAME', 'audio');
+ this.session.activate()
+ .then(() => {
+ Logger.info(TAG, `activate succeed.`);
+ })
+ .catch((error) => {
+ let err = error as BusinessError;
+ Logger.error(TAG, `activate failed. code=${err.code}, message=${err.message}`);
+ })
+ Logger.info(TAG, `session create done : sessionId : ${this.session.sessionId}`);
+ } catch (err) {
+ }
this.setAVMetadata();
let wantAgentInfo: wantAgent.WantAgentInfo = {
wants: [
@@ -223,27 +229,44 @@ export class MediaService {
requestCode: 0,
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}
- wantAgent.getWantAgent(wantAgentInfo).then((agent) => {
- this.session?.setLaunchAbility(agent);
- })
+ wantAgent.getWantAgent(wantAgentInfo)
+ .then((agent) => {
+ this.session?.setLaunchAbility(agent)
+ .catch((error) => {
+ let err = error as BusinessError;
+ Logger.error(TAG, `setLaunchAbility failed. code=${err.code}, message=${err.message}`);
+ })
+ })
+ .catch((error) => {
+ let err = error as BusinessError;
+ Logger.error(TAG, `getWantAgent failed. code=${err.code}, message=${err.message}`);
+ })
this.setListenerForMesFromController();
}
-
+
private setListenerForMesFromController(): void {
if (this.session) {
- this.session.on('play', this.avSessionPlayCall);
- this.session.on('pause', this.avSessionPauseCall);
- this.session.on('playNext', this.avSessionPlayNextCall);
- this.session.on('playPrevious', this.avSessionPlayPreviousCall);
+ try {
+ this.session.on('play', this.avSessionPlayCall);
+ this.session.on('pause', this.avSessionPauseCall);
+ this.session.on('playNext', this.avSessionPlayNextCall);
+ this.session.on('playPrevious', this.avSessionPlayPreviousCall);
+ } catch (error) {
+ Logger.error(TAG, `setListenerForMesFromController failed. code=${error.code}, message=${error.message}`);
+ }
}
}
-
+
private unregisterSessionListener(): void {
if (this.session) {
- this.session.off('play');
- this.session.off('pause');
- this.session.off('playNext');
- this.session.off('playPrevious');
+ try {
+ this.session.off('play');
+ this.session.off('pause');
+ this.session.off('playNext');
+ this.session.off('playPrevious');
+ } catch (error) {
+ Logger.error(TAG, `unregisterSessionListener failed. code=${error.code}, message=${error.message}`);
+ }
}
}
@@ -356,11 +379,19 @@ export class MediaService {
public async release(): Promise {
if (this.avPlayer && this.session && this.context) {
- this.avPlayer.release();
+ this.avPlayer.release()
+ .catch((err) => {
+ let error = err as BusinessError;
+ Logger.error(TAG, `release error, code=${error.code}, message=${error.message}`);
+ })
this.songItemBuilder.release();
BackgroundUtil.stopContinuousTask(this.context);
this.unregisterSessionListener();
- this.session.destroy();
+ this.session.destroy()
+ .catch((err) => {
+ let error = err as BusinessError;
+ Logger.error(TAG, `destroy error, code=${error.code}, message=${error.message}`);
+ })
}
}
diff --git a/XiaoyiAgentDemo/entry/src/main/ets/utils/audioplayer/MediaTools.ets b/XiaoyiAgentDemo/entry/src/main/ets/utils/audioplayer/MediaTools.ets
index 5c11e9ff..2aff2b9d 100644
--- a/XiaoyiAgentDemo/entry/src/main/ets/utils/audioplayer/MediaTools.ets
+++ b/XiaoyiAgentDemo/entry/src/main/ets/utils/audioplayer/MediaTools.ets
@@ -16,12 +16,21 @@
import { image } from '@kit.ImageKit';
import { common } from '@kit.AbilityKit';
import { resourceManager } from '@kit.LocalizationKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { BusinessError } from '@kit.BasicServicesKit';
export class MediaTools {
static async getPixelMapFromResource(context: common.UIAbilityContext,
name: resourceManager.Resource): Promise {
let resourceMgr = context.resourceManager;
- let fileData: Uint8Array = await resourceMgr.getMediaContent(name);
+ let fileData: Uint8Array | null = null;
+ resourceMgr.getMediaContent(name)
+ .then((data: Uint8Array) => {
+ fileData = data;
+ })
+ .catch((error: BusinessError) => {
+ hilog.error(0x000, 'testTag', `getMediaContent failed. code=${error.code}, message=${error.message}`);
+ })
return await image.createImageSource(fileData.buffer as ArrayBuffer).createPixelMap();
}
--
Gitee
From 609322f67a8886650a93630d5aa6877236d4a081 Mon Sep 17 00:00:00 2001
From: rex <1491721419@qq.com>
Date: Fri, 12 Sep 2025 20:22:22 +0800
Subject: [PATCH 3/4] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=BB=A3=E7=A0=81?=
=?UTF-8?q?=E6=9C=AA=E6=8D=95=E8=8E=B7=E8=AD=A6=E5=91=8A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
HDRVivid/AVCodecVideo/entry/src/main/module.json5 | 7 +++++++
XiaoyiAgentDemo/entry/src/main/module.json5 | 5 +++++
2 files changed, 12 insertions(+)
diff --git a/HDRVivid/AVCodecVideo/entry/src/main/module.json5 b/HDRVivid/AVCodecVideo/entry/src/main/module.json5
index 8bd98e4a..c3621aa9 100644
--- a/HDRVivid/AVCodecVideo/entry/src/main/module.json5
+++ b/HDRVivid/AVCodecVideo/entry/src/main/module.json5
@@ -54,6 +54,13 @@
"abilities": ["EntryAbility"],
"when": "always"
}
+ },
+ {
+ "name": "ohos.permission.WRITE_IMAGEVIDEO",
+ "reason": "$string:EntryAbility_desc",
+ "usedScene": {
+ "when": "always"
+ }
}
]
}
diff --git a/XiaoyiAgentDemo/entry/src/main/module.json5 b/XiaoyiAgentDemo/entry/src/main/module.json5
index ae47ef2b..ba70614a 100644
--- a/XiaoyiAgentDemo/entry/src/main/module.json5
+++ b/XiaoyiAgentDemo/entry/src/main/module.json5
@@ -39,6 +39,11 @@
]
// [End module]
}
+ ],
+ "requestPermissions": [
+ {
+ "name": "ohos.permission.KEEP_BACKGROUND_RUNNING"
+ }
]
}
}
\ No newline at end of file
--
Gitee
From b2a9046b49bf6f43639a16fae0a8c82b2b0d3d59 Mon Sep 17 00:00:00 2001
From: rex <1491721419@qq.com>
Date: Thu, 18 Sep 2025 15:41:36 +0800
Subject: [PATCH 4/4] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=BB=A3=E7=A0=81?=
=?UTF-8?q?=E6=9C=AA=E6=8D=95=E8=8E=B7=E8=AD=A6=E5=91=8A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../ets/controller/AvPlayerController.ets | 53 +++++++----
.../ets/controller/AvSessionController.ets | 87 ++++++++++++-------
.../main/ets/utils/BackgroundTaskManager.ets | 5 +-
.../src/main/ets/utils/ImageUtil.ets | 16 ++--
.../main/ets/entryability/EntryAbility.ets | 30 +++++--
.../entry/src/main/ets/pages/IndexPage.ets | 15 +++-
.../entry/src/main/ets/utils/WindowUtil.ets | 44 +++++++---
.../entry/src/main/ets/view/AVPlayer.ets | 66 +++++++++-----
.../entry/src/main/ets/view/VideoDetails.ets | 13 ++-
.../entry/src/main/ets/view/VideoSide.ets | 13 ++-
10 files changed, 239 insertions(+), 103 deletions(-)
diff --git a/HDRVivid/AVPlayer/MediaService/src/main/ets/controller/AvPlayerController.ets b/HDRVivid/AVPlayer/MediaService/src/main/ets/controller/AvPlayerController.ets
index ddbdb288..7c84876d 100644
--- a/HDRVivid/AVPlayer/MediaService/src/main/ets/controller/AvPlayerController.ets
+++ b/HDRVivid/AVPlayer/MediaService/src/main/ets/controller/AvPlayerController.ets
@@ -18,7 +18,6 @@ import { media } from '@kit.MediaKit';
import { audio } from '@kit.AudioKit';
import { avSession } from '@kit.AVSessionKit';
import { BusinessError } from '@kit.BasicServicesKit';
-import { BackgroundTaskManager } from '../utils/BackgroundTaskManager';
import { AVPlayerState, CommonConstants } from '../common/CommonConstants';
import { secondToTime } from '../utils/CommUtils'
import { VideoData } from '../model/VideoData';
@@ -58,11 +57,15 @@ export class AvPlayerController {
this.avPlayer = player;
// this.curSource.video is the local video path, and this.curSource.url is the network video path
if (this.curSource.video) {
- let fileDescriptor = this.context?.resourceManager.getRawFdSync(this.curSource.video);
- if (fileDescriptor) {
- let avFileDescriptor: media.AVFileDescriptor =
- { fd: fileDescriptor.fd, offset: fileDescriptor.offset, length: fileDescriptor.length };
- this.avPlayer.fdSrc = avFileDescriptor;
+ try {
+ let fileDescriptor = this.context?.resourceManager.getRawFdSync(this.curSource.video);
+ if (fileDescriptor) {
+ let avFileDescriptor: media.AVFileDescriptor =
+ { fd: fileDescriptor.fd, offset: fileDescriptor.offset, length: fileDescriptor.length };
+ this.avPlayer.fdSrc = avFileDescriptor;
+ }
+ } catch (error) {
+ Logger.error(`getRawFdSync failed, code is ${error.code}, message is ${error.message}`);
}
} else {
this.avPlayer.url = this.curSource.url;
@@ -108,7 +111,10 @@ export class AvPlayerController {
avPlayer.on('error', (err: BusinessError) => {
Logger.error(TAG, `Invoke avPlayer failed, code is ${err.code}, message is ${err.message}` +
`----state:${avPlayer.state} this.curIndex:${this.curIndex}`);
- avPlayer.reset(); // resets the resources and triggers the idle state
+ avPlayer.reset() // resets the resources and triggers the idle state
+ .catch((err: BusinessError) => {
+ Logger.error(TAG, `avPlayer reset failed, code is ${err.code}, message is ${err.message}`);
+ })
})
this.setInterruptCallback()
this.setStateChangeCallback(avPlayer);
@@ -119,13 +125,17 @@ export class AvPlayerController {
if (!this.avSessionController) {
return;
}
- this.avSessionController.getAvSession()?.on('play', () => this.sessionPlayCallback());
- this.avSessionController.getAvSession()?.on('pause', () => this.sessionPauseCallback());
- this.avSessionController.getAvSession()?.on('stop', () => this.sessionStopCallback());
- this.avSessionController.getAvSession()?.on('fastForward',
- (time?: number) => this.sessionFastForwardCallback(time));
- this.avSessionController.getAvSession()?.on('rewind', (time?: number) => this.sessionRewindCallback(time));
- this.avSessionController.getAvSession()?.on('seek', (seekTime: number) => this.sessionSeekCallback(seekTime));
+ try {
+ this.avSessionController.getAvSession()?.on('play', () => this.sessionPlayCallback());
+ this.avSessionController.getAvSession()?.on('pause', () => this.sessionPauseCallback());
+ this.avSessionController.getAvSession()?.on('stop', () => this.sessionStopCallback());
+ this.avSessionController.getAvSession()?.on('fastForward',
+ (time?: number) => this.sessionFastForwardCallback(time));
+ this.avSessionController.getAvSession()?.on('rewind', (time?: number) => this.sessionRewindCallback(time));
+ this.avSessionController.getAvSession()?.on('seek', (seekTime: number) => this.sessionSeekCallback(seekTime));
+ } catch (error) {
+ Logger.error(`getMediaContent failed, code is ${error.code}, message is ${error.message}`);
+ }
}
private setInterruptCallback() {
@@ -207,7 +217,10 @@ export class AvPlayerController {
case 'initialized':
Logger.info(TAG, 'AVPlayer state initialized called.' + ` this.curIndex:${this.curIndex}`);
avPlayer.surfaceId = this.surfaceID;
- avPlayer.prepare();
+ avPlayer.prepare()
+ .catch((err: BusinessError) => {
+ Logger.error(TAG, `avPlayer prepare failed, code is ${err.code}, message is ${err.message}`);
+ })
break;
case 'prepared':
// [StartExclude mode_volume]
@@ -405,7 +418,10 @@ export class AvPlayerController {
this.updateIsPlay(true);
Logger.error(TAG, `stopVideo failed, code is ${err.code}, message is ${err.message}`);
} else {
- this.avPlayer!.release();
+ this.avPlayer!.release()
+ .catch((err: BusinessError) => {
+ Logger.error(TAG, `avPlayer release failed, code is ${err.code}, message is ${err.message}`);
+ })
Logger.info(TAG, `stopVideo success, this.curIndex:${this.curIndex}`);
}
});
@@ -466,7 +482,10 @@ export class AvPlayerController {
this.avPlayer.off('speedDone');
this.avPlayer.off('error');
this.avPlayer.off('stateChange');
- this.avPlayer.release();
+ this.avPlayer.release()
+ .catch((err: BusinessError) => {
+ Logger.error(TAG, `avPlayer release failed, code is ${err.code}, message is ${err.message}`);
+ })
// [StartExclude destroy_instance]
this.avSessionController?.unregisterSessionListener();
// [EndExclude destroy_instance]
diff --git a/HDRVivid/AVPlayer/MediaService/src/main/ets/controller/AvSessionController.ets b/HDRVivid/AVPlayer/MediaService/src/main/ets/controller/AvSessionController.ets
index d0e8b644..cbbd01ae 100644
--- a/HDRVivid/AVPlayer/MediaService/src/main/ets/controller/AvSessionController.ets
+++ b/HDRVivid/AVPlayer/MediaService/src/main/ets/controller/AvSessionController.ets
@@ -46,13 +46,20 @@ export class AvSessionController {
Logger.info(TAG, `session create failed : conext is undefined`);
return;
}
- avSession.createAVSession(this.context, "SHORT_AUDIO_SESSION", 'video').then(async (avSession) => {
- this.avSession = avSession;
- Logger.info(TAG, `session create successed : sessionId : ${this.avSession.sessionId}`);
- BackgroundTaskManager.startContinuousTask(this.context);
- this.setLaunchAbility();
- this.avSession.activate();
- });
+ avSession.createAVSession(this.context, "SHORT_AUDIO_SESSION", 'video')
+ .then(async (avSession) => {
+ this.avSession = avSession;
+ Logger.info(TAG, `session create successed : sessionId : ${this.avSession.sessionId}`);
+ BackgroundTaskManager.startContinuousTask(this.context);
+ this.setLaunchAbility();
+ this.avSession.activate()
+ .catch((err: BusinessError) => {
+ Logger.error(TAG, `avSession activate failed Cause: ${JSON.stringify(err)}`);
+ })
+ })
+ .catch((err: BusinessError) => {
+ Logger.error(TAG, `createAVSession failed Cause: ${JSON.stringify(err)}`);
+ })
}
public getAvSession() {
@@ -70,19 +77,23 @@ export class AvSessionController {
}
const imagePixMap = await ImageUtil.getPixmapFromMedia(curSource.head, UIContext);
- let metadata: avSession.AVMetadata = {
- assetId: `${curSource.index}`,
- title: this.context?.resourceManager.getStringSync(curSource.name),
- mediaImage: imagePixMap,
- duration: duration
- };
- if (this.avSession) {
- this.avSession.setAVMetadata(metadata).then(() => {
- this.avSessionMetadata = metadata;
- Logger.info(TAG, 'SetAVMetadata successfully');
- }).catch((err: BusinessError) => {
- Logger.error(TAG, `SetAVMetadata BusinessError: code: ${err.code}, message: ${err.message}`);
- });
+ try {
+ let metadata: avSession.AVMetadata = {
+ assetId: `${curSource.index}`,
+ title: this.context?.resourceManager.getStringSync(curSource.name),
+ mediaImage: imagePixMap,
+ duration: duration
+ };
+ if (this.avSession) {
+ this.avSession.setAVMetadata(metadata).then(() => {
+ this.avSessionMetadata = metadata;
+ Logger.info(TAG, 'SetAVMetadata successfully');
+ }).catch((err: BusinessError) => {
+ Logger.error(TAG, `SetAVMetadata BusinessError: code: ${err.code}, message: ${err.message}`);
+ });
+ }
+ } catch (error) {
+ Logger.error(`getStringSync failed Cause: ${JSON.stringify(error)}`);
}
}
@@ -101,11 +112,17 @@ export class AvSessionController {
requestCode: 0,
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
};
- wantAgent.getWantAgent(wantAgentInfo).then((agent) => {
- if (this.avSession) {
- this.avSession.setLaunchAbility(agent);
- }
- });
+ wantAgent.getWantAgent(wantAgentInfo)
+ .then((agent) => {
+ if (this.avSession) {
+ this.avSession.setLaunchAbility(agent).catch((err: BusinessError) => {
+ Logger.error(TAG, `setLaunchAbility failed Cause: ${JSON.stringify(err)}`);
+ })
+ }
+ })
+ .catch((err: BusinessError) => {
+ Logger.error(TAG, `getWantAgent failed Cause: ${JSON.stringify(err)}`);
+ })
}
public setAvSessionPlayState(playbackState: avSession.AVPlaybackState) {
@@ -124,13 +141,17 @@ export class AvSessionController {
if (!this.avSession) {
return;
}
- this.avSession.off('play');
- this.avSession.off('pause');
- this.avSession.off('playNext');
- this.avSession.off('playPrevious');
- this.avSession.off('setLoopMode');
- this.avSession.off('seek');
- this.avSession.off('toggleFavorite');
- BackgroundTaskManager.stopContinuousTask(this.context);
+ try {
+ this.avSession.off('play');
+ this.avSession.off('pause');
+ this.avSession.off('playNext');
+ this.avSession.off('playPrevious');
+ this.avSession.off('setLoopMode');
+ this.avSession.off('seek');
+ this.avSession.off('toggleFavorite');
+ BackgroundTaskManager.stopContinuousTask(this.context);
+ } catch (error) {
+ Logger.error(`avSession off failed Cause: ${JSON.stringify(error)}`);
+ }
}
}
\ No newline at end of file
diff --git a/HDRVivid/AVPlayer/MediaService/src/main/ets/utils/BackgroundTaskManager.ets b/HDRVivid/AVPlayer/MediaService/src/main/ets/utils/BackgroundTaskManager.ets
index 0d530789..4fb542cc 100644
--- a/HDRVivid/AVPlayer/MediaService/src/main/ets/utils/BackgroundTaskManager.ets
+++ b/HDRVivid/AVPlayer/MediaService/src/main/ets/utils/BackgroundTaskManager.ets
@@ -47,7 +47,10 @@ export class BackgroundTaskManager {
}).catch((err: BusinessError) => {
Logger.error(TAG, `startBackgroundRunning failed Cause: ${JSON.stringify(err)}`);
});
- });
+ })
+ .catch((err: BusinessError) => {
+ Logger.error(TAG, `getWantAgent failed Cause: ${JSON.stringify(err)}`);
+ })
}
// cancel continuous task
diff --git a/HDRVivid/AVPlayer/MediaService/src/main/ets/utils/ImageUtil.ets b/HDRVivid/AVPlayer/MediaService/src/main/ets/utils/ImageUtil.ets
index 68db5f72..b268d315 100644
--- a/HDRVivid/AVPlayer/MediaService/src/main/ets/utils/ImageUtil.ets
+++ b/HDRVivid/AVPlayer/MediaService/src/main/ets/utils/ImageUtil.ets
@@ -14,16 +14,22 @@
*/
import { image } from '@kit.ImageKit';
+import Logger from './Logger';
export class ImageUtil {
constructor() {
}
public static async getPixmapFromMedia(resource: Resource, UIContext: UIContext) {
- let unit8Array = await UIContext.getHostContext()?.resourceManager?.getMediaContent({
- bundleName: resource.bundleName,
- moduleName: resource.moduleName,
- id: resource.id
- });
+ let unit8Array: Uint8Array | undefined = undefined;
+ try {
+ unit8Array = await UIContext.getHostContext()?.resourceManager?.getMediaContent({
+ bundleName: resource.bundleName,
+ moduleName: resource.moduleName,
+ id: resource.id
+ });
+ } catch (error) {
+ Logger.error(`getMediaContent failed Cause: ${JSON.stringify(error)}`);
+ }
let imageSource = image.createImageSource(unit8Array?.buffer.slice(0, unit8Array.buffer.byteLength));
let createPixelMap: image.PixelMap = await imageSource.createPixelMap({
desiredPixelFormat: image.PixelMapFormat.RGBA_8888
diff --git a/HDRVivid/AVPlayer/entry/src/main/ets/entryability/EntryAbility.ets b/HDRVivid/AVPlayer/entry/src/main/ets/entryability/EntryAbility.ets
index 8b2e9627..866c9f2a 100644
--- a/HDRVivid/AVPlayer/entry/src/main/ets/entryability/EntryAbility.ets
+++ b/HDRVivid/AVPlayer/entry/src/main/ets/entryability/EntryAbility.ets
@@ -14,6 +14,7 @@
*/
import { UIAbility } from '@kit.AbilityKit';
+import { BusinessError } from '@kit.BasicServicesKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { UIContext, window } from '@kit.ArkUI';
import { WindowUtil } from '../utils/WindowUtil';
@@ -31,21 +32,36 @@ export default class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage: window.WindowStage): void {
// Main window is created, set main page for this ability
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
- let windowClass: window.Window = windowStage.getMainWindowSync();
+ let windowClass: window.Window | undefined = undefined;
+ try {
+ windowClass = windowStage.getMainWindowSync();
+ } catch (err) {
+ hilog.error(0x0000, 'testTag',`getMainWindowSync failed, Code:${err.code}, message:${err.message}`);
+ }
AppStorage.setOrCreate('windowStage', windowStage);
- windowClass.setWindowLayoutFullScreen(true);
+ windowClass?.setWindowLayoutFullScreen(true)
+ .catch((err: BusinessError) => {
+ hilog.error(0x0000, 'testTag',`getMainWindowSync failed, Code:${err.code}, message:${err.message}`);
+ })
WindowUtil.getInstance().setWindowStage(windowStage);
- windowClass.setWindowSystemBarProperties({
+ windowClass?.setWindowSystemBarProperties({
statusBarContentColor: '#e6ffffff'
- });
+ })
+ .catch((err: BusinessError) => {
+ hilog.error(0x0000, 'testTag',`getMainWindowSync failed, Code:${err.code}, message:${err.message}`);
+ })
windowStage.loadContent('pages/IndexPage', (err) => {
if (err.code) {
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
- let uiContext: UIContext | undefined = windowStage.getMainWindowSync().getUIContext();
- AppStorage.setOrCreate('uiContext', uiContext);
- hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ try {
+ let uiContext: UIContext | undefined = windowStage.getMainWindowSync().getUIContext();
+ AppStorage.setOrCreate('uiContext', uiContext);
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ } catch (error) {
+ hilog.error(0x0000, 'testTag',`getMainWindowSync or getUIContext failed, Code:${err.code}, message:${err.message}`);
+ }
});
}
diff --git a/HDRVivid/AVPlayer/entry/src/main/ets/pages/IndexPage.ets b/HDRVivid/AVPlayer/entry/src/main/ets/pages/IndexPage.ets
index 05fc2588..dffa0474 100644
--- a/HDRVivid/AVPlayer/entry/src/main/ets/pages/IndexPage.ets
+++ b/HDRVivid/AVPlayer/entry/src/main/ets/pages/IndexPage.ets
@@ -14,6 +14,7 @@
*/
import { window } from '@kit.ArkUI';
+import { BusinessError } from '@kit.BasicServicesKit';
import { CommonConstants as Const, Logger, VideoData } from '@ohos/MediaService';
import { SOURCES, VideoSource } from '../model/DataModel';
import { WindowUtil } from '../utils/WindowUtil';
@@ -22,6 +23,7 @@ import { VideoList } from '../view/VideoList';
import { VideoPlayer } from '../view/AVPlayer';
import { VideoDetails } from '../view/VideoDetails';
import { common } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
const TAG = '[IndexPage]';
@@ -43,8 +45,17 @@ struct IndexPage {
async aboutToAppear(): Promise {
let context = this.uiContext.getHostContext() as common.UIAbilityContext;
- let windowClass = await window.getLastWindow(context);
- await windowClass.setWindowKeepScreenOn(true);
+ await window.getLastWindow(context)
+ .then((windowClass: window.Window) => {
+ windowClass.setWindowKeepScreenOn(true)
+ .catch((err: BusinessError) => {
+ hilog.error(0x0000, 'testTag',`setWindowKeepScreenOn failed, Code:${err.code}, message:${err.message}`);
+ })
+ })
+ .catch((err: BusinessError) => {
+ hilog.error(0x0000, 'testTag',`getLastWindow failed, Code:${err.code}, message:${err.message}`);
+ })
+
this.windowUtil.registerOnWindowSizeChange((size) => {
if (size.width > size.height) {
this.isFullLandscapeScreen = true;
diff --git a/HDRVivid/AVPlayer/entry/src/main/ets/utils/WindowUtil.ets b/HDRVivid/AVPlayer/entry/src/main/ets/utils/WindowUtil.ets
index e41aaf59..db2a5fd9 100644
--- a/HDRVivid/AVPlayer/entry/src/main/ets/utils/WindowUtil.ets
+++ b/HDRVivid/AVPlayer/entry/src/main/ets/utils/WindowUtil.ets
@@ -14,7 +14,7 @@
*/
import { window } from '@kit.ArkUI';
-import { CommonConstants, Logger } from '@ohos/MediaService';
+import { Logger } from '@ohos/MediaService';
import { BusinessError } from '@kit.BasicServicesKit';
const TAG: string = '[WindowUtil]';
@@ -40,15 +40,19 @@ export class WindowUtil {
return;
}
this.mainWindowClass = windowClass;
- const properties = windowClass.getWindowProperties();
- // Get status bar height.
- let area: window.AvoidArea = windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM);
- let naviBarArea: window.AvoidArea =
- windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR);
- AppStorage.setOrCreate('deviceWidth', properties.windowRect.width);
- AppStorage.setOrCreate('deviceHeight', properties.windowRect.height);
- AppStorage.setOrCreate('statusBarHeight', uiContext?.px2vp(area.topRect.height));
- AppStorage.setOrCreate('navBarHeight', uiContext?.px2vp(naviBarArea.bottomRect.height));
+ try {
+ const properties = windowClass.getWindowProperties();
+ // Get status bar height.
+ let area: window.AvoidArea = windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM);
+ let naviBarArea: window.AvoidArea =
+ windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR);
+ AppStorage.setOrCreate('deviceWidth', properties.windowRect.width);
+ AppStorage.setOrCreate('deviceHeight', properties.windowRect.height);
+ AppStorage.setOrCreate('statusBarHeight', uiContext?.px2vp(area.topRect.height));
+ AppStorage.setOrCreate('navBarHeight', uiContext?.px2vp(naviBarArea.bottomRect.height));
+ } catch (error) {
+ Logger.error(`getWindowProperties or getWindowAvoidArea failed, Code:${err.code}, message:${err.message}`);
+ }
});
}
@@ -71,7 +75,10 @@ export class WindowUtil {
return;
}
// Set the status bar and navigation bar to be invisible in full-screen mode.
- this.mainWindowClass.setWindowSystemBarEnable([]);
+ this.mainWindowClass.setWindowSystemBarEnable([])
+ .catch((err: BusinessError) => {
+ Logger.error(TAG, `setWindowSystemBarEnable failed, Code:${err.code}, message:${err.message}`);
+ })
}
enableWindowSystemBar(): void {
@@ -79,7 +86,10 @@ export class WindowUtil {
Logger.error(`MainWindowClass is undefined`);
return;
}
- this.mainWindowClass.setWindowSystemBarEnable(['status', 'navigation']);
+ this.mainWindowClass.setWindowSystemBarEnable(['status', 'navigation'])
+ .catch((err: BusinessError) => {
+ Logger.error(TAG, `setWindowSystemBarEnable failed, Code:${err.code}, message:${err.message}`);
+ })
}
setLandscapeMultiWindow(enable: boolean) {
@@ -88,9 +98,15 @@ export class WindowUtil {
return;
}
if (enable) {
- this.mainWindowClass?.enableLandscapeMultiWindow();
+ this.mainWindowClass?.enableLandscapeMultiWindow()
+ .catch((err: BusinessError) => {
+ Logger.error(TAG, `enableLandscapeMultiWindow failed, Code:${err.code}, message:${err.message}`);
+ })
} else {
- this.mainWindowClass?.disableLandscapeMultiWindow();
+ this.mainWindowClass?.disableLandscapeMultiWindow()
+ .catch((err: BusinessError) => {
+ Logger.error(TAG, `disableLandscapeMultiWindow failed, Code:${err.code}, message:${err.message}`);
+ })
}
}
diff --git a/HDRVivid/AVPlayer/entry/src/main/ets/view/AVPlayer.ets b/HDRVivid/AVPlayer/entry/src/main/ets/view/AVPlayer.ets
index e0f634bf..5d1a6ab0 100644
--- a/HDRVivid/AVPlayer/entry/src/main/ets/view/AVPlayer.ets
+++ b/HDRVivid/AVPlayer/entry/src/main/ets/view/AVPlayer.ets
@@ -65,27 +65,33 @@ export struct VideoPlayer {
private screenHeight: number = 0;
private windowStage: window.WindowStage = AppStorage.get('windowStage') as window.WindowStage;
// Get the main window.
- private mainWin: window.Window = this.windowStage.getMainWindowSync();
+ private mainWin: window.Window | null = null;
uiContext = this.getUIContext()
aboutToAppear(): void {
+ try {
+ this.mainWin = this.windowStage.getMainWindowSync();
+ } catch (error) {
+ hilog.error(0x0000, 'AVPlayer', `getMainWindowSync failed. Cause code: ${error.code}, message: ${error.message}`);
+ }
const context = this.uiContext.getHostContext() as common.UIAbilityContext;
- ;
settings.getValue(context, settings.display.SCREEN_BRIGHTNESS_STATUS, settings.domainName.DEVICE_SHARED)
.then((value) => {
hilog.info(0x0000, 'AVPlayer', `Promise:value -> ${JSON.stringify(value)}`);
this.screenBrightness = Number(value) / 255;
})
- try {
- window.getLastWindow(context).then((data) => {
- this.screenHeight = data?.getWindowProperties().windowRect.height;
- });
- } catch (exception) {
- hilog.error(0x0000, 'AVPlayer',
- `Failed to obtain the top window. Cause code: ${exception.code}, message: ${exception.message}`);
- }
-
+ window.getLastWindow(context)
+ .then((data) => {
+ try {
+ this.screenHeight = data?.getWindowProperties().windowRect.height;
+ } catch (exception) {
+ hilog.error(0x0000, 'AVPlayer', `Failed to obtain the top window. Cause code: ${exception.code}, message: ${exception.message}`);
+ }
+ })
+ .catch((error: BusinessError) => {
+ hilog.error(0x0000, 'AVPlayer', `Failed to obtain the top window. Cause code: ${error.code}, message: ${error.message}`);
+ })
let groupId: number = audio.DEFAULT_VOLUME_GROUP_ID;
let audioManager = audio.getAudioManager();
let audioVolumeManger: audio.AudioVolumeManager = audioManager.getVolumeManager();
@@ -308,7 +314,7 @@ export struct VideoPlayer {
hilog.info(0x0000, 'AVPlayer', `this brightness is: ` + this.screenBrightness);
try {
- this.mainWin.setWindowBrightness(this.screenBrightness, (err) => {
+ this.mainWin?.setWindowBrightness(this.screenBrightness, (err) => {
if (err) {
hilog.error(0x0000, 'AVPlayer', `Failed to set the brightness. Cause: ${JSON.stringify(err)}`);
return;
@@ -481,10 +487,14 @@ export struct VideoPlayer {
.selectedBorderRadius(CommonConstants.TRACK_BORDER_RADIUS)
.zIndex(CommonConstants.SLIDER_INDEX)
.onAreaChange(() => {
- let videoSlider: componentUtils.ComponentInfo = this.getUIContext().getComponentUtils().getRectangleById('video_slider');
- this.slideWidth = this.uiContext.px2vp(videoSlider.size.width);
- this.offsetY = this.uiContext.px2vp(videoSlider.localOffset.y);
- this.beginX = this.uiContext.px2vp(videoSlider.localOffset.x);
+ try {
+ let videoSlider: componentUtils.ComponentInfo = this.getUIContext().getComponentUtils().getRectangleById('video_slider');
+ this.slideWidth = this.uiContext.px2vp(videoSlider.size.width);
+ this.offsetY = this.uiContext.px2vp(videoSlider.localOffset.y);
+ this.beginX = this.uiContext.px2vp(videoSlider.localOffset.x);
+ } catch (error) {
+ hilog.error(0x0000, 'testTag',`getRectangleById failed, Code:${error.code}, message:${error.message}`);
+ }
})
.onChange((value: number, mode: SliderChangeMode) => {
this.sliderOnchange(value, mode);
@@ -559,8 +569,16 @@ export struct VideoPlayer {
this.isTimeDisplay = 0;
this.trackThicknessSize = CommonConstants.TRACK_SIZE_MIN;
let context = this.uiContext.getHostContext() as common.UIAbilityContext;
- let windowClass = await window.getLastWindow(context);
- await windowClass.setWindowKeepScreenOn(false);
+ await window.getLastWindow(context)
+ .then((windowClass: window.Window) => {
+ windowClass.setWindowKeepScreenOn(false)
+ .catch((err: BusinessError) => {
+ hilog.error(0x0000, 'testTag',`setWindowKeepScreenOn failed, Code:${err.code}, message:${err.message}`);
+ })
+ })
+ .catch((err: BusinessError) => {
+ hilog.error(0x0000, 'testTag',`getLastWindow failed, Code:${err.code}, message:${err.message}`);
+ })
return;
}
if (this.avPlayerController.isReady === true) {
@@ -580,8 +598,16 @@ export struct VideoPlayer {
}, CommonConstants.TIMER_INTERVAL);
}
let context = this.uiContext.getHostContext() as common.UIAbilityContext;
- let windowClass = await window.getLastWindow(context);
- await windowClass.setWindowKeepScreenOn(true);
+ await window.getLastWindow(context)
+ .then((windowClass: window.Window) => {
+ windowClass.setWindowKeepScreenOn(true)
+ .catch((err: BusinessError) => {
+ hilog.error(0x0000, 'testTag',`setWindowKeepScreenOn failed, Code:${err.code}, message:${err.message}`);
+ })
+ })
+ .catch((err: BusinessError) => {
+ hilog.error(0x0000, 'testTag',`getLastWindow failed, Code:${err.code}, message:${err.message}`);
+ })
}
aboutToDisappear(): void {
diff --git a/HDRVivid/AVPlayer/entry/src/main/ets/view/VideoDetails.ets b/HDRVivid/AVPlayer/entry/src/main/ets/view/VideoDetails.ets
index cb0a6273..3c4b0f72 100644
--- a/HDRVivid/AVPlayer/entry/src/main/ets/view/VideoDetails.ets
+++ b/HDRVivid/AVPlayer/entry/src/main/ets/view/VideoDetails.ets
@@ -13,6 +13,7 @@
* limitations under the License.
*/
import { CommonConstants as Const, VideoData } from '@ohos/MediaService';
+import { hilog } from '@kit.PerformanceAnalysisKit';
@Component({ freezeWhenInactive: true })
export struct VideoDetails {
@@ -129,7 +130,11 @@ export struct VideoDetails {
.opacity($r('app.float.opacity_4'))
}
.onClick(() => {
- this.getPromptAction.showToast({ message: $r('app.string.comment'), duration: Const.TOAST_DURATION });
+ try {
+ this.getPromptAction.showToast({ message: $r('app.string.comment'), duration: Const.TOAST_DURATION })
+ } catch (error) {
+ hilog.error(0x0000, 'testTag',`getPromptAction showToast failed, Code:${error.code}, message:${error.message}`);
+ }
})
Column() {
@@ -143,7 +148,11 @@ export struct VideoDetails {
.opacity($r('app.float.opacity_4'))
}
.onClick(() => {
- this.getPromptAction.showToast({ message: $r('app.string.share'), duration: Const.TOAST_DURATION });
+ try {
+ this.getPromptAction.showToast({ message: $r('app.string.share'), duration: Const.TOAST_DURATION });
+ } catch (error) {
+ hilog.error(0x0000, 'testTag',`getPromptAction showToast failed, Code:${error.code}, message:${error.message}`);
+ }
})
}
.width(Const.FULL_SIZE)
diff --git a/HDRVivid/AVPlayer/entry/src/main/ets/view/VideoSide.ets b/HDRVivid/AVPlayer/entry/src/main/ets/view/VideoSide.ets
index 53b8adbb..9b8d2434 100644
--- a/HDRVivid/AVPlayer/entry/src/main/ets/view/VideoSide.ets
+++ b/HDRVivid/AVPlayer/entry/src/main/ets/view/VideoSide.ets
@@ -14,6 +14,7 @@
*/
import { CommonConstants as Const, VideoData } from '@ohos/MediaService';
+import { hilog } from '@kit.PerformanceAnalysisKit';
@Component
export struct RightSide {
@@ -91,7 +92,11 @@ export struct RightSide {
.fillColor(Color.White)
.margin({ bottom: $r('app.float.fabulous_margin_bottom') })
.onClick(() => {
- this.getPromptAction.showToast({ message: $r('app.string.comment'), duration: Const.TOAST_DURATION });
+ try {
+ this.getPromptAction.showToast({ message: $r('app.string.comment'), duration: Const.TOAST_DURATION });
+ } catch (error) {
+ hilog.error(0x0000, 'testTag',`getPromptAction showToast failed, Code:${error.code}, message:${error.message}`);
+ }
})
Text(this.item.commentCount)
.fontSize($r('app.float.fabulous_font_size'))
@@ -114,7 +119,11 @@ export struct RightSide {
.width($r('app.float.avatar_size'))
.alignItems(HorizontalAlign.Center)
.onClick(() => {
- this.getPromptAction.showToast({ message: $r('app.string.share'), duration: Const.TOAST_DURATION });
+ try {
+ this.getPromptAction.showToast({ message: $r('app.string.share'), duration: Const.TOAST_DURATION });
+ } catch (error) {
+ hilog.error(0x0000, 'testTag',`getPromptAction showToast failed, Code:${error.code}, message:${error.message}`);
+ }
})
}
.margin({ bottom: $r('app.float.video_side_margin_bottom'), right: $r('app.float.right_space') })
--
Gitee