VPN publicSDK整改

Signed-off-by: ywx1281445 <yuandongping@huawei.com>
This commit is contained in:
ywx1281445 2024-01-27 18:16:26 +08:00
parent 2943799b3e
commit ecfaa30e54
7 changed files with 38 additions and 24 deletions

View File

@ -125,6 +125,7 @@ Note:If the text contains special characters, please escape them according to th
<filteritem type="filepath" name="code/Solutions/Shopping/OrangeShopping/libs/ohos-video-component-1.0.5.tgz" desc="Provided by media/VideoShow"/>
<filteritem type="filepath" name="code/Solutions/Shopping/OrangeShopping/libs/ohos-notification-1.0.0.tgz" desc="Provided by Notification/CustomEmitter"/>
<filteritem type="filepath" name="code/Solutions/Media/MultiMedia/lib/VideoPlayer.tgz" desc="Provided by code/Solutions/Media/MultiMedia"/>
<filteritem type="filepath" name="code/BasicFeature/Connectivity/VPN/lib/VPNFoundation-1.0.0.tgz" desc="Provided by code/BasicFeature/Connectivity/VPN"/>
<filteritem type="filepath" name="code/DataMock/QuickFix/entry-signed-release.hqf" desc="Provided by code/BasicFeature/TaskManagement/TransientTask"/>
<filteritem type="filepath" name="code/Solutions/Shopping/ASOrangeShopping/data/freeinstall/famanager.hap" desc="Provided by BMS"/>
<filteritem type="filepath" name="code/Solutions/Shopping/ASOrangeShopping/data/freeinstall/launcher.hap" desc="Provided by code/SystemFeature/ApplicationModels/Launcher"/>
@ -163,6 +164,7 @@ Note:If the text contains special characters, please escape them according to th
<filteritem type="filepath" name="code/Project/HapBuild/compile-tool/tool/hap-sign-tool.jar" desc="Provided by code/Project/HapBuild"/>
<filteritem type="filepath" name="code/Project/HapBuild/compile-tool/tool/sign_tool/OpenHarmony.p12" desc="Provided by code/Project/HapBuild"/>
<filteritem type="filepath" name="code/Project/HapBuild/compile-tool/resources/app1-signed.hap" desc="Provided by code/Project/HapBuild"/>
<filteritem type="filepath" name="code/BasicFeature/Connectivity/VPN/lib/VPNFoundation-1.0.0.hap" desc="Provided by code/BasicFeature/Connectivity/VPN"/>
<filteritem type="filepath" name="code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/main/resources/base/media/compass.png" desc="Provided by code/BasicFeature/DeviceManagement/Sensor"/>
<filteritem type="filepath" name=" code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/resources/base/media/select.png" desc="Provided by code/BasicFeature/DeviceManagement/Vibrator"/>
@ -186,6 +188,7 @@ Note:If the text contains special characters, please escape them according to th
<filteritem type="filepath" name="code/Solutions/Shopping/OrangeShopping/libs/ohos-video-component-1.0.5.tgz" desc="二进制文件无需添加License头"/>
<filteritem type="filepath" name="code/Solutions/Shopping/OrangeShopping/libs/ohos-notification-1.0.0.tgz" desc="二进制文件无需添加License头"/>
<filteritem type="filepath" name="code/Solutions/Media/MultiMedia/lib/VideoPlayer.tgz" desc="二进制文件无需添加License头"/>
<filteritem type="filepath" name="code/BasicFeature/Connectivity/VPN/lib/VPNFoundation-1.0.0.tgz" desc="二进制文件无需添加License头"/>
</filefilter>
<filefilter name="copyrightPolicyFilter" desc="Copyright文件头校验策略的过滤条件" >
<filteritem type="filename" name="oh-package.json5" desc="OpenHarmony工程编译入口脚本无需添加版权头"/>
@ -206,6 +209,7 @@ Note:If the text contains special characters, please escape them according to th
<filteritem type="filepath" name="code/Solutions/Shopping/OrangeShopping/libs/ohos-updatedialog-1.0.0.tgz" desc="二进制文件,无需添加版权头"/>
<filteritem type="filepath" name="code/Solutions/Shopping/OrangeShopping/libs/ohos-video-component-1.0.5.tgz" desc="二进制文件,无需添加版权头"/>
<filteritem type="filepath" name="code/Solutions/Media/MultiMedia/lib/VideoPlayer.tgz" desc="二进制文件,无需添加版权头"/>
<filteritem type="filepath" name="code/BasicFeature/Connectivity/VPN/lib/VPNFoundation-1.0.0.tgz" desc="二进制文件,无需添加版权头"/>
</filefilter>
</filefilterlist>
</oatconfig>

View File

