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

Commit 5e78c8d0 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[PM] Update the check flow in PIA V2" into main

parents 484668de d48e6b9c
Loading
Loading
Loading
Loading
+22 −26
Original line number Diff line number Diff line
@@ -471,8 +471,11 @@ class InstallRepository(private val context: Context) {
    /**
     * Processes Install session, file:// or package:// URI to generate data pertaining to user
     * confirmation for an install. This method also checks if the source app has the AppOp granted
     * to install unknown apps. If an AppOp is to be requested, cache the user action prompt data to
     * be reused once appOp has been granted
     * to install unknown apps when {@code forceSourceCheck} is true. If an AppOp is to be
     * requested, cache the user action prompt data to be reused once appOp has been granted.
     *
     * When the identity of the install source could not be determined, user can skip checking the
     * source and directly proceed with the install by setting {@code forceSourceCheck} to false.
     *
     * @return
     *  * [InstallAborted]
@@ -486,21 +489,8 @@ class InstallRepository(private val context: Context) {
     *      * If AppOP is granted and user action is required to proceed with install
     *      * If AppOp grant is to be requested from the user
     */
    fun requestUserConfirmation(): InstallStage? {
        return if (isTrustedSource) {
            if (localLogv) {
                Log.i(LOG_TAG, "Install allowed")
            }
            maybeDeferUserConfirmation()
        } else {
            val unknownSourceStage = handleUnknownSources(appOpRequestInfo)
            if (unknownSourceStage.stageCode == InstallStage.STAGE_READY) {
                // Source app already has appOp granted.
                maybeDeferUserConfirmation()
            } else {
                unknownSourceStage
            }
        }
    fun requestUserConfirmation(forceSourceCheck: Boolean = true): InstallStage? {
        return maybeDeferUserConfirmation(forceSourceCheck)
    }

    /**
@@ -508,7 +498,7 @@ class InstallRepository(private val context: Context) {
     *  user and directly proceed with the install. The system will request another
     *  user confirmation shortly.
     */
    private fun maybeDeferUserConfirmation(): InstallStage? {
    private fun maybeDeferUserConfirmation(forceSourceCheck: Boolean = true): InstallStage? {
        // Returns InstallUserActionRequired stage if install details could be successfully
        // computed, else it returns InstallAborted.
        val confirmationSnippet: InstallStage = generateConfirmationSnippet()
@@ -516,6 +506,20 @@ class InstallRepository(private val context: Context) {
            return confirmationSnippet
        }

        // check source is trusted or granted permission
        if (forceSourceCheck) {
            if (isTrustedSource) {
                if (localLogv) {
                    Log.i(LOG_TAG, "Install allowed")
                }
            } else {
                val unknownSourceStage = handleUnknownSources(appOpRequestInfo)
                if (unknownSourceStage.stageCode != InstallStage.STAGE_READY) {
                    return unknownSourceStage
                }
            }
        }

        val existingUpdateOwner: CharSequence? = getExistingUpdateOwner(newPackageInfo!!)
        return if (sessionId == SessionInfo.INVALID_ID &&
            !TextUtils.isEmpty(existingUpdateOwner) &&
@@ -1088,14 +1092,6 @@ class InstallRepository(private val context: Context) {
        }
    }

    /**
     * When the identity of the install source could not be determined, user can skip checking the
     * source and directly proceed with the install.
     */
    fun forcedSkipSourceCheck(): InstallStage? {
        return maybeDeferUserConfirmation()
    }

    fun abortStaging() {
        sessionStager!!.cancel()
        stagingJob.cancel()
+1 −1
Original line number Diff line number Diff line
@@ -94,7 +94,7 @@ class InstallViewModel(application: Application, val repository: InstallReposito
    }

    fun forcedSkipSourceCheck() {
        val stage = repository.forcedSkipSourceCheck()
        val stage = repository.requestUserConfirmation(/* forceSourceCheck= */ false)
        if (stage != null) {
            _currentInstallStage.value = stage
        }