diff --git a/.gitee/ISSUE_TEMPLATE.zh-CN.md b/.gitee/ISSUE_TEMPLATE.zh-CN.md
deleted file mode 100755
index f09d98d..0000000
--- a/.gitee/ISSUE_TEMPLATE.zh-CN.md
+++ /dev/null
@@ -1,13 +0,0 @@
-### 该问题是怎么引起的?
-
-
-
-### 重现步骤
-
-
-
-### 报错信息
-
-
-
-
diff --git a/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md
deleted file mode 100755
index 33948fd..0000000
--- a/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md
+++ /dev/null
@@ -1,15 +0,0 @@
-### 相关的Issue
-
-
-### 原因(目的、解决的问题等)
-
-
-### 描述(做了什么,变更了什么)
-
-
-### 测试用例(新增、改动、可能影响的功能)
-
-
-
-
-
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..140896a
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+communication
+screensaver
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
old mode 100755
new mode 100644
index 4947287..4a45986
--- a/LICENSE
+++ b/LICENSE
@@ -1,177 +1,177 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
END OF TERMS AND CONDITIONS
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..1f82e33
--- /dev/null
+++ b/README.md
@@ -0,0 +1,53 @@
+# CAMERA\_SAMPLE\_APP
+
+- [Introduction](#section11660541593)
+- [Directory Structure](#section176641621345)
+- [Usage](#section1648194512427)
+- [Constraints](#section722512541395)
+- [Repositories Involved](#section16511040154318)
+
+## Introduction
+
+This repository provides media-related applications, such as the home screen and settings.
+
+**Figure 1** Position of this repository \(in the dotted blue box\) in the multimedia subsystem
+-in-the-multimedia-subsystem.png "position-of-this-repository-(in-the-dotted-blue-box)-in-the-multimedia-subsystem")
+
+## Directory Structure
+
+```
+applications/sample/camera
+├── cameraApp # Camera app
+├── gallery # Photo gallery
+├── launcher # Home screen
+├── media # Apps of photographing, video recording, and audio and video playback
+└── setting # Settings
+```
+
+## Usage
+
+Build a single repository in the root directory.
+
+```
+# Select the development board.
+hb set
+# Build this repository.
+hb build camera_lite
+```
+
+## Constraints
+
+C++ 11 or later
+
+## Repositories Involved
+
+/hmf/multimedia/camera\_lite
+
+/hmf/multimedia/audio\_lite
+
+/hmf/multimedia/media\_lite
+
+/hmf/multimedia/utils\_lite
+
+/hmf/multimedia/service\_lite
+
diff --git a/README_zh.md b/README_zh.md
new file mode 100644
index 0000000..e1cefd8
--- /dev/null
+++ b/README_zh.md
@@ -0,0 +1,53 @@
+# 媒体子系统CAMERA\_SAMPLE\_APP组件
+
+- [简介](#section11660541593)
+- [目录](#section176641621345)
+- [使用说明](#section1648194512427)
+- [约束](#section722512541395)
+- [相关仓](#section16511040154318)
+
+## 简介
+
+CAMERA\_SAMPLE\_APP组件,提供媒体能力开发的相关应用,提供桌面应用和设置应用。
+
+**图 1** 媒体子系统架构(蓝色虚线框是sample\_app)
+.png "媒体子系统架构(蓝色虚线框是sample_app)")
+
+## 目录
+
+```
+applications/sample/camera
+├── cameraApp 相机应用
+├── gallery 图库应用
+├── launcher 桌面应用
+├── media 拍照录像应用和音视频播放应用
+└── setting 设置
+```
+
+## 使用说明
+
+单仓的编译构建,在根目录下进行单仓的构建和编译
+
+```
+# 开发板选择
+hb set
+# 单仓构建和编译
+hb build camera_lite
+```
+
+## 约束
+
+C++11版本或以上
+
+## 相关仓
+
+/hmf/multimedia/camera\_lite
+
+/hmf/multimedia/audio\_lite
+
+/hmf/multimedia/media\_lite
+
+/hmf/multimedia/utils\_lite
+
+/hmf/multimedia/service\_lite
+
diff --git a/app/BUILD.gn b/app/BUILD.gn
deleted file mode 100755
index 5304267..0000000
--- a/app/BUILD.gn
+++ /dev/null
@@ -1,43 +0,0 @@
-# Copyright (c) 2020 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("//build/lite/config/component/lite_component.gni")
-import("//build/lite/ndk/ndk.gni")
-
-static_library("hello_world") {
- sources = [
- "src/helloworld.c",
- "src/los_sample.c"
- ]
-
- include_dirs = [
- "include",
- ]
-}
-
-lite_component("camera_app") {
- target_type = "executable"
-
- features = [
- ":hello_world",
- ]
-}
-
-ndk_lib("app_sample") {
- deps = [
- ":hello_world"
- ]
- head_files = [
- "include"
- ]
-}
diff --git a/app/include/los_sample.h b/app/include/los_sample.h
deleted file mode 100755
index 965c8ed..0000000
--- a/app/include/los_sample.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2020 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.
- */
-
-#ifndef _LOS_SAMPLE_H
-#define _LOS_SAMPLE_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-extern int g_num;
-
-extern void LOS_Sample(int param);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* _LOS_SAMPLE_H */
\ No newline at end of file
diff --git a/app/src/helloworld.c b/app/src/helloworld.c
deleted file mode 100755
index 5e03ab9..0000000
--- a/app/src/helloworld.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2020 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.
- */
-
-#include
-#include "los_sample.h"
-
-int main(int argc, char **argv)
-{
- printf("\n************************************************\n");
- printf("\n\t\tHello OHOS!\n");
- printf("\n************************************************\n\n");
-
- LOS_Sample(g_num);
-
- return 0;
-}
diff --git a/app/src/los_sample.c b/app/src/los_sample.c
deleted file mode 100755
index 265c3c7..0000000
--- a/app/src/los_sample.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2020 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.
- */
-
-#include
-
-int g_num = 81;
-void LOS_Sample(int param)
-{
- printf("This is a sample: Param = %d\n", param);
-}
diff --git a/cameraApp/BUILD.gn b/cameraApp/BUILD.gn
old mode 100644
new mode 100755
index aaf41d3..6447fd7
--- a/cameraApp/BUILD.gn
+++ b/cameraApp/BUILD.gn
@@ -11,68 +11,59 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import("//build/lite/config/component/lite_component.gni")
import("//build/lite/config/hap_pack.gni")
shared_library("cameraApp") {
- sources = [
- "cameraApp/src/main/cpp/camera_ability.cpp",
- "cameraApp/src/main/cpp/camera_ability_slice.cpp",
- "cameraApp/src/main/cpp/camera_manager.cpp"
- ]
+ sources = [
+ "cameraApp/src/main/cpp/camera_ability.cpp",
+ "cameraApp/src/main/cpp/camera_ability_slice.cpp",
+ "cameraApp/src/main/cpp/camera_manager.cpp",
+ ]
- deps = [
- "//foundation/aafwk/frameworks/ability_lite:aafwk_abilitykit_lite",
- "//foundation/appexecfwk/frameworks/bundle_lite:bundle",
- "//foundation/communication/frameworks/ipc_lite:liteipc_adapter",
- "//foundation/distributedschedule/services/samgr_lite/samgr:samgr",
- "//utils/native/lite/kv_store:kv_store",
- "//foundation/graphic/lite/frameworks/ui:ui",
- "//foundation/graphic/lite/utils:graphic_utils",
- "//foundation/graphic/lite/frameworks/surface",
- "//foundation/multimedia/frameworks/camera_lite:camera",
- "//foundation/multimedia/frameworks/recorder_lite:recorder",
- ]
+ deps = [
+ "${aafwk_lite_path}/frameworks/ability_lite:aafwk_abilitykit_lite",
+ "${appexecfwk_lite_path}/frameworks/bundle_lite:bundle",
+ "//foundation/communication/ipc_lite:liteipc_adapter",
+ "//foundation/distributedschedule/samgr_lite/samgr:samgr",
+ "//foundation/graphic/surface",
+ "//foundation/graphic/ui:lite_ui",
+ "//foundation/graphic/utils:lite_graphic_utils",
+ "//foundation/multimedia/camera_lite/frameworks:camera_lite",
+ "//foundation/multimedia/media_lite/frameworks/recorder_lite:recorder_lite",
+ "//utils/native/lite/kv_store:kv_store",
+ ]
- include_dirs = [
- "cameraApp/src/main/cpp",
- "//foundation/aafwk/interfaces/kits/ability_lite",
- "//foundation/graphic/lite/interfaces/kits/ui/components",
- "//foundation/graphic/lite/interfaces/kits/ui",
- "//foundation/graphic/lite/interfaces/kits/utils",
- "//foundation/graphic/lite/interfaces/kits/config",
- "//foundation/appexecfwk/interfaces/kits/bundle_lite",
- "//foundation/aafwk/interfaces/kits/want_lite",
- "//base/startup/interfaces/kits/syspara_lite",
- "//foundation/multimedia/interfaces/kits/camera_lite",
- "//foundation/multimedia/interfaces/kits/camera_lite"
- ]
- ldflags = [
- "-L$ohos_root_path/sysroot/usr/lib",
- "-Wl,-rpath-link=$ohos_root_path/sysroot/usr/lib",
- "-lstdc++", "-lcamera", "-lsurface", "-lrecorder"
- ]
- defines = [
- "ENABLE_WINDOW=1",
- "ABILITY_WINDOW_SUPPORT"
- ]
+ include_dirs = [
+ "cameraApp/src/main/cpp",
+ "${aafwk_lite_path}/interfaces/kits/ability_lite",
+ "${appexecfwk_lite_path}/interfaces/kits/bundle_lite",
+ "${aafwk_lite_path}/interfaces/kits/want_lite",
+ "//base/startup/syspara_lite/interfaces/kits",
+ "//foundation/multimedia/camera_lite/interfaces/kits",
+ "//foundation/multimedia/camera_lite/interfaces/kits",
+ ]
+ ldflags = [
+ "-L$ohos_root_path/sysroot/usr/lib",
+ "-Wl,-rpath-link=$ohos_root_path/sysroot/usr/lib",
+ "-lstdc++",
+ "-lcamera_lite",
+ "-lsurface",
+ "-lrecorder_lite",
+ ]
+ defines = [
+ "ENABLE_WINDOW=1",
+ "ABILITY_WINDOW_SUPPORT",
+ ]
}
-lite_component("cameraApp_component") {
-
- features = [
- ":cameraApp",
- ]
-}
-
-hap_pack("cameraApp_hap")
-{
- deps = [":cameraApp"]
- mode = "hap"
- json_path = "cameraApp/src/main/config.json"
- ability_so_path = "$root_out_dir/libcameraApp.so"
- force = "true"
- cert_profile = "cert/camera_HarmonyAppProvision_Release.p7b"
- resources_path = "cameraApp/src/main/resources"
- hap_name = "cameraApp"
+hap_pack("cameraApp_hap") {
+ deps = [ ":cameraApp" ]
+ mode = "hap"
+ json_path = "cameraApp/src/main/config.json"
+ ability_so_path = "$root_out_dir/libcameraApp.so"
+ force = "true"
+ cert_profile = "cert/camera_HarmonyAppProvision_Release.p7b"
+ resources_path = "cameraApp/src/main/resources"
+ hap_name = "cameraApp"
+ privatekey = "HOS Application Provision Release"
}
diff --git a/cameraApp/cameraApp/src/main/config.json b/cameraApp/cameraApp/src/main/config.json
old mode 100644
new mode 100755
index 37cf09c..af152f4
--- a/cameraApp/cameraApp/src/main/config.json
+++ b/cameraApp/cameraApp/src/main/config.json
@@ -1,99 +1,99 @@
-{
- "app": {
- "bundleName": "com.huawei.camera",
- "vendor": "huawei",
- "version": {
- "code": 2,
- "name": "2"
- },
- "apiVersion": {
- "compatible": 3,
- "target": 4
- }
- },
- "deviceConfig": {
- "default": {
- }
- },
- "module": {
- "package": "com.huawei.camera",
- "name": ".MyHarmonyAbilityPackage",
- "deviceType": [
- "phone",
- "tv",
- "tablet",
- "pc",
- "car",
- "smartWatch",
- "sportsWatch",
- "smartVision"
- ],
- "distro": {
- "deliveryWithInstall": true,
- "moduleName": "cameraApp",
- "moduleType": "entry"
- },
- "abilities": [
- {
- "name": "CameraAbility",
- "icon": "assets/cameraApp/resources/base/media/camera.png",
- "label": "test app 1",
- "launchType": "standard",
- "type": "page",
- "visible": true
- }
- ],
- "reqPermissions": [
- {
- "name": "ohos.permission.CAMERA",
- "reason": "USER_GRANT",
- "usedScene": {
- "ability": [
- ".FormAbility"
- ],
- "when": "inuse"
- }
- },
- {
- "name": "ohos.permission.MODIFY_AUDIO_SETTINGS",
- "reason": "SYSTEM_GRANT",
- "usedScene": {
- "ability": [
- ".FormAbility"
- ],
- "when": "inuse"
- }
- },
- {
- "name": "ohos.permission.READ_MEDIA",
- "reason": "USER_GRANT",
- "usedScene": {
- "ability": [
- ".FormAbility"
- ],
- "when": "inuse"
- }
- },
- {
- "name": "ohos.permission.MICROPHONE",
- "reason": "USER_GRANT",
- "usedScene": {
- "ability": [
- ".FormAbility"
- ],
- "when": "inuse"
- }
- },
- {
- "name": "ohos.permission.WRITE_MEDIA",
- "reason": "USER_GRANT",
- "usedScene": {
- "ability": [
- ".FormAbility"
- ],
- "when": "inuse"
- }
- }
- ]
- }
-}
+{
+ "app": {
+ "bundleName": "com.huawei.camera",
+ "vendor": "huawei",
+ "version": {
+ "code": 2,
+ "name": "2"
+ },
+ "apiVersion": {
+ "compatible": 3,
+ "target": 4
+ }
+ },
+ "deviceConfig": {
+ "default": {
+ }
+ },
+ "module": {
+ "package": "com.huawei.camera",
+ "name": ".MyHarmonyAbilityPackage",
+ "deviceType": [
+ "phone",
+ "tv",
+ "tablet",
+ "pc",
+ "car",
+ "smartWatch",
+ "sportsWatch",
+ "smartVision"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "cameraApp",
+ "moduleType": "entry"
+ },
+ "abilities": [
+ {
+ "name": "CameraAbility",
+ "icon": "assets/cameraApp/resources/base/media/camera.png",
+ "label": "test app 1",
+ "launchType": "standard",
+ "type": "page",
+ "visible": true
+ }
+ ],
+ "reqPermissions": [
+ {
+ "name": "ohos.permission.CAMERA",
+ "reason": "USER_GRANT",
+ "usedScene": {
+ "ability": [
+ ".FormAbility"
+ ],
+ "when": "inuse"
+ }
+ },
+ {
+ "name": "ohos.permission.MODIFY_AUDIO_SETTINGS",
+ "reason": "SYSTEM_GRANT",
+ "usedScene": {
+ "ability": [
+ ".FormAbility"
+ ],
+ "when": "inuse"
+ }
+ },
+ {
+ "name": "ohos.permission.READ_MEDIA",
+ "reason": "USER_GRANT",
+ "usedScene": {
+ "ability": [
+ ".FormAbility"
+ ],
+ "when": "inuse"
+ }
+ },
+ {
+ "name": "ohos.permission.MICROPHONE",
+ "reason": "USER_GRANT",
+ "usedScene": {
+ "ability": [
+ ".FormAbility"
+ ],
+ "when": "inuse"
+ }
+ },
+ {
+ "name": "ohos.permission.WRITE_MEDIA",
+ "reason": "USER_GRANT",
+ "usedScene": {
+ "ability": [
+ ".FormAbility"
+ ],
+ "when": "inuse"
+ }
+ }
+ ]
+ }
+}
diff --git a/cameraApp/cameraApp/src/main/cpp/camera_ability.cpp b/cameraApp/cameraApp/src/main/cpp/camera_ability.cpp
old mode 100644
new mode 100755
diff --git a/cameraApp/cameraApp/src/main/cpp/camera_ability.h b/cameraApp/cameraApp/src/main/cpp/camera_ability.h
old mode 100644
new mode 100755
diff --git a/cameraApp/cameraApp/src/main/cpp/camera_ability_slice.cpp b/cameraApp/cameraApp/src/main/cpp/camera_ability_slice.cpp
old mode 100644
new mode 100755
index c757642..5cbfdcf
--- a/cameraApp/cameraApp/src/main/cpp/camera_ability_slice.cpp
+++ b/cameraApp/cameraApp/src/main/cpp/camera_ability_slice.cpp
@@ -36,8 +36,8 @@ class SliderAnimator : public Animator, public AnimatorCallback {
public:
explicit SliderAnimator(UISlider *slider, UIImageView *backview, UISurfaceView *surface,
SampleCameraManager *cManager, uint16_t duration)
- : Animator(this, slider, duration, true), slider_(slider), backgroundView_(backview), mSurfaceview(surface),
- camManager(cManager), duration_(duration) {}
+ : Animator(this, slider, duration, true), backgroundView_(backview), mSurfaceview(surface),
+ camManager(cManager), ss(0), runType_(0), camRestart(false) {}
virtual ~SliderAnimator() {}
void Callback(UIView *view) override
@@ -92,12 +92,10 @@ public:
}
private:
UIImageView *backgroundView_;
- UISlider *slider_;
UISurfaceView *mSurfaceview;
SampleCameraManager *camManager;
- uint32_t duration_;
- uint32_t ss = 0;
- uint32_t runType_ = 0;
+ uint32_t ss;
+ uint32_t runType_;
bool camRestart;
void BackViewSetImage(const char *image)
@@ -115,7 +113,7 @@ private:
scaleHeight = static_cast(SCREEN_HEIGHT) / imageHeight;
float scale = (scaleWidth < scaleHeight) ? scaleWidth : scaleHeight;
- transMap.Scale(Vector2(scale, scale), Vector2(0, 0));
+ transMap.Scale(Vector2(scale, scale), Vector2(0, 0));
backgroundView_->SetTransformMap(transMap);
backgroundView_->SetTransformAlgorithm(TransformAlgorithm::NEAREST_NEIGHBOR);
imageWidth = imageWidth * scale;
@@ -131,13 +129,16 @@ class CameraImageButtonOnClickListener : public UIView::OnClickListener {
public:
CameraImageButtonOnClickListener(UIView *uiView, UISurfaceView *surface,
UIImageView *iamgeview, TaskView *taskView, SliderAnimator *animator) : uiView_(uiView),
- mSurfaceview(surface), backgroundView_(iamgeview), gTaskView_(taskView), animator_(animator)
+ backgroundView_(iamgeview), mSurfaceview(surface), animator_(animator), gTaskView_(taskView)
{
+ cManager_ = nullptr;
bttnLeft = nullptr;
bttnRight = nullptr;
bttnMidle = nullptr;
bttnRecord = nullptr;
recordImage = nullptr;
+ tmLabel = nullptr;
+ bttnIdx_ = 0;
}
virtual ~CameraImageButtonOnClickListener(){}
@@ -221,6 +222,7 @@ private:
UIImageView *backgroundView_;
UISurfaceView *mSurfaceview;
SliderAnimator *animator_;
+ TaskView *gTaskView_;
int16_t bttnIdx_;
SampleCameraManager *cManager_;
@@ -230,7 +232,6 @@ private:
UIImageView *bttnRecord;
UIImageView *recordImage;
UILabel *tmLabel;
- TaskView *gTaskView_;
void StartGallery(void)
{
Want want1 = { nullptr };
@@ -327,7 +328,7 @@ private:
scaleHeight = static_cast(SCREEN_HEIGHT) / imageHeight;
float scale = (scaleWidth < scaleHeight) ? scaleWidth : scaleHeight;
- transMap.Scale(Vector2(scale, scale), Vector2(0, 0));
+ transMap.Scale(Vector2(scale, scale), Vector2(0, 0));
backgroundView_->SetTransformMap(transMap);
backgroundView_->SetTransformAlgorithm(TransformAlgorithm::NEAREST_NEIGHBOR);
imageWidth = imageWidth * scale;
@@ -498,8 +499,8 @@ void CameraAbilitySlice::OnStart(const Want &want)
background_->SetVisible(true);
background_->Invalidate();
- cam_manager = new SampleCameraManager(0);
- cam_manager->SampleCameraCreate(0);
+ cam_manager = new SampleCameraManager();
+ cam_manager->SampleCameraCreate();
SetHead();
diff --git a/cameraApp/cameraApp/src/main/cpp/camera_ability_slice.h b/cameraApp/cameraApp/src/main/cpp/camera_ability_slice.h
old mode 100644
new mode 100755
diff --git a/cameraApp/cameraApp/src/main/cpp/camera_manager.cpp b/cameraApp/cameraApp/src/main/cpp/camera_manager.cpp
old mode 100644
new mode 100755
index 0c6fc92..f61383e
--- a/cameraApp/cameraApp/src/main/cpp/camera_manager.cpp
+++ b/cameraApp/cameraApp/src/main/cpp/camera_manager.cpp
@@ -30,13 +30,15 @@ static constexpr int TEMP_BUF_LEN = 8;
static constexpr int MAX_THM_SIZE = (64 * PAGE_SIZE);
static constexpr int FILE_NAME_LEN = 128;
static constexpr int MILLI_SECONDS = 1000;
+static constexpr int PIC_WIDTH = 1920;
+static constexpr int PIC_HEIGHT = 1080;
char* g_dstBuf = nullptr;
static int32_t SampleDealThumb(char* psrc, uint32_t srcSize, uint32_t* dstSize, uint16_t u16THMLen)
{
int32_t endpos = 0;
- int32_t s32I = 0;
+ uint32_t s32I = 0;
int32_t startpos = 0;
char tempbuf[TEMP_BUF_LEN] = { 0 };
int32_t bufpos = 0;
@@ -44,6 +46,9 @@ static int32_t SampleDealThumb(char* psrc, uint32_t srcSize, uint32_t* dstSize,
char endflag[2] = { 0xff, 0xd9 };
while (s32I < srcSize) {
+ if (bufpos >= TEMP_BUF_LEN) {
+ break;
+ }
tempbuf[bufpos] = psrc[s32I++];
if (bufpos > 0) {
if (0 == memcmp(tempbuf + bufpos - 1, startflag, sizeof(startflag))) {
@@ -55,15 +60,13 @@ static int32_t SampleDealThumb(char* psrc, uint32_t srcSize, uint32_t* dstSize,
if (0 == memcmp(tempbuf + bufpos - 1, endflag, sizeof(endflag))) {
if (u16THMLen == s32I) {
endpos = s32I;
- break;
} else {
endpos = s32I;
- break;
}
+ break;
}
}
- bufpos++;
- if (bufpos == (TEMP_BUF_LEN - 1)) {
+ if (++bufpos == (TEMP_BUF_LEN - 1)) {
if (tempbuf[bufpos - 1] != 0xFF) {
bufpos = 0;
}
@@ -72,7 +75,7 @@ static int32_t SampleDealThumb(char* psrc, uint32_t srcSize, uint32_t* dstSize,
}
}
- if ((endpos - startpos <= 0) || (endpos - startpos >= srcSize)) {
+ if ((endpos - startpos <= 0) || (static_cast(endpos - startpos) >= srcSize)) {
return -1;
}
@@ -93,9 +96,8 @@ static int32_t SampleDealThumb(char* psrc, uint32_t srcSize, uint32_t* dstSize,
return 0;
}
-static int32_t SampleGetThmFromJpg(char* jpegPath, uint32_t* dstSize)
+static int32_t SampleGetThmFromJpg(const char* jpegPath, uint32_t* dstSize)
{
- int32_t s32RtnVal = 0;
FILE* fpJpg = nullptr;
fpJpg = fopen(jpegPath, "rb");
char* pszFile = nullptr;
@@ -111,6 +113,10 @@ static int32_t SampleGetThmFromJpg(char* jpegPath, uint32_t* dstSize)
pszFile = (char*)malloc(stStat.st_size);
if ((pszFile == nullptr) || (stStat.st_size < 6)) { /* 6 min size of thumb head */
fclose(fpJpg);
+ if (pszFile) {
+ free(pszFile);
+ pszFile = nullptr;
+ }
printf("memory malloc fail!\n");
return -1;
}
@@ -124,7 +130,8 @@ static int32_t SampleGetThmFromJpg(char* jpegPath, uint32_t* dstSize)
fclose(fpJpg);
// The fourth byte is shifted to the left by eight bits then the fifth byte is added.
- uint16_t u16THMLen = (pszFile[4] << 8) + pszFile[5];
+ // the 4 byte is the length high 8 bit, and byte 5 is low 8bit;
+ uint16_t u16THMLen = (static_cast(pszFile[4]) << 8) + pszFile[5];
if (SampleDealThumb(pszFile, stStat.st_size, dstSize, u16THMLen) < 0) {
printf("get jpg thumb failed! \n");
free(pszFile);
@@ -146,7 +153,7 @@ int32_t SampleGetdcfinfo(const char* srcJpgPath, const char* dstThmPath)
if (sprintf_s(jpegDesPath, sizeof(jpegDesPath), "%s", dstThmPath) < 0) {
return -1;
}
- s32RtnVal = SampleGetThmFromJpg(jpegSrcPath, &dstSize);
+ s32RtnVal = SampleGetThmFromJpg(static_cast(jpegSrcPath), &dstSize);
if ((s32RtnVal != 0) || (dstSize == 0)) {
printf("fail to get thm\n");
return -1;
@@ -156,7 +163,7 @@ int32_t SampleGetdcfinfo(const char* srcJpgPath, const char* dstThmPath)
printf("file to create file %s\n", jpegDesPath);
return -1;
}
- int32_t u32WritenSize = 0;
+ uint32_t u32WritenSize = 0;
while (u32WritenSize < dstSize) {
s32RtnVal = fwrite(g_dstBuf + u32WritenSize, 1, dstSize, fpTHM);
if (s32RtnVal <= 0) {
@@ -176,12 +183,11 @@ int32_t SampleGetdcfinfo(const char* srcJpgPath, const char* dstThmPath)
return 0;
}
-static void SampleSaveCapture(const char* p, uint32_t size, int type, char *timeStamp, int length)
+static void SampleSaveCapture(const char* p, uint32_t size, int type, const char *timeStamp, int length)
{
char acFileDcf[FILE_NAME_LEN] = {0};
FILE *fp = nullptr;
char acFile[FILE_NAME_LEN] = { 0 };
- int ws = 0;
if (type == 0) {
char tmpFile[FILE_NAME_LEN] = {0};
@@ -190,7 +196,7 @@ static void SampleSaveCapture(const char* p, uint32_t size, int type, char *time
}
fp = fopen(tmpFile, "w+");
if (fp) {
- ws = fwrite(p, 1, size, fp);
+ fwrite(p, 1, size, fp);
fclose(fp);
}
}
@@ -204,7 +210,7 @@ static void SampleSaveCapture(const char* p, uint32_t size, int type, char *time
if (fp == NULL) {
return;
}
- ws = fwrite(p, 1, size, fp);
+ fwrite(p, 1, size, fp);
fclose(fp);
if (type == 0) {
@@ -222,12 +228,16 @@ static void SampleSaveCapture(const char* p, uint32_t size, int type, char *time
SampleGetdcfinfo(static_cast(acFile), static_cast(acFileDcf));
}
-static int CameraGetRecordFd(char* p)
+static int CameraGetRecordFd(const char* p)
{
int fd = -1;
char pname[128] = {0};
- char *pe = strrchr(p, '.');
- char *ps = strrchr(p, '/');
+ char *ptr = const_cast(p);
+ char *pe = strrchr(ptr, '.');
+ char *ps = strrchr(ptr, '/');
+ if (pe == nullptr || ps == nullptr) {
+ return -1;
+ }
if (strcpy_s(static_cast(pname), sizeof(pname), VIDEO_PATH) != 0) {
return -1;
@@ -240,9 +250,8 @@ static int CameraGetRecordFd(char* p)
if (strcat_s(pname, sizeof(pname), ".mp4") < 0) {
return -1;
}
-
- fd = open(pname, O_RDWR | O_CREAT | O_CLOEXEC | O_TRUNC, S_IRUSR | S_IWUSR);
- if (fd <= 0) {
+ fd = open(pname, O_RDWR | O_CREAT | O_CLOEXEC | O_TRUNC, S_IROTH | S_IRUSR | S_IWUSR);
+ if (fd < 0) {
return -1;
}
@@ -318,7 +327,8 @@ void TestFrameStateCallback::OnFrameFinished(Camera &camera, FrameConfig &fc, Fr
if (buffer != nullptr) {
char *virtAddr = static_cast(buffer->GetVirAddr());
if (virtAddr != nullptr) {
- SampleSaveCapture(virtAddr, buffer->GetSize(), gPhotoType_, timeStamp_, sizeof(timeStamp_));
+ SampleSaveCapture(virtAddr, buffer->GetSize(),
+ gPhotoType_, static_cast(timeStamp_), sizeof(timeStamp_));
}
surface->ReleaseBuffer(buffer);
} else {
@@ -345,7 +355,7 @@ bool TestFrameStateCallback::IsFinish(void)
return gIsFinished_;
}
-void TestFrameStateCallback::GetVideoName(char *pName, int length)
+void TestFrameStateCallback::GetVideoName(char *pName, size_t length) const
{
if (strlen(videoName_) <= 0)
return;
@@ -575,10 +585,9 @@ SampleCameraManager::~SampleCameraManager()
}
}
-int SampleCameraManager::SampleCameraCreate(int picMode)
+int SampleCameraManager::SampleCameraCreate()
{
int retval = 0;
- int timeout = 0;
printf("camera start init!!! \n");
camKit = CameraKit::GetInstance();
if (camKit == nullptr) {
@@ -592,9 +601,11 @@ int SampleCameraManager::SampleCameraCreate(int picMode)
const CameraAbility *ability = camKit->GetCameraAbility(cam);
/* find camera which fits user's ability */
list sizeList = ability->GetSupportedSizes(0);
- if (find(sizeList.begin(), sizeList.end(), CAM_PIC_1080P) != sizeList.end()) {
- camId = cam;
- break;
+ for (auto &pic : sizeList) {
+ if (pic.width == PIC_WIDTH && pic.height == PIC_HEIGHT) {
+ camId = cam;
+ break;
+ }
}
}
@@ -614,13 +625,13 @@ int SampleCameraManager::SampleCameraCreate(int picMode)
camKit->CreateCamera(camId, *CamStateMng, eventHdlr_);
printf("after CreateCamera \n");
if (!access("/userdata/", F_OK | R_OK | W_OK)) {
- if (access(PHOTO_PATH, F_OK)) {
+ if (access(PHOTO_PATH, F_OK) != 0) {
mkdir(PHOTO_PATH, FILE_MODE);
}
- if (access(THUMB_PATH, F_OK)) {
+ if (access(THUMB_PATH, F_OK) != 0) {
mkdir(THUMB_PATH, FILE_MODE);
}
- if (access(VIDEO_PATH, F_OK)) {
+ if (access(VIDEO_PATH, F_OK) != 0) {
mkdir(VIDEO_PATH, FILE_MODE);
}
}
diff --git a/cameraApp/cameraApp/src/main/cpp/camera_manager.h b/cameraApp/cameraApp/src/main/cpp/camera_manager.h
old mode 100644
new mode 100755
index b21d856..47791c5
--- a/cameraApp/cameraApp/src/main/cpp/camera_manager.h
+++ b/cameraApp/cameraApp/src/main/cpp/camera_manager.h
@@ -48,26 +48,34 @@ typedef enum {
class TestFrameStateCallback : public FrameStateCallback {
public:
- TestFrameStateCallback(){}
+ TestFrameStateCallback() : gPhotoType_(0), gIsFinished_(false) {}
~TestFrameStateCallback(){}
void OnFrameFinished(Camera &camera, FrameConfig &fc, FrameResult &result) override;
void SetPhotoType(int type);
bool IsFinish(void);
- void GetVideoName(char *pName, int length);
+ void GetVideoName(char *pName, size_t length) const;
void InitVideoName();
void InitTimeStamp();
private:
int gPhotoType_;
bool gIsFinished_;
- char videoName_[256];
- char timeStamp_[256];
+ char videoName_[256] = {0};
+ char timeStamp_[256] = {0};
};
class SampleCameraStateMng : public CameraStateCallback {
public:
SampleCameraStateMng() = delete;
- SampleCameraStateMng(EventHandler &eventHdlr) : eventHdlr_(eventHdlr) {}
+ SampleCameraStateMng(EventHandler &eventHdlr) : eventHdlr_(eventHdlr)
+ {
+ gRecordSta_ = 0;
+ gPreviewSta_ = 0;
+ gRecFd_ = -1;
+ cam_ = nullptr;
+ recorder_ = nullptr;
+ fc_ = nullptr;
+ }
~SampleCameraStateMng();
void OnCreated(Camera &c) override;
@@ -84,23 +92,27 @@ public:
bool IsCaptureOver(void);
private:
- int gRecordSta_ = 0;
- int gPreviewSta_ = 0;
- int gRecFd_ = -1;
+ int gRecordSta_;
+ int gPreviewSta_;
+ int gRecFd_;
EventHandler &eventHdlr_;
- Camera *cam_ = nullptr;
- Recorder *recorder_ = nullptr;
+ Camera *cam_;
+ Recorder *recorder_;
TestFrameStateCallback fsCb_;
- FrameConfig *fc_ = nullptr;
+ FrameConfig *fc_;
};
class SampleCameraManager {
public:
- SampleCameraManager() = delete;
- SampleCameraManager(int mode) : picMode(mode) {}
+ SampleCameraManager()
+ {
+ camKit = nullptr;
+ camId = "";
+ CamStateMng = nullptr;
+ }
~SampleCameraManager();
- int SampleCameraCreate(int picMode);
+ int SampleCameraCreate();
bool SampleCameraExist(void);
int SampleCameraStart(Surface *surface);
int SampleCameraStop(void);
@@ -116,7 +128,6 @@ private:
CameraKit *camKit;
string camId;
SampleCameraStateMng *CamStateMng;
- int picMode = 0;
EventHandler eventHdlr_;
};
diff --git a/cameraApp/cameraApp/src/main/cpp/event_listener.h b/cameraApp/cameraApp/src/main/cpp/event_listener.h
old mode 100644
new mode 100755
index 1249046..6c5305c
--- a/cameraApp/cameraApp/src/main/cpp/event_listener.h
+++ b/cameraApp/cameraApp/src/main/cpp/event_listener.h
@@ -36,20 +36,28 @@ public:
onLongPress_ = std::move(onLongPress);
}
- bool OnClick(UIView &view, const ClickEvent &event) override
+ bool OnClick(UIView& view, const ClickEvent &event) override
{
if (!onClick_) {
return false;
}
- return onClick_(view, event);
+ UIView *currentView = &view;
+ if (currentView == nullptr) {
+ return false;
+ }
+ return onClick_(*currentView, event);
}
- bool OnLongPress(UIView &view, const LongPressEvent &event) override
+ bool OnLongPress(UIView& view, const LongPressEvent &event) override
{
if (!onLongPress_) {
return false;
}
- return onLongPress_(view, event);
+ UIView *currentView = &view;
+ if (currentView == nullptr) {
+ return false;
+ }
+ return onLongPress_(*currentView, event);
}
private:
diff --git a/cameraApp/cameraApp/src/main/cpp/ui_config.h b/cameraApp/cameraApp/src/main/cpp/ui_config.h
old mode 100644
new mode 100755
diff --git a/cameraApp/cameraApp/src/main/resources/base/media/camera.png b/cameraApp/cameraApp/src/main/resources/base/media/camera.png
old mode 100644
new mode 100755
diff --git a/cameraApp/cameraApp/src/main/resources/base/media/ic_back.png b/cameraApp/cameraApp/src/main/resources/base/media/ic_back.png
old mode 100644
new mode 100755
diff --git a/cameraApp/cameraApp/src/main/resources/base/media/ic_camera_photo.png b/cameraApp/cameraApp/src/main/resources/base/media/ic_camera_photo.png
old mode 100644
new mode 100755
diff --git a/cameraApp/cameraApp/src/main/resources/base/media/ic_camera_record.png b/cameraApp/cameraApp/src/main/resources/base/media/ic_camera_record.png
old mode 100644
new mode 100755
diff --git a/cameraApp/cameraApp/src/main/resources/base/media/ic_camera_record_camra.png b/cameraApp/cameraApp/src/main/resources/base/media/ic_camera_record_camra.png
old mode 100644
new mode 100755
diff --git a/cameraApp/cameraApp/src/main/resources/base/media/ic_camera_record_continue.png b/cameraApp/cameraApp/src/main/resources/base/media/ic_camera_record_continue.png
old mode 100644
new mode 100755
diff --git a/cameraApp/cameraApp/src/main/resources/base/media/ic_camera_record_pause.png b/cameraApp/cameraApp/src/main/resources/base/media/ic_camera_record_pause.png
old mode 100644
new mode 100755
diff --git a/cameraApp/cameraApp/src/main/resources/base/media/ic_camera_record_shutter.png b/cameraApp/cameraApp/src/main/resources/base/media/ic_camera_record_shutter.png
old mode 100644
new mode 100755
diff --git a/cameraApp/cameraApp/src/main/resources/base/media/ic_camera_record_stop.png b/cameraApp/cameraApp/src/main/resources/base/media/ic_camera_record_stop.png
old mode 100644
new mode 100755
diff --git a/cameraApp/cameraApp/src/main/resources/base/media/ic_camera_shutter.png b/cameraApp/cameraApp/src/main/resources/base/media/ic_camera_shutter.png
old mode 100644
new mode 100755
diff --git a/cameraApp/cameraApp/src/main/resources/base/media/ic_camera_video.png b/cameraApp/cameraApp/src/main/resources/base/media/ic_camera_video.png
old mode 100644
new mode 100755
diff --git a/cameraApp/cameraApp/src/main/resources/base/media/ic_timer.png b/cameraApp/cameraApp/src/main/resources/base/media/ic_timer.png
old mode 100644
new mode 100755
diff --git a/cameraApp/cert/camera_HarmonyAppProvision_Release.p7b b/cameraApp/cert/camera_HarmonyAppProvision_Release.p7b
old mode 100644
new mode 100755
diff --git a/communication/BUILD.gn b/communication/BUILD.gn
deleted file mode 100755
index 18a1ad9..0000000
--- a/communication/BUILD.gn
+++ /dev/null
@@ -1,27 +0,0 @@
-# Copyright (c) 2020 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("//build/lite/config/component/lite_component.gni")
-
-lite_component("sample") {
- features = [
- ]
-}
-
-generate_notice_file("communication_sample") {
- module_name = "communication_sample"
- module_source_dir_list = [
- "//third_party/wpa_supplicant/wpa_supplicant-2.9/hostapd",
- "//third_party/wpa_supplicant/wpa_supplicant-2.9/wpa_supplicant",
- ]
-}
diff --git a/communication/hostapd/BUILD.gn b/communication/hostapd/BUILD.gn
deleted file mode 100755
index 3fe3aa4..0000000
--- a/communication/hostapd/BUILD.gn
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright (c) 2020 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("//build/lite/config/component/lite_component.gni")
-
-sample_sources = [
- "src/hostapd_sample.c",
-]
-
-config_file = [
- "config/hostapd.conf"
-]
-
-executable("hostapd_sample_exe") {
- output_name = "hostapd"
- sources = sample_sources
-}
-
-group("hostapd_sample") {
- deps = [
- ":hostapd_sample_exe",
- ]
-}
-
-copy("config") {
- sources = config_file
- outputs = [
- "$root_out_dir/etc/hostapd.conf"
- ]
-}
diff --git a/communication/hostapd/config/hostapd.conf b/communication/hostapd/config/hostapd.conf
deleted file mode 100755
index bc6057c..0000000
--- a/communication/hostapd/config/hostapd.conf
+++ /dev/null
@@ -1,7 +0,0 @@
-interface=wlan0
-driver=hdf wifi
-ctrl_interface=udp
-ssid=testap
-hw_mode=g
-channel=1
-ignore_broadcast_ssid=0
diff --git a/communication/hostapd/src/hostapd_sample.c b/communication/hostapd/src/hostapd_sample.c
deleted file mode 100755
index fa1975b..0000000
--- a/communication/hostapd/src/hostapd_sample.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2020 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.
- */
-
-#include
-#include
-#include
-#include
-
-pthread_t g_apThread;
-
-char* g_apArg[20] = {0};
-int g_apArgc = 0;
-
-static void* ThreadMain()
-{
- printf("[HostapdSample]init hostapd.\n");
-
- void *handleLibWpa = dlopen("/usr/lib/libwpa.so", RTLD_NOW | RTLD_LOCAL);
- if (handleLibWpa == NULL) {
- printf("[HostapdSample]dlopen libwpa failed.\n");
- return NULL;
- }
- int (*func)(int, char **) = NULL;
- func = dlsym(handleLibWpa, "ap_main");
- if (func == NULL) {
- dlclose(handleLibWpa);
- printf("[HostapdSample]dlsym ap_main failed.\n");
- return NULL;
- }
- int ret = func(g_apArgc, g_apArg);
-
- printf("[HostapdSample]run ap_main failed, ret:%d.\n", ret);
- for (int i = 0; i < g_apArgc; i++) {
- printf("[HostapdSample]arg %d:%s.\n", i, g_apArg[i]);
- }
-
- if (dlclose(handleLibWpa) != 0) {
- printf("[HostapdSample]dlclose libwpa failed.\n");
- return NULL;
- }
- return NULL;
-}
-
-int main(int argc, char *argv[])
-{
- g_apArgc = argc;
- for (int i = 0; i < g_apArgc; i++) {
- g_apArg[i] = argv[i];
- }
-
- int ret = pthread_create(&g_apThread, NULL, ThreadMain, NULL);
- if (ret != 0) {
- printf("[HostapdSample]create thread failed error:%s.\n", strerror(ret));
- return 1;
- }
- pthread_join(g_apThread, NULL);
- return 0;
-}
diff --git a/communication/wpa_cli/BUILD.gn b/communication/wpa_cli/BUILD.gn
deleted file mode 100755
index f29be47..0000000
--- a/communication/wpa_cli/BUILD.gn
+++ /dev/null
@@ -1,44 +0,0 @@
-# Copyright (c) 2020 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("//build/lite/config/component/lite_component.gni")
-
-sample_sources = [
- "src/wpa_cli_sample.c",
-]
-
-sample_include_dirs = [
- "//third_party/wpa_supplicant/wpa_supplicant-2.9/src/",
- "//third_party/bounds_checking_function:libsec_shared/include/"
-]
-
-executable("wpa_cli_exe") {
- output_name = "wpa_cli"
- sources = sample_sources
- include_dirs = sample_include_dirs
- out_dir = rebase_path(root_build_dir)
- deps = [
- "//third_party/wpa_supplicant/wpa_supplicant-2.9:wpa_supplicant",
- "//third_party/bounds_checking_function:libsec_shared"
- ]
- ldflags = [
- "-L${out_dir}",
- "-lwpa_client"
- ]
-}
-
-group("wpa_cli_sample") {
- deps = [
- ":wpa_cli_exe",
- ]
-}
diff --git a/communication/wpa_cli/src/wpa_cli_sample.c b/communication/wpa_cli/src/wpa_cli_sample.c
deleted file mode 100755
index 0895f79..0000000
--- a/communication/wpa_cli/src/wpa_cli_sample.c
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Copyright (c) 2020 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.
- */
-
-#include "utils/includes.h"
-#include "pthread.h"
-#include "common/wpa_ctrl.h"
-#include "securec.h"
-
-
-#define WPA_IFACE_NAME "wlan0"
-#define WIFI_AUTH_FAILED_REASON_STR "WRONG_KEY"
-#define WIFI_AUTH_FAILED_REASON_CODE "reason=2"
-#define WPA_CTRL_REQUEST_OK "OK"
-#define WPA_CTRL_REQUEST_FAIL "FAIL"
-
-#define SAMPLE_INFO(format, args...) \
- do { \
- fprintf(stderr, "\033[1;32m WpaCliSample(%s:%d):\t\033[0m" format, __func__, __LINE__, ##args); \
- printf("\n"); \
- } while (0)
-
-#define SAMPLE_ERROR(format, args...) \
- do { \
- fprintf(stderr, "\033[1;31m WpaCliSample(%s:%d):\t\033[0m" format, __func__, __LINE__, ##args); \
- printf("\n"); \
- } while (0)
-
-
-static struct wpa_ctrl *g_monitorConn;
-static struct wpa_ctrl *g_ctrlConn;
-static pthread_t g_wpaThreadId;
-static int g_scanAvailable = 0;
-
-static void DumpString(const char *buf, int len, const char *tag)
-{
- SAMPLE_INFO("%s dump start.", tag);
- for (int i = 0; i < len; i++) {
- printf("%c", buf[i]);
- }
- printf("\n");
- SAMPLE_INFO("%s dump end.", tag);
-}
-
-static int StrMatch(const char *a, const char *b)
-{
- return strncmp(a, b, strlen(b)) == 0;
-}
-
-static void WifiEventHandler(char *rawEvent, int len)
-{
- char *pos = rawEvent;
- if (*pos == '<') {
- pos = strchr(pos, '>');
- if (pos) {
- pos++;
- } else {
- pos = rawEvent;
- }
- }
- if (StrMatch(pos, WPA_EVENT_CONNECTED)) {
- SAMPLE_INFO("WIFI_EVENT_CONNECTED");
- return;
- }
- if (StrMatch(pos, WPA_EVENT_SCAN_RESULTS)) {
- SAMPLE_INFO("WIFI_EVENT_SCAN_DONE");
- g_scanAvailable = 1;
- return;
- }
- if (StrMatch(pos, WPA_EVENT_TEMP_DISABLED) && strstr(pos, WIFI_AUTH_FAILED_REASON_STR)) {
- SAMPLE_INFO("WIFI_EVENT_WRONG_KEY");
- return;
- }
- if (StrMatch(pos, WPA_EVENT_DISCONNECTED) && !strstr(pos, WIFI_AUTH_FAILED_REASON_CODE)) {
- SAMPLE_INFO("WIFI_EVENT_DISCONNECTED");
- return;
- }
-}
-
-static void CliRecvPending(void)
-{
- while (wpa_ctrl_pending(g_monitorConn)) {
- char buf[4096];
- size_t len = sizeof(buf) - 1;
- if (wpa_ctrl_recv(g_monitorConn, buf, &len) == 0) {
- buf[len] = '\0';
- SAMPLE_INFO("event received %s", buf);
- WifiEventHandler(buf, len);
- } else {
- SAMPLE_INFO("could not read pending message.");
- break;
- }
- }
-}
-
-static void* MonitorTask(void *args)
-{
- (void)args;
- int fd, ret;
- fd_set rfd;
- while (1) {
- fd = wpa_ctrl_get_fd(g_monitorConn);
- FD_ZERO(&rfd);
- FD_SET(fd, &rfd);
- ret = select(fd + 1, &rfd, NULL, NULL, NULL);
- if (ret <= 0) {
- SAMPLE_INFO("select failed ret = %d\n", ret);
- break;
- }
- CliRecvPending();
- sleep(1);
- }
- return NULL;
-}
-
-static int SendCtrlCommand(const char *cmd, char *reply, size_t *replyLen)
-{
- size_t len = *replyLen - 1;
- wpa_ctrl_request(g_ctrlConn, cmd, strlen(cmd), reply, &len, 0);
- DumpString(reply, len, "SendCtrlCommand raw return");
- if (len != 0 && !StrMatch(reply, WPA_CTRL_REQUEST_FAIL)) {
- *replyLen = len;
- return 0;
- }
- SAMPLE_ERROR("send ctrl request [%s] failed.", cmd);
- return -1;
-}
-
-static void TestNetworkConfig(void)
-{
- char networkId[20] = {0};
- size_t networkIdLen = sizeof(networkId);
- int ret = SendCtrlCommand("DISCONNECT", networkId, &networkIdLen);
- ret += SendCtrlCommand("ADD_NETWORK", networkId, &networkIdLen);
- if (ret != 0) {
- SAMPLE_ERROR("add network failed.");
- return;
- }
- SAMPLE_INFO("add network success, network id [%.*s]", networkIdLen, networkId);
- char reply[100] = {0};
- size_t replyLen = sizeof(reply);
- char cmd[200] = {0};
- sprintf_s(cmd, sizeof(cmd), "SET_NETWORK %.*s ssid \"example\"", networkIdLen, networkId);
- ret += SendCtrlCommand(cmd, reply, &replyLen);
- replyLen = sizeof(reply);
- sprintf_s(cmd, sizeof(cmd), "SET_NETWORK %.*s psk \"012345678\"", networkIdLen, networkId);
- ret += SendCtrlCommand(cmd, reply, &replyLen);
- replyLen = sizeof(reply);
- sprintf_s(cmd, sizeof(cmd), "ENABLE_NETWORK %.*s", networkIdLen, networkId);
- ret += SendCtrlCommand(cmd, reply, &replyLen);
- replyLen = sizeof(reply);
- ret += SendCtrlCommand("RECONNECT", reply, &replyLen);
- replyLen = sizeof(reply);
- if (ret == 0) {
- SAMPLE_INFO("network config success.");
- return;
- }
- sprintf_s(cmd, sizeof(cmd), "REMOVE_NETWORK %.*s", networkIdLen, networkId);
- SendCtrlCommand(cmd, reply, &replyLen);
- SAMPLE_ERROR("network config failed remove network [%.*s].", networkIdLen, networkId);
-}
-
-static void TestCliConnection(void)
-{
- char reply[100] = {0};
- size_t replyLen = sizeof(reply);
- int ret = SendCtrlCommand("PING", reply, &replyLen);
- if (ret == 0 && StrMatch(reply, "PONG")) {
- SAMPLE_INFO("connect to wpa success.");
- return;
- }
- SAMPLE_INFO("connect to wpa failed, err = %s.", reply);
-}
-
-static void TestScan()
-{
- char reply[100] = {0};
- size_t replyLen = sizeof(reply);
- g_scanAvailable = 0;
- SendCtrlCommand("SCAN", reply, &replyLen);
- while (1) {
- sleep(1);
- if (g_scanAvailable == 1) {
- SAMPLE_INFO("scan result received.");
- break;
- }
- SAMPLE_INFO("waiting scan result.");
- }
- char scanResult[4096] = {0};
- size_t scanLen = sizeof(scanResult);
- int ret = SendCtrlCommand("SCAN_RESULTS", scanResult, &scanLen);
- if (ret != 0) {
- SAMPLE_ERROR("request scan results failed.");
- return;
- }
- DumpString(scanResult, scanLen, "scan results");
-}
-
-static void StartTest()
-{
- TestCliConnection(); // test if wpa control interface connected successfully
- TestScan(); // test scan and get scan results
- TestNetworkConfig(); // test config network and connect
-}
-
-int InitControlInterface()
-{
- g_ctrlConn = wpa_ctrl_open(WPA_IFACE_NAME); // create control interface for send cmd
- g_monitorConn = wpa_ctrl_open(WPA_IFACE_NAME); // create control interface for event monitor
- if (!g_ctrlConn || !g_monitorConn) {
- SAMPLE_ERROR("open wpa control interface failed.");
- return -1;
- }
- if (wpa_ctrl_attach(g_monitorConn) == 0) { // start monitor
- pthread_create(&g_wpaThreadId, NULL, MonitorTask, NULL); // create thread for read event
- return 0;
- }
- return -1;
-}
-
-int main()
-{
- if (InitControlInterface() != 0) {
- SAMPLE_ERROR("control interface init failed, exit client.");
- return -1;
- }
- SAMPLE_INFO("control interface init success.");
- StartTest();
- pthread_join(g_wpaThreadId, NULL);
- SAMPLE_INFO("test finished, exit client.");
-}
diff --git a/communication/wpa_supplicant/BUILD.gn b/communication/wpa_supplicant/BUILD.gn
deleted file mode 100755
index 81d52a4..0000000
--- a/communication/wpa_supplicant/BUILD.gn
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright (c) 2020 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("//build/lite/config/component/lite_component.gni")
-
-sample_sources = [
- "src/wpa_sample.c",
-]
-
-config_file = [
- "config/wpa_supplicant.conf"
-]
-
-executable("wpa_sample_exe") {
- output_name = "wpa_supplicant"
- sources = sample_sources
-}
-
-group("wpa_sample") {
- deps = [
- ":wpa_sample_exe",
- ]
-}
-
-copy("config") {
- sources = config_file
- outputs = [
- "$root_out_dir/etc/wpa_supplicant.conf"
- ]
-}
diff --git a/communication/wpa_supplicant/config/wpa_supplicant.conf b/communication/wpa_supplicant/config/wpa_supplicant.conf
deleted file mode 100755
index f4a3a12..0000000
--- a/communication/wpa_supplicant/config/wpa_supplicant.conf
+++ /dev/null
@@ -1,4 +0,0 @@
-country=GB
-ctrl_interface=udp
-network={
-}
diff --git a/communication/wpa_supplicant/src/wpa_sample.c b/communication/wpa_supplicant/src/wpa_sample.c
deleted file mode 100755
index a30d8f6..0000000
--- a/communication/wpa_supplicant/src/wpa_sample.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2020 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.
- */
-
-#include
-#include
-#include
-#include
-
-pthread_t g_wpaThread;
-
-char* g_wpaArg[20] = {0};
-int g_wpaArgc = 0;
-
-static void* ThreadMain()
-{
- printf("[WpaSample]init wpa_supplicant.\n");
-
- void *handleLibWpa = dlopen("/usr/lib/libwpa.so", RTLD_NOW | RTLD_LOCAL);
- if (handleLibWpa == NULL) {
- printf("[WpaSample]dlopen libwpa failed.\n");
- return NULL;
- }
- int (*func)(int, char **) = NULL;
- func = dlsym(handleLibWpa, "wpa_main");
- if (func == NULL) {
- dlclose(handleLibWpa);
- printf("[WpaSample]dlsym wpa_main failed.\n");
- return NULL;
- }
- int ret = func(g_wpaArgc, g_wpaArg);
-
- printf("[WpaSample]run wpa_main failed, ret:%d.\n", ret);
- for (int i = 0; i < g_wpaArgc; i++) {
- printf("[WpaSample]arg %d:%s.\n", i, g_wpaArg[i]);
- }
-
- if (dlclose(handleLibWpa) != 0) {
- printf("[WpaSample]dlclose libwpa failed.\n");
- return NULL;
- }
- return NULL;
-}
-
-int main(int argc, char *argv[])
-{
- g_wpaArgc = argc;
- for (int i = 0; i < g_wpaArgc; i++) {
- g_wpaArg[i] = argv[i];
- }
-
- int ret = pthread_create(&g_wpaThread, NULL, ThreadMain, NULL);
- if (ret != 0) {
- printf("[WpaSample]create thread failed error:%s.\n", strerror(ret));
- return 1;
- }
- pthread_join(g_wpaThread, NULL);
- return 0;
-}
diff --git a/example/BUILD.gn b/example/BUILD.gn
deleted file mode 100755
index e070881..0000000
--- a/example/BUILD.gn
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright (c) 2020 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("//build/lite/config/component/lite_component.gni")
-
-lite_component("service_example") {
- features = [
- "consumer:consumer_service",
- "provider:provider_service",
- ]
-}
diff --git a/example/consumer/BUILD.gn b/example/consumer/BUILD.gn
deleted file mode 100755
index 5d3c95a..0000000
--- a/example/consumer/BUILD.gn
+++ /dev/null
@@ -1,49 +0,0 @@
-# Copyright (c) 2020 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("//build/lite/config/component/lite_component.gni")
-
-executable("consumer_proc") {
- sources = [
- "proc.c",
- "client_example.c",
- "default_call_test.c",
- "feature_call_test.c",
- ]
-
- ldflags = [
- "-Wl,-Map=consumer_proc.map",
- ]
-
- include_dirs = [
- "include",
- "//kernel/liteos_a/kernel/include",
- "//kernel/liteos_a/kernel/common",
- "//third_party/bounds_checking_function/include",
- "//kernel/liteos_a/kernel/include",
- "//kernel/liteos_a/kernel/common",
- "//utils/native/lite/include",
- "//foundation/distributedschedule/interfaces/kits/samgr_lite/registry",
- "//foundation/distributedschedule/interfaces/kits/samgr_lite/samgr",
- "//foundation/distributedschedule/interfaces/kits/samgr_lite/communication/broadcast",
- ]
-
- deps = [
- "//foundation/distributedschedule/services/samgr_lite/samgr:samgr",
- ]
-}
-
-lite_component("consumer_service") {
- features = [
- ":consumer_proc",
- ]
-}
diff --git a/example/consumer/client_example.c b/example/consumer/client_example.c
deleted file mode 100755
index ce70a63..0000000
--- a/example/consumer/client_example.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (c) 2020 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.
- */
-#include "example.h"
-#include
-#include
-#include
-#include
-#include
-
-#define MAX_DATA_LEN 0x100
-enum FUNCID {
- ID_ASYNCALL = 0,
- ID_ASYNTIMECALL,
- ID_SYNCCALL,
- ID_ASYNCCALLBACK
-};
-typedef struct DemoClientProxy {
- INHERIT_CLIENT_IPROXY;
- BOOL (*AsyncCall)(IUnknown *iUnknown, const char *buff);
- BOOL (*AsyncTimeCall)(IUnknown *iUnknown);
- BOOL (*SyncCall)(IUnknown *iUnknown, struct Payload *payload);
- BOOL (*AsyncCallBack)(IUnknown *iUnknown, const char *buff, IOwner notify, INotifyFunc handler);
-} DemoClientProxy;
-
-typedef struct DemoClientEntry {
- INHERIT_IUNKNOWNENTRY(DemoClientProxy);
-} DemoClientEntry;
-static BOOL AsyncCall(IUnknown *iUnknown, const char *buff);
-static BOOL AsyncTimeCall(IUnknown *iUnknown);
-static BOOL SyncCall(IUnknown *iUnknown, struct Payload *payload);
-static BOOL AsyncCallBack(IUnknown *iUnknown, const char *buff, IOwner notify, INotifyFunc handler);
-void *DEMO_CreatClient(const char *service, const char *feature, uint32 size)
-{
- (void)service;
- (void)feature;
- uint32 len = size + sizeof(DemoClientEntry);
- uint8 *client = malloc(len);
- if (client == NULL) {
- return NULL;
- }
- (void)memset_s(client, len, 0, len);
- DemoClientEntry *entry = (DemoClientEntry *)&client[size];
- entry->ver = ((uint16)CLIENT_PROXY_VER | (uint16)DEFAULT_VERSION);
- entry->ref = 1;
- entry->iUnknown.QueryInterface = IUNKNOWN_QueryInterface;
- entry->iUnknown.AddRef = IUNKNOWN_AddRef;
- entry->iUnknown.Release = IUNKNOWN_Release;
- entry->iUnknown.Invoke = NULL;
- entry->iUnknown.AsyncCall = AsyncCall;
- entry->iUnknown.AsyncTimeCall = AsyncTimeCall;
- entry->iUnknown.SyncCall = SyncCall;
- entry->iUnknown.AsyncCallBack = AsyncCallBack;
- return client;
-}
-void DEMO_DestroyClient(const char *service, const char *feature, void *iproxy)
-{
- free(iproxy);
-}
-
-static BOOL AsyncCall(IUnknown *iUnknown, const char *buff)
-{
- DemoClientProxy *proxy = (DemoClientProxy *)iUnknown;
- IpcIo request;
- char data[MAX_DATA_LEN];
- IpcIoInit(&request, data, MAX_DATA_LEN, 0);
- IpcIoPushString(&request, buff);
- int ret = proxy->Invoke((IClientProxy *)proxy, ID_ASYNCALL, &request, NULL, NULL);
- return ret == EC_SUCCESS;
-}
-static BOOL AsyncTimeCall(IUnknown *iUnknown)
-{
- DemoClientProxy *proxy = (DemoClientProxy *)iUnknown;
- IpcIo request;
- char data[MAX_DATA_LEN];
- IpcIoInit(&request, data, MAX_DATA_LEN, 0);
- int ret = proxy->Invoke((IClientProxy *)proxy, ID_ASYNTIMECALL, &request, NULL, NULL);
- return ret == EC_SUCCESS;
-}
-
-static int Callback(IOwner owner, int code, IpcIo *reply)
-{
- size_t len = 0;
- char *src = (char *)IpcIoPopString(reply, &len);
- if (src == NULL) {
- return EC_BADPTR;
- }
- return strcpy_s(owner, MAX_DATA_LEN, src);
-}
-static BOOL SyncCall(IUnknown *iUnknown, struct Payload *payload)
-{
- DemoClientProxy *proxy = (DemoClientProxy *)iUnknown;
- IpcIo request;
- char data[MAX_DATA_LEN];
- IpcIoInit(&request, data, MAX_DATA_LEN, 0);
- IpcIoPushInt32(&request, payload->id);
- IpcIoPushInt32(&request, payload->value);
- IpcIoPushString(&request, payload->name);
- int ret = proxy->Invoke((IClientProxy *)proxy, ID_SYNCCALL, &request, data, Callback);
- data[MAX_DATA_LEN - 1] = 0;
- HILOG_INFO(HILOG_MODULE_APP, "[TID:0x%lx]Remote response is %s!", (unsigned long)pthread_self(), data);
- return ret == EC_SUCCESS;
-}
-struct CurrentNotify {
- IOwner notify;
- INotifyFunc handler;
-};
-static int CurrentCallback(IOwner owner, int code, IpcIo *reply)
-{
- struct CurrentNotify *notify = (struct CurrentNotify *)owner;
- size_t len = 0;
- char *response = (char *)IpcIoPopString(reply, &len);
- if (response == NULL) {
- return EC_BADPTR;
- }
- HILOG_INFO(HILOG_MODULE_APP, "[TID:0x%lx]Notify Remote response is %s!", (unsigned long)pthread_self(), response);
- notify->handler(notify->notify, response);
- return EC_SUCCESS;
-}
-
-static BOOL AsyncCallBack(IUnknown *iUnknown, const char *buff, IOwner notify, INotifyFunc handler)
-{
- struct CurrentNotify owner = {notify, handler};
- DemoClientProxy *proxy = (DemoClientProxy *)iUnknown;
- IpcIo request;
- char data[MAX_DATA_LEN];
- IpcIoInit(&request, data, MAX_DATA_LEN, 0);
- IpcIoPushString(&request, buff);
- int ret = proxy->Invoke((IClientProxy *)proxy, ID_ASYNCCALLBACK, &request, &owner, CurrentCallback);
- return ret == EC_SUCCESS;
-}
diff --git a/example/consumer/default_call_test.c b/example/consumer/default_call_test.c
deleted file mode 100755
index 74a090d..0000000
--- a/example/consumer/default_call_test.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2020 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.
- */
-#include "example.h"
-#include
-#include
-#include
-#include
-
-#define MAX_DATA_LEN 250
-static IClientProxy *CASE_GetRemoteIUnknown(void)
-{
- IClientProxy *demoApi = NULL;
- HILOG_INFO(HILOG_MODULE_APP, "[TID:0x%lx][GetDefaultFeatureApi S:%s]: BEGIN",
- (unsigned long)pthread_self(), EXAMPLE_SERVICE);
- IUnknown *iUnknown = SAMGR_GetInstance()->GetDefaultFeatureApi(EXAMPLE_SERVICE);
- if (iUnknown == NULL) {
- HILOG_INFO(HILOG_MODULE_APP, "[TID:0x%lx][GetDefaultFeatureApi S:%s]: error is NULL",
- (unsigned long)pthread_self(), EXAMPLE_SERVICE);
- return NULL;
- }
- (void)iUnknown->QueryInterface(iUnknown, CLIENT_PROXY_VER, (void **)&demoApi);
- HILOG_INFO(HILOG_MODULE_APP, "[TID:0x%lx][QueryInterface CLIENT_PROXY_VER S:%s]: is %p",
- (unsigned long)pthread_self(), EXAMPLE_SERVICE, demoApi);
- return demoApi;
-}
-
-static void CASE_SyncCall(IClientProxy *defaultApi)
-{
- HILOG_INFO(HILOG_MODULE_APP, "[TID:0x%lx][CASE_SyncCall api S:%s]: is %p",
- (unsigned long)pthread_self(), EXAMPLE_SERVICE, defaultApi);
- if (defaultApi == NULL) {
- return;
- }
- IpcIo request;
- char data[MAX_DATA_LEN];
- IpcIoInit(&request, data, sizeof(data), 0);
- defaultApi->Invoke(defaultApi, 0, &request, NULL, NULL);
-}
-
-static void CASE_ReleaseIUnknown(IUnknown *demoApi)
-{
- if (demoApi == NULL) {
- return;
- }
- int32 ref = demoApi->Release((IUnknown *)demoApi);
- HILOG_INFO(HILOG_MODULE_APP, "[TID:0x%lx][Release api S:%s]: is %p ref:%d",
- (unsigned long)pthread_self(), EXAMPLE_SERVICE, demoApi, ref);
-}
-
-void RunServiceTestCase(void)
-{
- IClientProxy *remoteApi = CASE_GetRemoteIUnknown();
- CASE_SyncCall(remoteApi);
- CASE_ReleaseIUnknown((IUnknown *)remoteApi);
-}
diff --git a/example/consumer/example.h b/example/consumer/example.h
deleted file mode 100755
index c406757..0000000
--- a/example/consumer/example.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2020 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.
- */
-#ifndef LITE_EXAMPLE_H
-#define LITE_EXAMPLE_H
-
-#include
-#include
-#include
-
-#ifdef __cplusplus
-#if __cplusplus
-extern "C" {
-#endif
-#endif
-
-#define EXAMPLE_SERVICE "ex_service"
-#define EXAMPLE_FEATURE "ex_feature"
-typedef struct DefaultFeatureApi {
- INHERIT_SERVER_IPROXY;
- void (*SyncCall)(IUnknown *iUnknown);
-} DefaultFeatureApi;
-
-struct Payload {
- int id;
- const char *name;
- int value;
-};
-typedef void *IOwner;
-typedef void (*INotifyFunc)(IOwner owner, const char *resp);
-typedef struct ClientDemo {
- INHERIT_CLIENT_IPROXY;
- BOOL (*AsyncCall)(IUnknown *iUnknown, const char *buff);
- BOOL (*AsyncTimeCall)(IUnknown *iUnknown);
- BOOL (*SyncCall)(IUnknown *iUnknown, struct Payload *payload);
- BOOL (*AsyncCallBack)(IUnknown *iUnknown, const char *buff, IOwner notify, INotifyFunc handler);
-} ClientDemo;
-void DEMO_DestroyClient(const char *service, const char *feature, void *iproxy);
-void *DEMO_CreatClient(const char *service, const char *feature, uint32 size);
-void RunServiceTestCase(void);
-void RunFeatureTestCase(void);
-#ifdef __cplusplus
-#if __cplusplus
-}
-#endif
-#endif
-#endif // LITE_EXAMPLE_H
diff --git a/example/consumer/feature_call_test.c b/example/consumer/feature_call_test.c
deleted file mode 100755
index 956f2b2..0000000
--- a/example/consumer/feature_call_test.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 2020 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.
- */
-#include "example.h"
-#include
-#include
-#include
-
-static ClientDemo *CASE_GetIUnknown(void)
-{
- ClientDemo *demoApi = NULL;
- HILOG_INFO(HILOG_MODULE_APP, "[TID:0x%lx][GetFeatureApi S:%s F:%s]: BEGIN\n",
- (unsigned long)pthread_self(), EXAMPLE_SERVICE, EXAMPLE_FEATURE);
- IUnknown *iUnknown = SAMGR_GetInstance()->GetFeatureApi(EXAMPLE_SERVICE, EXAMPLE_FEATURE);
- if (iUnknown == NULL) {
- HILOG_INFO(HILOG_MODULE_APP, "[TID:0x%lx][GetFeatureApi S:%s F:%s]: error is NULL\n",
- (unsigned long)pthread_self(), EXAMPLE_SERVICE, EXAMPLE_FEATURE);
- return NULL;
- }
-
- (void)iUnknown->QueryInterface(iUnknown, DEFAULT_VERSION, (void **)&demoApi);
- HILOG_INFO(HILOG_MODULE_APP, "[TID:0x%lx][QueryInterface DEFAULT_VERSION S:%s, F:%s]: is %p\n",
- (unsigned long)pthread_self(), EXAMPLE_SERVICE, EXAMPLE_FEATURE, demoApi);
- return demoApi;
-}
-
-static void CASE_SyncCall(ClientDemo *demoApi)
-{
- if (demoApi == NULL || demoApi->SyncCall == NULL) {
- return;
- }
-
- HILOG_INFO(HILOG_MODULE_APP, "[TID:0x%lx]SyncCall BEGIN\n", (unsigned long)pthread_self());
- struct Payload payload = {
- .id = 0,
- .name = "I wanna sync call good result!",
- .value = 1
- };
- BOOL ret = demoApi->SyncCall((IUnknown *)demoApi, &payload);
- HILOG_INFO(HILOG_MODULE_APP, "[TID:0x%lx]SyncCall End(%d)\n", (unsigned long)pthread_self(), ret);
-}
-
-
-static void CASE_AsyncCall(ClientDemo *demoApi)
-{
- if (demoApi == NULL || demoApi->AsyncCall == NULL) {
- return;
- }
- HILOG_INFO(HILOG_MODULE_APP, "[TID:0x%lx]AsyncCall BEGIN\n", (unsigned long)pthread_self());
- BOOL ret = demoApi->AsyncCall((IUnknown *)demoApi, "I wanna async call good result!");
- HILOG_INFO(HILOG_MODULE_APP, "[TID:0x%lx]AsyncCall End(%d)\n", (unsigned long)pthread_self(), ret);
-}
-
-static void CASE_AsyncTimeCall(ClientDemo *demoApi)
-{
- if (demoApi == NULL || demoApi->AsyncTimeCall == NULL) {
- return;
- }
- HILOG_INFO(HILOG_MODULE_APP, "[TID:0x%lx]AsyncTimeCall BEGIN\n", (unsigned long)pthread_self());
- BOOL ret = demoApi->AsyncTimeCall((IUnknown *)demoApi);
- HILOG_INFO(HILOG_MODULE_APP, "[TID:0x%lx]AsyncTimeCall End(%d)\n", (unsigned long)pthread_self(), ret);
-}
-
-void AsyncHandler(IOwner owner, const char *resp)
-{
- HILOG_INFO(HILOG_MODULE_APP, "[TID:0x%lx]AsyncCallBack Owner:%p, Response:%s\n",
- (unsigned long)pthread_self(), owner, resp);
-}
-
-static void CASE_AsyncCallBack(ClientDemo *demoApi)
-{
- if (demoApi == NULL || demoApi->AsyncCallBack == NULL) {
- return;
- }
- HILOG_INFO(HILOG_MODULE_APP, "[TID:0x%lx]AsyncCallBack BEGIN\n", (unsigned long)pthread_self());
- BOOL ret = demoApi->AsyncCallBack((IUnknown *)demoApi,
- "I wanna async call callback good result!", NULL, AsyncHandler);
- HILOG_INFO(HILOG_MODULE_APP, "[TID:0x%lx]AsyncCallBack End(%d)\n", (unsigned long)pthread_self(), ret);
-}
-
-static void CASE_ReleaseIUnknown(ClientDemo *demoApi)
-{
- if (demoApi == NULL) {
- return;
- }
- int32 ref = demoApi->Release((IUnknown *)demoApi);
- HILOG_INFO(HILOG_MODULE_APP, "[TID:0x%lx][Release api S:%s, F:%s]: is %p ref:%d\n",
- (unsigned long)pthread_self(), EXAMPLE_SERVICE, EXAMPLE_FEATURE, demoApi, ref);
-}
-
-void RunFeatureTestCase(void)
-{
- ClientDemo *demoApi = CASE_GetIUnknown();
- CASE_AsyncCall(demoApi);
- CASE_AsyncTimeCall(demoApi);
- CASE_SyncCall(demoApi);
- CASE_AsyncCallBack(demoApi);
- CASE_ReleaseIUnknown(demoApi);
-}
diff --git a/example/consumer/proc.c b/example/consumer/proc.c
deleted file mode 100755
index aea14cd..0000000
--- a/example/consumer/proc.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2020 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.
- */
-#include
-#include
-#include "samgr_lite.h"
-#include "registry.h"
-#include "example.h"
-const char FUN_ARG_S[] = "0123456I";
-#define DEFAULT 0
-#define INTERVAL 10
-#define MAX_LEN 0x100
-#define MAX_TEST_TIMES 3600
-void __attribute__((weak)) OHOS_SystemInit(void)
-{
- SAMGR_Bootstrap();
-};
-void HiLogPrintf(unsigned char module, unsigned char level, const char *nums, const char *fmt, ...);
-
-int main()
-{
- HiLogPrintf(DEFAULT, DEFAULT, NULL, "Start Consumer System Start");
- SAMGR_RegisterFactory(EXAMPLE_SERVICE, EXAMPLE_FEATURE, DEMO_CreatClient, DEMO_DestroyClient);
- OHOS_SystemInit();
- HiLogPrintf(DEFAULT, DEFAULT, NULL, "Start Consumer System End");
- int times = 0;
- while (times < MAX_TEST_TIMES) {
- sleep(INTERVAL);
- RunServiceTestCase();
- RunFeatureTestCase();
- ++times;
- }
-}
-void __attribute__((weak)) HiLogPrintf(unsigned char module, unsigned char level,
- const char *nums, const char *fmt, ...)
-{
- static char buf[MAX_LEN] = {0};
- va_list args;
- va_start(args, fmt);
- int ret = vsprintf_s(buf, sizeof(buf), fmt, args);
- va_end(args);
- if (ret < 0) {
- printf("Consumer fmt failed(%d)", ret);
- }
- printf("Consumer M:%d l:%d %s\n", module, level, buf);
-}
diff --git a/example/intermediary/BUILD.gn b/example/intermediary/BUILD.gn
deleted file mode 100755
index ab6f4eb..0000000
--- a/example/intermediary/BUILD.gn
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright (c) 2020 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("//build/lite/config/component/lite_component.gni")
-
-
-executable("server_proc") {
- sources = [
- "proc.c",
- ]
-
- ldflags = [
- "-Wl,-Map=server_proc.map",
- ]
-
- include_dirs = [
- "include",
- "//third_party/bounds_checking_function/include",
- "//utils/native/lite/include",
- "//foundation/distributedschedule/interfaces/kits/samgr_lite/samgr",
- ]
-
- deps = [
- "//foundation/distributedschedule/services/samgr_lite/samgr_server:server",
- ]
-}
-
-lite_component("samgr_server") {
- features = [
- ":server_proc",
- ]
-}
diff --git a/example/intermediary/proc.c b/example/intermediary/proc.c
deleted file mode 100755
index 51e174c..0000000
--- a/example/intermediary/proc.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2020 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.
- */
-#include
-#include
-#include "samgr_lite.h"
-const char FUN_ARG_S[] = "0123456I";
-#define DEFAULT 0
-#define MAX_LEN 0x100
-void __attribute__((weak)) OHOS_SystemInit(void)
-{
- SAMGR_Bootstrap();
-};
-void HiLogPrintf(unsigned char module, unsigned char level, const char *nums, const char *fmt, ...);
-
-int main()
-{
- HiLogPrintf(DEFAULT, DEFAULT, NULL, "Start Server System Start");
- OHOS_SystemInit();
- HiLogPrintf(DEFAULT, DEFAULT, NULL, "Start Server System End");
- pause();
-}
-void __attribute__((weak)) HiLogPrintf(unsigned char module, unsigned char level,
- const char *nums, const char *fmt, ...)
-{
- static char buf[MAX_LEN] = {0};
- va_list args;
- va_start(args, fmt);
- int ret = vsprintf_s(buf, sizeof(buf), fmt, args);
- va_end(args);
- if (ret < 0) {
- printf("Server fmt failed(%d)", ret);
- }
- printf("Server M:%d l:%d %s\n", module, level, buf);
-}
diff --git a/example/provider/BUILD.gn b/example/provider/BUILD.gn
deleted file mode 100755
index 356b9bb..0000000
--- a/example/provider/BUILD.gn
+++ /dev/null
@@ -1,49 +0,0 @@
-# Copyright (c) 2020 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("//build/lite/config/component/lite_component.gni")
-
-executable("provider_proc") {
- sources = [
- "proc.c",
- "feature_example.c",
- "service_example.c",
- ]
-
- ldflags = [
- "-Wl,-Map=provider_proc.map",
- ]
-
- include_dirs = [
- "include",
- "//third_party/bounds_checking_function/include",
- "//kernel/liteos_a/kernel/include",
- "//kernel/liteos_a/kernel/common",
- "//utils/native/lite/include",
- "//kernel/liteos_a/kernel/include",
- "//kernel/liteos_a/kernel/common",
- "//foundation/distributedschedule/interfaces/kits/samgr_lite/registry",
- "//foundation/distributedschedule/interfaces/kits/samgr_lite/samgr",
- "//foundation/distributedschedule/interfaces/kits/samgr_lite/communication/broadcast",
- "//foundation/distributedschedule/services/samgr_lite/samgr/source",
- ]
-
- deps = [
- "//foundation/distributedschedule/services/samgr_lite/samgr:samgr",
- ]
-}
-
-lite_component("provider_service") {
- features = [
- ":provider_proc",
- ]
-}
diff --git a/example/provider/example.h b/example/provider/example.h
deleted file mode 100755
index 37eeabd..0000000
--- a/example/provider/example.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2020 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.
- */
-#ifndef LITE_EXAMPLE_H
-#define LITE_EXAMPLE_H
-
-#include
-#include
-#include
-
-#ifdef __cplusplus
-#if __cplusplus
-extern "C" {
-#endif
-#endif
-
-#define EXAMPLE_SERVICE "ex_service"
-#define EXAMPLE_FEATURE "ex_feature"
-typedef struct DefaultFeatureApi {
- INHERIT_SERVER_IPROXY;
- void (*SyncCall)(IUnknown *iUnknown);
-} DefaultFeatureApi;
-
-struct Payload {
- int id;
- const char *name;
- int value;
-};
-typedef void *IOwner;
-typedef void (*INotifyFunc)(IOwner owner, const char *resp);
-
-typedef struct ClientDemo {
- INHERIT_CLIENT_IPROXY;
- BOOL (*AsyncCall)(IUnknown *iUnknown, const char *buff);
- BOOL (*AsyncTimeCall)(IUnknown *iUnknown);
- BOOL (*SyncCall)(IUnknown *iUnknown, struct Payload *payload);
- BOOL (*AsyncCallBack)(IUnknown *iUnknown, const char *buff, IOwner notify, INotifyFunc handler);
-} ClientDemo;
-#ifdef __cplusplus
-#if __cplusplus
-}
-#endif
-#endif
-#endif // LITE_EXAMPLE_H
diff --git a/example/provider/feature_example.c b/example/provider/feature_example.c
deleted file mode 100755
index 1f67051..0000000
--- a/example/provider/feature_example.c
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * Copyright (c) 2020 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.
- */
-#include "example.h"
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include "feature.h"
-#include "service.h"
-#include "samgr_lite.h"
-
-#define WAIT_FEATURE_PROC 1000
-enum MessageId {
- MSG_PROC,
- MSG_TIME_PROC,
-};
-typedef struct DemoFeatureApi {
- INHERIT_SERVER_IPROXY;
- BOOL (*AsyncCall)(IUnknown *iUnknown, const char *buff);
- BOOL (*AsyncTimeCall)(IUnknown *iUnknown);
- BOOL (*SyncCall)(IUnknown *iUnknown, struct Payload *payload);
- BOOL (*AsyncCallBack)(IUnknown *iUnknown, const char *buff, IOwner notify, INotifyFunc handler);
-} DemoFeatureApi;
-
-typedef struct DemoFeature {
- INHERIT_FEATURE;
- INHERIT_IUNKNOWNENTRY(DemoFeatureApi);
- Identity identity;
-} DemoFeature;
-
-static BOOL AsyncCall(IUnknown *iUnknown, const char *body);
-static BOOL AsyncTimeCall(IUnknown *iUnknown);
-static BOOL SyncCall(IUnknown *iUnknown, struct Payload *payload);
-static BOOL AsyncCallBack(IUnknown *iUnknown, const char *body, IOwner notify, INotifyFunc handler);
-static const char *FEATURE_GetName(Feature *feature);
-static void FEATURE_OnInitialize(Feature *feature, Service *parent, Identity identity);
-static void FEATURE_OnStop(Feature *feature, Identity identity);
-static BOOL FEATURE_OnMessage(Feature *feature, Request *request);
-static int32 Invoke(IServerProxy *iProxy, int funcId, void *origin, IpcIo *req, IpcIo *reply);
-static DemoFeature g_example = {
- .GetName = FEATURE_GetName,
- .OnInitialize = FEATURE_OnInitialize,
- .OnStop = FEATURE_OnStop,
- .OnMessage = FEATURE_OnMessage,
- SERVER_IPROXY_IMPL_BEGIN,
- .Invoke = Invoke,
- .AsyncCall = AsyncCall,
- .AsyncTimeCall = AsyncTimeCall,
- .SyncCall = SyncCall,
- .AsyncCallBack = AsyncCallBack,
- IPROXY_END,
- .identity = {-1, -1, NULL},
-};
-static const char *FEATURE_GetName(Feature *feature)
-{
- (void)feature;
- return EXAMPLE_FEATURE;
-}
-
-static void FEATURE_OnInitialize(Feature *feature, Service *parent, Identity identity)
-{
- DemoFeature *demoFeature = (DemoFeature *)feature;
- demoFeature->identity = identity;
-}
-
-static void FEATURE_OnStop(Feature *feature, Identity identity)
-{
- (void)feature;
- (void)identity;
- g_example.identity.queueId = NULL;
- g_example.identity.featureId = -1;
- g_example.identity.serviceId = -1;
-}
-
-static BOOL FEATURE_OnMessage(Feature *feature, Request *msg)
-{
- HILOG_INFO(HILOG_MODULE_APP, "[TID:0x%lx]OnMessage(%s)! Request<%d, %d, %p>",
- (unsigned long)pthread_self(), feature->GetName(feature), msg->msgId, msg->msgValue, msg->data);
- if (msg->msgId == MSG_PROC) {
- Response response;
- response.data = "Yes, you did!";
- response.len = 0;
- SAMGR_SendResponse(msg, &response);
- return TRUE;
- }
- if (msg->msgId == MSG_TIME_PROC) {
- if (msg->msgValue) {
- SAMGR_PrintServices();
- } else {
- SAMGR_PrintOperations();
- }
- return TRUE;
- }
- return FALSE;
-}
-
-static BOOL SyncCall(IUnknown *iUnknown, struct Payload *payload)
-{
- (void)iUnknown;
- if (payload != NULL && payload->name != NULL) {
- HILOG_INFO(HILOG_MODULE_APP, "[TID:0x%lx]SyncCall[%p, %p]! Payload<%s, %d, %d>",
- (unsigned long)pthread_self(), iUnknown, payload, payload->name, payload->id, payload->value);
- return TRUE;
- }
- HILOG_INFO(HILOG_MODULE_APP, "[TID:0x%lx]SyncCall[%p, %p]!", (unsigned long)pthread_self(), iUnknown, payload);
- return FALSE;
-}
-
-static BOOL AsyncCall(IUnknown *iUnknown, const char *body)
-{
- Request request;
- request.msgId = MSG_PROC;
- request.msgValue = 0;
- request.len = (uint32_t)(strlen(body) + 1);
- request.data = malloc(request.len);
- if (request.data == NULL) {
- return FALSE;
- }
- if (strcpy_s(request.data, request.len, body) != EOK) {
- free(request.data);
- return FALSE;
- }
- DemoFeature *feature = GET_OBJECT(iUnknown, DemoFeature, iUnknown);
- HILOG_INFO(HILOG_MODULE_APP, "[TID:0x%lx]AsyncCall[%p, %s]!", (unsigned long)pthread_self(), iUnknown, body);
- return SAMGR_SendRequest(&feature->identity, &request, NULL);
-}
-static BOOL AsyncTimeCall(IUnknown *iUnknown)
-{
- static BOOL cnt = FALSE;
- cnt = !cnt;
- HILOG_INFO(HILOG_MODULE_APP, "[TID:0x%lx]AsyncTimeCall[%p] MSG_TIME_PROC count=%d!",
- (unsigned long)pthread_self(), iUnknown, cnt);
- Request request;
- request.msgId = MSG_TIME_PROC;
- request.msgValue = cnt;
- request.len = 0;
- request.data = NULL;
- DemoFeature *feature = GET_OBJECT(iUnknown, DemoFeature, iUnknown);
- return SAMGR_SendRequest(&feature->identity, &request, NULL);
-}
-typedef struct AsyncBody {
- IOwner owner;
- INotifyFunc handler;
- char body[0];
-} AsyncBody;
-static void LocalHandler(const Request *request, const Response *response)
-{
- AsyncBody *body = (AsyncBody *)request->data;
- body->handler(body->owner, response->data);
-}
-static BOOL AsyncCallBack(IUnknown *iUnknown, const char *body, IOwner notify, INotifyFunc handler)
-{
- int len = strlen(body) + 1;
- Request request;
- request.msgId = MSG_PROC;
- request.msgValue = 0;
- request.len = (uint32_t)(sizeof(struct AsyncBody) + len);
- request.data = malloc(request.len);
- if (request.data == NULL) {
- return FALSE;
- }
- if (strcpy_s(((AsyncBody *)request.data)->body, len, body) != EOK) {
- free(request.data);
- return FALSE;
- }
- ((AsyncBody *)request.data)->owner = notify;
- ((AsyncBody *)request.data)->handler = handler;
- DemoFeature *feature = GET_OBJECT(iUnknown, DemoFeature, iUnknown);
- HILOG_INFO(HILOG_MODULE_APP, "[TID:0x%lx]AsyncCallBack[%p, %s, %p, %p]!",
- (unsigned long)pthread_self(), iUnknown, body, notify, handler);
- return SAMGR_SendRequest(&feature->identity, &request, LocalHandler);
-}
-enum FUNCID {
- ID_ASYNCALL = 0,
- ID_ASYNTIMECALL,
- ID_SYNCCALL,
- ID_ASYNCCALLBACK
-};
-static int32 Invoke(IServerProxy *iProxy, int funcId, void *origin, IpcIo *req, IpcIo *reply)
-{
- HILOG_INFO(HILOG_MODULE_APP, "[TID:0x%lx]Feature Remote Invoke is called! <%p, %d, %p, %p, %p>",
- (unsigned long)pthread_self(), iProxy, funcId, origin, req, reply);
- DemoFeatureApi *api = (DemoFeatureApi *)iProxy;
- BOOL ret;
- size_t len = 0;
- switch (funcId) {
- case ID_ASYNCALL:
- ret = api->AsyncCall((IUnknown *)iProxy, (char *)IpcIoPopString(req, &len));
- IpcIoPushBool(reply, ret);
- break;
- case ID_ASYNTIMECALL:
- ret = api->AsyncTimeCall((IUnknown *)iProxy);
- IpcIoPushBool(reply, ret);
- break;
- case ID_SYNCCALL: {
- struct Payload payload;
- payload.id = IpcIoPopInt32(req);
- payload.value = IpcIoPopInt32(req);
- payload.name = (char *)IpcIoPopString(req, &len);
- ret = api->SyncCall((IUnknown *)iProxy, &payload);
- IpcIoPushString(reply, ret ? "TRUE" : "FALSE");
- }
- break;
- case ID_ASYNCCALLBACK: { // convert to sync proxy
- IpcIoPushString(reply, "Yes, you did!");
- IpcIoPushBool(reply, TRUE);
- }
- break;
- default:
- IpcIoPushBool(reply, FALSE);
- break;
- }
- return EC_SUCCESS;
-}
-static void Init(void)
-{
- SAMGR_GetInstance()->RegisterFeature(EXAMPLE_SERVICE, (Feature *)&g_example);
- SAMGR_GetInstance()->RegisterFeatureApi(EXAMPLE_SERVICE, EXAMPLE_FEATURE, GET_IUNKNOWN(g_example));
-}
-SYSEX_FEATURE_INIT(Init);
-
diff --git a/example/provider/proc.c b/example/provider/proc.c
deleted file mode 100755
index b2cb1ab..0000000
--- a/example/provider/proc.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2020 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.
- */
-#include
-#include
-#include "samgr_lite.h"
-const char FUN_ARG_S[] = "0123456I";
-#define DEFAULT 0
-#define MAX_LEN 0x100
-void __attribute__((weak)) OHOS_SystemInit(void)
-{
- SAMGR_Bootstrap();
-};
-void HiLogPrintf(unsigned char module, unsigned char level, const char *nums, const char *fmt, ...);
-int main()
-{
- HiLogPrintf(DEFAULT, DEFAULT, NULL, "Start Provider System Start");
- OHOS_SystemInit();
- HiLogPrintf(DEFAULT, DEFAULT, NULL, "Start Provider System End");
- pause();
-}
-void __attribute__((weak)) HiLogPrintf(unsigned char module, unsigned char level,
- const char *nums, const char *fmt, ...)
-{
- static char buf[MAX_LEN] = {0};
- va_list args;
- va_start(args, fmt);
- int ret = vsprintf_s(buf, sizeof(buf), fmt, args);
- va_end(args);
- if (ret < 0) {
- printf("Provider fmt failed(%d)", ret);
- }
- printf("Provider M:%d l:%d %s\n", module, level, buf);
-}
\ No newline at end of file
diff --git a/example/provider/service_example.c b/example/provider/service_example.c
deleted file mode 100755
index e148e8c..0000000
--- a/example/provider/service_example.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2020 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.
- */
-#include "example.h"
-#include
-#include
-#include
-#include
-#include "iproxy_server.h"
-#include "feature.h"
-#include "service.h"
-#include "samgr_lite.h"
-
-typedef struct ExampleService {
- INHERIT_SERVICE;
- INHERIT_IUNKNOWNENTRY(DefaultFeatureApi);
- Identity identity;
-} ExampleService;
-
-static const char *GetName(Service *service)
-{
- (void)service;
- return EXAMPLE_SERVICE;
-}
-static BOOL Initialize(Service *service, Identity identity)
-{
- ExampleService *example = (ExampleService *)service;
- example->identity = identity;
- HILOG_DEBUG(HILOG_MODULE_APP, "[TID:0x%lx]Initialize(%s)! Identity<%d, %d, %p>", (unsigned long)pthread_self(),
- EXAMPLE_SERVICE, identity.serviceId, identity.featureId, identity.queueId);
- return TRUE;
-}
-
-static BOOL MessageHandle(Service *service, Request *msg)
-{
- HILOG_INFO(HILOG_MODULE_APP, "[TID:0x%lx]MessageHandle(%s)! Request<%d, %d, %p>",
- (unsigned long)pthread_self(), service->GetName(service), msg->msgId, msg->msgValue, msg->data);
- return FALSE;
-}
-
-static TaskConfig GetTaskConfig(Service *service)
-{
- (void)service;
- TaskConfig config = {LEVEL_HIGH, PRI_BELOW_NORMAL, 0x800, 20, SHARED_TASK};
- return config;
-}
-static void SyncCall(IUnknown *iUnknown)
-{
- HILOG_INFO(HILOG_MODULE_APP, "[TID:0x%lx]SyncCall is called! iUnknown[%p]",
- (unsigned long)pthread_self(), iUnknown);
-}
-static int32 Invoke(IServerProxy *iProxy, int funcId, void *origin, IpcIo *req, IpcIo *reply)
-{
- HILOG_INFO(HILOG_MODULE_APP, "[TID:0x%lx]Service Remote Invoke is called! <%p, %d, %p, %p, %p>",
- (unsigned long)pthread_self(), iProxy, funcId, origin, req, reply);
- DefaultFeatureApi *defaultApi = (DefaultFeatureApi *)iProxy;
- if (funcId == 0) {
- defaultApi->SyncCall((IUnknown *)iProxy);
- }
- return EC_SUCCESS;
-}
-static ExampleService g_example = {
- .GetName = GetName,
- .Initialize = Initialize,
- .MessageHandle = MessageHandle,
- .GetTaskConfig = GetTaskConfig,
- SERVER_IPROXY_IMPL_BEGIN,
- .Invoke = Invoke,
- .SyncCall = SyncCall,
- IPROXY_END,
-};
-
-static void Init(void)
-{
- SAMGR_GetInstance()->RegisterService((Service *)&g_example);
- SAMGR_GetInstance()->RegisterDefaultFeatureApi(EXAMPLE_SERVICE, GET_IUNKNOWN(g_example));
-}
-SYSEX_SERVICE_INIT(Init);
diff --git a/figures/position-of-this-repository-(in-the-dotted-blue-box)-in-the-multimedia-subsystem.png b/figures/position-of-this-repository-(in-the-dotted-blue-box)-in-the-multimedia-subsystem.png
new file mode 100644
index 0000000..51177ee
Binary files /dev/null and b/figures/position-of-this-repository-(in-the-dotted-blue-box)-in-the-multimedia-subsystem.png differ
diff --git a/figures/媒体子系统架构(蓝色虚线框是sample_app).png b/figures/媒体子系统架构(蓝色虚线框是sample_app).png
new file mode 100644
index 0000000..ea8b237
Binary files /dev/null and b/figures/媒体子系统架构(蓝色虚线框是sample_app).png differ
diff --git a/gallery/BUILD.gn b/gallery/BUILD.gn
old mode 100644
new mode 100755
index 3c7e28c..330925c
--- a/gallery/BUILD.gn
+++ b/gallery/BUILD.gn
@@ -11,79 +11,66 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import("//build/lite/config/component/lite_component.gni")
import("//build/lite/config/hap_pack.gni")
shared_library("gallery") {
- sources = [
- "src/gallery_ability.cpp",
- "src/gallery_ability_slice.cpp",
- "src/picture_ability_slice.cpp",
- "src/player_ability_slice.cpp",
- ]
+ sources = [
+ "src/gallery_ability.cpp",
+ "src/gallery_ability_slice.cpp",
+ "src/picture_ability_slice.cpp",
+ "src/player_ability_slice.cpp",
+ ]
- include_dirs = [
- "include",
- "//foundation/aafwk/interfaces/kits/ability_lite",
- "//foundation/graphic/lite/interfaces/kits/ui/components",
- "//foundation/graphic/lite/interfaces/kits/ui",
- "//foundation/graphic/lite/interfaces/kits/utils",
- "//foundation/graphic/lite/interfaces/kits/config",
- "//foundation/appexecfwk/interfaces/kits/bundle_lite",
- "//foundation/aafwk/interfaces/kits/want_lite",
- "//foundation/multimedia/interfaces/kits/player_lite",
- "//base/startup/interfaces/kits/syspara_lite"
- ]
+ include_dirs = [
+ "include",
+ "${aafwk_lite_path}/interfaces/kits/ability_lite",
+ "${appexecfwk_lite_path}/interfaces/kits/bundle_lite",
+ "${aafwk_lite_path}/interfaces/kits/want_lite",
+ "//foundation/multimedia/media_lite/interfaces/kits/player_lite",
+ "//base/startup/syspara_lite/interfaces/kits",
+ ]
- deps = [
- "//foundation/aafwk/frameworks/ability_lite:aafwk_abilitykit_lite",
- "//foundation/appexecfwk/frameworks/bundle_lite:bundle",
- "//foundation/communication/frameworks/ipc_lite:liteipc_adapter",
- "//foundation/distributedschedule/services/samgr_lite/samgr:samgr",
- "//utils/native/lite/kv_store:kv_store",
- "//foundation/graphic/lite/frameworks/ui:ui",
- "//foundation/graphic/lite/frameworks/surface",
- "//foundation/graphic/lite/utils:graphic_utils",
- "//foundation/multimedia/frameworks/recorder_lite:recorder",
- "//foundation/multimedia/frameworks/player_lite:player"
- ]
+ deps = [
+ "${aafwk_lite_path}/frameworks/ability_lite:aafwk_abilitykit_lite",
+ "${appexecfwk_lite_path}/frameworks/bundle_lite:bundle",
+ "//foundation/communication/ipc_lite:liteipc_adapter",
+ "//foundation/distributedschedule/samgr_lite/samgr:samgr",
+ "//foundation/graphic/surface",
+ "//foundation/graphic/ui:lite_ui",
+ "//foundation/graphic/utils:lite_graphic_utils",
+ "//foundation/multimedia/media_lite/frameworks/player_lite:player_lite",
+ "//foundation/multimedia/media_lite/frameworks/recorder_lite:recorder_lite",
+ "//utils/native/lite/kv_store:kv_store",
+ ]
- ldflags = [
- "-shared",
- ]
+ ldflags = [ "-shared" ]
- ldflags += ["-lstdc++"]
- ldflags += ["-lpthread"]
- ldflags += ["-L$ohos_root_path/sysroot/usr/lib"]
- ldflags += ["-Wl,-rpath-link=$ohos_root_path/sysroot/usr/lib"]
- ldflags += ["-lui",
- "-lsurface",
- "-lplayer",
- "-lability"
- ]
+ ldflags += [ "-lstdc++" ]
+ ldflags += [ "-lpthread" ]
+ ldflags += [ "-L$ohos_root_path/sysroot/usr/lib" ]
+ ldflags += [ "-Wl,-rpath-link=$ohos_root_path/sysroot/usr/lib" ]
+ ldflags += [
+ "-lui",
+ "-lsurface",
+ "-lplayer_lite",
+ "-lability",
+ ]
- defines = [
- "OHOS_APPEXECFWK_BMS_BUNDLEMANAGER",
- "ENABLE_WINDOW=1",
- "ABILITY_WINDOW_SUPPORT"
- ]
+ defines = [
+ "OHOS_APPEXECFWK_BMS_BUNDLEMANAGER",
+ "ENABLE_WINDOW=1",
+ "ABILITY_WINDOW_SUPPORT",
+ ]
}
-lite_component("gallery_component") {
-
- features = [
- ":gallery",
- ]
-}
-
-hap_pack("gallery_hap")
-{
- deps = [":gallery"]
- mode = "hap"
- json_path = "config.json"
- ability_so_path = "$root_out_dir/libgallery.so"
- force = "true"
- cert_profile = "cert/gallery_HarmonyAppProvision_Release.p7b"
- resources_path = "resources"
- hap_name = "gallery"
+hap_pack("gallery_hap") {
+ deps = [ ":gallery" ]
+ mode = "hap"
+ json_path = "config.json"
+ ability_so_path = "$root_out_dir/libgallery.so"
+ force = "true"
+ cert_profile = "cert/gallery_HarmonyAppProvision_Release.p7b"
+ resources_path = "resources"
+ hap_name = "gallery"
+ privatekey = "HOS Application Provision Release"
}
diff --git a/gallery/cert/gallery_HarmonyAppProvision_Release.p7b b/gallery/cert/gallery_HarmonyAppProvision_Release.p7b
old mode 100644
new mode 100755
diff --git a/gallery/config.json b/gallery/config.json
old mode 100644
new mode 100755
index 53c68e3..b0bcaf8
--- a/gallery/config.json
+++ b/gallery/config.json
@@ -1,99 +1,99 @@
-{
- "app": {
- "bundleName": "com.huawei.gallery",
- "vendor": "huawei",
- "version": {
- "code": 1,
- "name": "1.0"
- },
- "apiVersion": {
- "compatible": 3,
- "target": 4
- }
- },
- "deviceConfig": {
- "default": {
- }
- },
- "module": {
- "package": "com.huawei.gallery",
- "name": ".MyHarmonyAbilityPackage",
- "deviceType": [
- "phone",
- "tv",
- "tablet",
- "pc",
- "car",
- "smartWatch",
- "sportsWatch",
- "smartVision"
- ],
- "distro": {
- "deliveryWithInstall": true,
- "moduleName": "gallery",
- "moduleType": "entry"
- },
- "abilities": [
- {
- "name": "GalleryAbility",
- "icon": "assets/gallery/resources/drawable/com.huawei.photos.png",
- "label": "test app 1",
- "launchType": "standard",
- "type": "page",
- "visible": true
- }
- ],
- "reqPermissions": [
- {
- "name": "ohos.permission.MODIFY_AUDIO_SETTINGS",
- "reason": "SYSTEM_GRANT",
- "usedScene": {
- "ability": [
- ".FormAbility"
- ],
- "when": "inuse"
- }
- },
- {
- "name": "ohos.permission.READ_MEDIA",
- "reason": "USER_GRANT",
- "usedScene": {
- "ability": [
- ".FormAbility"
- ],
- "when": "inuse"
- }
- },
- {
- "name": "ohos.permission.READ_MEDIA_AUDIO",
- "reason": "USER_GRANT",
- "usedScene": {
- "ability": [
- ".FormAbility"
- ],
- "when": "inuse"
- }
- },
- {
- "name": "ohos.permission.READ_MEDIA_IMAGES",
- "reason": "USER_GRANT",
- "usedScene": {
- "ability": [
- ".FormAbility"
- ],
- "when": "inuse"
- }
- },
- {
- "name": "ohos.permission.READ_MEDIA_VIDEO",
- "reason": "USER_GRANT",
- "usedScene": {
- "ability": [
- ".FormAbility"
- ],
- "when": "inuse"
- }
- }
- ]
- }
+{
+ "app": {
+ "bundleName": "com.huawei.gallery",
+ "vendor": "huawei",
+ "version": {
+ "code": 1,
+ "name": "1.0"
+ },
+ "apiVersion": {
+ "compatible": 3,
+ "target": 4
+ }
+ },
+ "deviceConfig": {
+ "default": {
+ }
+ },
+ "module": {
+ "package": "com.huawei.gallery",
+ "name": ".MyHarmonyAbilityPackage",
+ "deviceType": [
+ "phone",
+ "tv",
+ "tablet",
+ "pc",
+ "car",
+ "smartWatch",
+ "sportsWatch",
+ "smartVision"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "gallery",
+ "moduleType": "entry"
+ },
+ "abilities": [
+ {
+ "name": "GalleryAbility",
+ "icon": "assets/gallery/resources/drawable/com.huawei.photos.png",
+ "label": "test app 1",
+ "launchType": "standard",
+ "type": "page",
+ "visible": true
+ }
+ ],
+ "reqPermissions": [
+ {
+ "name": "ohos.permission.MODIFY_AUDIO_SETTINGS",
+ "reason": "SYSTEM_GRANT",
+ "usedScene": {
+ "ability": [
+ ".FormAbility"
+ ],
+ "when": "inuse"
+ }
+ },
+ {
+ "name": "ohos.permission.READ_MEDIA",
+ "reason": "USER_GRANT",
+ "usedScene": {
+ "ability": [
+ ".FormAbility"
+ ],
+ "when": "inuse"
+ }
+ },
+ {
+ "name": "ohos.permission.READ_MEDIA_AUDIO",
+ "reason": "USER_GRANT",
+ "usedScene": {
+ "ability": [
+ ".FormAbility"
+ ],
+ "when": "inuse"
+ }
+ },
+ {
+ "name": "ohos.permission.READ_MEDIA_IMAGES",
+ "reason": "USER_GRANT",
+ "usedScene": {
+ "ability": [
+ ".FormAbility"
+ ],
+ "when": "inuse"
+ }
+ },
+ {
+ "name": "ohos.permission.READ_MEDIA_VIDEO",
+ "reason": "USER_GRANT",
+ "usedScene": {
+ "ability": [
+ ".FormAbility"
+ ],
+ "when": "inuse"
+ }
+ }
+ ]
+ }
}
\ No newline at end of file
diff --git a/gallery/include/event_listener.h b/gallery/include/event_listener.h
old mode 100644
new mode 100755
index 2c4403f..977d14e
--- a/gallery/include/event_listener.h
+++ b/gallery/include/event_listener.h
@@ -36,20 +36,28 @@ public:
onLongPress_ = std::move(onLongPress);
}
- bool OnClick(UIView &view, const ClickEvent &event) override
+ bool OnClick(UIView& view, const ClickEvent &event) override
{
if (!onClick_) {
return false;
}
- return onClick_(view, event);
+ UIView *currentView = &view;
+ if (currentView == nullptr) {
+ return false;
+ }
+ return onClick_(*currentView, event);
}
- bool OnLongPress(UIView &view, const LongPressEvent &event) override
+ bool OnLongPress(UIView& view, const LongPressEvent &event) override
{
if (!onLongPress_) {
return false;
}
- return onLongPress_(view, event);
+ UIView *currentView = &view;
+ if (currentView == nullptr) {
+ return false;
+ }
+ return onLongPress_(*currentView, event);
}
private:
diff --git a/gallery/include/gallery_ability.h b/gallery/include/gallery_ability.h
old mode 100644
new mode 100755
diff --git a/gallery/include/gallery_ability_slice.h b/gallery/include/gallery_ability_slice.h
old mode 100644
new mode 100755
index 0222f52..446a89c
--- a/gallery/include/gallery_ability_slice.h
+++ b/gallery/include/gallery_ability_slice.h
@@ -59,6 +59,8 @@ private:
UIScrollView* picContainer_ { nullptr };
UIViewGroup* picList_ { nullptr };
char* pictureName_[MAX_PICTURE_COUNT] = { nullptr };
+ char backIconAbsolutePath[MAX_PATH_LENGTH] = { 0 };
+ char videoTagIconAbsolutePath[MAX_PATH_LENGTH] = { 0 };
uint16_t pictureOnClickListenerCount_ { 0 };
EventListener* pictureOnClickListener_[MAX_PICTURE_COUNT] = { nullptr };
};
diff --git a/gallery/include/gallery_config.h b/gallery/include/gallery_config.h
old mode 100644
new mode 100755
index b4ba13d..5106517
--- a/gallery/include/gallery_config.h
+++ b/gallery/include/gallery_config.h
@@ -25,8 +25,6 @@ static const char* const VIDEO_PAUSE_PATH = "/gallery/assets/gallery/resources/d
static constexpr int16_t MAX_PICTURE_COUNT = 256;
static constexpr uint16_t MAX_PATH_LENGTH = 512;
-static char g_backIconAbsolutePath[MAX_PATH_LENGTH] = {0};
-static char g_videoTagIconAbsolutePath[MAX_PATH_LENGTH] = {0};
/** thumb, photo, and video folder path */
static const char* const THUMBNAIL_DIRECTORY = "/userdata/thumb";
@@ -69,10 +67,6 @@ static const char* const PHOTO_PREFIX = "photo";
static const char* const AVAILABEL_SOURCE_TYPE = ".mp4";
static const char* const AVAILABEL_SOURCE_TYPE_MP4 = ".MP4";
-/** player */
-static char g_videoPlayAbsolutePath[MAX_PATH_LENGTH] = {0};
-static char g_videoPauseAbsolutePath[MAX_PATH_LENGTH] = {0};
-
/** playback status bar */
static constexpr uint16_t STATUS_BAR_GROUP_HEIGHT = 96;
static constexpr uint16_t TOGGLE_BUTTON_OFFSET_X = 36;
diff --git a/gallery/include/picture_ability_slice.h b/gallery/include/picture_ability_slice.h
old mode 100644
new mode 100755
index 1e63818..cda41dd
--- a/gallery/include/picture_ability_slice.h
+++ b/gallery/include/picture_ability_slice.h
@@ -20,6 +20,7 @@
#include "components/ui_image_view.h"
#include "components/ui_view_group.h"
#include "event_listener.h"
+#include "gallery_config.h"
namespace OHOS {
class PictureAbilitySlice : public AbilitySlice {
@@ -43,6 +44,7 @@ private:
UIImageView* backIcon_ { nullptr };
EventListener* backIconListener_ { nullptr };
UIImageView* picture_ { nullptr };
+ char backIconAbsolutePath[MAX_PATH_LENGTH] = { 0 };
};
}
diff --git a/gallery/include/player_ability_slice.h b/gallery/include/player_ability_slice.h
old mode 100644
new mode 100755
index 79981d9..0b6d091
--- a/gallery/include/player_ability_slice.h
+++ b/gallery/include/player_ability_slice.h
@@ -52,7 +52,7 @@ public:
virtual ~ToggleBtnListener() {}
- bool OnClick(UIView& view, const ClickEvent& event) override;
+ bool OnClick(UIView &view, const ClickEvent& event) override;
void SetCompleteFlag(bool state)
{
@@ -145,6 +145,9 @@ private:
UISlider* slider_ { nullptr };
UILabel* totalTimeLabel_ { nullptr };
UILabel* errorTips_ { nullptr };
+ char backIconAbsolutePath[MAX_PATH_LENGTH] = { 0 };
+ char videoPlayAbsolutePath[MAX_PATH_LENGTH] = { 0 };
+ char videoPauseAbsolutePath[MAX_PATH_LENGTH] = { 0 };
};
} // namespace OHOS
#endif // OHOS_PLAYER_ABILITY_SLICE_H
\ No newline at end of file
diff --git a/gallery/resources/drawable/bg_gradient_mask.png b/gallery/resources/drawable/bg_gradient_mask.png
old mode 100644
new mode 100755
diff --git a/gallery/resources/drawable/com.huawei.photos.png b/gallery/resources/drawable/com.huawei.photos.png
old mode 100644
new mode 100755
diff --git a/gallery/resources/drawable/ctrl_progressbar_dot.png b/gallery/resources/drawable/ctrl_progressbar_dot.png
old mode 100644
new mode 100755
diff --git a/gallery/resources/drawable/ctrl_seekbar_dot.png b/gallery/resources/drawable/ctrl_seekbar_dot.png
old mode 100644
new mode 100755
diff --git a/gallery/resources/drawable/ic_back.png b/gallery/resources/drawable/ic_back.png
old mode 100644
new mode 100755
diff --git a/gallery/resources/drawable/ic_gallery_pause.png b/gallery/resources/drawable/ic_gallery_pause.png
old mode 100644
new mode 100755
diff --git a/gallery/resources/drawable/ic_gallery_play.png b/gallery/resources/drawable/ic_gallery_play.png
old mode 100644
new mode 100755
diff --git a/gallery/resources/drawable/ic_gallery_video_tag.png b/gallery/resources/drawable/ic_gallery_video_tag.png
old mode 100644
new mode 100755
diff --git a/gallery/src/gallery_ability.cpp b/gallery/src/gallery_ability.cpp
old mode 100644
new mode 100755
diff --git a/gallery/src/gallery_ability_slice.cpp b/gallery/src/gallery_ability_slice.cpp
old mode 100644
new mode 100755
index 1e610b3..5fadc47
--- a/gallery/src/gallery_ability_slice.cpp
+++ b/gallery/src/gallery_ability_slice.cpp
@@ -121,7 +121,7 @@ void GalleryAbilitySlice::InitTitle()
printf("GalleryAbilitySlice::InitTitle | start \n");
backIcon_ = new UIImageView();
backIcon_->SetPosition(BACK_ICON_POSITION_X, BACK_ICON_POSITION_Y);
- backIcon_->SetSrc(g_backIconAbsolutePath);
+ backIcon_->SetSrc(backIconAbsolutePath);
backIcon_->SetTouchable(true);
backArea_ = new UIViewGroup();
@@ -198,19 +198,19 @@ void GalleryAbilitySlice::AddAllPictures(const Point& pos, int16_t numInLine)
{
printf("GalleryAbilitySlice::AddAllPictures | start | %d\n", numInLine);
Point imagePos = pos;
- void* drip = FileOpenDir(THUMBNAIL_DIRECTORY);
+ DIR* drip = opendir(THUMBNAIL_DIRECTORY);
if (drip == nullptr) {
return;
}
- FileDirentInfo* info = new FileDirentInfo();
- while (FileReadDir(drip, info) >= 0 && pictureCount_ < MAX_PICTURE_COUNT) {
- uint16_t imageNameLen = static_cast(strlen(info->name));
- if (imageNameLen > MAX_PATH_LENGTH) {
+ struct dirent* info = nullptr;
+ while ((info = readdir(drip)) != nullptr && pictureCount_ < MAX_PICTURE_COUNT) {
+ uint16_t imageNameLen = static_cast(strlen(info->d_name));
+ if (imageNameLen > MAX_PATH_LENGTH || (strcmp(info->d_name, ".") == 0) || (strcmp(info->d_name, "..") == 0)) {
printf("GalleryAbilitySlice::AddAllPictures | imageNameLen > MAX_PATH_LENGTH | %d\n", imageNameLen);
continue;
}
char* imageName = new char[imageNameLen + 1]();
- memcpy_s(imageName, imageNameLen + 1, info->name, imageNameLen + 1);
+ memcpy_s(imageName, imageNameLen + 1, info->d_name, imageNameLen + 1);
pictureName_[pictureCount_] = imageName;
pictureCount_++;
@@ -220,7 +220,7 @@ void GalleryAbilitySlice::AddAllPictures(const Point& pos, int16_t numInLine)
continue;
}
char* imagePath = new char[pathLen + 1]();
- if (sprintf_s(imagePath, pathLen + 1, "%s/%s", THUMBNAIL_DIRECTORY, info->name) < 0) {
+ if (sprintf_s(imagePath, pathLen + 1, "%s/%s", THUMBNAIL_DIRECTORY, info->d_name) < 0) {
printf("GalleryAbilitySlice::AddAllPictures | sprintf_s error\n");
delete[] imagePath;
continue;
@@ -237,7 +237,7 @@ void GalleryAbilitySlice::AddAllPictures(const Point& pos, int16_t numInLine)
}
}
delete info;
- FileCloseDir(drip);
+ closedir(drip);
}
UIView* GalleryAbilitySlice::CreateImageItem(const Point& pos, const char* imageName, const char* imagePath)
@@ -264,7 +264,7 @@ UIView* GalleryAbilitySlice::CreateImageItem(const Point& pos, const char* image
UIImageView* videoTag = new UIImageView();
videoTag->SetPosition(VIDEO_TAG_POSITION_X, VIDEO_TAG_POSITION_Y);
- videoTag->SetSrc(g_videoTagIconAbsolutePath);
+ videoTag->SetSrc(videoTagIconAbsolutePath);
videoTag->SetTouchable(true);
videoTag->SetOnClickListener(imageView->GetOnClickListener());
@@ -319,31 +319,31 @@ void GalleryAbilitySlice::DeleteAllData()
void GalleryAbilitySlice::DeleteAllFilesInDir(const char* path)
{
- void* drip = FileOpenDir(path);
+ DIR* drip = opendir(path);
if (drip == nullptr) {
return;
}
- FileDirentInfo* info = new FileDirentInfo();
- while (FileReadDir(drip, info) >= 0) {
- uint16_t fileNameLen = static_cast(strlen(info->name));
+ struct dirent* info = nullptr;
+ while ((info = readdir(drip)) != nullptr) {
+ uint16_t fileNameLen = static_cast(strlen(info->d_name));
uint16_t pathLen = static_cast(strlen(path)) + fileNameLen + 1;
if (pathLen > MAX_PATH_LENGTH) {
printf("GalleryAbilitySlice::AddAllPictures | pathLen > MAX_PATH_LENGTH | %d\n", pathLen);
continue;
}
char* filePath = new char[pathLen + 1]();
- if (sprintf_s(filePath, pathLen + 1, "%s/%s", path, info->name) < 0) {
+ if (sprintf_s(filePath, pathLen + 1, "%s/%s", path, info->d_name) < 0) {
printf("GalleryAbilitySlice::AddAllPictures | sprintf_s error\n");
delete[] filePath;
continue;
}
- if (FileUnlink(filePath) != 0) {
+ if (unlink(filePath) != 0) {
printf("unlink file error | %s\n", filePath);
}
delete[] filePath;
}
delete info;
- FileCloseDir(drip);
+ closedir(drip);
printf("GalleryAbilitySlice::DeleteAllFilesInDir() | success | %s\n", path);
}
@@ -357,12 +357,12 @@ void GalleryAbilitySlice::OnStart(const Want &want)
rootView_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
const char* pathHeader = GetSrcPath();
- if (sprintf_s(g_backIconAbsolutePath, MAX_PATH_LENGTH, "%s%s", pathHeader, BACK_ICON_PATH) < 0) {
- printf("GalleryAbilitySlice::OnStart | g_backIconAbsolutePath error");
+ if (sprintf_s(backIconAbsolutePath, MAX_PATH_LENGTH, "%s%s", pathHeader, BACK_ICON_PATH) < 0) {
+ printf("GalleryAbilitySlice::OnStart | backIconAbsolutePath error");
return;
}
- if (sprintf_s(g_videoTagIconAbsolutePath, MAX_PATH_LENGTH, "%s%s", pathHeader, VIDEO_TAG_ICON_PATH) < 0) {
- printf("GalleryAbilitySlice::OnStart | g_videoTagIconAbsolutePath error");
+ if (sprintf_s(videoTagIconAbsolutePath, MAX_PATH_LENGTH, "%s%s", pathHeader, VIDEO_TAG_ICON_PATH) < 0) {
+ printf("GalleryAbilitySlice::OnStart | videoTagIconAbsolutePath error");
return;
}
diff --git a/gallery/src/picture_ability_slice.cpp b/gallery/src/picture_ability_slice.cpp
old mode 100644
new mode 100755
index e038eac..63e26e1
--- a/gallery/src/picture_ability_slice.cpp
+++ b/gallery/src/picture_ability_slice.cpp
@@ -58,7 +58,7 @@ void PictureAbilitySlice::InitTitle()
printf("PictureAbilitySlice::InitTitle | start \n");
backIcon_ = new UIImageView();
backIcon_->SetPosition(BACK_ICON_POSITION_X, BACK_ICON_POSITION_Y);
- backIcon_->SetSrc(g_backIconAbsolutePath);
+ backIcon_->SetSrc(backIconAbsolutePath);
backIcon_->SetTouchable(true);
backArea_ = new UIViewGroup();
@@ -101,7 +101,7 @@ void PictureAbilitySlice::InitPicture(const char* path)
}
float scale = (scaleWidth < scaleHeight) ? scaleWidth : scaleHeight;
printf("########## scale: %f \n", scale);
- transMap.Scale(Vector2(scale, scale), Vector2(0, 0));
+ transMap.Scale(Vector2(scale, scale), Vector2(0, 0));
picture_->SetTransformMap(transMap);
picture_->SetTransformAlgorithm(TransformAlgorithm::NEAREST_NEIGHBOR);
imageWidth = imageWidth * scale;
@@ -134,12 +134,16 @@ void PictureAbilitySlice::OnStart(const Want &want)
char* imagePath = new char[imagePathLen + 1]();
if (sprintf_s(imagePath, imagePathLen + 1, "%s/%s", PHOTO_DIRECTORY, reinterpret_cast(want.data)) < 0) {
printf("PictureAbilitySlice::OnStart | imagePath\n");
+ delete[] imagePath;
+ imagePath = nullptr;
return;
}
const char* pathHeader = GetSrcPath();
- if (sprintf_s(g_backIconAbsolutePath, MAX_PATH_LENGTH, "%s%s", pathHeader, BACK_ICON_PATH) < 0) {
- printf("PictureAbilitySlice::OnStart | g_backIconAbsolutePath\n");
+ if (sprintf_s(backIconAbsolutePath, MAX_PATH_LENGTH, "%s%s", pathHeader, BACK_ICON_PATH) < 0) {
+ printf("PictureAbilitySlice::OnStart | backIconAbsolutePath\n");
+ delete[] imagePath;
+ imagePath = nullptr;
return;
}
@@ -174,4 +178,4 @@ void PictureAbilitySlice::OnStop()
AbilitySlice::OnStop();
Clear();
}
-}
\ No newline at end of file
+}
diff --git a/gallery/src/player_ability_slice.cpp b/gallery/src/player_ability_slice.cpp
old mode 100644
new mode 100755
index 589bc49..4e943b6
--- a/gallery/src/player_ability_slice.cpp
+++ b/gallery/src/player_ability_slice.cpp
@@ -134,11 +134,11 @@ void PlayerAbilitySlice::SetUpBackArea(const char* pathHeader)
backIcon_ = new UIImageView();
backIcon_->SetPosition(BACK_ICON_POSITION_X, BACK_ICON_POSITION_Y);
- if (sprintf_s(g_backIconAbsolutePath, MAX_PATH_LENGTH, "%s%s", pathHeader, BACK_ICON_PATH) < 0) {
- printf("PlayerAbilitySlice::OnStart | g_backIconAbsolutePath | %s\n", pathHeader);
+ if (sprintf_s(backIconAbsolutePath, MAX_PATH_LENGTH, "%s%s", pathHeader, BACK_ICON_PATH) < 0) {
+ printf("PlayerAbilitySlice::OnStart | backIconAbsolutePath | %s\n", pathHeader);
return;
}
- backIcon_->SetSrc(g_backIconAbsolutePath);
+ backIcon_->SetSrc(backIconAbsolutePath);
backIcon_->SetTouchable(true);
backIconListener_ = new EventListener(onClick, nullptr);
backIcon_->SetOnClickListener(backIconListener_);
@@ -303,20 +303,19 @@ void PlayerAbilitySlice::SetUpToggleButton(const char* pathHeader)
TOGGLE_BUTTON_WIDTH, TOGGLE_BUTTON_HEIGHT);
toggleButton_->SetState(true);
- if (sprintf_s(g_videoPlayAbsolutePath, MAX_PATH_LENGTH, "%s%s", pathHeader, VIDEO_PALY_PATH) < 0) {
- printf("PlayerAbilitySlice::OnStart | g_videoPlayAbsolutePath\n");
+ if (sprintf_s(videoPlayAbsolutePath, MAX_PATH_LENGTH, "%s%s", pathHeader, VIDEO_PALY_PATH) < 0) {
+ printf("PlayerAbilitySlice::OnStart | videoPlayAbsolutePath\n");
return;
}
- if (sprintf_s(g_videoPauseAbsolutePath, MAX_PATH_LENGTH, "%s%s", pathHeader, VIDEO_PAUSE_PATH) < 0) {
- printf("PlayerAbilitySlice::OnStart | g_videoPauseAbsolutePath\n");
+ if (sprintf_s(videoPauseAbsolutePath, MAX_PATH_LENGTH, "%s%s", pathHeader, VIDEO_PAUSE_PATH) < 0) {
+ printf("PlayerAbilitySlice::OnStart | videoPauseAbsolutePath\n");
return;
}
- toggleButton_->SetImages(g_videoPauseAbsolutePath, g_videoPlayAbsolutePath);
+ toggleButton_->SetImages(videoPauseAbsolutePath, videoPlayAbsolutePath);
onClickListener_ = new ToggleBtnListener(toggleButton_, videoPlayer_, animator_, surfaceView_);
toggleButtonArea_ = new UIViewGroup();
- toggleButtonArea_->SetStyle(STYLE_BACKGROUND_OPA, 0);
toggleButtonArea_->SetPosition(0, 0, TOGGLE_BUTTON_OFFSET_X + TOGGLE_BUTTON_WIDTH, STATUS_BAR_GROUP_HEIGHT);
toggleButtonArea_->SetTouchable(true);
toggleButtonArea_->SetOnClickListener(onClickListener_);
@@ -428,7 +427,7 @@ void SliderAnimator::Callback(UIView* view)
}
}
-bool ToggleBtnListener::OnClick(UIView& view, const ClickEvent& event)
+bool ToggleBtnListener::OnClick(UIView &view, const ClickEvent& event)
{
button_->OnClickEvent(event);
if (completeFlag_) {
diff --git a/launcher/BUILD.gn b/launcher/BUILD.gn
old mode 100644
new mode 100755
index 0e672f5..d68095a
--- a/launcher/BUILD.gn
+++ b/launcher/BUILD.gn
@@ -10,66 +10,55 @@
# 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("//build/lite/config/component/lite_component.gni")
+
import("//build/lite/config/hap_pack.gni")
shared_library("launcher") {
- sources = [
- "launcher/src/main/cpp/main_ability.cpp",
- "launcher/src/main/cpp/main_ability_slice.cpp",
- "launcher/src/main/cpp/swipe_view.cpp",
- "launcher/src/main/cpp/app_info.cpp",
- "launcher/src/main/cpp/long_press_view.cpp",
- "launcher/src/main/cpp/app_manage.cpp",
- "launcher/src/main/cpp/view_group_page.cpp",
- "launcher/src/main/cpp/time_weather_view.cpp"
- ]
+ sources = [
+ "launcher/src/main/cpp/app_info.cpp",
+ "launcher/src/main/cpp/app_manage.cpp",
+ "launcher/src/main/cpp/long_press_view.cpp",
+ "launcher/src/main/cpp/main_ability.cpp",
+ "launcher/src/main/cpp/main_ability_slice.cpp",
+ "launcher/src/main/cpp/swipe_view.cpp",
+ "launcher/src/main/cpp/time_weather_view.cpp",
+ "launcher/src/main/cpp/view_group_page.cpp",
+ ]
- deps = [
- "//foundation/aafwk/frameworks/ability_lite:aafwk_abilitykit_lite",
- "//foundation/appexecfwk/frameworks/bundle_lite:bundle",
- "//foundation/communication/frameworks/ipc_lite:liteipc_adapter",
- "//foundation/distributedschedule/services/samgr_lite/samgr:samgr",
- "//utils/native/lite/kv_store:kv_store",
- "//foundation/graphic/lite/frameworks/ui:ui",
- "//foundation/graphic/lite/utils:graphic_utils",
- "//foundation/graphic/lite/frameworks/surface",
- ]
+ deps = [
+ "${aafwk_lite_path}/frameworks/ability_lite:aafwk_abilitykit_lite",
+ "${appexecfwk_lite_path}/frameworks/bundle_lite:bundle",
+ "//foundation/communication/ipc_lite:liteipc_adapter",
+ "//foundation/distributedschedule/samgr_lite/samgr:samgr",
+ "//foundation/graphic/surface",
+ "//foundation/graphic/ui:lite_ui",
+ "//foundation/graphic/utils:lite_graphic_utils",
+ "//utils/native/lite/kv_store:kv_store",
+ ]
- include_dirs = [
- "launcher/src/main/cpp",
- "//foundation/aafwk/interfaces/kits/ability_lite",
- "//foundation/graphic/lite/interfaces/kits/ui/components",
- "//foundation/graphic/lite/interfaces/kits/ui",
- "//foundation/graphic/lite/interfaces/kits/utils",
- "//foundation/graphic/lite/interfaces/kits/config",
- "//foundation/appexecfwk/interfaces/kits/bundle_lite",
- "//foundation/aafwk/interfaces/kits/want_lite",
- "//base/startup/interfaces/kits/syspara_lite",
- ]
+ include_dirs = [
+ "launcher/src/main/cpp",
+ "${aafwk_lite_path}/interfaces/kits/ability_lite",
+ "${appexecfwk_lite_path}/interfaces/kits/bundle_lite",
+ "${aafwk_lite_path}/interfaces/kits/want_lite",
+ "//base/startup/syspara_lite/interfaces/kits",
+ ]
- defines = [
- "ENABLE_WINDOW=1",
- "ABILITY_WINDOW_SUPPORT",
- "OHOS_APPEXECFWK_BMS_BUNDLEMANAGER"
- ]
+ defines = [
+ "ENABLE_WINDOW=1",
+ "ABILITY_WINDOW_SUPPORT",
+ "OHOS_APPEXECFWK_BMS_BUNDLEMANAGER",
+ ]
}
-lite_component("launcher_component") {
-
- features = [
- ":launcher",
- ]
-}
-
-hap_pack("launcher_hap")
-{
- deps = [":launcher"]
- mode = "hap"
- json_path = "launcher/src/main/config.json"
- ability_so_path = "$root_out_dir/liblauncher.so"
- force = "true"
- cert_profile = "cert/com.huawei.launcher_HarmonyAppProvision_release.p7b"
- resources_path = "launcher/src/main/resources"
- hap_name = "launcher"
+hap_pack("launcher_hap") {
+ deps = [ ":launcher" ]
+ mode = "hap"
+ json_path = "launcher/src/main/config.json"
+ ability_so_path = "$root_out_dir/liblauncher.so"
+ force = "true"
+ cert_profile = "cert/com.huawei.launcher_HarmonyAppProvision_release.p7b"
+ resources_path = "launcher/src/main/resources"
+ hap_name = "launcher"
+ privatekey = "HOS Application Provision Release"
}
diff --git a/launcher/cert/com.huawei.launcher_HarmonyAppProvision_release.p7b b/launcher/cert/com.huawei.launcher_HarmonyAppProvision_release.p7b
old mode 100644
new mode 100755
diff --git a/launcher/launcher/src/main/config.json b/launcher/launcher/src/main/config.json
old mode 100644
new mode 100755
index 2cc4c39..b447a32
--- a/launcher/launcher/src/main/config.json
+++ b/launcher/launcher/src/main/config.json
@@ -1,43 +1,43 @@
-{
- "app": {
- "bundleName": "com.huawei.launcher",
- "vendor": "huawei",
- "version": {
- "code": 1,
- "name": "1.0"
- },
- "apiVersion": {
- "compatible": 3,
- "target": 4
- }
- },
- "deviceConfig": {
- "default": {
- "keepAlive": true
- },
- "smartCamera": {
- "keepAlive": true
- }
- },
- "module": {
- "package": "com.huawei.launcher",
- "name": ".MyHarmonyAbilityPackage",
- "deviceType": [
- "phone", "tv","tablet", "pc","car","smartWatch","sportsWatch","smartVision"
- ],
- "distro": {
- "deliveryWithInstall": true,
- "moduleName": "launcher",
- "moduleType": "entry"
- },
- "abilities": [{
- "name": "MainAbility",
- "icon": "assets/launcher/resources/base/media/background.png",
- "label": "launcher",
- "launchType": "standard",
- "type": "page",
- "visible":true
- }
- ]
- }
-}
+{
+ "app": {
+ "bundleName": "com.huawei.launcher",
+ "vendor": "huawei",
+ "version": {
+ "code": 1,
+ "name": "1.0"
+ },
+ "apiVersion": {
+ "compatible": 3,
+ "target": 4
+ }
+ },
+ "deviceConfig": {
+ "default": {
+ "keepAlive": true
+ },
+ "smartCamera": {
+ "keepAlive": true
+ }
+ },
+ "module": {
+ "package": "com.huawei.launcher",
+ "name": ".MyHarmonyAbilityPackage",
+ "deviceType": [
+ "phone", "tv","tablet", "pc","car","smartWatch","sportsWatch","smartVision"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "launcher",
+ "moduleType": "entry"
+ },
+ "abilities": [{
+ "name": "MainAbility",
+ "icon": "assets/launcher/resources/base/media/background.png",
+ "label": "launcher",
+ "launchType": "standard",
+ "type": "page",
+ "visible":true
+ }
+ ]
+ }
+}
diff --git a/launcher/launcher/src/main/cpp/app_info.cpp b/launcher/launcher/src/main/cpp/app_info.cpp
old mode 100644
new mode 100755
index 2ea58fc..f2d2036
--- a/launcher/launcher/src/main/cpp/app_info.cpp
+++ b/launcher/launcher/src/main/cpp/app_info.cpp
@@ -39,10 +39,6 @@ void AppInfo::Release()
delete appLpListener_;
appLpListener_ = nullptr;
}
- if (appDListener_) {
- delete appDListener_;
- appDListener_ = nullptr;
- }
}
AppInfo::~AppInfo()
@@ -56,7 +52,6 @@ void AppInfo::ReSet()
lable_ = nullptr;
appClickListener_ = nullptr;
appLpListener_ = nullptr;
- appDListener_ = nullptr;
}
void AppInfo::SetButton(UILabelButton* button)
@@ -92,16 +87,13 @@ void AppInfo::SetLable(UILabel* lable)
void AppInfo::SetListener(AppInfo* app)
{
- AppClickListener* appClickListener = new AppClickListener(app->funcclick_, this);
- button_->SetOnClickListener(appClickListener);
- appClickListener_ = static_cast(appClickListener);
- AppLongPressListener* appLpListener = new AppLongPressListener(app->funclPress_, this);
- button_->SetOnLongPressListener(appLpListener);
- appLpListener_ = static_cast(appLpListener);
- AppDragListener* appDListener = new AppDragListener(this);
+ AppClickListener* clickListener = new AppClickListener(app->funcclick_, this);
+ button_->SetOnClickListener(clickListener);
+ appClickListener_ = static_cast(clickListener);
+ AppLongPressListener* lPListener = new AppLongPressListener(app->funclPress_, this);
+ button_->SetOnLongPressListener(lPListener);
+ appLpListener_ = static_cast(lPListener);
button_->SetDraggable(true);
- button_->SetOnDragListener(appDListener);
- appDListener_ = static_cast(appDListener);
}
void AppInfo::SetLocation(int16_t r, int16_t c)
diff --git a/launcher/launcher/src/main/cpp/app_info.h b/launcher/launcher/src/main/cpp/app_info.h
old mode 100644
new mode 100755
index fecf807..fab38e3
--- a/launcher/launcher/src/main/cpp/app_info.h
+++ b/launcher/launcher/src/main/cpp/app_info.h
@@ -26,10 +26,10 @@
namespace OHOS {
class AppInfo;
-typedef bool (*funcLongPress)(AppInfo *app);
-typedef bool (*funcClick)(AppInfo *app);
-typedef bool (*UninstallApp)(AppInfo *app);
-typedef bool (*AddApp)(AppInfo *app);
+using funcLongPress = bool (*)(AppInfo *app);
+using funcClick = bool (*)(AppInfo *app);
+using UninstallApp = bool (*)(AppInfo *app);
+using AddApp = bool (*)(AppInfo *app);
struct MyPoint {
int16_t x; // the x coordinate of the point
@@ -51,7 +51,6 @@ public:
UILabel* lable_ { nullptr };
UIView::OnLongPressListener* appLpListener_ { nullptr };
- UIView::OnDragListener* appDListener_ { nullptr };
UIView::OnClickListener* appClickListener_ { nullptr };
funcClick funcclick_ { nullptr };
@@ -61,30 +60,9 @@ public:
MyPoint buttonXY_ { 0 };
MyPoint buttonHV_ { 0 };
MyPoint row_col_ { 0 };
- char appName_[TMP_BUF_SIZE];
- char abilityName_[TMP_BUF_SIZE];
- char appIconDir_[TMP_BUF_SIZE];
-};
-
-class AppDragListener : public UIView::OnDragListener {
-public:
- AppDragListener(AppInfo* app) : appInfo_(app) {}
- virtual ~AppDragListener() {}
- bool OnDrag(UIView &view, const DragEvent &event) override
- {
- return true;
- }
- bool OnDragEnd(UIView& view, const DragEvent& event) override
- {
- return true;
- }
- bool OnDragStart(UIView& view, const DragEvent& event) override
- {
- return true;
- }
-
-private:
- AppInfo* appInfo_ { nullptr };
+ char appName_[TMP_BUF_SIZE] = { 0 };
+ char abilityName_[TMP_BUF_SIZE] = { 0 };
+ char appIconDir_[TMP_BUF_SIZE] = { 0 };
};
class AppClickListener : public UIView::OnClickListener {
diff --git a/launcher/launcher/src/main/cpp/app_manage.cpp b/launcher/launcher/src/main/cpp/app_manage.cpp
old mode 100644
new mode 100755
index 768a152..8cfd7fa
--- a/launcher/launcher/src/main/cpp/app_manage.cpp
+++ b/launcher/launcher/src/main/cpp/app_manage.cpp
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-#include
+#include
#include
#include "app_manage.h"
@@ -96,9 +96,10 @@ void AppManage::MyBundleStateCallback(
if (installType == 0) { // install update
if (resultCode == 0 && bundleName != nullptr) {
char tmpName[TMP_BUF_SIZE] = {0};
- memcpy_s(tmpName, sizeof(tmpName), bundleName, strlen(bundleName));
- tmpName[strlen(bundleName)] = 0;
- GetAppInstallInfo(tmpName);
+ if (memcpy_s(tmpName, sizeof(tmpName), bundleName, strlen(bundleName)) == LAUNCHER_SUCCESS) {
+ tmpName[strlen(bundleName)] = 0;
+ GetAppInstallInfo(tmpName);
+ }
}
}
}
diff --git a/launcher/launcher/src/main/cpp/app_manage.h b/launcher/launcher/src/main/cpp/app_manage.h
old mode 100644
new mode 100755
diff --git a/launcher/launcher/src/main/cpp/event_listener.h b/launcher/launcher/src/main/cpp/event_listener.h
old mode 100644
new mode 100755
index 38c321e..144610a
--- a/launcher/launcher/src/main/cpp/event_listener.h
+++ b/launcher/launcher/src/main/cpp/event_listener.h
@@ -39,7 +39,11 @@ public:
if (!onClick_) {
return false;
}
- return onClick_(view, event);
+ UIView *currentView = &view;
+ if (currentView == nullptr) {
+ return false;
+ }
+ return onClick_(*currentView, event);
}
bool OnLongPress(UIView& view, const LongPressEvent& event) override
@@ -47,7 +51,11 @@ public:
if (!onLongPress_) {
return false;
}
- return onLongPress_(view, event);
+ UIView *currentView = &view;
+ if (currentView == nullptr) {
+ return false;
+ }
+ return onLongPress_(*currentView, event);
}
private:
diff --git a/launcher/launcher/src/main/cpp/long_press_view.cpp b/launcher/launcher/src/main/cpp/long_press_view.cpp
old mode 100644
new mode 100755
index 421ebe5..89720f9
--- a/launcher/launcher/src/main/cpp/long_press_view.cpp
+++ b/launcher/launcher/src/main/cpp/long_press_view.cpp
@@ -88,12 +88,16 @@ void LongPressView::Show(UIViewGroup* viewParent, AppInfo* pApp)
bool LongPressView::OnClick(UIView& view, const ClickEvent& event)
{
+ UIView *currentView = &view;
+ if (currentView == nullptr) {
+ return false;
+ }
UILabelButton* lbutt = nullptr;
- lbutt = static_cast(&view);
+ lbutt = static_cast(currentView);
RemoveLview();
- if (&view == buttUninstall_) {
+ if (currentView == buttUninstall_) {
uninstall_(app_);
}
return true;
}
-} // namespace OHOS
\ No newline at end of file
+} // namespace OHOS
diff --git a/launcher/launcher/src/main/cpp/long_press_view.h b/launcher/launcher/src/main/cpp/long_press_view.h
old mode 100644
new mode 100755
index 1d231e6..8ac473b
--- a/launcher/launcher/src/main/cpp/long_press_view.h
+++ b/launcher/launcher/src/main/cpp/long_press_view.h
@@ -23,9 +23,9 @@
namespace OHOS {
class LongPressView : public UIView::OnClickListener, public NativeBase {
public:
- LongPressView(UninstallApp uninstall);
+ explicit LongPressView(UninstallApp uninstall);
virtual ~LongPressView();
- bool OnClick(UIView &view, const ClickEvent& event) override;
+ bool OnClick(UIView& view, const ClickEvent& event) override;
void RemoveLview();
void Show(UIViewGroup* viewParent, AppInfo* pApp);
void SetStatus(bool status)
@@ -33,7 +33,7 @@ public:
bStatus_ = status;
}
- bool GetStatus()
+ bool GetStatus() const
{
return bStatus_;
}
diff --git a/launcher/launcher/src/main/cpp/main_ability.cpp b/launcher/launcher/src/main/cpp/main_ability.cpp
old mode 100644
new mode 100755
diff --git a/launcher/launcher/src/main/cpp/main_ability.h b/launcher/launcher/src/main/cpp/main_ability.h
old mode 100644
new mode 100755
diff --git a/launcher/launcher/src/main/cpp/main_ability_slice.cpp b/launcher/launcher/src/main/cpp/main_ability_slice.cpp
old mode 100644
new mode 100755
index 1b0f8d4..f2e5376
--- a/launcher/launcher/src/main/cpp/main_ability_slice.cpp
+++ b/launcher/launcher/src/main/cpp/main_ability_slice.cpp
@@ -58,7 +58,7 @@ void MainAbilitySlice::SetHead()
sprintf_s(tmp, sizeof(tmp), "%02d : %02d", st->tm_hour, st->tm_min);
UILabel* label = new UILabel();
rootview_->Add(label);
- label->SetPosition(0, 0, LA_HORIZONTAL_RESOLUTION, LABLE_TITLE_HEIGHT);
+ label->SetPosition(0, 0, Screen::GetInstance().GetWidth(), LABLE_TITLE_HEIGHT);
label->SetText(tmp);
label->SetAlign(TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_TOP);
label->SetFont(FOND_PATH, LAUNCHER_FOND_ID);
@@ -72,7 +72,8 @@ void MainAbilitySlice::SetTail()
{
UILabel* label = new UILabel();
rootview_->Add(label);
- label->SetPosition(0, LA_VERTICAL_RESOLUTION - LABLE_TAIL_HEIGHT, LA_HORIZONTAL_RESOLUTION, LABLE_TAIL_HEIGHT);
+ label->SetPosition(0, Screen::GetInstance().GetHeight() - LABLE_TAIL_HEIGHT,
+ Screen::GetInstance().GetWidth(), LABLE_TAIL_HEIGHT);
char buf[TMP_BUF_SIZE] = { 0 };
sprintf_s(buf, sizeof(buf), ".%d.", 1);
label->SetText(buf);
@@ -89,7 +90,7 @@ void MainAbilitySlice::SetImageView()
uiImageView_ = new UIImageView();
// modify image view height
- uiImageView_->SetPosition(0, 0, LA_HORIZONTAL_RESOLUTION, LA_VERTICAL_RESOLUTION);
+ uiImageView_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
uiImageView_->SetStyle(STYLE_BACKGROUND_COLOR, Color::ColorTo32(Color::White()));
uiImageView_->SetSrc(TABLE_BACKGROUND);
uiImageView_->SetStyle(STYLE_BACKGROUND_OPA, UN_OPACITY);
@@ -106,11 +107,9 @@ void MainAbilitySlice::SetSwipe()
void MainAbilitySlice::OnStart(const Want& want)
{
AbilitySlice::OnStart(want);
- LA_HORIZONTAL_RESOLUTION = Screen::GetInstance().GetWidth();
- LA_VERTICAL_RESOLUTION = Screen::GetInstance().GetHeight();
rootview_ = RootView::GetWindowRootView();
rootview_->SetPosition(0, 0);
- rootview_->Resize(LA_HORIZONTAL_RESOLUTION, LA_VERTICAL_RESOLUTION);
+ rootview_->Resize(Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
rootview_->SetStyle(STYLE_BACKGROUND_OPA, UN_OPACITY);
rootview_->SetStyle(STYLE_BACKGROUND_COLOR, Color::ColorTo32(Color::GetColorFromRGB(0x30, 0x30, 0x30)));
diff --git a/launcher/launcher/src/main/cpp/main_ability_slice.h b/launcher/launcher/src/main/cpp/main_ability_slice.h
old mode 100644
new mode 100755
diff --git a/launcher/launcher/src/main/cpp/native_base.h b/launcher/launcher/src/main/cpp/native_base.h
old mode 100644
new mode 100755
index d88dfe7..10508cc
--- a/launcher/launcher/src/main/cpp/native_base.h
+++ b/launcher/launcher/src/main/cpp/native_base.h
@@ -21,6 +21,8 @@
namespace OHOS {
class NativeBase : public HeapBase {
public:
+ NativeBase() {}
+ virtual ~NativeBase() {}
void DeleteChildren(UIView *view)
{
if (view == nullptr) {
diff --git a/launcher/launcher/src/main/cpp/swipe_view.cpp b/launcher/launcher/src/main/cpp/swipe_view.cpp
old mode 100644
new mode 100755
index 46ffbbe..1fe5348
--- a/launcher/launcher/src/main/cpp/swipe_view.cpp
+++ b/launcher/launcher/src/main/cpp/swipe_view.cpp
@@ -45,11 +45,9 @@ SwipeView::~SwipeView()
void SwipeView::SetUpSwipe()
{
- LA_HORIZONTAL_RESOLUTION = Screen::GetInstance().GetWidth();
- LA_VERTICAL_RESOLUTION = Screen::GetInstance().GetHeight();
swipe_ = new UISwipeView();
- swipe_->SetPosition(0, LABLE_TITLE_HEIGHT, LA_HORIZONTAL_RESOLUTION,
- LA_VERTICAL_RESOLUTION - LABLE_TITLE_HEIGHT - LABLE_TAIL_HEIGHT);
+ swipe_->SetPosition(0, LABLE_TITLE_HEIGHT, Screen::GetInstance().GetWidth(),
+ Screen::GetInstance().GetHeight() - LABLE_TITLE_HEIGHT - LABLE_TAIL_HEIGHT);
swipe_->SetStyle(STYLE_BACKGROUND_OPA, TOTAL_OPACITY);
swipe_->SetLoopState(true);
swipe_->SetAnimatorTime(20); // set swipe view animator time 20s
@@ -61,8 +59,8 @@ UIViewGroup* SwipeView::AddViewGroup()
return nullptr;
}
UIViewGroup* viewGroup = new UIViewGroup();
- viewGroup->SetPosition(0, LABLE_TITLE_HEIGHT, LA_HORIZONTAL_RESOLUTION,
- LA_VERTICAL_RESOLUTION - LABLE_TITLE_HEIGHT - LABLE_TAIL_HEIGHT);
+ viewGroup->SetPosition(0, LABLE_TITLE_HEIGHT, Screen::GetInstance().GetWidth(),
+ Screen::GetInstance().GetHeight() - LABLE_TITLE_HEIGHT - LABLE_TAIL_HEIGHT);
viewGroup->SetStyle(STYLE_BACKGROUND_OPA, TOTAL_OPACITY);
groupCount_++;
ViewGroupPage* page = new ViewGroupPage(viewGroup);
@@ -74,8 +72,8 @@ UIViewGroup* SwipeView::AddViewGroup()
UIViewGroup* SwipeView::AddFirstViewGroup()
{
UIViewGroup* firstView = new UIViewGroup();
- firstView->SetPosition(0, LABLE_TITLE_HEIGHT, LA_HORIZONTAL_RESOLUTION,
- LA_VERTICAL_RESOLUTION - LABLE_TITLE_HEIGHT - LABLE_TAIL_HEIGHT);
+ firstView->SetPosition(0, LABLE_TITLE_HEIGHT, Screen::GetInstance().GetWidth(),
+ Screen::GetInstance().GetHeight() - LABLE_TITLE_HEIGHT - LABLE_TAIL_HEIGHT);
firstView->SetStyle(STYLE_BACKGROUND_OPA, TOTAL_OPACITY);
UIViewGroup* viewTimeWeather = new UIViewGroup();
@@ -129,6 +127,10 @@ void SwipeView::OnSetUpView()
if (memcmp(LAUNCHER_BUNDLE_NAME, pBundleInfos[j].bundleName, strlen(pBundleInfos[j].bundleName)) == 0) {
break;
}
+ if (memcmp(SCREENSAVER_BUNDLE_NAME, pBundleInfos[j].bundleName, strlen(pBundleInfos[j].bundleName)) == 0) {
+ break;
+ }
+
AppInfo* app = new AppInfo();
app->funcclick_ = AppEvent::ClickEvent;
app->funclPress_ = AppEvent::LongPressEvent;
@@ -188,13 +190,21 @@ void SwipeView::InstallApp(AppInfo* app)
{
appManage_->InstallApp(app);
AppInfo* pApp = new AppInfo();
+ if (pApp == nullptr) {
+ return;
+ }
app->funcclick_ = AppEvent::ClickEvent;
app->funclPress_ = AppEvent::LongPressEvent;
- for (int16_t i = 0; i < groupCount_; i++) {
+ int16_t i;
+ for (i = 0; i < groupCount_; i++) {
if (arrPage_[i]->AddApp(pApp)) {
break;
}
}
+ if (i == groupCount_) {
+ delete pApp;
+ pApp = nullptr;
+ }
}
void SwipeView::OnStop()
diff --git a/launcher/launcher/src/main/cpp/swipe_view.h b/launcher/launcher/src/main/cpp/swipe_view.h
old mode 100644
new mode 100755
index 9e8c813..4b100ca
--- a/launcher/launcher/src/main/cpp/swipe_view.h
+++ b/launcher/launcher/src/main/cpp/swipe_view.h
@@ -16,7 +16,7 @@
#ifndef OHOS_SWIPE_VIEW_H
#define OHOS_SWIPE_VIEW_H
-#include
+#include
#include
#include
#include
@@ -36,7 +36,7 @@
namespace OHOS {
class ViewPageListener : public UIView::OnClickListener {
public:
- ViewPageListener(LongPressView* view) : view_(view) {}
+ explicit ViewPageListener(LongPressView* view) : view_(view) {}
virtual ~ViewPageListener() {}
bool OnClick(UIView& view, const ClickEvent& event) override
{
@@ -62,9 +62,9 @@ public:
}
private:
+ LongPressView* view_ { nullptr };
UISwipeView* swipe_ { nullptr };
UILabel* lable_ { nullptr };
- LongPressView* view_ { nullptr };
};
class SwipeView : public Task, public NativeBase {
@@ -82,12 +82,16 @@ public:
char tmp[TMP_BUF_SIZE] = { 0 };
time_t t = time(nullptr);
struct tm* st = localtime(&t);
- sprintf_s(tmp, sizeof(tmp), "%02d : %02d", st->tm_hour, st->tm_min);
- lableTitle_->SetText(tmp);
- timeWeatherView_->SetUpTimeView();
+ if (st != nullptr) {
+ int ret = sprintf_s(tmp, sizeof(tmp), "%02d : %02d", st->tm_hour, st->tm_min);
+ if (ret != LAUNCHER_PARAMERROR) {
+ lableTitle_->SetText(tmp);
+ timeWeatherView_->SetUpTimeView();
+ }
+ }
}
- UISwipeView* GetSwipeView()
+ UISwipeView* GetSwipeView() const
{
return swipe_;
}
diff --git a/launcher/launcher/src/main/cpp/time_weather_view.cpp b/launcher/launcher/src/main/cpp/time_weather_view.cpp
old mode 100644
new mode 100755
index 2737052..d5b7b5e
--- a/launcher/launcher/src/main/cpp/time_weather_view.cpp
+++ b/launcher/launcher/src/main/cpp/time_weather_view.cpp
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-#include
+#include
#include
#include "time_weather_view.h"
@@ -27,6 +27,7 @@ static constexpr int16_t BIGLABEL_H = 100;
static constexpr int16_t SMALLLABEL_H = 35;
static constexpr int16_t IMAGE_H = 40;
static constexpr int16_t IMAGE_W = 40;
+const char* g_weekDate[WEEK_DAY_MAX] = {"星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
TimeWeatherView::TimeWeatherView(UIViewGroup* viewGroup)
{
@@ -65,10 +66,22 @@ void TimeWeatherView::SetUpTimeView()
const int16_t commonYear = 1970;
time_t t = time(nullptr);
struct tm* st = localtime(&t);
- sprintf_s(hour_min, sizeof(hour_min), "%02d : %02d", st->tm_hour, st->tm_min);
- sprintf_s(mont_day, sizeof(mont_day), "%02d月%02d日", st->tm_mon + january, st->tm_mday);
+ if (st == nullptr) {
+ return;
+ }
+ int ret = sprintf_s(hour_min, sizeof(hour_min), "%02d : %02d", st->tm_hour, st->tm_min);
+ if (ret == LAUNCHER_PARAMERROR) {
+ return;
+ }
+ ret = sprintf_s(mont_day, sizeof(mont_day), "%02d月%02d日", st->tm_mon + january, st->tm_mday);
+ if (ret == LAUNCHER_PARAMERROR) {
+ return;
+ }
GetWeekdayByYearday(st->tm_year + commonYear, st->tm_mon + january, st->tm_mday, week_day, sizeof(week_day));
- sprintf_s(date, sizeof(date), "%s %s", mont_day, week_day);
+ ret = sprintf_s(date, sizeof(date), "%s %s", mont_day, week_day);
+ if (ret == LAUNCHER_PARAMERROR) {
+ return;
+ }
if (viewTime_ == nullptr) {
viewTime_ = new UIViewGroup();
viewTime_->SetPosition(BLANK_TW, BLANK_H, viewGroup_->GetWidth() - BLANK_W,
@@ -99,14 +112,24 @@ void TimeWeatherView::SetUpTimeView()
viewTime_->Add(lable2);
viewGroup_->Add(viewTime_);
} else {
- static_cast(viewTime_->GetChildById("labletime"))->SetText(hour_min);
- static_cast(viewTime_->GetChildById("labledate"))->SetText(date);
+ UILabel* label = nullptr;
+ label = static_cast(viewTime_->GetChildById("labletime"));
+ if (label) {
+ label->SetText(hour_min);
+ }
+ label = static_cast(viewTime_->GetChildById("labledate"));
+ if (label) {
+ label->SetText(date);
+ }
viewTime_->Invalidate();
}
}
void TimeWeatherView::GetWeekdayByYearday(int iY, int iM, int iD, char* date, int size)
{
+ if (date == nullptr) {
+ return;
+ }
const int16_t months = 12;
const int16_t january = 1;
const int16_t february = 2;
@@ -119,39 +142,13 @@ void TimeWeatherView::GetWeekdayByYearday(int iY, int iM, int iD, char* date, in
}
// 1 : MONDAY_LAUNCHER, 2 : TUESDAY_LAUNCHER, 3 : WEDNESDAY_LAUNCHER, 4 : , 5 : ect
iWeekDay = (iD + 1 + 2 * iM + 3 * (iM + 1) / 5 + iY + iY / 4 - iY / oneHundred + iY / fourHundred) % WEEKEND_LAUNCHER;
- switch (iWeekDay) {
- case SUNDAY_LAUNCHER:
- memcpy_s(date, size, "星期天", strlen("星期天"));
- date[strlen("星期天")] = 0;
- break;
- case MONDAY_LAUNCHER:
- memcpy_s(date, size, "星期一", strlen("星期一"));
- date[strlen("星期一")] = 0;
- break;
- case TUESDAY_LAUNCHER:
- memcpy_s(date, size, "星期二", strlen("星期二"));
- date[strlen("星期二")] = 0;
- break;
- case WEDNESDAY_LAUNCHER:
- memcpy_s(date, size, "星期三", strlen("星期三"));
- date[strlen("星期三")] = 0;
- break;
- case THURSDAY_LAUNCHER:
- memcpy_s(date, size, "星期四", strlen("星期四"));
- date[strlen("星期四")] = 0;
- break;
- case FRIDAY_LAUNCHER:
- memcpy_s(date, size, "星期五", strlen("星期五"));
- date[strlen("星期五")] = 0;
- break;
- case STAURDAY_LAUNCHER:
- memcpy_s(date, size, "星期六", strlen("星期六"));
- date[strlen("星期六")] = 0;
- break;
- default:
- memcpy_s(date, size, "星期天", strlen("星期天"));
- date[strlen("星期天")] = 0;
- break;
+ for (int i = 0; i < WEEK_DAY_MAX; i++) {
+ if (iWeekDay == i) {
+ if (memcpy_s(date, size, g_weekDate[i], strlen(g_weekDate[i])) == LAUNCHER_SUCCESS) {
+ date[strlen(g_weekDate[i])] = 0;
+ break;
+ }
+ }
}
return;
}
diff --git a/launcher/launcher/src/main/cpp/time_weather_view.h b/launcher/launcher/src/main/cpp/time_weather_view.h
old mode 100644
new mode 100755
index c572ea7..3259e66
--- a/launcher/launcher/src/main/cpp/time_weather_view.h
+++ b/launcher/launcher/src/main/cpp/time_weather_view.h
@@ -40,7 +40,7 @@ enum DATE_LAUNCHER {
class TimeWeatherView : public NativeBase {
public:
TimeWeatherView() = delete;
- TimeWeatherView(UIViewGroup* viewGroup);
+ explicit TimeWeatherView(UIViewGroup* viewGroup);
virtual ~TimeWeatherView();
void SetStyle(Style sty);
void SetPosion(int16_t width, int16_t height, int16_t x, int16_t y);
diff --git a/launcher/launcher/src/main/cpp/ui_config.h b/launcher/launcher/src/main/cpp/ui_config.h
old mode 100644
new mode 100755
index 32062ad..34bd039
--- a/launcher/launcher/src/main/cpp/ui_config.h
+++ b/launcher/launcher/src/main/cpp/ui_config.h
@@ -17,10 +17,9 @@
#define OHOS_UI_CONFIG_H
#include
+#include
namespace OHOS {
-static int16_t LA_HORIZONTAL_RESOLUTION = 960; // launcher table width
-static int16_t LA_VERTICAL_RESOLUTION = 480; // launcher table height
static constexpr int16_t LABLE_TITLE_HEIGHT = 30; // tail lable height
static constexpr int16_t LABLE_TAIL_HEIGHT = 30;
static constexpr int16_t APP_WIDTH_COUNT = 7; // blank + app + blank + app + blank
@@ -38,11 +37,28 @@ static constexpr int16_t BUTTON_RADIUS = 20; // app icon radius
static constexpr int16_t LABLE_RADIUS = 0; // lable icon radius
static constexpr int16_t TITLE_LABLE_OPACITY = 255; // translucent
static constexpr int16_t GROUP_VIEW_RADIUS = 20; // view radius
+
+#ifndef TMP_BUF_SIZE
#define TMP_BUF_SIZE 128
+#endif
+
#define LAUNCHER_BUNDLE_NAME "com.huawei.launcher"
+#define SCREENSAVER_BUNDLE_NAME "com.huawei.screensaver"
#define TABLE_BACKGROUND \
"/storage/app/run/com.huawei.launcher/launcher/assets/launcher/resources/base/media/background.png"
#define RES_WEATHER "/storage/app/run/com.huawei.launcher/launcher/assets/launcher/resources/base/media/weather.png"
#define FOND_PATH "SourceHanSansSC-Regular.otf"
+
+#ifndef LAUNCHER_SUCCESS
+#define LAUNCHER_SUCCESS 0
+#endif
+
+#ifndef LAUNCHER_PARAMERROR
+#define LAUNCHER_PARAMERROR (-1)
+#endif
+
+#ifndef WEEK_DAY_MAX
+#define WEEK_DAY_MAX 7
+#endif
} // namespace OHOS
#endif
diff --git a/launcher/launcher/src/main/cpp/view_group_page.cpp b/launcher/launcher/src/main/cpp/view_group_page.cpp
old mode 100644
new mode 100755
index f2fa923..0b64953
--- a/launcher/launcher/src/main/cpp/view_group_page.cpp
+++ b/launcher/launcher/src/main/cpp/view_group_page.cpp
@@ -77,7 +77,6 @@ void ViewGroupPage::SetMatrix(int16_t rows, int16_t cols)
void ViewGroupPage::CalculateAppPosition(AppInfo* pAppInfo, int16_t row, int16_t col)
{
- int16_t h = viewGroup_->GetHeight();
int16_t w = viewGroup_->GetWidth();
const double scale = scale_;
diff --git a/launcher/launcher/src/main/cpp/view_group_page.h b/launcher/launcher/src/main/cpp/view_group_page.h
old mode 100644
new mode 100755
index a26c501..1a9bcc3
--- a/launcher/launcher/src/main/cpp/view_group_page.h
+++ b/launcher/launcher/src/main/cpp/view_group_page.h
@@ -29,7 +29,7 @@ namespace OHOS {
class ViewGroupPage {
public:
ViewGroupPage() = delete;
- ViewGroupPage(UIViewGroup* viewGroup);
+ explicit ViewGroupPage(UIViewGroup* viewGroup);
virtual ~ViewGroupPage();
void SetMatrix(int16_t rows, int16_t cols);
bool AddApp(AppInfo* pAppInfo);
diff --git a/launcher/launcher/src/main/resources/base/media/background.png b/launcher/launcher/src/main/resources/base/media/background.png
old mode 100644
new mode 100755
diff --git a/launcher/launcher/src/main/resources/base/media/weather.png b/launcher/launcher/src/main/resources/base/media/weather.png
old mode 100644
new mode 100755
diff --git a/media/BUILD.gn b/media/BUILD.gn
index a3e1b87..383623f 100755
--- a/media/BUILD.gn
+++ b/media/BUILD.gn
@@ -13,55 +13,52 @@
import("//build/lite/config/component/lite_component.gni")
copy("camera_config") {
- if (board_name == "hi3516dv300") {
- sources = ["cameradev_imx335.ini"]
- } else if(board_name == "hi3518ev300" && ohos_build_compiler == "clang") {
- sources = ["cameradev_jxf23.ini"]
- } else {
- sources = ["cameradev_imx307.ini"]
- }
- outputs = [ "$root_out_dir/data/cameradev.ini" ]
+ if (board_name == "hi3516dv300" || board_name == "hispark_taurus") {
+ sources = [ "cameradev_imx335.ini" ]
+ } else if ((board_name == "hi3518ev300" || board_name == "hispark_aries") &&
+ ohos_build_compiler == "clang") {
+ sources = [ "cameradev_jxf23.ini" ]
+ } else {
+ sources = [ "cameradev_imx307.ini" ]
+ }
+ outputs = [ "$root_out_dir/data/cameradev.ini" ]
}
executable("camera_sample") {
- sources = [
- "camera_sample.cpp"
- ]
- cflags = ["-Wall"]
- cflags_cc = cflags
- include_dirs = []
+ sources = [ "camera_sample.cpp" ]
+ cflags = [ "-Wall" ]
+ cflags_cc = cflags
+ include_dirs = []
- ldflags = ["-lstdc++"]
- ldflags += ["-lpthread"]
- ldflags += ["-Wl,-rpath-link=$ohos_root_path/$root_out_dir"]
+ ldflags = [ "-lstdc++" ]
+ ldflags += [ "-lpthread" ]
+ ldflags += [ "-Wl,-rpath-link=$ohos_root_path/$root_out_dir" ]
- deps = [
- "//foundation/multimedia/frameworks/camera_lite:camera",
- "//foundation/multimedia/frameworks/recorder_lite:recorder",
- ]
- output_dir = "$root_out_dir/dev_tools"
+ deps = [
+ "//foundation/multimedia/camera_lite/frameworks:camera_lite",
+ "//foundation/multimedia/media_lite/frameworks/recorder_lite:recorder_lite",
+ ]
+ output_dir = "$root_out_dir/dev_tools"
}
executable("player_sample") {
- sources = [
- "player_sample.cpp"
- ]
- cflags = ["-Wall"]
- cflags_cc = cflags
- include_dirs = []
- ldflags = ["-lstdc++"]
- ldflags += ["-lpthread"]
- ldflags += ["-Wl,-rpath-link=$ohos_root_path/$root_out_dir"]
- deps = [
- "//third_party/bounds_checking_function:libsec_shared",
- "//foundation/multimedia/frameworks/player_lite:player",
- ]
- output_dir = "$root_out_dir/dev_tools"
+ sources = [ "player_sample.cpp" ]
+ cflags = [ "-Wall" ]
+ cflags_cc = cflags
+ include_dirs = []
+ ldflags = [ "-lstdc++" ]
+ ldflags += [ "-lpthread" ]
+ ldflags += [ "-Wl,-rpath-link=$ohos_root_path/$root_out_dir" ]
+ deps = [
+ "//foundation/multimedia/media_lite/frameworks/player_lite:player_lite",
+ "//third_party/bounds_checking_function:libsec_shared",
+ ]
+ output_dir = "$root_out_dir/dev_tools"
}
lite_component("media_sample") {
- features = [
- ":camera_sample",
- ":player_sample",
- ]
+ features = [
+ ":camera_sample",
+ ":player_sample",
+ ]
}
diff --git a/media/camera_sample.cpp b/media/camera_sample.cpp
index 8751c31..770d148 100755
--- a/media/camera_sample.cpp
+++ b/media/camera_sample.cpp
@@ -40,7 +40,7 @@ static int32_t SampleGetRecordFd()
if (ltm != nullptr) {
ostringstream ss("Capture_");
ss << "Record" << ltm->tm_hour << "-" << ltm->tm_min << "-" << ltm->tm_sec << ".mp4";
- fd = open(("/sdcard/" + ss.str()).c_str(), O_WRONLY | O_CREAT | O_CLOEXEC | O_TRUNC, S_IRUSR | S_IWUSR);
+ fd = open(("/sdcard/" + ss.str()).c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
cout << "Open "
<< "/sdcard/" << ss.str() << endl;
@@ -64,6 +64,7 @@ static void SampleSaveCapture(const char *p, uint32_t size)
ofstream pic("/sdcard/" + ss.str(), ofstream::out | ofstream::trunc);
cout << "write " << size << " bytes" << endl;
pic.write(p, size);
+ pic.close();
cout << "Saving picture end" << endl;
}
}
@@ -375,9 +376,11 @@ int main()
const CameraAbility *ability = camKit->GetCameraAbility(cam);
/* find camera which fits user's ability */
list sizeList = ability->GetSupportedSizes(0);
- if (find(sizeList.begin(), sizeList.end(), CAM_PIC_1080P) != sizeList.end()) {
- camId = cam;
- break;
+ for (auto &pic : sizeList) {
+ if (pic.width == 1920 && pic.height == 1080) {
+ camId = cam;
+ break;
+ }
}
}
diff --git a/setting/BUILD.gn b/setting/BUILD.gn
index 9e2e340..7f857b3 100644
--- a/setting/BUILD.gn
+++ b/setting/BUILD.gn
@@ -11,78 +11,67 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import("//build/lite/config/component/lite_component.gni")
import("//build/lite/config/hap_pack.gni")
shared_library("setting") {
- sources = [
- "setting/src/main/cpp/setting_main_ability.cpp",
- "setting/src/main/cpp/main_ability_slice.cpp",
- "setting/src/main/cpp/setting_about_ability_slice.cpp",
- "setting/src/main/cpp/setting_wifi_ability_slice.cpp",
- "setting/src/main/cpp/setting_wifi_input_password_ability_slice.cpp",
- "setting/src/main/cpp/setting_utils.cpp",
- "setting/src/main/cpp/app_info_ability_slice.cpp",
- "setting/src/main/cpp/app_ability_slice.cpp",
- "setting/src/main/cpp/wpa_work.c"
- ]
+ sources = [
+ "setting/src/main/cpp/app_ability_slice.cpp",
+ "setting/src/main/cpp/app_info_ability_slice.cpp",
+ "setting/src/main/cpp/main_ability_slice.cpp",
+ "setting/src/main/cpp/setting_about_ability_slice.cpp",
+ "setting/src/main/cpp/setting_display_ability_slice.cpp",
+ "setting/src/main/cpp/setting_main_ability.cpp",
+ "setting/src/main/cpp/setting_utils.cpp",
+ "setting/src/main/cpp/setting_wifi_ability_slice.cpp",
+ "setting/src/main/cpp/setting_wifi_input_password_ability_slice.cpp",
+ "setting/src/main/cpp/wpa_work.c",
+ ]
- deps = [
- "//foundation/aafwk/frameworks/ability_lite:aafwk_abilitykit_lite",
- "//foundation/appexecfwk/frameworks/bundle_lite:bundle",
- "//foundation/communication/frameworks/ipc_lite:liteipc_adapter",
- "//foundation/distributedschedule/services/samgr_lite/samgr:samgr",
- "//utils/native/lite/kv_store:kv_store",
- "//foundation/graphic/lite/frameworks/ui:ui",
- "//foundation/graphic/lite/utils:graphic_utils",
- "//foundation/graphic/lite/frameworks/surface",
- "//third_party/wpa_supplicant/wpa_supplicant-2.9:wpa_supplicant",
- "//base/startup/frameworks/syspara_lite/parameter:parameter"
- ]
+ deps = [
+ "${aafwk_lite_path}/frameworks/ability_lite:aafwk_abilitykit_lite",
+ "${appexecfwk_lite_path}/frameworks/bundle_lite:bundle",
+ "//base/startup/syspara_lite/frameworks/parameter:parameter",
+ "//foundation/communication/ipc_lite:liteipc_adapter",
+ "//foundation/distributedschedule/samgr_lite/samgr:samgr",
+ "//foundation/graphic/surface",
+ "//foundation/graphic/ui:lite_ui",
+ "//foundation/graphic/utils:lite_graphic_utils",
+ "//third_party/wpa_supplicant/wpa_supplicant-2.9:wpa_supplicant",
+ "//utils/native/lite/kv_store:kv_store",
+ ]
- include_dirs = [
- "setting/src/main/cpp",
- "//foundation/aafwk/interfaces/kits/ability_lite",
- "//foundation/graphic/lite/interfaces/kits/ui/components",
- "//foundation/graphic/lite/interfaces/kits/ui",
- "//foundation/graphic/lite/interfaces/kits/utils",
- "//foundation/graphic/lite/interfaces/kits/config",
- "//foundation/appexecfwk/interfaces/kits/bundle_lite",
- "//foundation/aafwk/interfaces/kits/want_lite",
- "//base/startup/interfaces/kits/syspara_lite",
- "//base/security/interfaces/kits/iam_lite",
- "//third_party/wpa_supplicant/wpa_supplicant-2.9/src/common"
- ]
+ include_dirs = [
+ "setting/src/main/cpp",
+ "${aafwk_lite_path}/interfaces/kits/ability_lite",
+ "${appexecfwk_lite_path}/interfaces/kits/bundle_lite",
+ "${aafwk_lite_path}/interfaces/kits/want_lite",
+ "//base/startup/syspara_lite/interfaces/kits",
+ "//base/security/permission/interfaces/kits/permission_lite",
+ "//third_party/wpa_supplicant/wpa_supplicant-2.9/src/common",
+ ]
- ldflags = [
- "-lwpa",
- "-lwpa_client",
- "-lsysparam",
- "-lpms_client"
- ]
+ ldflags = [
+ "-lwpa",
+ "-lwpa_client",
+ "-lsysparam",
+ "-lpms_client",
+ ]
- defines = [
- "ENABLE_WINDOW=1",
- "ABILITY_WINDOW_SUPPORT",
- "OHOS_APPEXECFWK_BMS_BUNDLEMANAGER",
- ]
+ defines = [
+ "ENABLE_WINDOW=1",
+ "ABILITY_WINDOW_SUPPORT",
+ "OHOS_APPEXECFWK_BMS_BUNDLEMANAGER",
+ ]
}
-lite_component("setting_component") {
-
- features = [
- ":setting",
- ]
-}
-
-hap_pack("setting_hap")
-{
- deps = [":setting"]
- mode = "hap"
- json_path = "setting/src/main/config.json"
- ability_so_path = "$root_out_dir/libsetting.so"
- force = "true"
- cert_profile = "cert/com.huawei.setting_HarmonyAppProvision_release.p7b"
- resources_path = "setting/src/main/resources"
- hap_name = "setting"
+hap_pack("setting_hap") {
+ deps = [ ":setting" ]
+ mode = "hap"
+ json_path = "setting/src/main/config.json"
+ ability_so_path = "$root_out_dir/libsetting.so"
+ force = "true"
+ cert_profile = "cert/com.huawei.setting_HarmonyAppProvision_release.p7b"
+ resources_path = "setting/src/main/resources"
+ hap_name = "setting"
+ privatekey = "HOS Application Provision Release"
}
diff --git a/setting/cert/com.huawei.setting_HarmonyAppProvision_release.p7b b/setting/cert/com.huawei.setting_HarmonyAppProvision_release.p7b
old mode 100644
new mode 100755
diff --git a/setting/setting/src/main/config.json b/setting/setting/src/main/config.json
old mode 100644
new mode 100755
index c0de2bb..4a3de02
--- a/setting/setting/src/main/config.json
+++ b/setting/setting/src/main/config.json
@@ -1,40 +1,40 @@
-{
- "app": {
- "bundleName": "com.huawei.setting",
- "vendor": "huawei",
- "version": {
- "code": 1,
- "name": "1.0"
- },
- "apiVersion": {
- "compatible": 3,
- "target": 4
- }
- },
- "deviceConfig": {
- "default": {
-
- }
- },
- "module": {
- "package": "com.huawei.setting",
- "name": ".MyHarmonyAbilityPackage",
- "deviceType": [
- "phone", "tv","tablet", "pc","car","smartWatch","sportsWatch","smartVision"
- ],
- "distro": {
- "deliveryWithInstall": true,
- "moduleName": "setting",
- "moduleType": "entry"
- },
- "abilities": [{
- "name": "SettingMainAbility",
- "icon": "assets/setting/resources/base/media/setting.png",
- "label": "test testapp2 1",
- "launchType": "standard",
- "type": "page",
- "visible":true
- }
- ]
- }
-}
+{
+ "app": {
+ "bundleName": "com.huawei.setting",
+ "vendor": "huawei",
+ "version": {
+ "code": 1,
+ "name": "1.0"
+ },
+ "apiVersion": {
+ "compatible": 3,
+ "target": 4
+ }
+ },
+ "deviceConfig": {
+ "default": {
+
+ }
+ },
+ "module": {
+ "package": "com.huawei.setting",
+ "name": ".MyHarmonyAbilityPackage",
+ "deviceType": [
+ "phone", "tv","tablet", "pc","car","smartWatch","sportsWatch","smartVision"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "setting",
+ "moduleType": "entry"
+ },
+ "abilities": [{
+ "name": "SettingMainAbility",
+ "icon": "assets/setting/resources/base/media/setting.png",
+ "label": "test testapp2 1",
+ "launchType": "standard",
+ "type": "page",
+ "visible":true
+ }
+ ]
+ }
+}
diff --git a/setting/setting/src/main/cpp/app_ability_slice.cpp b/setting/setting/src/main/cpp/app_ability_slice.cpp
old mode 100644
new mode 100755
index 0fa1d1a..36d8778
--- a/setting/setting/src/main/cpp/app_ability_slice.cpp
+++ b/setting/setting/src/main/cpp/app_ability_slice.cpp
@@ -62,6 +62,9 @@ void AppAbilitySlice::SetAppButtonListener(const char* appName)
auto onClick2 = [this, appName](UIView& view, const Event& event) -> bool {
Want want1 = { nullptr };
bool ret = SetWantData(&want1, appName, strlen(appName) + 1);
+ if (ret != true) {
+ return false;
+ }
StartAbility(want1);
AbilitySlice* nextSlice = AbilityLoader::GetInstance().GetAbilitySliceByName("AppInfoAbilitySlice");
if (nextSlice == nullptr) {
@@ -114,7 +117,7 @@ void AppAbilitySlice::SetAnAppInfo(const int count, BundleInfo& pBundleInfo)
printf("[ERROR]strcpy_s pBundleInfo.bundleName failed, err = %d\n", err);
return;
}
- for (int i = 0; i < strlen(pBundleInfo.bundleName); i++) {
+ for (size_t i = 0; i < strlen(pBundleInfo.bundleName); i++) {
buff[i] = pBundleInfo.bundleName[i];
}
SetAppButtonListener(pBundleInfo.bundleName);
diff --git a/setting/setting/src/main/cpp/app_ability_slice.h b/setting/setting/src/main/cpp/app_ability_slice.h
old mode 100644
new mode 100755
diff --git a/setting/setting/src/main/cpp/app_info_ability_slice.cpp b/setting/setting/src/main/cpp/app_info_ability_slice.cpp
old mode 100644
new mode 100755
index e882e28..45f5096
--- a/setting/setting/src/main/cpp/app_info_ability_slice.cpp
+++ b/setting/setting/src/main/cpp/app_info_ability_slice.cpp
@@ -104,10 +104,11 @@ void AppInfoAbilitySlice::SetAppPermissionInfo(int index, PermissionSaved& permi
} else {
togglebutton->SetState(true);
}
- ToggBtnOnListener* listern = new ToggBtnOnListener(togglebutton, permissions.name, strlen(permissions.name),
- bundleName_, strlen(bundleName_));
- togglebutton->SetOnClickListener(listern);
- listListener_.PushBack(listern);
+ ToggBtnOnListener* listener = new ToggBtnOnListener(togglebutton);
+ listener->SetPermissionName(permissions.name, strlen(permissions.name));
+ listener->SetBundleName(bundleName_, strlen(bundleName_));
+ togglebutton->SetOnClickListener(listener);
+ listListener_.PushBack(listener);
itemView->Add(togglebutton);
}
@@ -134,11 +135,14 @@ void AppInfoAbilitySlice::PermissionInfoList()
void AppInfoAbilitySlice::OnStart(const Want& want)
{
+ int ret;
printf("[LOG]receive the data -> %s\n", static_cast(want.data));
AbilitySlice::OnStart(want);
- memcpy_s(bundleName_, sizeof(bundleName_), want.data, want.dataLength);
-
+ ret = memcpy_s(bundleName_, sizeof(bundleName_), want.data, want.dataLength);
+ if (ret != EOK) {
+ return;
+ }
rootView_ = RootView::GetWindowRootView();
rootView_->SetPosition(DE_ROOT_X, DE_ROOT_Y, DE_ROOT_WIDTH, DE_ROOT_HEIGHT);
rootView_->SetStyle(STYLE_BACKGROUND_COLOR, DE_ROOT_BACKGROUND_COLOR);
diff --git a/setting/setting/src/main/cpp/app_info_ability_slice.h b/setting/setting/src/main/cpp/app_info_ability_slice.h
old mode 100644
new mode 100755
index 7a18ac2..dd8567a
--- a/setting/setting/src/main/cpp/app_info_ability_slice.h
+++ b/setting/setting/src/main/cpp/app_info_ability_slice.h
@@ -34,46 +34,68 @@
#include "setting_utils.h"
#include "want.h"
#include "pms_interface.h"
-#include
-#include
+
+#include
+#include
namespace OHOS {
class ToggBtnOnListener : public UIView::OnClickListener {
public:
- ToggBtnOnListener(UIToggleButton* togglebutton, const char* name, int len1, const char* bundleName, int len2)
+
+ explicit ToggBtnOnListener(UIToggleButton* togglebutton)
{
- memcpy_s(name_, sizeof(name_), name, len1);
- name_[len1] = 0;
- memcpy_s(bundleName_, sizeof(bundleName_), bundleName, len2);
- bundleName_[len2] = 0;
status_ = false;
togglebutton_ = togglebutton;
}
+ virtual ~ToggBtnOnListener(){}
+
+ void SetPermissionName(const char* permissionsName, int nameLenght)
+ {
+ int ret;
+ ret = memcpy_s(name_, sizeof(name_), permissionsName, nameLenght);
+ if (ret != EOK) {
+ printf("[ERR] memcpy_s func[SetToggleButton]\n");
+ return;
+ }
+ name_[nameLenght] = 0;
+ }
+
+ void SetBundleName(const char* bundleName, int nameLength)
+ {
+ int ret;
+ ret = memcpy_s(bundleName_, sizeof(bundleName_), bundleName, nameLength);
+ if (ret != EOK) {
+ printf("[ERR] memcpy_s func[SetBundleName]\n");
+ return;
+ }
+ bundleName_[nameLength] = 0;
+ }
+
bool OnClick(UIView& view, const ClickEvent& event) override
{
- int ret = -1;
+ int ret;
if (status_) {
- if ((ret = RevokePermission(bundleName_, name_)) == 0) {
+ ret = RevokePermission(bundleName_, name_);
+ if (ret == 0) {
status_ = false;
togglebutton_->SetState(false);
- } else {
}
} else {
- if ((ret = GrantPermission(bundleName_, name_)) == 0) {
+ ret = GrantPermission(bundleName_, name_);
+ if (ret == 0) {
status_ = true;
togglebutton_->SetState(true);
- } else {
}
}
return true;
}
private:
- char name_[128];
- char bundleName_[128];
- bool status_;
- UIToggleButton* togglebutton_;
+ char name_[128] = {0};
+ char bundleName_[128] = {0};
+ bool status_ = false;
+ UIToggleButton* togglebutton_ = nullptr;
};
class AppInfoAbilitySlice : public AbilitySlice {
diff --git a/setting/setting/src/main/cpp/event_listener.h b/setting/setting/src/main/cpp/event_listener.h
old mode 100644
new mode 100755
index ba7d323..980df14
--- a/setting/setting/src/main/cpp/event_listener.h
+++ b/setting/setting/src/main/cpp/event_listener.h
@@ -35,20 +35,28 @@ public:
onLongPress_ = std::move(onLongPress);
}
- bool OnClick(UIView &view, const ClickEvent &event) override
+ bool OnClick(UIView& view, const ClickEvent &event) override
{
if (!onClick_) {
return false;
}
- return onClick_(view, event);
+ UIView *currentView = &view;
+ if (currentView == nullptr) {
+ return false;
+ }
+ return onClick_(*currentView, event);
}
- bool OnLongPress(UIView &view, const LongPressEvent &event) override
+ bool OnLongPress(UIView& view, const LongPressEvent &event) override
{
if (!onLongPress_) {
return false;
}
- return onLongPress_(view, event);
+ UIView *currentView = &view;
+ if (currentView == nullptr) {
+ return false;
+ }
+ return onLongPress_(*currentView, event);
}
private:
diff --git a/setting/setting/src/main/cpp/main_ability_slice.cpp b/setting/setting/src/main/cpp/main_ability_slice.cpp
old mode 100644
new mode 100755
index 188d3c3..0f80f35
--- a/setting/setting/src/main/cpp/main_ability_slice.cpp
+++ b/setting/setting/src/main/cpp/main_ability_slice.cpp
@@ -51,6 +51,11 @@ MainAbilitySlice::~MainAbilitySlice()
buttonWifiListener_ = nullptr;
}
+ if (buttonDisplayListener_) {
+ delete buttonDisplayListener_;
+ buttonDisplayListener_ = nullptr;
+ }
+
if (buttonAppListener_) {
delete buttonAppListener_;
buttonAppListener_ = nullptr;
@@ -81,7 +86,6 @@ void MainAbilitySlice::SetButtonListenerApp(void)
{
auto onClick2 = [this](UIView& view, const Event& event) -> bool {
Want want1 = { nullptr };
- ElementName element = { nullptr };
AbilitySlice* nextSlice = AbilityLoader::GetInstance().GetAbilitySliceByName("AppAbilitySlice");
if (nextSlice == nullptr) {
printf("[warning]undefined AppInfoAbilitySlice\n");
@@ -93,19 +97,35 @@ void MainAbilitySlice::SetButtonListenerApp(void)
buttonAppListener_ = new EventListener(onClick2, nullptr);
}
-void MainAbilitySlice::SetButtonListenerAbout(void)
+void MainAbilitySlice::SetButtonListenerDisplay(void)
{
auto onClick3 = [this](UIView& view, const Event& event) -> bool {
Want want1 = { nullptr };
- AbilitySlice* nextSlice = AbilityLoader::GetInstance().GetAbilitySliceByName("SettingAboutAbilitySlice");
+ AbilitySlice* nextSlice = AbilityLoader::GetInstance().GetAbilitySliceByName("SettingDisplayAbilitySlice");
if (nextSlice == nullptr) {
- printf("[warning]undefined NextAbilitySlice\n");
+ printf("[warning]undefined SettingDisplayAbilitySlice\n");
} else {
Present(*nextSlice, want1);
}
return true;
};
- buttonAboutListener_ = new EventListener(onClick3, nullptr);
+ buttonDisplayListener_ = new EventListener(onClick3, nullptr);
+}
+
+
+void MainAbilitySlice::SetButtonListenerAbout(void)
+{
+ auto onClick4 = [this](UIView& view, const Event& event) -> bool {
+ Want want1 = { nullptr };
+ AbilitySlice* nextSlice = AbilityLoader::GetInstance().GetAbilitySliceByName("SettingAboutAbilitySlice");
+ if (nextSlice == nullptr) {
+ printf("[warning]undefined SettingAboutAbilitySlice\n");
+ } else {
+ Present(*nextSlice, want1);
+ }
+ return true;
+ };
+ buttonAboutListener_ = new EventListener(onClick4, nullptr);
}
void MainAbilitySlice::SetHead(void)
@@ -199,6 +219,30 @@ void MainAbilitySlice::SetAppButtonView(void)
buttonView->Add(imageView);
}
+void MainAbilitySlice::SetDisplayButtonView(void)
+{
+ UIViewGroup* buttonView = new UIViewGroup();
+ buttonView->SetPosition(DISPALY_BUTTON_X, DISPALY_BUTTON_Y, DE_BUTTON_WIDTH, DE_BUTTON_HEIGHT);
+ buttonView->SetStyle(STYLE_BORDER_RADIUS, DE_BUTTON_RADIUS);
+ buttonView->SetStyle(STYLE_BACKGROUND_COLOR, DE_BUTTON_BACKGROUND_COLOR);
+ buttonView->SetTouchable(true);
+ buttonView->SetOnClickListener(buttonDisplayListener_);
+ scrollView_->Add(buttonView);
+
+ UILabel* lablelFont = new UILabel();
+ lablelFont->SetPosition(DE_TITLE_TEXT_X, DE_TITLE_TEXT_Y, DE_TITLE_TEXT_WIDTH, DE_TITLE_TEXT_HEIGHT);
+ lablelFont->SetText("显示");
+ lablelFont->SetFont(DE_FONT_OTF, DE_TITLE_TEXT_SIZE);
+
+ lablelFont->SetStyle(STYLE_TEXT_COLOR, DE_TITLE_TEXT_COLOR);
+ buttonView->Add(lablelFont);
+
+ UIImageView* imageView = new UIImageView();
+ imageView->SetPosition(DE_FORWARD_IMG_X, DE_FORWARD_IMG_Y, DE_FORWARD_IMG_WIDTH, DE_FORWARD_IMG_HEIGHT);
+ imageView->SetSrc(DE_IMAGE_FORWORD);
+ buttonView->Add(imageView);
+}
+
static void setAboutTest(UIViewGroup *buttonView, int positionX, int positionY, const char *setText)
{
UILabel* lablelFontSystem = new UILabel();
@@ -231,6 +275,8 @@ void MainAbilitySlice::SetAboutButtonView(void)
int err = sprintf_s(buff, sizeof(buff), "系统版本: %s", gDV);
if (err < 0) {
printf("[ERROR]sprintf_s failed, err = %d\n", err);
+ free(gDV);
+ gDV = nullptr;
return;
}
free(gDV);
@@ -245,6 +291,8 @@ void MainAbilitySlice::SetAboutButtonView(void)
err = sprintf_s(buff, sizeof(buff), "设备名称: %s", gPT);
if (err < 0) {
printf("[ERROR]sprintf_s failed, err = %d\n", err);
+ free(gPT);
+ gPT = nullptr;
return;
}
free(gPT);
@@ -266,6 +314,7 @@ void MainAbilitySlice::SetScrollView()
rootView_->Add(scrollView_);
SetWifiButtonView();
SetAppButtonView();
+ SetDisplayButtonView();
SetAboutButtonView();
}
@@ -274,6 +323,7 @@ void MainAbilitySlice::OnStart(const Want& want)
AbilitySlice::OnStart(want);
SetButtonListenerWifi();
SetButtonListenerApp();
+ SetButtonListenerDisplay();
SetButtonListenerAbout();
rootView_ = RootView::GetWindowRootView();
rootView_->SetPosition(DE_ROOT_X, DE_ROOT_Y, DE_ROOT_WIDTH, DE_ROOT_HEIGHT);
diff --git a/setting/setting/src/main/cpp/main_ability_slice.h b/setting/setting/src/main/cpp/main_ability_slice.h
old mode 100644
new mode 100755
index a5911b8..3af36af
--- a/setting/setting/src/main/cpp/main_ability_slice.h
+++ b/setting/setting/src/main/cpp/main_ability_slice.h
@@ -44,8 +44,8 @@ class MainAbilitySlice : public AbilitySlice {
public:
MainAbilitySlice()
: headView_(nullptr), scrollView_(nullptr), rootView_(nullptr), lablelFontSsid_(nullptr),
- buttonWifiListener_(nullptr), buttonAppListener_(nullptr), buttonAboutListener_(nullptr),
- buttonBackListener_(nullptr) {}
+ buttonWifiListener_(nullptr), buttonAppListener_(nullptr), buttonDisplayListener_(nullptr),
+ buttonAboutListener_(nullptr), buttonBackListener_(nullptr) {}
virtual ~MainAbilitySlice();
protected:
@@ -58,9 +58,11 @@ protected:
private:
void SetButtonListenerWifi();
void SetButtonListenerApp();
+ void SetButtonListenerDisplay();
void SetButtonListenerAbout();
void SetAboutButtonView();
void SetAppButtonView();
+ void SetDisplayButtonView();
void SetWifiButtonView();
void SetScrollView();
void SetHead();
@@ -69,9 +71,9 @@ private:
UIScrollView* scrollView_;
RootView* rootView_;
UILabel* lablelFontSsid_;
- char ssidBuff[64];
EventListener* buttonWifiListener_;
EventListener* buttonAppListener_;
+ EventListener* buttonDisplayListener_;
EventListener* buttonAboutListener_;
EventListener* buttonBackListener_;
@@ -84,8 +86,11 @@ private:
constexpr static int APP_BUTTON_X = 0;
constexpr static int APP_BUTTON_Y = 95;
+ constexpr static int DISPALY_BUTTON_X = 0;
+ constexpr static int DISPALY_BUTTON_Y = 190;
+
constexpr static int ABOUT_BUTTON_X = 0;
- constexpr static int ABOUT_BUTTON_Y = 190;
+ constexpr static int ABOUT_BUTTON_Y = 190 + DE_BUTTON_HEIGHT + 6;
constexpr static int ABOUT_BUTTON_HEIGHT = 113;
constexpr static int ABOUT_BUTTON_TEXT_ABOUT_Y = 5;
constexpr static int ABOUT_BUTTON_TEXT_SYSTEM_X = 18;
diff --git a/setting/setting/src/main/cpp/setting_about_ability_slice.cpp b/setting/setting/src/main/cpp/setting_about_ability_slice.cpp
old mode 100644
new mode 100755
diff --git a/setting/setting/src/main/cpp/setting_about_ability_slice.h b/setting/setting/src/main/cpp/setting_about_ability_slice.h
old mode 100644
new mode 100755
index b508fa0..921512b
--- a/setting/setting/src/main/cpp/setting_about_ability_slice.h
+++ b/setting/setting/src/main/cpp/setting_about_ability_slice.h
@@ -1,67 +1,67 @@
-/*
- * Copyright (c) 2020 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.
- */
-
-#ifndef OHOS_SETTING_ABOUT_ABILITY_SLICE_H
-#define OHOS_SETTING_ABOUT_ABILITY_SLICE_H
-
-#include "ability_info.h"
-#include "ability_loader.h"
-#include "ability_slice.h"
-#include "bundle_manager.h"
-#include "components/ui_image_view.h"
-#include "components/ui_label.h"
-#include "components/ui_label_button.h"
-#include "components/ui_list.h"
-#include "components/ui_scroll_view.h"
-#include "components/ui_toggle_button.h"
-#include "element_name.h"
-#include "event_listener.h"
-#include "list.h"
-#include "module_info.h"
-#include "parameter.h"
-#include "setting_utils.h"
-#include "want.h"
-
-namespace OHOS {
-class SettingAboutAbilitySlice : public AbilitySlice {
-public:
- SettingAboutAbilitySlice()
- : headView_(nullptr), scrollView_(nullptr), rootView_(nullptr), buttonBackListener_(nullptr) {}
- virtual ~SettingAboutAbilitySlice();
-protected:
- void OnStart(const Want& want) override;
- void OnInactive() override;
- void OnActive(const Want& want) override;
- void OnBackground() override;
- void OnStop() override;
-private:
- void SetItemInfo();
- void SetButtonListener();
- void SetScrollItem(int count);
- void SetScroll();
- void SetHead();
-
- UIViewGroup* headView_;
- UIScrollView* scrollView_;
- RootView* rootView_;
- EventListener *buttonBackListener_;
- constexpr static int SCROLL_ITEM_NUM = 9;
- char *itemInfo_[SCROLL_ITEM_NUM][2];
- constexpr static int ITEM_X = 0;
- constexpr static int ITEM_INFO_X = 465;
- constexpr static int ITEM_INFO_Y = 36;
-};
-} // namespace OHOS
-#endif
+/*
+ * Copyright (c) 2020 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.
+ */
+
+#ifndef OHOS_SETTING_ABOUT_ABILITY_SLICE_H
+#define OHOS_SETTING_ABOUT_ABILITY_SLICE_H
+
+#include "ability_info.h"
+#include "ability_loader.h"
+#include "ability_slice.h"
+#include "bundle_manager.h"
+#include "components/ui_image_view.h"
+#include "components/ui_label.h"
+#include "components/ui_label_button.h"
+#include "components/ui_list.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_toggle_button.h"
+#include "element_name.h"
+#include "event_listener.h"
+#include "list.h"
+#include "module_info.h"
+#include "parameter.h"
+#include "setting_utils.h"
+#include "want.h"
+
+namespace OHOS {
+class SettingAboutAbilitySlice : public AbilitySlice {
+public:
+ SettingAboutAbilitySlice()
+ : headView_(nullptr), scrollView_(nullptr), rootView_(nullptr), buttonBackListener_(nullptr) {}
+ virtual ~SettingAboutAbilitySlice();
+protected:
+ void OnStart(const Want& want) override;
+ void OnInactive() override;
+ void OnActive(const Want& want) override;
+ void OnBackground() override;
+ void OnStop() override;
+private:
+ void SetItemInfo();
+ void SetButtonListener();
+ void SetScrollItem(int count);
+ void SetScroll();
+ void SetHead();
+
+ UIViewGroup* headView_;
+ UIScrollView* scrollView_;
+ RootView* rootView_;
+ EventListener *buttonBackListener_;
+ constexpr static int SCROLL_ITEM_NUM = 9;
+ char *itemInfo_[SCROLL_ITEM_NUM][2];
+ constexpr static int ITEM_X = 0;
+ constexpr static int ITEM_INFO_X = 465;
+ constexpr static int ITEM_INFO_Y = 36;
+};
+} // namespace OHOS
+#endif
diff --git a/setting/setting/src/main/cpp/setting_display_ability_slice.cpp b/setting/setting/src/main/cpp/setting_display_ability_slice.cpp
new file mode 100755
index 0000000..e89ace0
--- /dev/null
+++ b/setting/setting/src/main/cpp/setting_display_ability_slice.cpp
@@ -0,0 +1,203 @@
+/*
+ * Copyright (c) 2020 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.
+ */
+
+#include "setting_display_ability_slice.h"
+#include
+#include
+#include "style.h"
+
+namespace OHOS {
+REGISTER_AS(SettingDisplayAbilitySlice)
+
+const char * const BATTERY_MANAGE_SERVICE = "power_service";
+const char * const PERM_INNER = "power_feature";
+#define COM_SET_ON 0
+#define COM_SET_OFF 1
+#define COM_GET_STATUS 2
+
+SettingDisplayAbilitySlice::~SettingDisplayAbilitySlice()
+{
+ if (toggleButtonView_) {
+ DeleteChildren(toggleButtonView_);
+ toggleButtonView_ = nullptr;
+ }
+
+ if (headView_) {
+ DeleteChildren(headView_);
+ headView_ = nullptr;
+ }
+
+ if (changeListener_) {
+ delete changeListener_;
+ changeListener_ = nullptr;
+ }
+
+ if (buttonBackListener_) {
+ delete buttonBackListener_;
+ buttonBackListener_ = nullptr;
+ }
+}
+
+static int Callback(IOwner owner, int code, IpcIo *reply)
+{
+ size_t src = IpcIoPopInt32(reply);
+ printf("[setting]IpcIoPopInt32 src -> %d\n", src);
+
+ int ret = memcpy_s(owner, sizeof(size_t), &src, sizeof(size_t));
+ if (ret < 0) {
+ printf("memcpy_s Error\n");
+ return -1;
+ }
+ printf("[setting]owner -> %d\n", *(int*)owner);
+ return 0;
+}
+
+static int GetDisapayStatus(IClientProxy *defaultApi)
+{
+ if (defaultApi == NULL) {
+ printf("[Error] defaultApi == NULL)\n");
+ return -1;
+ }
+ int ret;
+ int com = COM_GET_DISPLAY_STATUS;
+ IpcIo request;
+ char data[MAX_DATA_LEN];
+ IpcIoInit(&request, data, sizeof(data), 0);
+ defaultApi->Invoke(defaultApi, com, &request, &ret, Callback);
+ printf("[setting]ret get for ret -> %d \n", ret);
+ return ret;
+}
+
+static IClientProxy *CASE_GetRemoteIUnknown(void)
+{
+ IClientProxy *demoApi = nullptr;
+
+ printf("[setting] service -> %s \n", BATTERY_MANAGE_SERVICE);
+ IUnknown *iUnknown = SAMGR_GetInstance()->GetFeatureApi(BATTERY_MANAGE_SERVICE, PERM_INNER);
+ if (iUnknown == nullptr) {
+ printf("[ERR] SAMGR_GetInstance()->GetFeatureApi(POWER_SERVICE)\n");
+ return nullptr;
+ }
+ (void)iUnknown->QueryInterface(iUnknown, CLIENT_PROXY_VER, (void **)&demoApi);
+ printf("[setting]iUnknown->QueryInterface suc\n");
+ return demoApi;
+}
+
+void SettingDisplayAbilitySlice::SetButtonListener(void)
+{
+ auto onClick = [this](UIView& view, const Event& event) -> bool {
+ Want want1 = { nullptr };
+ AbilitySlice* nextSlice = AbilityLoader::GetInstance().GetAbilitySliceByName("MainAbilitySlice");
+ if (nextSlice == nullptr) {
+ printf("[warning]undefined MainAbilitySlice\n");
+ } else {
+ Present(*nextSlice, want1);
+ }
+ return true;
+ };
+ buttonBackListener_ = new EventListener(onClick, nullptr);
+}
+
+void SettingDisplayAbilitySlice::SetHead(void)
+{
+ headView_ = new UIViewGroup();
+ rootView_->Add(headView_);
+ headView_->SetPosition(DE_HEAD_X, DE_HEAD_Y, DE_HEAD_WIDTH, DE_HEAD_HEIGHT);
+ headView_->SetStyle(STYLE_BACKGROUND_OPA, 0);
+ headView_->SetTouchable(true);
+ headView_->SetOnClickListener(buttonBackListener_);
+
+ UIImageView* imageView = new UIImageView();
+ headView_->Add(imageView);
+ imageView->SetPosition(DE_HEAD_IMAGE_X, DE_HEAD_IMAGE_Y, DE_HEAD_IMAGE_WIDTH, DE_HEAD_IMAGE_HEIGHT);
+ imageView->SetSrc(DE_IMAGE_BACK);
+
+ UILabel* lablelFont = new UILabel();
+ lablelFont->SetPosition(DE_HEAD_TEXT_X, DE_HEAD_TEXT_Y, DE_HEAD_TEXT_WIDTH, DE_HEAD_TEXT_HEIGHT);
+ lablelFont->SetText("显示");
+ lablelFont->SetFont(DE_FONT_OTF, DE_HEAD_TEXT_SIZE);
+ lablelFont->SetStyle(STYLE_TEXT_COLOR, DE_HEAD_TEXT_COLOR);
+ headView_->Add(lablelFont);
+}
+
+void SettingDisplayAbilitySlice::SetToggleButton(void)
+{
+ toggleButtonView_ = new UIViewGroup();
+ toggleButtonView_->SetPosition(TOGGLE_X, TOGGLE_Y, DE_BUTTON_WIDTH, DE_BUTTON_HEIGHT);
+ toggleButtonView_->SetStyle(STYLE_BACKGROUND_COLOR, DE_BUTTON_BACKGROUND_COLOR);
+ toggleButtonView_->SetStyle(STYLE_BACKGROUND_OPA, DE_OPACITY_ALL);
+ toggleButtonView_->SetStyle(STYLE_BORDER_RADIUS, DE_BUTTON_RADIUS);
+ rootView_->Add(toggleButtonView_);
+
+ auto lablelFont = new UILabel();
+ lablelFont->SetPosition(DE_TITLE_TEXT_X, DE_TITLE_TEXT_Y, DE_TITLE_TEXT_WIDTH, DE_TITLE_TEXT_HEIGHT);
+ lablelFont->SetText("屏保");
+ lablelFont->SetFont(DE_FONT_OTF, DE_TITLE_TEXT_SIZE);
+ lablelFont->SetStyle(STYLE_TEXT_COLOR, DE_TITLE_TEXT_COLOR);
+ toggleButtonView_->Add(lablelFont);
+
+ int ret = GetDisapayStatus(remoteApi_);
+ UIToggleButton* togglebutton = new UIToggleButton();
+ if (ret == 0) {
+ togglebutton->SetState(true);
+ } else {
+ togglebutton->SetState(false);
+ }
+ changeListener_ = new DisBtnOnStateChangeListener(remoteApi_, togglebutton);
+ togglebutton->SetOnClickListener(changeListener_);
+ togglebutton->SetPosition(DE_TOGGLE_BUTTON_X, DE_TOGGLE_BUTTON_Y);
+ toggleButtonView_->Add(togglebutton);
+}
+
+void SettingDisplayAbilitySlice::OnStart(const Want& want)
+{
+ AbilitySlice::OnStart(want);
+
+ rootView_ = RootView::GetWindowRootView();
+ rootView_->SetPosition(DE_ROOT_X, DE_ROOT_Y, DE_ROOT_WIDTH, DE_ROOT_HEIGHT);
+ rootView_->SetStyle(STYLE_BACKGROUND_COLOR, DE_ROOT_BACKGROUND_COLOR);
+ SetButtonListener();
+ SetHead();
+ remoteApi_ = CASE_GetRemoteIUnknown();
+ if (remoteApi_ != NULL) {
+ printf("[setting]remoteApi_ is ok \n");
+ } else {
+ printf("[setting] remoteApi_ is faild \n");
+ }
+
+ SetToggleButton();
+ SetUIContent(rootView_);
+}
+
+void SettingDisplayAbilitySlice::OnInactive()
+{
+ AbilitySlice::OnInactive();
+}
+
+void SettingDisplayAbilitySlice::OnActive(const Want& want)
+{
+ AbilitySlice::OnActive(want);
+}
+
+void SettingDisplayAbilitySlice::OnBackground()
+{
+ AbilitySlice::OnBackground();
+}
+
+void SettingDisplayAbilitySlice::OnStop()
+{
+ AbilitySlice::OnStop();
+}
+} // namespace OHOS
diff --git a/setting/setting/src/main/cpp/setting_display_ability_slice.h b/setting/setting/src/main/cpp/setting_display_ability_slice.h
new file mode 100755
index 0000000..e351b2f
--- /dev/null
+++ b/setting/setting/src/main/cpp/setting_display_ability_slice.h
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2020 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.
+ */
+
+#ifndef OHOS_SETTING_DISPLAY_ABILITY_SLICE_H
+#define OHOS_SETTING_DISPLAY_ABILITY_SLICE_H
+
+#include
+#include
+#include
+#include
+
+#include "samgr_lite.h"
+#include "ability_loader.h"
+#include "components/ui_label.h"
+#include "components/ui_label_button.h"
+#include "components/ui_list.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_toggle_button.h"
+#include "event_listener.h"
+#include "list.h"
+#include "parameter.h"
+#include "setting_utils.h"
+
+namespace OHOS {
+/*
+0: on
+1: off
+2:return 0:off, return 1:on
+*/
+enum ComDisplay {
+ COM_SET_DISPLAY_STEADY_ON,
+ COM_SET_DISPLAY_NO_STEADY_ON,
+ COM_GET_DISPLAY_STATUS,
+};
+const int MAX_DATA_LEN = 0x100;
+
+class DisBtnOnStateChangeListener : public OHOS::UICheckBox::OnChangeListener, public OHOS::UIView::OnClickListener {
+public:
+ ~DisBtnOnStateChangeListener() {}
+ explicit DisBtnOnStateChangeListener(IClientProxy* iClientProxy, UIToggleButton* togglebutton)
+ : myIClientProxy(iClientProxy), myTogglebutton(togglebutton) {}
+
+ bool OnChange(UICheckBox::UICheckBoxState state) override
+ {
+ return true;
+ }
+ bool OnClick(UIView& view, const ClickEvent& event) override
+ {
+ int com;
+ bool status = myTogglebutton->GetState();
+ if (status == true) {
+ com = COM_SET_DISPLAY_NO_STEADY_ON;
+ } else {
+ com = COM_SET_DISPLAY_STEADY_ON;
+ }
+ IpcIo request;
+ char data[MAX_DATA_LEN];
+ IpcIoInit(&request, data, sizeof(data), 0);
+ if (myIClientProxy != NULL) {
+ myIClientProxy->Invoke(myIClientProxy, com, &request, NULL, NULL);
+ }
+ return true;
+ }
+private:
+ int funcId_ = 0;
+ IClientProxy* myIClientProxy;
+ UIToggleButton* myTogglebutton;
+};
+
+class SettingDisplayAbilitySlice : public AbilitySlice {
+public:
+ SettingDisplayAbilitySlice()
+ : headView_(nullptr), toggleButtonView_(nullptr), rootView_(nullptr),
+ buttonBackListener_(nullptr), changeListener_(nullptr) {}
+
+ virtual ~SettingDisplayAbilitySlice();
+protected:
+ void OnStart(const Want& want) override;
+ void OnInactive() override;
+ void OnActive(const Want& want) override;
+ void OnBackground() override;
+ void OnStop() override;
+
+private:
+ void SetButtonListener();
+ void SetHead();
+ void SetToggleButton();
+
+ IClientProxy* remoteApi_ = nullptr;
+ UIViewGroup* headView_;
+ UIViewGroup* toggleButtonView_;
+ RootView* rootView_;
+ EventListener* buttonBackListener_;
+ DisBtnOnStateChangeListener* changeListener_;
+ constexpr static int TOGGLE_X = 36;
+ constexpr static int TOGGLE_Y = 72;
+
+ constexpr static int USE_WIFI_FONT_X = 54;
+ constexpr static int USE_WIFI_FONT_Y = 187;
+
+ constexpr static int ADD_WIFI_X = 0;
+ constexpr static int SCROLL_WIFI_X = 36;
+ constexpr static int SCROLL_WIFI_Y = 242;
+ constexpr static int SCROLL_WIFI_WIDTH = 960;
+ constexpr static int SCROLL_WIFI_HEIGHT = 238;
+};
+} // namespace OHOS
+#endif
diff --git a/setting/setting/src/main/cpp/setting_main_ability.cpp b/setting/setting/src/main/cpp/setting_main_ability.cpp
old mode 100644
new mode 100755
diff --git a/setting/setting/src/main/cpp/setting_main_ability.h b/setting/setting/src/main/cpp/setting_main_ability.h
old mode 100644
new mode 100755
diff --git a/setting/setting/src/main/cpp/setting_utils.cpp b/setting/setting/src/main/cpp/setting_utils.cpp
old mode 100644
new mode 100755
index 43e6cf3..8d24987
--- a/setting/setting/src/main/cpp/setting_utils.cpp
+++ b/setting/setting/src/main/cpp/setting_utils.cpp
@@ -1,37 +1,37 @@
-/*
- * Copyright (c) 2020 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.
- */
-
-#include "setting_utils.h"
-
-namespace OHOS {
-void DeleteChildren(UIView *view)
-{
- if (view == nullptr) {
- return;
- }
- while (view != nullptr) {
- UIView *tempView = view;
- view = view->GetNextSibling();
- if (tempView->IsViewGroup()) {
- DeleteChildren(static_cast(tempView)->GetChildrenHead());
- }
- if (tempView->GetParent()) {
- static_cast(tempView->GetParent())->Remove(tempView);
- }
- delete tempView;
- tempView = nullptr;
- }
-}
-} // namespace OHOS
+/*
+ * Copyright (c) 2020 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.
+ */
+
+#include "setting_utils.h"
+
+namespace OHOS {
+void DeleteChildren(UIView *view)
+{
+ if (view == nullptr) {
+ return;
+ }
+ while (view != nullptr) {
+ UIView *tempView = view;
+ view = view->GetNextSibling();
+ if (tempView->IsViewGroup()) {
+ DeleteChildren(static_cast(tempView)->GetChildrenHead());
+ }
+ if (tempView->GetParent()) {
+ static_cast(tempView->GetParent())->Remove(tempView);
+ }
+ delete tempView;
+ tempView = nullptr;
+ }
+}
+} // namespace OHOS
diff --git a/setting/setting/src/main/cpp/setting_utils.h b/setting/setting/src/main/cpp/setting_utils.h
old mode 100644
new mode 100755
diff --git a/setting/setting/src/main/cpp/setting_wifi_ability_slice.cpp b/setting/setting/src/main/cpp/setting_wifi_ability_slice.cpp
old mode 100644
new mode 100755
index 79b168e..c194f44
--- a/setting/setting/src/main/cpp/setting_wifi_ability_slice.cpp
+++ b/setting/setting/src/main/cpp/setting_wifi_ability_slice.cpp
@@ -86,6 +86,9 @@ void SettingWifiAbilitySlice::SetWifiButtonListener(char* ssid)
auto onClick2 = [this, ssid](UIView& view, const Event& event) -> bool {
Want want1 = { nullptr };
bool ret = SetWantData(&want1, ssid, strlen(ssid) + 1);
+ if (ret != true) {
+ return false;
+ }
StartAbility(want1);
AbilitySlice* nextSlice =
AbilityLoader::GetInstance().GetAbilitySliceByName("SettingWifiInputPasswordAbilitySlice");
@@ -161,7 +164,6 @@ void SettingWifiAbilitySlice::AddWifi(void)
{
int ssidIndex, ssidCount;
- char* buff = nullptr;
ssidCount = GetIdNum();
if (ssidCount == 0) {
printf("[LOG]SettingWifiAbilitySlice::AddWifi ssidCount == 0 \n");
diff --git a/setting/setting/src/main/cpp/setting_wifi_ability_slice.h b/setting/setting/src/main/cpp/setting_wifi_ability_slice.h
old mode 100644
new mode 100755
index a340431..dad9ddd
--- a/setting/setting/src/main/cpp/setting_wifi_ability_slice.h
+++ b/setting/setting/src/main/cpp/setting_wifi_ability_slice.h
@@ -16,6 +16,7 @@
#ifndef OHOS_SETTING_WIFI_ABILITY_SLICE_H
#define OHOS_SETTING_WIFI_ABILITY_SLICE_H
+#include
#include
#include
@@ -30,7 +31,6 @@
#include "parameter.h"
#include "pthread.h"
#include "setting_utils.h"
-#include "stddef.h"
#include "wpa_work.h"
#include "common/task.h"
diff --git a/setting/setting/src/main/cpp/setting_wifi_input_password_ability_slice.cpp b/setting/setting/src/main/cpp/setting_wifi_input_password_ability_slice.cpp
old mode 100644
new mode 100755
index d316217..109aa92
--- a/setting/setting/src/main/cpp/setting_wifi_input_password_ability_slice.cpp
+++ b/setting/setting/src/main/cpp/setting_wifi_input_password_ability_slice.cpp
@@ -22,7 +22,7 @@ REGISTER_AS(SettingWifiInputPasswordAbilitySlice)
static UIView::OnClickListener* clickLeftListener_ = nullptr;
static const int g_maxPassword = 10; // Maximum length of a password.
-static char* g_inputSsid;
+static char* g_inputSsid = nullptr;
static char g_inputPassword[g_maxPassword + 1] = { 0 };
static int g_inputCount = 0;
static int g_cursorPositionX = 20; // Initial position of cursor X
@@ -84,12 +84,8 @@ public:
bool OnClick(UIView& view, const ClickEvent& event) override
{
WpaScanReconnect(g_inputSsid, g_inputPassword, HIDDEN_OPEN);
- int err = memset_s(g_inputSsid, sizeof(g_inputSsid), 0, sizeof(g_inputSsid));
- if (err != EOK) {
- printf("[ERROR]memset_s failed, err = %d\n", err);
- return false;
- }
- err = memset_s(g_inputPassword, sizeof(g_inputPassword), 0, sizeof(g_inputPassword));
+ g_inputSsid = nullptr;
+ int err = memset_s(g_inputPassword, sizeof(g_inputPassword), 0, sizeof(g_inputPassword));
if (err != EOK) {
printf("[ERROR]memset_s failed, err = %d\n", err);
return false;
@@ -148,7 +144,7 @@ void SettingWifiInputPasswordAbilitySlice::SetInput(void)
lablelInputText_->SetText("输入密码");
lablelInputText_->SetFont(DE_FONT_OTF, DE_TITLE_TEXT_SIZE);
inputView_->Add(lablelInputText_);
-
+
lablelCursorText_ = new UILabel();
lablelCursorText_->SetPosition(g_cursorPositionX, INPUT_CURSOR_Y, INPUT_CURSOR_WIDTH, INPUT_CURSOR_HEIGHT);
lablelCursorText_->SetStyle(STYLE_BACKGROUND_COLOR, Color::ColorTo32(Color::GetColorFromRGB(0x0D, 0x9F, 0xF8)));
@@ -263,14 +259,13 @@ void SettingWifiInputPasswordAbilitySlice::OnInactive()
void SettingWifiInputPasswordAbilitySlice::OnActive(const Want& want)
{
- int err;
+ int err;
lablelInputText_->SetText("输入密码");
g_cursorPositionX = 20; // 20
lablelCursorText_->SetX(g_cursorPositionX);
g_inputCount = 0;
err = memset_s(g_inputPassword, sizeof(g_inputPassword), 0, sizeof(g_inputPassword));
if (err != EOK) {
- printf("[ERROR]memset_s g_inputPassword failed, err = %d\n", err);
return;
}
AbilitySlice::OnActive(want);
diff --git a/setting/setting/src/main/cpp/setting_wifi_input_password_ability_slice.h b/setting/setting/src/main/cpp/setting_wifi_input_password_ability_slice.h
old mode 100644
new mode 100755
index 118d3fc..0493e05
--- a/setting/setting/src/main/cpp/setting_wifi_input_password_ability_slice.h
+++ b/setting/setting/src/main/cpp/setting_wifi_input_password_ability_slice.h
@@ -33,9 +33,9 @@
namespace OHOS {
class SettingWifiInputPasswordAbilitySlice : public AbilitySlice {
public:
- SettingWifiInputPasswordAbilitySlice() : headView_(nullptr), inputView_(nullptr), scrollView_(nullptr),
- rootView_(nullptr), lablelInputText_(nullptr),
- buttonBackListener_(nullptr), lablelCursorText_(nullptr) {}
+ SettingWifiInputPasswordAbilitySlice() : headView_(nullptr), inputView_(nullptr), lablelCursorText_(nullptr),
+ scrollView_(nullptr), rootView_(nullptr), lablelInputText_(nullptr),
+ buttonBackListener_(nullptr) {}
virtual ~SettingWifiInputPasswordAbilitySlice();
protected:
diff --git a/setting/setting/src/main/cpp/wpa_work.c b/setting/setting/src/main/cpp/wpa_work.c
old mode 100644
new mode 100755
index c78d8dc..e6f5723
--- a/setting/setting/src/main/cpp/wpa_work.c
+++ b/setting/setting/src/main/cpp/wpa_work.c
@@ -80,13 +80,6 @@ static int SendCtrlCommand(const char *cmd, char *reply, size_t *replyLen)
return -1;
}
-static void printUseSsid(void)
-{
- for (int i = 0; i < g_useSsidCount; i++) {
- printf("[LOG]thegUseSsidD[%d]->%s\n", i, g_useSsidD[i]);
- }
-}
-
static void ProcessScanResult(const char *buf, int len)
{
int myUse1 = 1;
@@ -96,7 +89,6 @@ static void ProcessScanResult(const char *buf, int len)
int err = memset_s(g_mySsidD, sizeof(g_mySsidD), 0, sizeof(g_mySsidD));
g_ssidCount = 0;
if (err != EOK) {
- printf("[ERROR]memset_s g_ssidCount failed, err = %d\n", err);
return;
}
for (int i = 0; i < len; i++) {
@@ -146,6 +138,9 @@ int GetCurrentConnInfo(char *ssid, int len)
printf("[ERROR]strstr(ssid) is null");
return -1;
}
+ if (offset >= strlen(pos)) {
+ return -1;
+ }
pos += offset;
pos = strstr(pos, "ssid=");
if (pos == NULL) {
@@ -159,7 +154,6 @@ int GetCurrentConnInfo(char *ssid, int len)
}
int ssidLen = end - pos - offset;
if (len < ssidLen) {
- SAMPLE_ERROR("ssid len = %d, buffer len = %d", ssidLen, len);
return -1;
}
int i = 0;
@@ -167,7 +161,6 @@ int GetCurrentConnInfo(char *ssid, int len)
for (pos += myOffset; pos < end; pos++, i++) {
ssid[i] = *pos;
}
- printf("[LOG]getssid->%s\n", ssid);
return 0;
}
@@ -246,7 +239,6 @@ static void CheckSsid(void)
if (j == g_ssidCount) {
err = strcpy_s(g_useSsidD[g_useSsidCount], sizeof(g_useSsidD[g_useSsidCount]), g_mySsidD[i]);
if (err != EOK) {
- printf("[ERROR]strcpy_s g_useSsidD failed, err = %d\n", err);
continue;
}
g_useSsidCount++;
@@ -280,7 +272,6 @@ static void WifiEventHandler(char *rawEvent, int len)
ProcessScanResult(scanResult, scanLen);
CheckSsid();
g_scanAvailable = 1;
- printUseSsid();
pthread_mutex_unlock(&g_mutex);
return;
}
@@ -391,6 +382,10 @@ int InitControlInterface()
}
sleep(1);
}
+ if (g_monitorConn != NULL) {
+ free(g_monitorConn);
+ g_monitorConn = NULL;
+ }
g_monitorConn = wpa_ctrl_open(WPA_IFACE_NAME); // create control interface for event monitor
if (!g_ctrlConn || !g_monitorConn) {
SAMPLE_ERROR("open wpa control interface failed.");
diff --git a/setting/setting/src/main/cpp/wpa_work.h b/setting/setting/src/main/cpp/wpa_work.h
old mode 100644
new mode 100755
diff --git a/setting/setting/src/main/resources/base/element/wpa_supplicant.conf b/setting/setting/src/main/resources/base/element/wpa_supplicant.conf
old mode 100644
new mode 100755
diff --git a/setting/setting/src/main/resources/base/media/app.png b/setting/setting/src/main/resources/base/media/app.png
old mode 100644
new mode 100755
diff --git a/setting/setting/src/main/resources/base/media/back.png b/setting/setting/src/main/resources/base/media/back.png
old mode 100644
new mode 100755
diff --git a/setting/setting/src/main/resources/base/media/enter.png b/setting/setting/src/main/resources/base/media/enter.png
old mode 100644
new mode 100755
diff --git a/setting/setting/src/main/resources/base/media/forward.png b/setting/setting/src/main/resources/base/media/forward.png
old mode 100644
new mode 100755
diff --git a/setting/setting/src/main/resources/base/media/setting.png b/setting/setting/src/main/resources/base/media/setting.png
old mode 100644
new mode 100755