Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3a86dc44 authored by Sumedh Sen's avatar Sumedh Sen
Browse files

[piav2] Dont check for "no_install_unknown_sources" for installs from privileged sources.

Installs from privileged sources should only check for "no_install_apps"
retriction.

This was implemented in PiaV1 in ag/27495994

Bug: 324305636
Test: Manual. Follow repro steps in the bug
Flag: android.content.pm.use_pia_v2

Change-Id: I6004baa8d7a8cbcc9b89e5c0286a5846bd896902
parent fc47eba9
Loading
Loading
Loading
Loading
+12 −7
Original line number Diff line number Diff line
@@ -206,7 +206,7 @@ class InstallRepository(private val context: Context) {
            return InstallAborted(ABORT_REASON_INTERNAL_ERROR)
        }

        val restriction = getDevicePolicyRestrictions()
        val restriction = getDevicePolicyRestrictions(isTrustedSource)
        if (restriction != null) {
            val adminSupportDetailsIntent =
                devicePolicyManager!!.createAdminSupportIntent(restriction)
@@ -243,12 +243,17 @@ class InstallRepository(private val context: Context) {
            || isPermissionGranted(context, Manifest.permission.INSTALL_PACKAGES, callingUid)))
    }

    private fun getDevicePolicyRestrictions(): String? {
        val restrictions = arrayOf(
    private fun getDevicePolicyRestrictions(isTrustedSource: Boolean): String? {
        val restrictions: Array<String> = if (isTrustedSource) {
            arrayOf(UserManager.DISALLOW_INSTALL_APPS)
        } else {
            arrayOf(
                UserManager.DISALLOW_INSTALL_APPS,
                UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES,
                UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES_GLOBALLY
            )
        }

        for (restriction in restrictions) {
            if (!userManager!!.hasUserRestrictionForUser(restriction, Process.myUserHandle())) {
                continue