提交 7d61842c 编写于 作者: taohebin@dcloud.io's avatar taohebin@dcloud.io

update: install-apk

上级 6c0049b1
## 1.0.5(2024-04-28)
解决Android API 24版本以下设备,安装apk失败的问题。
## 1.0.4(2023-12-08)
兼容asset目录文件的处理
## 1.0.3(2023-10-27)
......
{
"id": "uni-installApk",
"displayName": "uni-installApk",
"version": "1.0.4",
"version": "1.0.5",
"description": "uni-installApk",
"keywords": [
"uni-installApk"
......@@ -48,7 +48,8 @@
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y"
"aliyun": "y",
"alipay": "n"
},
"client": {
"Vue": {
......
......@@ -7,6 +7,7 @@ import FileProvider from 'androidx.core.content.FileProvider';
import Context from 'android.content.Context';
import Uri from 'android.net.Uri';
import FileOutputStream from 'java.io.FileOutputStream';
import IOException from 'java.io.IOException';
export function installApk(options : InstallApkOptions) : void {
const context = UTSAndroid.getAppContext() as Context
......@@ -74,6 +75,11 @@ function copyAssetFileToPrivateDir(context : Context, fileName : string) : File
inputStream.close()
outputStream.close()
if (Build.VERSION.SDK_INT < 24) {
changePermissionRecursive(new File(context.getCacheDir().getPath() + "/apks/"))
}
return outFile
} catch (e : Exception) {
e.printStackTrace()
......@@ -81,3 +87,12 @@ function copyAssetFileToPrivateDir(context : Context, fileName : string) : File
return null
}
function changePermissionRecursive(file: File){
const cmd = "chmod -R 777 " + file.getAbsolutePath()
const runtime = Runtime.getRuntime()
try {
runtime.exec(cmd)
} catch (e: IOException) {
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册