提交 24f0ec42 编写于 作者: DCloud-yyl's avatar DCloud-yyl

同步代码@HBuilderX4.21

上级 d38d3d80
......@@ -61,14 +61,16 @@ export interface Uni {
* "android": {
* "osVer": "5.0",
* "uniVer": "3.8.15",
* "uniUtsPlugin": "3.9.0",
* "unixVer": "3.9.0",
* "utsPlugin": "3.9.0"
* "unixUtsPlugin": "3.9.0"
* },
* "ios": {
* "osVer": "x",
* "uniVer": "x",
* "uniUtsPlugin": "x",
* "unixVer": "x",
* "utsPlugin": "x"
* "unixUtsPlugin": "x"
* }
* },
* "web": {
......
......@@ -37,7 +37,7 @@
"getFileSystemManager": {
"name": "getFileSystemManager",
"app": {
"js": false,
"js": true,
"kotlin": true,
"swift": false
}
......
import File from 'java.io.File'
import ParcelFileDescriptor from 'android.os.ParcelFileDescriptor'
import { OpenFileOptions, OpenFileSuccessResult, OpenFileSyncOptions } from '../interface';
import { UniErrorSubject, UniErrors } from '../unierror';
import { UniErrorSubject,FileSystemManagerFailImpl,FileSystemManagerUniErrors } from '../unierror';
export class FileDescriptorUtil {
public openMap : Map<string, File> = new Map()
......@@ -28,12 +28,12 @@ export class FileDescriptorUtil {
case 'ax': //类似于 'a',但如果路径存在,则失败
{
if (file.exists()) {
let err = new UniError(UniErrorSubject, 1301005, UniErrors.get(1301005)!);
let err = new FileSystemManagerFailImpl(1301005);
options.fail?.(err)
options.complete?.(err)
} else {
if (file.parentFile?.exists() == false) {
let err = new UniError(UniErrorSubject, 1300002, UniErrors.get(1300002)!);
let err = new FileSystemManagerFailImpl(1300002);
options.fail?.(err)
options.complete?.(err)
return
......@@ -66,7 +66,7 @@ export class FileDescriptorUtil {
case 'ax+': //类似于 'a+',但如果路径存在,则失败
{
if (file.exists()) {
let err = new UniError(UniErrorSubject, 1301005, UniErrors.get(1301005)!);
let err = new FileSystemManagerFailImpl(1301005);
options.fail?.(err)
options.complete?.(err)
} else {
......@@ -84,7 +84,7 @@ export class FileDescriptorUtil {
case 'r': //打开文件用于读取。 如果文件不存在,则会发生异常
{
if (!file.exists()) {
let err = new UniError(UniErrorSubject, 1300002, UniErrors.get(1300002)!);
let err = new FileSystemManagerFailImpl(1300002);
options.fail?.(err)
options.complete?.(err)
} else {
......@@ -104,7 +104,7 @@ export class FileDescriptorUtil {
case 'r+': //打开文件用于读取和写入。 如果文件不存在,则会发生异常
{
if (!file.exists()) {
let err = new UniError(UniErrorSubject, 1300002, UniErrors.get(1300002)!);
let err = new FileSystemManagerFailImpl(1300002);
options.fail?.(err)
options.complete?.(err)
} else {
......@@ -136,7 +136,7 @@ export class FileDescriptorUtil {
case 'wx'://类似于 'w',但如果路径存在,则失败
{
if (file.exists()) {
let err = new UniError(UniErrorSubject, 1301005, UniErrors.get(1301005)!);
let err = new FileSystemManagerFailImpl(1301005);
options.fail?.(err)
options.complete?.(err)
} else {
......@@ -168,7 +168,7 @@ export class FileDescriptorUtil {
case 'wx+': // 类似于 'w+',但如果路径存在,则失败
{
if (file.exists()) {
let err = new UniError(UniErrorSubject, 1301005, UniErrors.get(1301005)!);
let err = new FileSystemManagerFailImpl(1301005);
options.fail?.(err)
options.complete?.(err)
} else {
......@@ -187,7 +187,7 @@ export class FileDescriptorUtil {
}
}
} catch (e) {
let err = new UniError(UniErrorSubject, 1300201, UniErrors.get(1300201)! + ":" + e + " " + options.filePath);
let err = new FileSystemManagerFailImpl(1300201);
options.fail?.(err)
options.complete?.(err)
}
......@@ -206,10 +206,10 @@ export class FileDescriptorUtil {
case 'ax': //类似于 'a',但如果路径存在,则失败
{
if (file.exists()) {
throw new Error(`${msgPrefix}${UniErrors[1301005]}`)
throw new Error(`${msgPrefix}${FileSystemManagerUniErrors[1301005]}`)
} else {
if (file.parentFile?.exists() == false) {
throw new Error(`${msgPrefix}${UniErrors[1300002]}`)
throw new Error(`${msgPrefix}${FileSystemManagerUniErrors[1300002]}`)
} else {
file.createNewFile()
let fd = this.open_a(file)
......@@ -228,7 +228,7 @@ export class FileDescriptorUtil {
case 'ax+': //类似于 'a+',但如果路径存在,则失败
{
if (file.exists()) {
throw new Error(`${msgPrefix}${UniErrors[1301005]}`)
throw new Error(`${msgPrefix}${FileSystemManagerUniErrors[1301005]}`)
} else {
let fd = this.open_ax(file)
this.openMap.set(fd, file)
......@@ -238,7 +238,7 @@ export class FileDescriptorUtil {
case 'r': //打开文件用于读取。 如果文件不存在,则会发生异常
{
if (!file.exists()) {
throw new Error(`${msgPrefix}${UniErrors[1300002]}`)
throw new Error(`${msgPrefix}${FileSystemManagerUniErrors[1300002]}`)
} else {
let mode = ParcelFileDescriptor.MODE_READ_ONLY
let pfd = ParcelFileDescriptor.open(file, mode);
......@@ -251,7 +251,7 @@ export class FileDescriptorUtil {
case 'r+': //打开文件用于读取和写入。 如果文件不存在,则会发生异常
{
if (!file.exists()) {
throw new Error(`${msgPrefix}${UniErrors[1300002]}`)
throw new Error(`${msgPrefix}${FileSystemManagerUniErrors[1300002]}`)
} else {
let mode = ParcelFileDescriptor.MODE_READ_WRITE
let pfd = ParcelFileDescriptor.open(file, mode);
......@@ -270,7 +270,7 @@ export class FileDescriptorUtil {
case 'wx'://类似于 'w',但如果路径存在,则失败
{
if (file.exists()) {
throw new Error(`${msgPrefix}${UniErrors[1301005]}`)
throw new Error(`${msgPrefix}${FileSystemManagerUniErrors[1301005]}`)
} else {
let fd = this.open_w(file)
this.openMap.set(fd, file)
......@@ -289,7 +289,7 @@ export class FileDescriptorUtil {
case 'wx+': // 类似于 'w+',但如果路径存在,则失败
{
if (file.exists()) {
throw new Error(`${msgPrefix}${UniErrors[1301005]}`)
throw new Error(`${msgPrefix}${FileSystemManagerUniErrors[1301005]}`)
} else {
let mode = ParcelFileDescriptor.MODE_CREATE | ParcelFileDescriptor.MODE_READ_WRITE | ParcelFileDescriptor.MODE_TRUNCATE
let pfd = ParcelFileDescriptor.open(file, mode);
......
import { WriteFileOptions, ReadFileOptions, MkDirOptions, RmDirOptions, UnLinkOptions, ReadDirOptions, AccessOptions, RenameOptions, GetFileInfoOptions, CopyFileOptions, StatOptions } from "../interface.uts"
import { ReadFileSuccessResult, FileManagerSuccessResult, ReadDirSuccessResult, GetFileInfoSuccessResult, StatSuccessResult, FileStats, Stats } from "../interface.uts"
import { GetFileSystemManager, FileSystemManager } from "../interface.uts"
import { UniErrorSubject, UniErrors } from "../unierror.uts"
export { Stats,FileStats } from '../interface.uts'
import { FileSystemManagerFailImpl, FileSystemManagerUniErrorSubject, FileSystemManagerUniErrors } from "../unierror.uts"
class InnerStats implements Stats {
/**
......@@ -93,7 +92,7 @@ class JsFileSystemManager implements FileSystemManager {
options.complete?.(ret)
},
function (code) {
let err = new UniError(UniErrorSubject, code, UniErrors.get(code)! + ":" + options.path);
let err = new FileSystemManagerFailImpl(code)
options.fail?.(err)
options.complete?.(err)
})
......@@ -103,7 +102,7 @@ class JsFileSystemManager implements FileSystemManager {
if(options.digestAlgorithm == null || options.digestAlgorithm == undefined){
options.digestAlgorithm = "md5"
} else if (options.digestAlgorithm!.toLowerCase() != 'md5' && options.digestAlgorithm!.toLowerCase() != 'sha1') {
let err = new UniError(UniErrorSubject, 1300022, UniErrors.get(1300022)! + ":invalid digestAlgorithm " + options.digestAlgorithm);
let err = new FileSystemManagerFailImpl(1300022);
options.fail?.(err)
options.complete?.(err)
return
......@@ -117,7 +116,7 @@ class JsFileSystemManager implements FileSystemManager {
options.complete?.(ret)
},
function (code) {
let err = new UniError(UniErrorSubject, code, UniErrors.get(code)! + ":" + options.filePath);
let err = new FileSystemManagerFailImpl(code);
options.fail?.(err)
options.complete?.(err)
})
......@@ -136,7 +135,7 @@ class JsFileSystemManager implements FileSystemManager {
options.complete?.(ret)
},
function (code) {
let err = new UniError(UniErrorSubject, code, UniErrors.get(code)!);
let err = new FileSystemManagerFailImpl(code);
options.fail?.(err)
options.complete?.(err)
})
......@@ -155,7 +154,7 @@ class JsFileSystemManager implements FileSystemManager {
options.complete?.(ret)
},
function (code) {
let err = new UniError(UniErrorSubject, code, UniErrors.get(code)!);
let err = new FileSystemManagerFailImpl(code);
options.fail?.(err)
options.complete?.(err)
})
......@@ -173,7 +172,7 @@ class JsFileSystemManager implements FileSystemManager {
options.complete?.(ret)
},
function (code) {
let err = new UniError(UniErrorSubject, code, UniErrors.get(code)! + ":" + options.path);
let err = new FileSystemManagerFailImpl(code);
options.fail?.(err)
options.complete?.(err)
})
......@@ -191,7 +190,7 @@ class JsFileSystemManager implements FileSystemManager {
options.complete?.(ret)
},
function (code) {
let err = new UniError(UniErrorSubject, code, UniErrors.get(code)! + ":" + options.dirPath);
let err = new FileSystemManagerFailImpl(code);
options.fail?.(err)
options.complete?.(err)
})
......@@ -214,7 +213,7 @@ class JsFileSystemManager implements FileSystemManager {
options.complete?.(ret)
},
function (code) {
let err = new UniError(UniErrorSubject, code, UniErrors.get(code)! + ":" + options.dirPath);
let err = new FileSystemManagerFailImpl(code);
options.fail?.(err)
options.complete?.(err)
})
......@@ -229,7 +228,7 @@ class JsFileSystemManager implements FileSystemManager {
options.complete?.(ret)
},
function (code) {
let err = new UniError(UniErrorSubject, code, UniErrors.get(code)! + ":" + options.dirPath);
let err = new FileSystemManagerFailImpl(code);
options.fail?.(err)
options.complete?.(err)
})
......@@ -248,7 +247,7 @@ class JsFileSystemManager implements FileSystemManager {
options.complete?.(ret)
},
function (code) {
let err = new UniError(UniErrorSubject, code, UniErrors.get(code)! + ":" + options.filePath);
let err = new FileSystemManagerFailImpl(code);
options.fail?.(err)
options.complete?.(err)
})
......@@ -266,7 +265,7 @@ class JsFileSystemManager implements FileSystemManager {
options.complete?.(ret)
},
function (code) {
let err = new UniError(UniErrorSubject, code, UniErrors.get(code)! + ":" + options.filePath);
let err = new FileSystemManagerFailImpl(code);
options.fail?.(err)
options.complete?.(err)
})
......@@ -286,7 +285,7 @@ class JsFileSystemManager implements FileSystemManager {
options.complete?.(ret)
},
function (code) {
let err = new UniError(UniErrorSubject, code, UniErrors.get(code)! + ":" + options.filePath);
let err = new FileSystemManagerFailImpl(code);
options.fail?.(err)
options.complete?.(err)
})
......
......@@ -21,7 +21,7 @@ export type FileManagerSuccessCallback = (res : FileManagerSuccessResult) => voi
/**
* 通用的错误返回结果回调
*/
export type FileManagerFailCallback = (res : UniError) => void
export type FileManagerFailCallback = (res : FileSystemManagerFail) => void
/**
* 通用的结束返回结果回调
*/
......@@ -39,7 +39,7 @@ export type ReadFileOptions = {
*/
encoding : "base64" | "utf-8",
/**
* 文件路径,支持相对地址和绝对地址
* 文件路径,支持相对地址和绝对地址,app-android平台支持代码包文件目录
*/
filePath : string.URIString,
/**
......@@ -553,7 +553,7 @@ export type ReadCompressedFileResult = {
export type ReadCompressedFileCallback = (res : ReadCompressedFileResult) => void
export type ReadCompressedFileOptions = {
/**
* 要读取的文件的路径 (本地用户文件或代码包文件)
* 要读取的文件的路径 (本地用户文件或代码包文件),app-android平台支持代码包文件目录
*/
filePath : string.URIString,
/**
......@@ -779,7 +779,7 @@ export type ZipFileItem = {
export type ReadZipEntryCallback = (res : EntriesResult) => void
export type ReadZipEntryOptions = {
/**
* 要读取的压缩包的路径 (本地路径)
* 要读取的压缩包的路径 (本地路径),app-android平台支持代码包文件目录
*/
filePath : string.URIString,
/**
......@@ -829,6 +829,8 @@ export interface FileSystemManager {
readFile(options : ReadFileOptions) : void;
/**
* FileSystemManager.readFile 的同步版本参数
* @param filePath 文件路径,支持相对地址和绝对地址,app-android平台支持代码包文件目录
* @param encoding base64 / utf-8
* @uniPlatform {
* "app": {
* "android": {
......@@ -873,6 +875,9 @@ export interface FileSystemManager {
writeFile(options : WriteFileOptions) : void;
/**
* FileSystemManager.writeFile 的同步版本
* @param filePath 文件路径,只支持绝对地址
* @param data 写入的文本内容
* @param encoding 指定写入文件的字符编码,支持:ascii base64 utf-8
* @uniPlatform {
* "app": {
* "android": {
......@@ -917,6 +922,7 @@ export interface FileSystemManager {
unlink(options : UnLinkOptions) : void;
/**
* FileSystemManager.unlink 的同步版本
* @param filePath 文件路径,只支持绝对地址
* @uniPlatform {
* "app": {
* "android": {
......@@ -961,6 +967,8 @@ export interface FileSystemManager {
mkdir(options : MkDirOptions) : void;
/**
* FileSystemManager.mkdir 的同步版本
* @param dirPath 创建的目录路径 (本地路径)
* @param recursive 是否在递归创建该目录的上级目录后再创建该目录。如果对应的上级目录已经存在,则不创建该上级目录。如 dirPath 为 a/b/c/d 且 recursive 为 true,将创建 a 目录,再在 a 目录下创建 b 目录,以此类推直至创建 a/b/c 目录下的 d 目录。
* @uniPlatform {
* "app": {
* "android": {
......@@ -1005,6 +1013,8 @@ export interface FileSystemManager {
rmdir(options : RmDirOptions) : void;
/**
* FileSystemManager.rmdir 的同步版本
* @param dirPath 要删除的目录路径 (本地路径)
* @param recursive 是否递归删除目录。如果为 true,则删除该目录和该目录下的所有子目录以及文件。
* @uniPlatform {
* "app": {
* "android": {
......@@ -1049,6 +1059,7 @@ export interface FileSystemManager {
readdir(options : ReadDirOptions) : void;
/**
* FileSystemManager.readdir 的同步版本
* @param dirPath 要读取的目录路径 (本地路径)
* @uniPlatform {
* "app": {
* "android": {
......@@ -1093,6 +1104,7 @@ export interface FileSystemManager {
access(options : AccessOptions) : void;
/**
* FileSystemManager.access 的同步版本
* @param path 要删除的目录路径 (本地路径)
* @uniPlatform {
* "app": {
* "android": {
......@@ -1137,6 +1149,8 @@ export interface FileSystemManager {
rename(options : RenameOptions) : void;
/**
* FileSystemManager.rename 的同步版本
* @param oldPath 源文件路径,支持本地路径
* @param newPath 新文件路径,支持本地路径
* @uniPlatform {
* "app": {
* "android": {
......@@ -1181,6 +1195,8 @@ export interface FileSystemManager {
copyFile(options : CopyFileOptions) : void;
/**
* FileSystemManager.copyFile 的同步版本
* @param srcPath 源文件路径,支持本地路径
* @param destPath 新文件路径,支持本地路径
* @uniPlatform {
* "app": {
* "android": {
......@@ -1247,6 +1263,8 @@ export interface FileSystemManager {
stat(options : StatOptions) : void;
/**
* FileSystemManager.stat 的同步版本
* @param path 文件/目录路径 (本地路径)
* @param recursive 是否递归获取目录下的每个文件的 Stats 信息
* @uniPlatform {
* "app": {
* "android": {
......@@ -1291,6 +1309,9 @@ export interface FileSystemManager {
appendFile(options : AppendFileOptions) : void;
/**
* FileSystemManager.appendFile 的同步版本
* @param filePath 要追加内容的文件路径 (本地路径)
* @param data 要追加的文本
* @param encoding 指定写入文件的字符编码支持:ascii base64 utf-8
* @uniPlatform {
* "app": {
* "android": {
......@@ -1335,6 +1356,8 @@ export interface FileSystemManager {
saveFile(options : SaveFileOptions) : void;
/**
* FileSystemManager.saveFile 的同步版本
* @param tempFilePath 临时存储文件路径 (本地路径)
* @param filePath 要存储的文件路径 (本地路径)
* @uniPlatform {
* "app": {
* "android": {
......@@ -1445,6 +1468,8 @@ export interface FileSystemManager {
truncate(options : TruncateFileOptions) : void;
/**
* 对文件内容进行截断操作 (truncate 的同步版本)
* @param filePath 要截断的文件路径 (本地路径)
* @param length 截断位置,默认0。如果 length 小于文件长度(字节),则只有前面 length 个字节会保留在文件中,其余内容会被删除;如果 length 大于文件长度,不做处理
* @uniPlatform {
* "app": {
* "android": {
......@@ -1489,6 +1514,8 @@ export interface FileSystemManager {
readCompressedFile(options : ReadCompressedFileOptions) : void;
/**
* 同步读取指定压缩类型的本地文件内容
* @param filePath 要读取的文件的路径 (本地用户文件或代码包文件),app-android平台支持代码包文件目录
* @param compressionAlgorithm 文件压缩类型,目前仅支持 'br'。
* @uniPlatform {
* "app": {
* "android": {
......@@ -1618,7 +1645,7 @@ export interface FileSystemManager {
* }
* }
*/
close(options : CloseOptions);
close(options : CloseOptions) : void;
/**
* 同步关闭文件
* @uniPlatform {
......@@ -1781,4 +1808,26 @@ export interface Uni {
* @uniVueVersion 2,3 //支持的vue版本
*/
getFileSystemManager() : FileSystemManager
}
\ No newline at end of file
}
/**
* 错误码
* - 1200002 类型错误。仅支持 base64 / utf-8
* - 1300002 未找到文件
* - 1300013 无权限
* - 1300021 是目录
* - 1300022 参数无效
* - 1300066 目录非空
* - 1301003 对目录的非法操作
* - 1301005 文件已存在
* - 1300201 系统错误
* - 1300202 超出文件存储限制的最大尺寸
* - 1301111 brotli解压失败
* - 1302003 标志无效
* - 1300009 文件描述符错误
*/
export type FileSystemManagerErrorCode = 1200002 | 1300002 | 1300013 | 1300021 | 1300022 | 1300066 | 1301003 | 1301005 | 1300201 | 1300202 | 1301111 | 1302003 | 1300009;
export type FileSystemManagerFail = IFileSystemManagerFail;
export interface IFileSystemManagerFail extends IUniError {
errCode : FileSystemManagerErrorCode
};
import { FileSystemManagerErrorCode,IFileSystemManagerFail } from "./interface.uts"
/**
* 错误主题
*/
export const UniErrorSubject = 'uni-fileSystemManager';
export const FileSystemManagerUniErrorSubject = 'uni-fileSystemManager';
/**
* 错误码
* @UniError
*/
export const UniErrors : Map<number, string> = new Map([
export const FileSystemManagerUniErrors : Map<FileSystemManagerErrorCode, string> = new Map([
[1200002, 'type error. only support base64 / utf-8'],
[1300002, 'no such file or directory'],
......@@ -22,4 +24,12 @@ export const UniErrors : Map<number, string> = new Map([
[1301111, 'brotli decompress fail'],
[1302003, 'invalid flag'],
[1300009, 'bad file descriptor']
]);
\ No newline at end of file
]);
export class FileSystemManagerFailImpl extends UniError implements IFileSystemManagerFail {
constructor(errCode : FileSystemManagerErrorCode) {
super();
this.errSubject = FileSystemManagerUniErrorSubject;
this.errCode = errCode;
this.errMsg = FileSystemManagerUniErrors.get(errCode) ?? "";
}
}
\ No newline at end of file
......@@ -41,7 +41,8 @@ export type GetAppAuthorizeSettingResult = {
* - authorized: 已经获得授权,无需再次请求授权
* - denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限)
* - not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关)
* @type 'authorized' | 'denied' | 'not determined'
* - config error: 当前应用没有配置相册权限描述
* @type 'authorized' | 'denied' | 'not determined' | 'config error'
* @uniPlatform
* {
* "app": {
......@@ -58,13 +59,13 @@ export type GetAppAuthorizeSettingResult = {
* }
* }
*/
albumAuthorized?: 'authorized' | 'denied' | 'not determined' | null,
albumAuthorized?: 'authorized' | 'denied' | 'not determined' | 'config error' | null,
/**
* 允许 App 使用蓝牙的开关(仅 iOS 支持)
* - authorized: 已经获得授权,无需再次请求授权
* - denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限)
* - not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关)
* - config error: Android平台没有该值;iOS平台:表示没有在 `manifest.json -> App模块配置` 中配置 `BlueTooth(低功耗蓝牙)` 模块
* - config error: Android平台没有该值;iOS平台:当前应用没有配置蓝牙权限描述
* @type 'authorized' | 'denied' | 'not determined' | 'config error'
* @uniPlatform
* {
......@@ -88,7 +89,7 @@ export type GetAppAuthorizeSettingResult = {
* - authorized: 已经获得授权,无需再次请求授权
* - denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限)
* - not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关)
* - config error: Android平台:表示没有配置 `android.permission.CAMERA` 权限,[权限配置详情](https://uniapp.dcloud.net.cn/tutorial/app-nativeresource-android.html#permissions);iOS平台没有该值
* - config error: Android平台:表示没有配置 `android.permission.CAMERA` 权限,[权限配置详情](https://uniapp.dcloud.net.cn/tutorial/app-nativeresource-android.html#permissions);iOS平台:当前应用没有配置相机权限描述
* @type 'authorized' | 'denied' | 'not determined' | 'config error'
* @uniPlatform
* {
......@@ -112,7 +113,7 @@ export type GetAppAuthorizeSettingResult = {
* - authorized: 已经获得授权,无需再次请求授权
* - denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限)
* - not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关)
* - config error: Android平台:表示没有配置 `android.permission.ACCESS_COARSE_LOCATION` 权限,[权限配置详情](https://uniapp.dcloud.net.cn/tutorial/app-nativeresource-android.html#permissions);iOS平台:表示没有在 `manifest.json -> App模块配置` 中配置 `Geolocation(定位)` 模块
* - config error: Android平台:表示没有配置 `android.permission.ACCESS_COARSE_LOCATION` 权限,[权限配置详情](https://uniapp.dcloud.net.cn/tutorial/app-nativeresource-android.html#permissions);iOS平台:当前应用没有配置定位权限描述
* @type 'authorized' | 'denied' | 'not determined' | 'config error'
* @uniPlatform
* {
......@@ -135,7 +136,7 @@ export type GetAppAuthorizeSettingResult = {
* 定位准确度。
* - reduced: 模糊定位
* - full: 精准定位
* - unsupported: 不支持(包括用户拒绝定位权限和没有在 `manifest.json -> App模块配置` 中配置 `Geolocation(定位)` 模块
* - unsupported: 不支持(包括用户拒绝定位权限和没有包含定位权限描述
* @type 'reduced' | 'full' | 'unsupported'
* @uniPlatform
* {
......@@ -179,7 +180,7 @@ export type GetAppAuthorizeSettingResult = {
* - authorized: 已经获得授权,无需再次请求授权
* - denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限)
* - not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关)
* - config error: Android平台:表示没有配置 `android.permission.RECORD_AUDIO` 权限,[权限配置详情](https://uniapp.dcloud.net.cn/tutorial/app-nativeresource-android.html#permissions);iOS平台没有该值
* - config error: Android平台:表示没有配置 `android.permission.RECORD_AUDIO` 权限,[权限配置详情](https://uniapp.dcloud.net.cn/tutorial/app-nativeresource-android.html#permissions);iOS平台:当前应用没有配置麦克风权限描述
* @type 'authorized' | 'denied' | 'not determined' | 'config error'
* @uniPlatform
* {
......@@ -203,7 +204,7 @@ export type GetAppAuthorizeSettingResult = {
* - authorized: 已经获得授权,无需再次请求授权
* - denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限)
* - not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关)
* - config error: Android平台没有该值;iOS平台:表示没有在 `manifest.json -> App模块配置` 中配置 `Push(推送)` 模块
* - config error: Android平台没有该值;iOS平台:没有包含推送权限描述
* @type 'authorized' | 'denied' | 'not determined' | 'config error'
* @uniPlatform
* {
......@@ -227,7 +228,7 @@ export type GetAppAuthorizeSettingResult = {
* - authorized: 已经获得授权,无需再次请求授权
* - denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限)
* - not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关)
* - config error: 没有在 `manifest.json -> App模块配置` 中配置 `Push(推送)` 模块
* - config error: 当前应用没有配置推送权限描述
* @type 'authorized' | 'denied' | 'not determined' | 'config error'
* @uniPlatform
* {
......@@ -251,7 +252,7 @@ export type GetAppAuthorizeSettingResult = {
* - authorized: 已经获得授权,无需再次请求授权
* - denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限)
* - not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关)
* - config error: 没有在 `manifest.json -> App模块配置` 中配置 `Push(推送)` 模块
* - config error: 当前应用没有配置推送权限描述
* @type 'authorized' | 'denied' | 'not determined' | 'config error'
* @uniPlatform
* {
......@@ -275,7 +276,7 @@ export type GetAppAuthorizeSettingResult = {
* - authorized: 已经获得授权,无需再次请求授权
* - denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限)
* - not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关)
* - config error: 没有在 `manifest.json -> App模块配置` 中配置 `Push(推送)` 模块
* - config error: 当前应用没有配置推送权限描述
* @type 'authorized' | 'denied' | 'not determined' | 'config error'
* @uniPlatform
* {
......
......@@ -39,7 +39,8 @@ export const getAppBaseInfo : GetAppBaseInfo = (config : GetAppBaseInfoOptions |
"uniCompilerVersionCode",
"uniRuntimeVersionCode",
"packageName",
"signature"
"signature",
"appTheme",
];
filter = defaultFilter;
}
......@@ -134,6 +135,10 @@ function getBaseInfo(filterArray : Array<string>) : GetAppBaseInfoResult {
if (filterArray.indexOf("signature") != -1) {
result.signature = AppBaseInfoDeviceUtil.getAppSignatureSHA1(activity);
}
if (filterArray.indexOf("appTheme") != -1) {
result.appTheme = UTSAndroid.getAppTheme();
}
return result;
......
......@@ -35,7 +35,8 @@ export const getAppBaseInfo : GetAppBaseInfo = (config : GetAppBaseInfoOptions |
"uniPlatform",
"uniRuntimeVersion",
"uniCompilerVersionCode",
"uniRuntimeVersionCode"
"uniRuntimeVersionCode",
"appTheme",
];
filter = defaultFilter;
}
......@@ -115,6 +116,10 @@ function getBaseInfo(filterArray : Array<string>) : GetAppBaseInfoResult {
if (filterArray.indexOf("uniRuntimeVersionCode") != -1) {
result.uniRuntimeVersionCode = AppBaseInfoConvertVersionCode(UTSiOS.getRuntimeVersion());
}
if (filterArray.indexOf("appTheme") != -1) {
result.appTheme = UTSiOS.getAppTheme();
}
return result;
......
......@@ -22,7 +22,11 @@ export type GetAppBaseInfoResult = {
* "uniVer": "√",
* "unixVer": "4.11"
* }
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* }
*/
appId?: string,
......@@ -42,7 +46,11 @@ export type GetAppBaseInfoResult = {
* "uniVer": "√",
* "unixVer": "4.11"
* }
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* }
*/
appName?: string,
......@@ -62,7 +70,11 @@ export type GetAppBaseInfoResult = {
* "uniVer": "√",
* "unixVer": "4.11"
* }
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* }
*/
appVersion?: string,
......@@ -82,7 +94,11 @@ export type GetAppBaseInfoResult = {
* "uniVer": "√",
* "unixVer": "4.11"
* }
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* }
*/
appVersionCode?: string,
......@@ -102,7 +118,11 @@ export type GetAppBaseInfoResult = {
* "uniVer": "√",
* "unixVer": "4.11"
* }
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* }
*/
appLanguage?: string,
......@@ -122,7 +142,11 @@ export type GetAppBaseInfoResult = {
* "uniVer": "√",
* "unixVer": "4.11"
* }
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* }
*/
language?: string,
......@@ -143,7 +167,11 @@ export type GetAppBaseInfoResult = {
* "uniVer": "√",
* "unixVer": "4.11"
* }
* }
* },
* "web": {
* "uniVer": "x",
* "unixVer": "x"
* }
* }
*/
version?: string,
......@@ -331,7 +359,11 @@ export type GetAppBaseInfoResult = {
* "uniVer": "√",
* "unixVer": "4.11"
* }
* }
* },
* "web": {
* "uniVer": "x",
* "unixVer": "4.18"
* }
* }
*/
isUniAppX ?: boolean,
......@@ -353,7 +385,11 @@ export type GetAppBaseInfoResult = {
* "uniVer": "√",
* "unixVer": "4.11"
* }
* }
* },
* "web": {
* "uniVer": "x",
* "unixVer": "x"
* }
* }
*/
uniCompileVersion ?: string,
......@@ -375,8 +411,8 @@ export type GetAppBaseInfoResult = {
* }
* },
* "web": {
* "uniVer": "",
* "unixVer": "4.0"
* "uniVer": "x",
* "unixVer": "4.18"
* }
* }
*/
......@@ -397,7 +433,11 @@ export type GetAppBaseInfoResult = {
* "uniVer": "√",
* "unixVer": "4.11"
* }
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* }
*/
uniPlatform ?: 'app' | 'web' | 'mp-weixin' | 'mp-alipay' | 'mp-baidu' | 'mp-toutiao' | 'mp-lark' | 'mp-qq' | 'mp-kuaishou' | 'mp-jd' | 'mp-360' | 'quickapp-webview' | 'quickapp-webview-union' | 'quickapp-webview-huawei',
......@@ -417,7 +457,11 @@ export type GetAppBaseInfoResult = {
* "uniVer": "√",
* "unixVer": "4.11"
* }
* }
* },
* "web": {
* "uniVer": "x",
* "unixVer": "4.18"
* }
* }
*/
uniRuntimeVersion ?: string,
......@@ -438,7 +482,11 @@ export type GetAppBaseInfoResult = {
* "uniVer": "√",
* "unixVer": "4.11"
* }
* }
* },
* "web": {
* "uniVer": "x",
* "unixVer": "x"
* }
* }
*/
uniCompileVersionCode?: number,
......@@ -460,8 +508,8 @@ export type GetAppBaseInfoResult = {
* }
* },
* "web": {
* "uniVer": "",
* "unixVer": "4.0"
* "uniVer": "x",
* "unixVer": "4.18"
* }
* }
*/
......@@ -482,7 +530,11 @@ export type GetAppBaseInfoResult = {
* "uniVer": "√",
* "unixVer": "4.11"
* }
* }
* },
* "web": {
* "uniVer": "x",
* "unixVer": "x"
* }
* }
*/
uniRuntimeVersionCode?: number,
......@@ -559,6 +611,30 @@ export type GetAppBaseInfoResult = {
* }
*/
signature?: string,
/**
* 当前App的主题
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "x",
* "unixVer": "4.18"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "x",
* "unixVer": "4.18"
* }
* },
* "web": {
* "uniVer": "x",
* "unixVer": "x"
* }
* }
*/
appTheme?: 'light' | 'dark' | 'auto' | null,
}
/**
......@@ -589,10 +665,10 @@ export interface Uni {
* "unixVer": "4.11"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* }
* @example
```typescript
......
......@@ -215,6 +215,15 @@ export class DeviceUtil {
public static getOaid(): string {
return UTSAndroid.getOAID();
}
public static getRomName():string{
DeviceUtil.setCustomInfo(Build.MANUFACTURER);
return DeviceUtil.customOS ?? "";
}
public static getRomVersion():string{
DeviceUtil.setCustomInfo(Build.MANUFACTURER);
return DeviceUtil.customOSVersion ?? "";
}
/**
......
......@@ -89,12 +89,7 @@ function getBaseInfo(filterArray : Array<string>) : GetDeviceInfoResult {
result.osLanguage = UTSiOS.getOsLanguage();
}
if (filterArray.indexOf("osTheme") != -1) {
let osTheme = 'light'
if(UTSiOS.available("iOS 13, *")){
let currentTraitCollection = UIApplication.shared.keyWindow?.traitCollection
osTheme = currentTraitCollection?.userInterfaceStyle == UIUserInterfaceStyle.dark ? "dark" : "light"
}
result.osTheme = osTheme;
result.osTheme = UTSiOS.getOsTheme();
}
if (filterArray.indexOf("romName") != -1) {
result.romName = "ios"
......
export type GetDeviceInfoOptions = {
/**
* @description 过滤字段的字符串数组,假如要获取指定字段,传入此数组。
*/
filter: Array<string>
}
export type GetDeviceInfoResult = {
/**
* 设备品牌
* @deprecated 已废弃,仅为了向下兼容保留
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "3.9+"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.11"
* }
* }
* }
*/
brand?: string
/**
* 设备品牌
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "3.9+"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.11"
* }
* }
* }
*/
deviceBrand?: string,
/**
* 设备 id 。由 uni-app 框架生成并存储,清空 Storage 会导致改变
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "3.9+"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.11"
* }
* }
* }
*/
deviceId?: string,
/**
* 设备型号
* @deprecated 已废弃,仅为了向下兼容保留
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "3.9+"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.11"
* }
* }
* }
*/
model?: string,
/**
* 设备型号
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "3.9+"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.11"
* }
* }
* }
*/
deviceModel?: string,
/**
* 设备类型phone、pad、pc
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "3.9+"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.11"
* }
* }
* }
*/
deviceType?: string,
/**
* 设备方向 竖屏 portrait、横屏 landscape
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "3.9+"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.11"
* }
* }
* }
*/
deviceOrientation?: string,
/**
* 设备像素比
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "3.9+"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.11"
* }
* }
* }
*/
devicePixelRatio?: string,
/**
* 操作系统及版本
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "3.9+"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.11"
* }
* }
* }
*/
system?: string,
/**
* 客户端平台
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "3.9+"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.11"
* }
* }
* }
*/
platform?: string,
/**
* 是否root
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "x",
* "unixVer": "3.9+"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "x",
* "unixVer": "4.11"
* }
* }
* }
*/
isRoot?: boolean,
/**
* 是否是模拟器
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "x",
* "unixVer": "3.9+"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "x",
* "unixVer": "4.11"
* }
* }
* }
*/
isSimulator?: boolean,
/**
* adb是否开启
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "x",
* "unixVer": "√"
* },
* "ios": {
* "osVer": "x",
* "uniVer": "x",
* "unixVer": "x"
* }
* }
* }
*/
isUSBDebugging?: boolean,
}
/**
* @param [options=包含所有字段的过滤对象] 过滤的字段对象, 不传参数默认为获取全部字段。
*/
export type GetDeviceInfo = (options?: GetDeviceInfoOptions | null) => GetDeviceInfoResult;
export interface Uni {
/**
* GetDeviceInfo(Object object)
* @description
* 获取设备信息
* @param {GetDeviceInfoOptions} options [options=包含所有字段的过滤对象] 过滤的字段对象, 不传参数默认为获取全部字段。
* @return {object}
* @tutorial https://uniapp.dcloud.net.cn/api/system/getDeviceInfo.html
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "3.9+"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.11"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* }
* @example
```typescript
uni.getDeviceInfo({
filter:[]
})
```
*/
getDeviceInfo(options?: GetDeviceInfoOptions | null): GetDeviceInfoResult;
}
export type GetDeviceInfoOptions = {
/**
* @description 过滤字段的字符串数组,假如要获取指定字段,传入此数组。
*/
filter: Array<string>
}
export type GetDeviceInfoResult = {
/**
* 设备品牌
* @deprecated 已废弃,仅为了向下兼容保留
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "3.9+"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.11"
* }
* },
* "web": {
* "uniVer": "x",
* "unixVer": "x"
* }
* }
*/
brand?: string
/**
* 设备品牌
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "3.9+"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.11"
* }
* },
* "web": {
* "uniVer": "x",
* "unixVer": "x"
* }
* }
*/
deviceBrand?: string,
/**
* 设备 id 。由 uni-app 框架生成并存储,清空 Storage 会导致改变
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "3.9+"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.11"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* }
*/
deviceId?: string,
/**
* 设备型号
* @deprecated 已废弃,仅为了向下兼容保留
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "3.9+"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.11"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* }
*/
model?: string,
/**
* 设备型号
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "3.9+"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.11"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* }
*/
deviceModel?: string,
/**
* 设备类型phone、pad、pc
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "3.9+"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.11"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* }
*/
deviceType?: string,
/**
* 设备方向 竖屏 portrait、横屏 landscape
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "3.9+"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.11"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* }
*/
deviceOrientation?: string,
/**
* 设备像素比
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "3.9+"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.11"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* }
*/
devicePixelRatio?: string,
/**
* 操作系统及版本
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "3.9+"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.11"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* }
*/
system?: string,
/**
* 客户端平台
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "3.9+"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.11"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* }
*/
platform?: string,
/**
* 是否root。iOS 为是否越狱
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "x",
* "unixVer": "3.9+"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "x",
* "unixVer": "4.11"
* }
* },
* "web": {
* "uniVer": "x",
* "unixVer": "x"
* }
* }
*/
isRoot?: boolean,
/**
* 是否是模拟器
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "x",
* "unixVer": "3.9+"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "x",
* "unixVer": "4.11"
* }
* },
* "web": {
* "uniVer": "x",
* "unixVer": "x"
* }
* }
*/
isSimulator?: boolean,
/**
* adb是否开启
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "x",
* "unixVer": "√"
* },
* "ios": {
* "osVer": "x",
* "uniVer": "x",
* "unixVer": "x"
* }
* },
* "web": {
* "uniVer": "x",
* "unixVer": "x"
* }
* }
*/
isUSBDebugging?: boolean,
/**
* 系统名称
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "x",
* "unixVer": "4.18"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "x",
* "unixVer": "4.18"
* }
* },
* "web": {
* "uniVer": "x",
* "unixVer": "4.18"
* }
* }
*/
osName?: 'ios' | 'android' | 'macos' | 'windows' | 'linux' | null,
/**
* 操作系统版本。如 ios 版本,andriod 版本
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "x",
* "unixVer": "4.18"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "x",
* "unixVer": "4.18"
* }
* },
* "web": {
* "uniVer": "x",
* "unixVer": "4.18"
* }
* }
*/
osVersion?: string | null,
/**
* 操作系统语言
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "x",
* "unixVer": "4.18"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "x",
* "unixVer": "4.18"
* }
* },
* "web": {
* "uniVer": "x",
* "unixVer": "x"
* }
* }
*/
osLanguage?: string | null,
/**
* 操作系统主题
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "x",
* "unixVer": "4.18"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "x",
* "unixVer": "4.18"
* }
* },
* "web": {
* "uniVer": "x",
* "unixVer": "x"
* }
* }
*/
osTheme?: 'light' | 'dark' | null,
/**
* Android 系统API库的版本。
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "x",
* "unixVer": "4.18"
* },
* "ios": {
* "osVer": "x",
* "uniVer": "x",
* "unixVer": "x"
* }
* },
* "web": {
* "uniVer": "x",
* "unixVer": "x"
* }
* }
*/
osAndroidAPILevel?: number | null,
/**
* rom 名称。Android 部分机型获取不到值。iOS 恒为 `ios`
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "x",
* "unixVer": "4.18"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "x",
* "unixVer": "4.18"
* }
* },
* "web": {
* "uniVer": "x",
* "unixVer": "x"
* }
* }
*/
romName?: string | null,
/**
* rom 版本号。Android 部分机型获取不到值。iOS 为操作系统版本号(同 `osVersion`)。
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "x",
* "unixVer": "4.18"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "x",
* "unixVer": "4.18"
* }
* },
* "web": {
* "uniVer": "x",
* "unixVer": "x"
* }
* }
*/
romVersion?: string | null,
}
/**
* @param [options=包含所有字段的过滤对象] 过滤的字段对象, 不传参数默认为获取全部字段。
*/
export type GetDeviceInfo = (options?: GetDeviceInfoOptions | null) => GetDeviceInfoResult;
export interface Uni {
/**
* GetDeviceInfo(Object object)
* @description
* 获取设备信息
* @param {GetDeviceInfoOptions} options [options=包含所有字段的过滤对象] 过滤的字段对象, 不传参数默认为获取全部字段。
* @return {object}
* @tutorial https://uniapp.dcloud.net.cn/api/system/getDeviceInfo.html
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "3.9+"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.11"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* }
* @example
```typescript
uni.getDeviceInfo({
filter:[]
})
```
*/
getDeviceInfo(options?: GetDeviceInfoOptions | null): GetDeviceInfoResult;
}
\ No newline at end of file
......@@ -112,7 +112,7 @@ export type GetLocationOptions = {
* 默认为 wgs84 返回 gps 坐标,gcj02 返回可用于uni.openLocation的坐标,web端需配置定位 SDK 信息才可支持 gcj02
* @defaultValue wgs84
*/
type?: "wgs84" | "gcj02" | "gps" | null,
type?: "wgs84" | "gcj02" | null,
/**
* 传入 true 会返回高度信息,由于获取高度需要较高精确度,会减慢接口返回速度
* @type boolean
......
......@@ -131,12 +131,12 @@ export interface Uni {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "",
* "uniVer": "x",
* "unixVer": "3.91"
* },
* "ios": {
* "osVer": "10.0",
* "uniVer": "",
* "osVer": "12.0",
* "uniVer": "x",
* "unixVer": "x"
* }
* },
......@@ -153,5 +153,5 @@ export interface Uni {
* }
* }
*/
getPerformance: Performance
getPerformance: GetPerformance
}
......@@ -9,13 +9,16 @@ export const getProvider : GetProvider = (options: GetProviderOptions) : void =>
options.fail?.(uniError);
}
} else {
const provider = UTSAndroid.getExtApiProviders(options.service)
const providers = UTSAndroid.getProviders(options.service)
// TODO
// const providers: any[] = []
if (options.success != null) {
const result = {
service: options.service,
provider,
provider: providers.map((provider): string => {
return provider.id
}),
providers,
errMsg: 'GetProvider:ok'
} as GetProviderSuccess;
options.success?.(result);
......
export type GetProviderSuccess = {
/**
* 服务类型
* - oauth: 授权登录
* - share: 分享
* - payment: 支付
* - push: 推送
* - location: 定位
* @type 'oauth' | 'share' | 'payment' | 'push' | 'location'
*/
service: 'oauth' | 'share' | 'payment' | 'push' | 'location',
/**
* 得到的服务供应商
* @type PlusShareShareService['id'][] | PlusPushClientInfo['id'][] | PlusOauthAuthService['id'][] | PlusPaymentPaymentChannel['id'][]
*/
provider: string[],
/**
* 描述信息
*/
errMsg: string
/**
* 服务类型
* - payment: 支付
* @type 'payment'
*/
service : 'payment',
/**
* 得到的服务供应商
* @type PlusShareShareService['id'][] | PlusPushClientInfo['id'][] | PlusOauthAuthService['id'][] | PlusPaymentPaymentChannel['id'][]
*/
provider : string[],
/**
* 得到的服务供应商服务对象
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "4.18"
* },
* "ios": {
* "osVer": "9.0",
* "uniVer": "√",
* "unixVer": "4.18"
* }
* },
* "web": {
* "uniVer": "x",
* "unixVer": "x"
* }
* }
*/
providers : UniProvider[],
/**
* 错误信息
*/
errMsg : string
};
export type GetProviderSuccessCallback = (result: GetProviderSuccess) => void;
export type GetProviderSuccessCallback = (result : GetProviderSuccess) => void;
export type GetProviderFail = UniError;
export type GetProviderFailCallback = (result: GetProviderFail) => void;
export type GetProviderFailCallback = (result : GetProviderFail) => void;
export type GetProviderComplete = any;
export type GetProviderCompleteCallback = (result: GetProviderComplete) => void;
export type GetProviderCompleteCallback = (result : GetProviderComplete) => void;
export type GetProviderOptions = {
/**
* 服务类型,可取值“oauth”、“share”、“payment”、“push”、“location”
* - oauth: 授权登录
* - share: 分享
* - payment: 支付
* - push: 推送
* - location: 定位
* @type 'oauth' | 'share' | 'payment' | 'push' | 'location'
*/
service: 'oauth' | 'share' | 'payment' | 'push' | 'location',
/**
* 接口调用成功的回调
*/
success?: GetProviderSuccessCallback | null,
/**
* 接口调用失败的回调函数
*/
fail?: GetProviderFailCallback | null,
/**
* 接口调用结束的回调函数(调用成功、失败都会执行)
*/
complete?: GetProviderCompleteCallback | null
/**
* 服务类型,可取值“payment”
* - payment: 支付 (Alipay、Wxpay)
* @type 'payment'
*/
service : 'payment',
/**
* 接口调用成功的回调
*/
success ?: GetProviderSuccessCallback | null,
/**
* 接口调用失败的回调函数
*/
fail ?: GetProviderFailCallback | null,
/**
* 接口调用结束的回调函数(调用成功、失败都会执行)
*/
complete ?: GetProviderCompleteCallback | null
};
export type GetProvider = (options: GetProviderOptions) => void;
export type GetProvider = (options : GetProviderOptions) => void;
export interface Uni {
/**
* 获取服务供应商
* @param {GetProviderOptions} options
* @return {void}
* @tutorial https://doc.dcloud.net.cn/uni-app-x/api/get-provider.html
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "4.11"
* },
* "ios": {
* "osVer": "9.0",
* "uniVer": "√",
* "unixVer": "x"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.05"
* }
* }
* @example
```typescript
uni.getProvider({service: ''})
```
*/
getProvider(options: GetProviderOptions) : void;
/**
* 获取服务供应商
* @param {GetProviderOptions} options
* @return {void}
* @tutorial https://doc.dcloud.net.cn/uni-app-x/api/get-provider.html
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "4.11"
* },
* "ios": {
* "osVer": "9.0",
* "uniVer": "√",
* "unixVer": "4.18"
* }
* },
* "web": {
* "uniVer": "x",
* "unixVer": "x"
* }
* }
* @example
```typescript
uni.getProvider({service: ''})
```
*/
getProvider(options : GetProviderOptions) : void;
}
......@@ -77,6 +77,7 @@ export const getSystemInfoSync : GetSystemInfoSync = function () : GetSystemInfo
height: windowHeight - safeAreaInsets.top - safeAreaInsets.bottom
}
const osAndroidAPILevel = Build.VERSION.SDK_INT;
const appTheme = UTSAndroid.getAppTheme();
const result = {
SDKVersion: "",
......@@ -125,6 +126,7 @@ export const getSystemInfoSync : GetSystemInfoSync = function () : GetSystemInfo
safeAreaInsets: safeAreaInsets,
safeArea: safeArea,
osAndroidAPILevel: osAndroidAPILevel,
appTheme: appTheme,
} as GetSystemInfoResult;
return result;
} catch (e : Exception) {
......
......@@ -16,12 +16,6 @@ export const getSystemInfoSync : GetSystemInfoSync = function () : GetSystemInfo
const osVersion = UIDevice.current.systemVersion
let osTheme = 'light'
if(UTSiOS.available("iOS 13, *")){
let currentTraitCollection = UIApplication.shared.keyWindow?.traitCollection
osTheme = currentTraitCollection?.userInterfaceStyle == UIUserInterfaceStyle.dark ? "dark" : "light"
}
let deviceOrientation = 'portrait'
const orient = UIApplication.shared.statusBarOrientation;
if (orient == UIInterfaceOrientation.landscapeLeft || orient == UIInterfaceOrientation.landscapeRight) {
......@@ -50,7 +44,7 @@ export const getSystemInfoSync : GetSystemInfoSync = function () : GetSystemInfo
osName: 'ios',
osVersion: osVersion,
osLanguage: UTSiOS.getOsLanguage(),
osTheme: osTheme,
osTheme: UTSiOS.getOsTheme(),
pixelRatio: windowInfo.pixelRatio,
platform: 'ios',
screenWidth: windowInfo.screenWidth,
......@@ -74,6 +68,7 @@ export const getSystemInfoSync : GetSystemInfoSync = function () : GetSystemInfo
windowBottom: windowInfo.windowBottom,
safeAreaInsets: windowInfo.safeAreaInsets,
safeArea: windowInfo.safeArea,
appTheme: UTSiOS.getAppTheme(),
};
return result;
}
......
......@@ -343,6 +343,7 @@ function copyFile(fromFilePath : string, toFilePath : string) : boolean {
if (!fromFile.canRead()) {
return false;
}
fis = new FileInputStream(fromFile);
}
if (fis == null) {
return false
......@@ -358,7 +359,6 @@ function copyFile(fromFilePath : string, toFilePath : string) : boolean {
toFile.createNewFile()
}
try {
// let fis = new FileInputStream(fromFile)
let fos = new FileOutputStream(toFile)
let byteArrays = ByteArray(1024)
var c = fis!!.read(byteArrays)
......@@ -592,6 +592,21 @@ export const getVideoInfo : GetVideoInfo = function (options : GetVideoInfoOptio
export const saveVideoToPhotosAlbum : SaveVideoToPhotosAlbum = function (options : SaveVideoToPhotosAlbumOptions) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
let requestPermissionList : Array<string> = [Manifest.permission.WRITE_EXTERNAL_STORAGE];
UTSAndroid.requestSystemPermission(UTSAndroid.getUniActivity()!, requestPermissionList, (a : boolean, b : string[]) => {
loadFile(options);
}, (a : boolean, b : string[]) => {
let error = new MediaErrorImpl(1101005, UniError_SaveVideoToPhotosAlbum);
options.fail?.(error);
options.complete?.(error);
})
} else {
loadFile(options);
}
}
function loadFile(options : SaveVideoToPhotosAlbumOptions) {
if (TextUtils.isEmpty(options.filePath)) {
let error = new MediaErrorImpl(1101003, UniError_SaveVideoToPhotosAlbum);
options.fail?.(error)
......
import { ChooseImageOptions, ChooseVideoOptions } from "./interface.uts"
import { ChooseImageOptions, ChooseVideoOptions } from "../../interface.uts"
import {
UniError_ChooseImage, UniError_ChooseVideo, MediaErrorImpl
} from "./unierror.uts"
} from "../../unierror.uts"
export const CODE_CAMERA_ERROR = 11;
export const CODE_GALLERY_ERROR = 12;
export const CODE_GET_IMAGE_INFO_CODE = 13
......
......@@ -8,7 +8,7 @@ import {
MediaErrorImpl
} from "../../unierror.uts"
import { getVideoMetadata } from "./MediaUtils.uts"
import { uniChooseImage, uniChooseVideo } from "../../ChooseImageUtils.uts"
import { uniChooseImage, uniChooseVideo } from "./ChooseImageUtils.uts"
import { getUniActivity } from "io.dcloud.uts.android";
import Intent from 'android.content.Intent';
import File from 'java.io.File';
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册