ServiceInstaller: Only give read URI permission to aurora services
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -89,7 +89,7 @@ abstract class InstallerBase(protected var context: Context) : IInstaller {
|
|||||||
return downloadDir.listFiles()!!.filter { it.path.endsWith(".apk") }
|
return downloadDir.listFiles()!!.filter { it.path.endsWith(".apk") }
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun getUri(file: File): Uri {
|
fun getUri(file: File): Uri {
|
||||||
return FileProvider.getUriForFile(
|
return FileProvider.getUriForFile(
|
||||||
context,
|
context,
|
||||||
"${BuildConfig.APPLICATION_ID}.fileProvider",
|
"${BuildConfig.APPLICATION_ID}.fileProvider",
|
||||||
|
|||||||
@@ -88,7 +88,15 @@ class ServiceInstaller @Inject constructor(
|
|||||||
val fileList = getFiles(download.packageName, download.versionCode)
|
val fileList = getFiles(download.packageName, download.versionCode)
|
||||||
xInstall(
|
xInstall(
|
||||||
download.packageName,
|
download.packageName,
|
||||||
fileList.map { getUri(it) },
|
fileList.map { file ->
|
||||||
|
getUri(file).also { uri ->
|
||||||
|
context.grantUriPermission(
|
||||||
|
PRIVILEGED_EXTENSION_PACKAGE_NAME,
|
||||||
|
uri,
|
||||||
|
Intent.FLAG_GRANT_READ_URI_PERMISSION
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
fileList.map { it.absolutePath }
|
fileList.map { it.absolutePath }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -286,20 +294,4 @@ class ServiceInstaller @Inject constructor(
|
|||||||
th.printStackTrace()
|
th.printStackTrace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getUri(file: File): Uri {
|
|
||||||
val uri = FileProvider.getUriForFile(
|
|
||||||
context,
|
|
||||||
"${BuildConfig.APPLICATION_ID}.fileProvider",
|
|
||||||
file
|
|
||||||
)
|
|
||||||
|
|
||||||
context.grantUriPermission(
|
|
||||||
PRIVILEGED_EXTENSION_PACKAGE_NAME,
|
|
||||||
uri,
|
|
||||||
Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
|
|
||||||
)
|
|
||||||
|
|
||||||
return uri
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user