update en/Community-Developer-Guides/openKylin_SDK_Guide_V2.0.md.

Signed-off-by: jlspcdd1227dd <12046126+jlspcdd1227dd@user.noreply.gitee.com>
This commit is contained in:
jlspcdd1227dd 2023-03-23 09:43:31 +00:00 committed by Gitee
parent eb02af40ce
commit 0be3fceb28
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 116 additions and 118 deletions

View File

@ -9,84 +9,84 @@
openSDK SIG openSDK SIG
目录 Table of contents
``` ```
1 概述 1 Overview
2 部署方式 2 Deployment methods
3 系统能力 SDK 3 System Capability SDK
3.1 系统信息 3.1 System Information
3.1.1 系统时间报时 3.1.1 System time reporting
3.1.2 获取硬件信息 3.1.2 Get hardware information
3.1.3 获取包列表信息 3.1.3 Get package list information
3.1.4 获取资源信息 3.1.4 Obtain resource information
3.1.5 获取操作系统基础信息 3.1.5 Obtain basic operating system information
3.1.6 获取网络信息 3.1.6 Get network information
3.1.7 获取系统运行时信息 3.1.7 Get system runtime information
3.1.8 获取当前地理信息 3.1.8 Get current geographic information
3.2 电源管理 3.2 Power Management
3.2.1 锁屏设置 3.2.1 Lock Screen Settings
3.3 文件管理 3.3 File Management
3.4 AI 能力 3.4 AI capabilities
3.4.1 OCR 文字识别功能 3.4.1 OCR character recognition function
3.5 打印机管理 3.5 Printer Management
4 应用支撑 SDK 4 Application Support SDK
4.1 QT 自研控件模块 4.1 QT self-developed control module
4.1.1 窗体模块 4.1.1 Form module
4.1.2 对话框模块 4.1.2 Dialog Module
4.1.3 输入框模块 4.1.3 Input box module
4.1.4 按钮模块 4.1.4 Button module
4.1.5 Bar 模块 4.1.5 Bar module
4.1.6 滑动条模块 4.1.6 Slider Module
4.1.7 消息提示模块 4.1.7 Message Prompt Module
4.1.8 面包屑 KBreadCrumb 4.1.8 Breadcrumbs KBreadCrumb
4.1.9 KCommentPanel 4.1.9 KCommentPanel
4.1.10 KListView 4.1.10 KListView
4.1.11 KTag 4.1.11 KTags
4.1.12 KTranslucentFloor 4.1.12 KTranslucentFloor
4.2 Wayland-helper 4.2 Wayland-helper
4.2.1 WindowManager 4.2.1 WindowManager
4.2.2 WindowInfo 4.2.2 WindowInfo
4.2.3 UkuiStyleHelper 4.2.3 UkuiStyleHelper
4.3 应用通用功能模块 4.3 Apply general function modules
4.3.1 日志模块 4.3.1 Log module
4.3.2 系统相关模块 4.3.2 System related modules
4.3.3 d-bus 模块------即将废弃 4.3.3 d-bus module------will be obsolete soon
4.3.4 系统信息模块 4.3.4 System information module
5 基础开发 SDK 5 Basic Development SDK
5.1 日志 5.1 log
5.2 定时器 5.2 Timers
5.3 C 语言字符串扩展 5.3 C language string extension
5.4 链表模块 5.4 Linked list module
5.5 配置文件操作 5.5 Configuration file operation
5.6 单位进制转换 5.6 Unit conversion
``` ```
# 1 概述 # 1 Overview
openKylin 自研开发者套件(以下简称 openSDK是在 openKylin 社区操作系统上为生态建设与软件开发提供安全、可靠、快捷、稳定的开发者接口。相比于社区中其他的开发者套件或框架openSDK 更加聚焦于解决开放麒麟桌面操作系统的兼容、适配、移植、优化等方面的问题。openSDK 当前聚焦三大模块,包括应用支撑 SDK、系统能力 SDK、基础开发 SDK同时充分考虑 openSDK 的兼容性。 The openKylin self-developed developer kit (hereinafter referred to as openSDK) is based on the openKylin community operating system, providing a safe, reliable, fast, and stable developer interface for ecological construction and software development. Compared with other developer kits or frameworks in the community, openSDK focuses more on solving the problems of compatibility, adaptation, transplantation, optimization and other aspects of the open Kylin desktop operating system. openSDK currently focuses on three major modules, including application support SDK, system capability SDK, and basic development SDK, while fully considering the compatibility of openSDK.
本文档旨在为开发者在 openKylin 系统上进行应用开发时,提供一种高效查阅 openSDK 接口的声明和使用方法的方式。减少开发者在使用 openSDK 时的学习成本。 This document aims to provide developers with an efficient way to refer to the declaration and usage of openSDK interfaces when developing applications on the openKylin system. Reduce the learning cost for developers when using openSDK.
SDK 的整体模块介绍如下: The overall modules of the SDK are introduced as follows:
| 模块 | 描述 | | module | describe |
|---|---| |---|---|
| 应用支撑 SDK | 聚焦于应用显示层,为开发者提供麒麟自研控件,向图形化应用提供图形化开发功能,可使用统一的 UI 框架,进行应用窗口的管理以及与系统进行互动等,降低应用开发与应用迁移学习成本; | | Application support SDK | Focusing on the application display layer, it provides developers with Kirin self-developed controls, provides graphical development functions for graphical applications, and can use a unified UI framework to manage application windows and interact with the system, reducing application development and application migration. study cost; |
| 系统能力 SDK | 聚焦于为开发者提供更多系统能力,开发者可快速获取基础的系统、硬件信息、当前的运行时信息等,提升开发效率,助力开发更聚焦实际业务内容;| | System Capability SDK | Focus on providing developers with more system capabilities, developers can quickly obtain basic system, hardware information, current runtime information, etc., improve development efficiency, and help development focus more on actual business content;|
| 基础开发 SDK | 聚焦于应用开发过程中,为开发者提供日志管理、封装字符串处理等能力,提升开发效率; | | Basic Development SDK | Focus on the application development process, providing developers with log management, package string processing and other capabilities to improve development efficiency; |
# 2 部署方式 # 2 Deployment method
openKylin 社区自研开发者套件下载使用时需提前添加 openSDK 源地址,安装步骤如下: When downloading and using the openKylin community self-developed developer kit, you need to add the openSDK source address in advance. The installation steps are as follows:
1软件源 (1) Software source:
``` ```
@ -98,151 +98,149 @@ deb http://archive.build.openKylin.top/openkylin/ yangtze-updates main cross pty
``` ```
(2) Update source after configuration:
2配置后更新源
``` ```
$ sudo apt update $ sudo apt update
``` ```
# 3 系统能力 SDK # 3 System Capability SDK
系统能力 SDK 中的每个软件包均表述了一个或一类系统能力,例如操作系统信息、硬件管理、系统内生安全策略、网络管理等; Each software package in the system capabilities SDK expresses one or a type of system capabilities, such as operating system information, hardware management, system built-in security policies, network management, etc.;
安装命令: Install command:
``` ```
$ sudo apt-get install libkysdk-system libkysdk-system-dev $ sudo apt-get install libkysdk-system libkysdk-system-dev
``` ```
## 3.1 系统信息 ## 3.1 System information
该层设计主要为应用提供与操作系统相关的功能接口,以自研、组合、封装三种方式,将与 OS 相关功能(如文件系统、硬件信息、通信等)以功能为角度重新实现;屏蔽系统差异、平台差异带来的开发复杂性与调试难度。 The design of this layer mainly provides applications with functional interfaces related to the operating system, and re-realizes OS-related functions (such as file systems, hardware information, communication, etc.) from the perspective of functions in three ways: self-development, combination, and packaging; Development complexity and debugging difficulty brought about by system differences and platform differences.
### 3.1.1 系统时间报时 ### 3.1.1 System time reporting
当系统时间在整分或系统时间被修改时com.kylin.kysdk.TimeServer Dbus 服务会发出报时信号。 The com.kylin.kysdk.TimeServer Dbus service will send out a time signal when the system time is at an integral minute or when the system time is modified.
``` ```
$ sudo apt-get install libdbus-1-dev libdbus-glib-1-dev libkysdk-systime libkysdk-systime-dev $ sudo apt-get install libdbus-1-dev libdbus-glib-1-dev libkysdk-systime libkysdk-systime-dev
``` ```
1dbus 服务名称:com.kylin.kysdk.TimeServer (1) dbus service name: com.kylin.kysdk.TimeServer
2路径名称/com/kylin/kysdk/Timer (2) Path name: /com/kylin/kysdk/Timer
3Interfacescom.kylin.kysdk.TimeInterface (3) Interfaces: com.kylin.kysdk.TimeInterface
4信号 (4) Signal:
系统时间修改信号:TimeChangeSignal System time modification signal: TimeChangeSignal
定时报时信号:TimeSignal Timed timing signal: TimeSignal
系统时间修改报时 System time modification time reporting
<table style="width: auto;"><tbody><tr><td colSpan="1" rowSpan="1" width="72">子模块</td><td colSpan="1" rowSpan="1" width="85">编程语言</td><td colSpan="2" rowSpan="1" width="266">声明</td><td colSpan="1" rowSpan="1" width="152">描述</td></tr><tr><td colSpan="1" rowSpan="3" width="72">系统时间报时</td><td colSpan="1" rowSpan="3" width="85">C</td><td colSpan="2" rowSpan="1" width="266">Void TimeChangeSignal(const char* t)</td><td colSpan="1" rowSpan="1" width="152">当系统时间被修改时com.kylin.kysdk.TimeServerDbus服务会发出报时信号</td></tr><tr><td colSpan="1" rowSpan="1" width="132">参数说明</td><td colSpan="1" rowSpan="1" width="133">返回值说明</td><td colSpan="1" rowSpan="1" width="152"></td></tr><tr><td colSpan="1" rowSpan="1" width="132">t:当前时间 如: "2021/09/26 21:13:28"</td><td colSpan="1" rowSpan="1" width="133"></td><td colSpan="1" rowSpan="1" width="152"></td></tr></tbody></table> <table style="width: auto;"><tbody><tr><td colSpan="1" rowSpan="1" width="72">submodule</td><td colSpan="1" rowSpan= "1" width="85">Programming language</td><td colSpan="2" rowSpan="1" width="266">Statement</td><td colSpan="1" rowSpan="1" width="152">Description</td></tr><tr><td colSpan="1" rowSpan="3" width="72">System time reporting</td><td colSpan="1" rowSpan="3" width="85">C</td><td colSpan="2" rowSpan="1" width="266">Void TimeChangeSignal(const char* t)</td><td colSpan= "1" rowSpan="1" width="152">When the system time is modified, the com.kylin.kysdk.TimeServerDbus service will send out a time signal</td></tr><tr><td colSpan="1 " rowSpan="1" width="132">parameter description</td><td colSpan="1" rowSpan="1" width="133">return value description</td><td colSpan="1" rowSpan="1" width="152"></td></tr><tr><td colSpan="1" rowSpan="1" width="132">t: current time such as: "2021/09 /26 21:13:28"</td><td colSpan="1" rowSpan="1" width="133">none</td><td colSpan="1" rowSpan="1" width=" 152"></td></tr></tbody></table>
系统时间整分报时 system time full minutes
<table style="width: auto;"><tbody><tr><td colSpan="1" rowSpan="1" width="71">子模块</td><td colSpan="1" rowSpan="1" width="86">编程语言</td><td colSpan="2" rowSpan="1" width="263">声明</td><td colSpan="1" rowSpan="1" width="154">描述</td></tr><tr><td colSpan="1" rowSpan="3" width="71">系统时间报时</td><td colSpan="1" rowSpan="3" width="86">C</td><td colSpan="2" rowSpan="1" width="263">void TimeSignal(const char* t)</td><td colSpan="1" rowSpan="1" width="154">当系统时间在整分时com.kylin.kysdk.TimeServerDbus服务会发出报时信号</td></tr><tr><td colSpan="1" rowSpan="1" width="132">参数说明</td><td colSpan="1" rowSpan="1" width="131">返回值说明</td><td colSpan="1" rowSpan="1" width="154"></td></tr><tr><td colSpan="1" rowSpan="1" width="132">t:当前时间 如: "2021/09/26 21:07:00"</td><td colSpan="1" rowSpan="1" width="131"></td><td colSpan="1" rowSpan="1" width="154"></td></tr></tbody></table> <table style="width: auto;"><tbody><tr><td colSpan="1" rowSpan="1" width="71">Submodule</td><td colSpan="1" rowSpan= "1" width="86">Programming language</td><td colSpan="2" rowSpan="1" width="263">Statement</td><td colSpan="1" rowSpan="1" width="154">Description</td></tr><tr><td colSpan="1" rowSpan="3" width="71">System time reporting</td><td colSpan="1" rowSpan="3" width="86">C</td><td colSpan="2" rowSpan="1" width="263">void TimeSignal(const char* t)</td><td colSpan= "1" rowSpan="1" width="154">When the system time is in full minutes, the com.kylin.kysdk.TimeServerDbus service will send out a time signal</td></tr><tr><td colSpan=" 1" rowSpan="1" width="132">parameter description</td><td colSpan="1" rowSpan="1" width="131">return value description</td><td colSpan="1 " rowSpan="1" width="154"></td></tr><tr><td colSpan="1" rowSpan="1" width="132">t: current time such as: "2021/ 09/26 21:07:00"</td><td colSpan="1" rowSpan="1" width="131">none</td><td colSpan="1" rowSpan="1" width= "154"></td></tr></tbody></table>
### **3.1.2** 获取硬件信息 ### **3.1.2** Get hardware information
``` ```
$ sudo apt-get install libkysdk-hardware libkysdk-hardware-dev $ sudo apt-get install libkysdk-hardware libkysdk-hardware-dev
``` ```
#### **3.1.2.1** 获取 CPU 信息 #### **3.1.2.1** Get CPU information
封装 C 接口获取 CPU 信息 Encapsulate C interface to obtain CPU information
1CMakeLists.txt 构建项目 (1) CMakeLists.txt build project
``` ```
aux_source_directory(. SOURCESCODE) aux_source_directory(. SOURCESCODE)
include_directories(.) include_directories(.)
add_library(kyhw SHARED \${SOURCESCODE}) add_library(kyhw SHARED \${SOURCESCODE})
add_executable(kycpu-test test/kycpu-test.c) add_executable(kycpu-test test/kycpu-test.c)
target_link_libraries(kyhw kylog kyconf pthread systemd udev) target_link_libraries(kyhw kylog kyconf pthread systemd udev)
target_link_libraries(kycpu-test kyhw) target_link_libraries(kycpu-test kyhw)
``` ```
2获取硬件 CPU 信息,需要添加头文件: (2) To obtain hardware CPU information, a header file needs to be added:
``` ```
#include "kysdk/kysdk-system/libkycpu.h" #include "kysdk/kysdk-system/libkycpu.h"
``` ```
获取 CPU 架构 Get CPU architecture
<table style="width: auto;"><tbody><tr><td colSpan="1" rowSpan="1" width="67">子模块</td><td colSpan="1" rowSpan="1" width="82">编程语言</td><td colSpan="2" rowSpan="1" width="282.36">声明</td><td colSpan="1" rowSpan="1" width="104">描述</td></tr><tr><td colSpan="1" rowSpan="3" width="67">获取CPU信息</td><td colSpan="1" rowSpan="3" width="82">C</td><td colSpan="2" rowSpan="1" width="306">extern const char* kdk_cpu_get_arch()</td><td colSpan="1" rowSpan="1" width="104">获取CPU架构</td></tr><tr><td colSpan="1" rowSpan="1" width="127">参数说明</td><td colSpan="1" rowSpan="1" width="178">返回值说明</td><td colSpan="1" rowSpan="1" width="104"></td></tr><tr><td colSpan="1" rowSpan="1" width="127"></td><td colSpan="1" rowSpan="1" width="178">const char* 架构信息,如"x86_64"返回的是const char*,不要free</td><td colSpan="1" rowSpan="1" width="104"></td></tr></tbody></table> <table style="width: auto;"><tbody><tr><td colSpan="1" rowSpan="1" width="67">submodule</td><td colSpan="1" rowSpan= "1" width="82">Programming language</td><td colSpan="2" rowSpan="1" width="282.36">Statement</td><td colSpan="1" rowSpan="1" width="104">Description</td></tr><tr><td colSpan="1" rowSpan="3" width="67">Get CPU information</td><td colSpan="1" rowSpan="3" width="82">C</td><td colSpan="2" rowSpan="1" width="306">extern const char* kdk_cpu_get_arch()</td><td colSpan=" 1" rowSpan="1" width="104">Get CPU Architecture</td></tr><tr><td colSpan="1" rowSpan="1" width="127">Parameter Description</td ><td colSpan="1" rowSpan="1" width="178">Return value description</td><td colSpan="1" rowSpan="1" width="104"></td></ tr><tr><td colSpan="1" rowSpan="1" width="127">None</td><td colSpan="1" rowSpan="1" width="178">const char* schema Information, such as "x86_64"; the return is const char*, not free</td><td colSpan="1" rowSpan="1" width="104"></td></tr></tbody> </table>
获取 CPU 制造厂商 Get CPU Manufacturer
| submodule | Programming language | statement | describe |
| 子模块 | 编程语言 | 声明 | 描述 |
|---------|------|-----------------------------------------|------------------------------------------------------------| |---------|------|-----------------------------------------|------------------------------------------------------------|
| 获取CPU信息 | C | extern const char* kdk_cpu_get_vendor() | 获取CPU制造商 | | Get CPU information | C | extern const char* kdk_cpu_get_vendor() | Get the CPU manufacturer |
| | | 参数说明 | 返回值说明 | | | | | Parameter Description | Return value description | |
| | | 无 | const char* 制造厂商字符串如“GenuineIntel”返回的是const char*,不要free | | | | none | const char* manufacturer string, such as "GenuineIntel"; return const char*, do not free |
获取 CPU 型号 Get CPU model
| 子模块 | 编程语言 | 声明 | 描述 | | submodule | Programming language | statement | describe |
|---------|------|----------------------------------------|----------------------------------------------------------------------------------------| |---------|------|----------------------------------------|----------------------------------------------------------------------------------------|
| 获取CPU信息 | C | extern const char* kdk_cpu_get_model() | 获取CPU型号 | | Get CPU information | C | extern const char* kdk_cpu_get_model() | Get the CPU model |
| | | 参数说明 | 返回值说明 | | | | | Parameter Description | Return value description | |
| | | 无 | const char* CPU型号名称如“Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz”返回的是const char*,不要free | | | | none | const char* CPU model name, such as "Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz"; return const char*, do not free |
获取 CPU 额定主频 Get the rated CPU frequency
| 子模块 | 编程语言 | 声明 | 描述 | | submodule | Programming language | statement | describe |
|---------|------|-------------------------------------------|---------------------------------------------------------------| |---------|------|-------------------------------------------|---------------------------------------------------------------|
| 获取CPU信息 | C | extern const char* kdk_cpu_get_freq_MHz() | 获取CPU额定主频 | | Get CPU information | C | extern const char* kdk_cpu_get_freq_MHz() | Obtain CPU rated main frequency |
| | | 参数说明 | 返回值说明 | | | | | Parameter Description | Return value description | |
| | | 无 | const char* 额定主频赫兹数如“1794.742”单位是MHz返回的是const char*,不要free | | | | none | const char* rated main frequency hertz number, such as "1794.742", the unit is MHz; return const char*, do not free |
获取 CPU 核心数量 Get the number of CPU cores
| 子模块 | 编程语言 | 声明 | 描述 | | submodule | Programming language | statement | describe |
|---------|------|--------------------------------------------|---------------------------| |---------|------|--------------------------------------------|---------------------------|
| 获取CPU信息 | C | extern unsigned int kdk_cpu_get_corenums() | 获取CPU核心数量 | | Get CPU information | C | extern unsigned int kdk_cpu_get_corenums() | Get the number of CPU cores |
| | | 参数说明 | 返回值说明 | | | | | Parameter Description | Return value description | |
| | | 无 | unsigned int 所有可用的CPU核心数量 | | | | none | unsigned int number of all available CPU cores |
获取 CPU 对虚拟化的支持 Get CPU support for virtualization
| 子模块 | 编程语言 | 声明 | 描述 | | submodule | 编程语言 | 声明 | 描述 |
|---------|------|--------------------------------|--------------------------------------------------------------------------| |---------|------|--------------------------------|--------------------------------------------------------------------------|
| 获取CPU信息 | C | const char* kdk_cpu_get_virt() | 获取CPU对虚拟化的支持 | | 获取CPU信息 | C | const char* kdk_cpu_get_virt() | 获取CPU对虚拟化的支持 |
| | | 参数说明 | 返回值说明 | | | | | 参数说明 | 返回值说明 | |