提交 8ffe1e04 编写于 作者: lizhongyi_'s avatar lizhongyi_

Merge branch 'dev' of https://gitcode.net/dcloud/hello-uts into dev

...@@ -67,29 +67,14 @@ ...@@ -67,29 +67,14 @@
}) })
}, },
gotoLottie: function () { gotoLottie: function () {
// if (checkHasLottieIntegration()) { uni.showToast({
// uni.navigateTo({ title:'暂时不支持uni-appx'
// url: '/pages/SDKIntegration/Lottie/index' })
// })
// } else {
// uni.showToast({
// icon: 'none',
// title: '需要在自定义基座中运行'
// })
// }
}, },
gotoTencentLocation: function () { gotoTencentLocation: function () {
// let ret = checkHasIntegration(); uni.showToast({
// if (!ret) { title:'暂时不支持uni-appx'
// uni.showToast({ })
// icon: 'none',
// title: '需要在自定义基座中运行'
// })
// } else {
// uni.navigateTo({
// url: '/pages/SDKIntegration/TencentLocation/TencentLocation'
// })
// }
}, },
gotoTencentMap: function () { gotoTencentMap: function () {
uni.navigateTo({ uni.navigateTo({
......
...@@ -63,9 +63,16 @@ export function privacyStateTest(callback : (ret : boolean, desc : string) => vo ...@@ -63,9 +63,16 @@ export function privacyStateTest(callback : (ret : boolean, desc : string) => vo
* UTSAndroid.getAppTempPath 测试示例 * UTSAndroid.getAppTempPath 测试示例
*/ */
export function getAppTempPathTest() : boolean { export function getAppTempPathTest() : boolean {
console.log(UTSAndroid.getAppTempPath())
// 1.0 的路径
if (UTSAndroid.getAppTempPath()!.contains("data/io.dcloud.HBuilder/apps/HBuilder/temp")) { if (UTSAndroid.getAppTempPath()!.contains("data/io.dcloud.HBuilder/apps/HBuilder/temp")) {
return true return true
} }
// 2.0的路径
if (UTSAndroid.getAppTempPath()!.contains("cache/temp")) {
return true
}
return false return false
} }
...@@ -261,13 +268,24 @@ export function unRegLifecycle() { ...@@ -261,13 +268,24 @@ export function unRegLifecycle() {
*/ */
export function arrayPermissionFlowTest(callback : (ret : boolean, desc : string) => void) { export function arrayPermissionFlowTest(callback : (ret : boolean, desc : string) => void) {
if("io.dcloud.uniappx" != UTSAndroid.getAppContext()?.packageName && "io.dcloud.HBuilder" != UTSAndroid.getAppContext()?.packageName){
/**
* 说明是自定义基座,不支持权限测试
*/
uni.showToast({
title:'自定义基座不支持当前测试'
})
return
}
/** /**
* 同时申请日历和联系人权限 * 同时申请日历和联系人权限
*/ */
let permissionNeed = utsArrayOf("android.permission.READ_CALENDAR", "android.permission.WRITE_CALENDAR", "android.permission.READ_CONTACTS", "android.permission.WRITE_CONTACTS", "android.permission.GET_ACCOUNTS") let permissionNeed = utsArrayOf("android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.ACCESS_FINE_LOCATION", "android.permission.READ_PHONE_STATE")
if (UTSAndroid.getSystemPermissionDenied(UTSAndroid.getUniActivity()!, permissionNeed).isEmpty()) { if (UTSAndroid.getSystemPermissionDenied(UTSAndroid.getUniActivity()!, permissionNeed).isEmpty()) {
callback(false, "已具备 日历/联系人权限") callback(false, "已具备请求权限")
return; return;
} }
...@@ -302,23 +320,23 @@ export function getDeviceInfoTest():string { ...@@ -302,23 +320,23 @@ export function getDeviceInfoTest():string {
let info = '' let info = ''
info += 'isUniMp: '+UTSAndroid.isUniMp() + "\n "; info += 'isUniMp: '+UTSAndroid.isUniMp() + "\n ";
info += 'getAppDarkMode: '+UTSAndroid.getAppDarkMode() + "\n "; info += 'getAppDarkMode: '+UTSAndroid.getAppDarkMode() + "\n ";
info += 'getLanguageInfo: '+UTSAndroid.getLanguageInfo(UTSAndroid.getAppContext()!!) + "\n "; info += 'getLanguageInfo: '+ JSON.stringify(UTSAndroid.getLanguageInfo(UTSAndroid.getAppContext()!!)) + "\n ";
info += 'getWebViewInfo: '+UTSAndroid.getWebViewInfo(UTSAndroid.getAppContext()!!) + "\n "; info += 'getWebViewInfo: '+ JSON.stringify(UTSAndroid.getWebViewInfo(UTSAndroid.getAppContext()!!)) + "\n ";
info += 'getDeviceID: '+UTSAndroid.getDeviceID(UTSAndroid.getAppContext()!!) + "\n "; info += 'getDeviceID: '+UTSAndroid.getDeviceID(UTSAndroid.getAppContext()!!) + "\n ";
info += 'getOAID: '+UTSAndroid.getOAID() + "\n "; info += 'getOAID: '+UTSAndroid.getOAID() + "\n ";
info += 'getInnerVersion: '+UTSAndroid.getInnerVersion() + "\n "; info += 'getInnerVersion: '+UTSAndroid.getInnerVersion() + "\n ";
info += 'getUniCompileVersion: '+UTSAndroid.getUniCompileVersion() + "\n "; info += 'getUniCompileVersion: '+UTSAndroid.getUniCompileVersion() + "\n ";
info += 'getUniRuntimeVersion: '+UTSAndroid.getUniRuntimeVersion() + "\n "; info += 'getUniRuntimeVersion: '+UTSAndroid.getUniRuntimeVersion() + "\n ";
info += 'getAppId: '+UTSAndroid.getAppId() + "\n "; info += 'getAppId: '+UTSAndroid.getAppId() + "\n ";
info += 'getAppVersion: '+UTSAndroid.getAppVersion() + "\n "; info += 'getAppVersion: '+JSON.stringify(UTSAndroid.getAppVersion()) + "\n ";
info += 'getAppName: '+UTSAndroid.getAppName() + "\n "; info += 'getAppName: '+UTSAndroid.getAppName() + "\n ";
info += 'getOsTheme: '+UTSAndroid.getOsTheme() + "\n "; info += 'getOsTheme: '+UTSAndroid.getOsTheme() + "\n ";
info += 'getScreenInfo: '+UTSAndroid.getScreenInfo() + "\n "; info += 'getScreenInfo: '+JSON.stringify(UTSAndroid.getScreenInfo()) + "\n ";
info += 'getStatusBarHeight: '+UTSAndroid.getStatusBarHeight() + "\n "; info += 'getStatusBarHeight: '+UTSAndroid.getStatusBarHeight() + "\n ";
info += 'isTitleNViewShow: '+UTSAndroid.isTitleNViewShow() + "\n "; info += 'isTitleNViewShow: '+UTSAndroid.isTitleNViewShow() + "\n ";
info += 'isTabBarShow: '+UTSAndroid.isTabBarShow() + "\n "; info += 'isTabBarShow: '+UTSAndroid.isTabBarShow() + "\n ";
info += 'getWindowHeight: '+UTSAndroid.getWindowHeight() + "\n "; info += 'getWindowHeight: '+UTSAndroid.getWindowHeight() + "\n ";
info += 'getSafeAreaInsets: '+UTSAndroid.getSafeAreaInsets() + "\n "; info += 'getSafeAreaInsets: '+JSON.stringify(UTSAndroid.getSafeAreaInsets()) + "\n ";
info += 'isUniAppX: '+UTSAndroid.isUniAppX() + "\n "; info += 'isUniAppX: '+UTSAndroid.isUniAppX() + "\n ";
return info return info
...@@ -370,10 +388,18 @@ export function convert2AbsFullPathTest() : boolean { ...@@ -370,10 +388,18 @@ export function convert2AbsFullPathTest() : boolean {
return false; return false;
} }
if("io.dcloud.uniappx" == UTSAndroid.getAppContext()?.packageName || "io.dcloud.HBuilder" == UTSAndroid.getAppContext()?.packageName){
/**
* 只有标准基座,校验这个选项
*/
if (!resourcePath.contains("Android/data/io.dcloud")) { if (!resourcePath.contains("Android/data/io.dcloud")) {
console.log("路径转换结果错误") console.log("路径转换结果错误")
return false; return false;
} }
}
let sdcardPath = UTSAndroid.convert2AbsFullPath(resourcePath) let sdcardPath = UTSAndroid.convert2AbsFullPath(resourcePath)
console.log(sdcardPath) console.log(sdcardPath)
...@@ -393,18 +419,26 @@ export function convert2AbsFullPathTest() : boolean { ...@@ -393,18 +419,26 @@ export function convert2AbsFullPathTest() : boolean {
*/ */
export function singlePermissionFlowTest(callback : (ret : boolean, desc : string) => void) { export function singlePermissionFlowTest(callback : (ret : boolean, desc : string) => void) {
let permissionNeed = utsArrayOf("android.permission.RECORD_AUDIO") if("io.dcloud.uniappx" != UTSAndroid.getAppContext()?.packageName && "io.dcloud.HBuilder" != UTSAndroid.getAppContext()?.packageName){
/**
* 说明是自定义基座,不支持权限测试
*/
uni.showToast({
title:'自定义基座不支持当前测试'
})
return
}
let permissionNeed = utsArrayOf("android.permission.READ_PHONE_STATE")
if (UTSAndroid.getSystemPermissionDenied(UTSAndroid.getUniActivity()!, permissionNeed).isEmpty()) { if (UTSAndroid.getSystemPermissionDenied(UTSAndroid.getUniActivity()!, permissionNeed).isEmpty()) {
callback(false, "预期当前不具备 录音的权限") callback(false, "已具备权限")
return; return;
} }
UTSAndroid.requestSystemPermission(UTSAndroid.getUniActivity()!, permissionNeed, function (allRight : boolean, _grantedList : string[]) { UTSAndroid.requestSystemPermission(UTSAndroid.getUniActivity()!, permissionNeed, function (allRight : boolean, _grantedList : string[]) {
if (allRight) { if (allRight) {
// 交给目前的location 引擎,真实执行
// 测试权限api 返回值 // 测试权限api 返回值
if (!UTSAndroid.getSystemPermissionDenied(UTSAndroid.getUniActivity()!, permissionNeed).isEmpty()) { if (!UTSAndroid.getSystemPermissionDenied(UTSAndroid.getUniActivity()!, permissionNeed).isEmpty()) {
// 预期当前基座具备了读写日历的权限
callback(false, "权限请求完成,getSystemPermissionDenied 失败") callback(false, "权限请求完成,getSystemPermissionDenied 失败")
return; return;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册