@ -9,11 +9,12 @@
| ![main.jpeg](sceenshots%2Fmain.jpeg) | ![start.jpeg](sceenshots%2Fstart.jpeg) | ![stop.jpeg](sceenshots%2Fstop.jpeg) |
使用说明
1. 进入应用后主界面有启用VPN和停用VPN的选项。分别对应开启和关闭VPN功能。
2. 在主界面可以点击启用VPN来创建VPN连接。
3. 在VPN启动界面可以配置VPN服务器IP地址/隧道IP地址/使用VPN的应用程序。
4. 在VPN启动界面点击创建对象可以创建VPN隧道点击隧道保护可以开启隧道保护点击启动VPN可以进行网络连接。
5. 在主界面可以点击停用VPN来断开和关闭VPN连接。
1. 进入应用前请先安装[VPNFoundation](./lib/VPNFoundation-1.0.0.hap)。
2. 进入应用后主界面有启用VPN和停用VPN的选项。分别对应开启和关闭VPN功能。
3. 在主界面可以点击启用VPN来创建VPN连接。
4. 在VPN启动界面可以配置VPN服务器IP地址/隧道IP地址/使用VPN的应用程序。
5. 在VPN启动界面点击创建对象可以创建VPN隧道点击隧道保护可以开启隧道保护点击启动VPN可以进行网络连接。
6. 在主界面可以点击停用VPN来断开和关闭VPN连接。
### 工程目录
@ -58,9 +59,7 @@ entry/src/main/ets/
5.该示例运行测试完成后,再次运行需要重新启动服务端和客户端。
6.本示例需要使用 [@ohos.net.vpn](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-net-vpn.md) 系统权限的系统接口。使用Full SDK时需要手动从镜像站点获取并在DevEcoStudio中替换具体操作可参考 [替换指南](https://docs.openharmony.cn/pages/v3.2/zh-cn/application-dev/quick-start/full-sdk-switch-guide.md/) 。
7.本示例使用了system_basic级别的权限相关权限级别请查看[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/permission-list.md) ),需要手动配置高级别的权限签名(具体操作可查看[自动化签名方案](https://docs.openharmony.cn/pages/v3.2/zh-cn/application-dev/security/hapsigntool-overview.md/) ) 。
6.本示例使用了system_basic级别的权限相关权限级别请查看[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/permission-list.md) ),需要手动配置高级别的权限签名(具体操作可查看[自动化签名方案](https://docs.openharmony.cn/pages/v3.2/zh-cn/application-dev/security/hapsigntool-overview.md/) ) 。
### 下载

View File

@ -21,6 +21,7 @@ import window from '@ohos.window';
export default class EntryAbility extends UIAbility {
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
AppStorage.setOrCreate('context', this.context);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
}

View File

@ -14,8 +14,9 @@
*/
import hilog from '@ohos.hilog';
import router from '@ohos.router';
import { BusinessError } from '@ohos.base';
import common from '@ohos.app.ability.common';
import Want from '@ohos.app.ability.Want';
let g_tunFd = -1;
@ -26,6 +27,24 @@ let g_tunnelFd = -1;
struct Index {
@State message: string = 'Toy VPN';
// 拉起vpn_foundation指定页面
startVPNFoundation(pagePath: string) {
let context: common.UIAbilityContext | undefined = AppStorage.get('context');
let want: Want = {
bundleName: "com.samples.vpn_foundation",
abilityName: "EntryAbility",
parameters: {
page: pagePath
}
};
context && context.startAbility(want, (err: BusinessError) => {
if (err.code) {
hilog.error(0x0000, '[Sample_VPN]', '%{public}s', `Failed to startAbility. Code: ${err.code}, message: ${err.message}`);
}
}
);
}
build() {
Row() {
Column() {
@ -37,21 +56,11 @@ struct Index {
})
Button('Start VPN').onClick(() => {
hilog.info(0x0000, 'developTag', '%{public}s', 'Succeeded in clicking the button.');
router.pushUrl({ url: 'pages/StartVpn' }).then(() => {
hilog.info(0x0000, 'developTag', '%{public}s', 'Succeeded in jumping to the second page.');
}).catch((err: BusinessError) => {
hilog.error(0x0000, 'developTag', 'Failed to jump to the second page: %{public}s',
JSON.stringify(err) ?? '');
})
this.startVPNFoundation('pages/StartVpn');
}).width('70%').fontSize(45).margin(16)
Button('Stop VPN').onClick(() => {
hilog.info(0x0000, 'developTag', '%{public}s', 'Succeeded in clicking the button.');
router.pushUrl({ url: 'pages/StopVpn' }).then(() => {
hilog.info(0x0000, 'developTag', '%{public}s', 'Succeeded in jumping to the second page.');
}).catch((err: BusinessError) => {
hilog.error(0x0000, 'developTag', 'Failed to jump to the second page: %{public}s',
JSON.stringify(err) ?? '');
})
this.startVPNFoundation('pages/StopVpn');
}).width('70%').fontSize(45)
}.width('100%')
}.height('100%')

View File

@ -1,7 +1,5 @@
{
"src": [
"pages/Index",
"pages/StartVpn",
"pages/StopVpn"
"pages/Index"
]
}

Binary file not shown.