From e46c31f15f1579f4307ca411b1663d58c6e990f2 Mon Sep 17 00:00:00 2001 From: yanyilin Date: Thu, 14 Dec 2023 13:57:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4uni-installApk=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=EF=BC=8C=E4=BD=BF=E7=94=A8=E5=86=85=E7=BD=AE=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uni_modules/uni-installApk/changelog.md | 8 -- uni_modules/uni-installApk/package.json | 93 ------------------- uni_modules/uni-installApk/readme.md | 37 -------- .../utssdk/app-android/AndroidManifest.xml | 5 - .../utssdk/app-android/index.uts | 39 -------- .../uni-installApk/utssdk/app-ios/index.uts | 0 uni_modules/uni-installApk/utssdk/index.d.ts | 78 ---------------- .../uni-installApk/utssdk/interface.uts | 76 --------------- .../uni-installApk/utssdk/unierror.uts | 26 ------ 9 files changed, 362 deletions(-) delete mode 100644 uni_modules/uni-installApk/changelog.md delete mode 100644 uni_modules/uni-installApk/package.json delete mode 100644 uni_modules/uni-installApk/readme.md delete mode 100644 uni_modules/uni-installApk/utssdk/app-android/AndroidManifest.xml delete mode 100644 uni_modules/uni-installApk/utssdk/app-android/index.uts delete mode 100644 uni_modules/uni-installApk/utssdk/app-ios/index.uts delete mode 100644 uni_modules/uni-installApk/utssdk/index.d.ts delete mode 100644 uni_modules/uni-installApk/utssdk/interface.uts delete mode 100644 uni_modules/uni-installApk/utssdk/unierror.uts diff --git a/uni_modules/uni-installApk/changelog.md b/uni_modules/uni-installApk/changelog.md deleted file mode 100644 index f6c95831..00000000 --- a/uni_modules/uni-installApk/changelog.md +++ /dev/null @@ -1,8 +0,0 @@ -## 1.0.3(2023-10-27) -遵循UniError规范 -## 1.0.2(2023-10-27) -修改文档 -## 1.0.1(2023-10-27) -支持js层调用 -## 1.0.0(2023-10-26) -安装apk的插件 diff --git a/uni_modules/uni-installApk/package.json b/uni_modules/uni-installApk/package.json deleted file mode 100644 index c3889207..00000000 --- a/uni_modules/uni-installApk/package.json +++ /dev/null @@ -1,93 +0,0 @@ -{ - "id": "uni-installApk", - "displayName": "uni-installApk", - "version": "1.0.3", - "description": "uni-installApk", - "keywords": [ - "uni-installApk" - ], - "repository": "", - "engines": { - "HBuilderX": "^3.94" - }, - "dcloudext": { - "type": "uts", - "sale": { - "regular": { - "price": "0.00" - }, - "sourcecode": { - "price": "0.00" - } - }, - "contact": { - "qq": "" - }, - "declaration": { - "ads": "无", - "data": "无", - "permissions": "android.permission.REQUEST_INSTALL_PACKAGES" - }, - "npmurl": "" - }, - "uni_modules": { - "dependencies": [], - "uni-ext-api": { - "uni": { - "installApk": { - "name": "installApk", - "app": { - "js": true, - "kotlin": true, - "swift": false - } - } - } - }, - "encrypt": [], - "platforms": { - "cloud": { - "tcb": "y", - "aliyun": "y" - }, - "client": { - "Vue": { - "vue2": "y", - "vue3": "y" - }, - "App": { - "app-android": "y", - "app-ios": "n" - }, - "H5-mobile": { - "Safari": "n", - "Android Browser": "n", - "微信浏览器(Android)": "n", - "QQ浏览器(Android)": "n" - }, - "H5-pc": { - "Chrome": "n", - "IE": "n", - "Edge": "n", - "Firefox": "n", - "Safari": "n" - }, - "小程序": { - "微信": "n", - "阿里": "n", - "百度": "n", - "字节跳动": "n", - "QQ": "n", - "钉钉": "n", - "快手": "n", - "飞书": "n", - "京东": "n" - }, - "快应用": { - "华为": "n", - "联盟": "n" - } - } - } - } -} \ No newline at end of file diff --git a/uni_modules/uni-installApk/readme.md b/uni_modules/uni-installApk/readme.md deleted file mode 100644 index 898834d7..00000000 --- a/uni_modules/uni-installApk/readme.md +++ /dev/null @@ -1,37 +0,0 @@ -# uni-installApk - -## 使用说明 - -Android平台安装Apk - -**注意: 3.95以下需要自定义基座** - -### uni.installApk(options : InstallApkOptions):void - -安装apk - -参数说明 - -``` -type InstallApkOptions = { - /** - * apk文件地址 - */ - filePath : string, - /** - * 接口调用成功的回调函数 - * @defaultValue null - */ - success ?: (res : any) => void, - /** - * 接口调用失败的回调函数 - * @defaultValue null - */ - fail ?: (err : any) => void, - /** - * 接口调用结束的回调函数(调用成功、失败都会执行) - * @defaultValue null - */ - complete ?: (res : any) => void, -} -``` \ No newline at end of file diff --git a/uni_modules/uni-installApk/utssdk/app-android/AndroidManifest.xml b/uni_modules/uni-installApk/utssdk/app-android/AndroidManifest.xml deleted file mode 100644 index 5cf3ce22..00000000 --- a/uni_modules/uni-installApk/utssdk/app-android/AndroidManifest.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/uni_modules/uni-installApk/utssdk/app-android/index.uts b/uni_modules/uni-installApk/utssdk/app-android/index.uts deleted file mode 100644 index cfdef2ed..00000000 --- a/uni_modules/uni-installApk/utssdk/app-android/index.uts +++ /dev/null @@ -1,39 +0,0 @@ -import { InstallApkOptions, InstallApkSuccess } from "../interface.uts" -import { InstallApkFailImpl } from "../unierror.uts" -import Intent from 'android.content.Intent'; -import Build from 'android.os.Build'; -import File from 'java.io.File'; -import FileProvider from 'androidx.core.content.FileProvider'; -import Context from 'android.content.Context'; -import Uri from 'android.net.Uri'; - -export function installApk(options : InstallApkOptions) : void { - const context = UTSAndroid.getAppContext() as Context - const filePath = UTSAndroid.convert2AbsFullPath(options.filePath) - const apkFile = new File(filePath) - if (!apkFile.exists() && !apkFile.isFile()) { - let error = new InstallApkFailImpl(1300002); - options.fail?.(error) - options.complete?.(error) - return - } - const intent = new Intent() - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - intent.setAction(Intent.ACTION_VIEW) - - if (Build.VERSION.SDK_INT >= 24) { - const authority = context.getPackageName() + ".dc.fileprovider" - const apkUri = FileProvider.getUriForFile(context, authority, apkFile) - intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); - intent.setDataAndType(apkUri, "application/vnd.android.package-archive"); - } else { - intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive"); - } - - context.startActivity(intent) - const success : InstallApkSuccess = { - errMsg: "success" - } - options.success?.(success) - options.complete?.(success) -} \ No newline at end of file diff --git a/uni_modules/uni-installApk/utssdk/app-ios/index.uts b/uni_modules/uni-installApk/utssdk/app-ios/index.uts deleted file mode 100644 index e69de29b..00000000 diff --git a/uni_modules/uni-installApk/utssdk/index.d.ts b/uni_modules/uni-installApk/utssdk/index.d.ts deleted file mode 100644 index ad24effb..00000000 --- a/uni_modules/uni-installApk/utssdk/index.d.ts +++ /dev/null @@ -1,78 +0,0 @@ -declare namespace UniNamespace { - -interface InstallApkSuccess { - /** - * 安装成功消息 - */ - errMsg : string -} - -type InstallApkErrorCode = 1300002 -interface InstallApkFail { - errCode : InstallApkErrorCode -} - -type InstallApkComplete = any - -type InstallApkSuccessCallback = (res : InstallApkSuccess) => void -type InstallApkFailCallback = (err : InstallApkFail) => void -type InstallApkCompleteCallback = (res : InstallApkComplete) => void - -interface InstallApkOptions { - /** - * apk文件地址 - */ - filePath : string, - /** - * 接口调用成功的回调函数 - * @defaultValue null - */ - success ?: InstallApkSuccessCallback | null, - /** - * 接口调用失败的回调函数 - * @defaultValue null - */ - fail ?: InstallApkFailCallback | null, - /** - * 接口调用结束的回调函数(调用成功、失败都会执行) - * @defaultValue null - */ - complete ?: InstallApkCompleteCallback | null -} - -} - - -declare interface Uni { - /** - * installApk() - * @description - * 安装apk - * @param {InstallApkOptions} - * @return {void} - * @uniPlatform { - * "app": { - * "android": { - * "osVer": "4.4", - * "uniVer": "3.94+", - * "unixVer": "3.94+" - * }, - * "ios": { - * "osVer": "x", - * "uniVer": "x", - * "unixVer": "x" - * } - * } - * } - * @example - ```typescript - uni.installApk({ - filePath: "/xx/xx/xx.apk", - complete: (res: any) => { - console.log("complete => " + JSON.stringify(res)); - } - }); - ``` - */ - installApk(options : UniNamespace.InstallApkOptions) : void -} diff --git a/uni_modules/uni-installApk/utssdk/interface.uts b/uni_modules/uni-installApk/utssdk/interface.uts deleted file mode 100644 index 35edfcd7..00000000 --- a/uni_modules/uni-installApk/utssdk/interface.uts +++ /dev/null @@ -1,76 +0,0 @@ -export interface Uni { - /** - * installApk() - * @description - * 安装apk - * @param {InstallApkOptions} - * @return {void} - * @uniPlatform { - * "app": { - * "android": { - * "osVer": "4.4", - * "uniVer": "3.94+", - * "unixVer": "3.94+" - * }, - * "ios": { - * "osVer": "x", - * "uniVer": "x", - * "unixVer": "x" - * } - * } - * } - * @example - ```typescript - uni.installApk({ - filePath: "/xx/xx/xx.apk", - complete: (res: any) => { - console.log("complete => " + JSON.stringify(res)); - } - }); - ``` - */ - installApk(options : InstallApkOptions) : void -} -export type InstallApkSuccess = { - /** - * 安装成功消息 - */ - errMsg : string -} -export type InstallApkComplete = any -export type InstallApkSuccessCallback = (res : InstallApkSuccess) => void -/** - * 错误码 - * - 1300002 找不到文件 - */ -export type InstallApkErrorCode = 1300002 -/** - * 网络请求失败的错误回调参数 - */ -export interface InstallApkFail extends IUniError { - errCode : InstallApkErrorCode -}; -export type InstallApkFailCallback = (err : InstallApkFail) => void -export type InstallApkCompleteCallback = (res : InstallApkComplete) => void - -export type InstallApkOptions = { - /** - * apk文件地址 - */ - filePath : string, - /** - * 接口调用成功的回调函数 - * @defaultValue null - */ - success ?: InstallApkSuccessCallback | null, - /** - * 接口调用失败的回调函数 - * @defaultValue null - */ - fail ?: InstallApkFailCallback | null, - /** - * 接口调用结束的回调函数(调用成功、失败都会执行) - * @defaultValue null - */ - complete ?: InstallApkCompleteCallback | null -} \ No newline at end of file diff --git a/uni_modules/uni-installApk/utssdk/unierror.uts b/uni_modules/uni-installApk/utssdk/unierror.uts deleted file mode 100644 index 8b849401..00000000 --- a/uni_modules/uni-installApk/utssdk/unierror.uts +++ /dev/null @@ -1,26 +0,0 @@ -import { InstallApkErrorCode, InstallApkFail } from "./interface.uts" - -/** - * 错误主题 - */ -export const UniErrorSubject = 'uni-installApk'; -/** - * 错误码 - * @UniError - */ -export const UniErrors : Map = new Map([ - /** - * 找不到文件 - */ - [1300002, 'No such file'], -]); - -export class InstallApkFailImpl extends UniError implements InstallApkFail { - override errCode : InstallApkErrorCode - constructor(errCode : InstallApkErrorCode) { - super(); - this.errSubject = UniErrorSubject; - this.errCode = errCode; - this.errMsg = UniErrors[errCode] ?? ""; - } -} \ No newline at end of file -- GitLab