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

Commit 01ed269c authored by Song Chun Fan's avatar Song Chun Fan Committed by Android (Google) Code Review
Browse files

Merge changes I37ee37bd,Ibc3fcab1 into main

* changes:
  [ADI][59/N] allow set-developer-verification-result without a verifier
  [ADI][58/N] Support Retry on network errors with fail_closed
parents 3e19486f dbd006eb
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -975,8 +975,8 @@ public class PackageInstaller {
    @SystemApi
    public static final int DEVELOPER_VERIFICATION_USER_RESPONSE_ABORT = 1;
    /**
     * For an incomplete developer verification, the user has asked to retry the verification.
     * Notice that this is currently not supported.
     * For an incomplete developer verification with network error, the user has asked to retry the
     * verification if the developer verification policy for the session is fail_closed.
     * @hide
     */
    @FlaggedApi(Flags.FLAG_VERIFICATION_SERVICE)
+1 −0
Original line number Diff line number Diff line
@@ -227,6 +227,7 @@
    <string name="button_restore">Restore</string>
    <string name="button_uninstall_updates_system_app">Uninstall updates</string>
    <string name="button_settings">Settings</string>
    <string name="button_retry">Retry</string>
    <!-- Dialog Buttons end -->

    <!-- Miscellaneous -->
+24 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.content.pm.PackageInstaller
import android.content.pm.PackageInstaller.DEVELOPER_VERIFICATION_USER_RESPONSE_ABORT
import android.content.pm.PackageInstaller.DEVELOPER_VERIFICATION_USER_RESPONSE_ERROR
import android.content.pm.PackageInstaller.DEVELOPER_VERIFICATION_USER_RESPONSE_INSTALL_ANYWAY
import android.content.pm.PackageInstaller.DEVELOPER_VERIFICATION_USER_RESPONSE_RETRY
import android.content.pm.PackageInstaller.DeveloperVerificationUserConfirmationInfo
import android.content.pm.PackageInstaller.SessionInfo
import android.content.pm.PackageInstaller.SessionParams
@@ -903,6 +904,29 @@ class InstallRepository(private val context: Context) : EventResultPersister.Eve
        }
    }

    fun setRetryVerificationUserResponse(): InstallStage {
        if (PackageInstaller.ACTION_CONFIRM_DEVELOPER_VERIFICATION != intent.action) {
            Log.e(LOG_TAG, "Cannot set verification response for this request: $intent")
            return InstallAborted(ABORT_REASON_INTERNAL_ERROR)
        }
        if (localLogv) {
            Log.d(LOG_TAG, "Setting retry verification user response")
        }
        packageInstaller.setDeveloperVerificationUserResponse(
            sessionId, DEVELOPER_VERIFICATION_USER_RESPONSE_RETRY
        )
        // If it is triggered by PIA itself, show the installing dialog and wait for the
        // result from the receiver. Don't need to set the aborted.
        if (wasUserConfirmationTriggeredByPia) {
            wasUserConfirmationTriggeredByPia = false
            return InstallInstalling(appSnippet, isAppUpdating)
        } else {
            return InstallAborted(
                ABORT_REASON_DONE, activityResultCode = Activity.RESULT_OK
            )
        }
    }

    /**
     * Once the user returns from Settings related to installing from unknown sources, reattempt
     * the installation if the source app is granted permission to install other apps. Abort the
+5 −0
Original line number Diff line number Diff line
@@ -36,6 +36,11 @@ interface InstallActionListener {

    fun onNegativeResponse(resultCode: Int, data: Intent?)

    /**
     * Method to handle a retry response from the user.
     */
    fun onRetryResponse()

    /**
     * Launch the intent to open the newly installed / updated app.
     */
+4 −0
Original line number Diff line number Diff line
@@ -335,6 +335,10 @@ class InstallLaunch : FragmentActivity(), InstallActionListener {
        setResult(resultCode, data, true)
    }

    override fun onRetryResponse() {
        installViewModel!!.onRetryVerificationUserResponse()
    }

    override fun sendUnknownAppsIntent(sourcePackageName: String) {
        if (localLogv) {
            Log.d(LOG_TAG, "Launching unknown-apps settings intent for $sourcePackageName")
Loading