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

Commit e5f93c51 authored by Songchun Fan's avatar Songchun Fan Committed by Android Build Coastguard Worker
Browse files

Revert "[ADI][18/N] Add VERIFICATION_USER_ACTION_NEEDED_REASON constants"

FLAG: EXEMPT just revert
BUG: 422535876
Test: n/a just revert

This reverts commit 2dde455f.
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:0959a25f850d51501bae3ca34e8d2e35f5c22448)
Merged-In: Idb9c0194ab45c56a550d2badfcdb645edec51ddf
Change-Id: Idb9c0194ab45c56a550d2badfcdb645edec51ddf
parent e11cffc2
Loading
Loading
Loading
Loading
+1 −4
Original line number Original line Diff line number Diff line
@@ -4392,13 +4392,10 @@ package android.content.pm {
    ctor public PackageInstaller.VerificationUserConfirmationInfo();
    ctor public PackageInstaller.VerificationUserConfirmationInfo();
    ctor public PackageInstaller.VerificationUserConfirmationInfo(int, int);
    ctor public PackageInstaller.VerificationUserConfirmationInfo(int, int);
    method public int describeContents();
    method public int describeContents();
    method public int getVerificationFailureReason();
    method public int getVerificationPolicy();
    method public int getVerificationPolicy();
    method public int getVerificationUserActionNeededReason();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.content.pm.PackageInstaller.VerificationUserConfirmationInfo> CREATOR;
    field @NonNull public static final android.os.Parcelable.Creator<android.content.pm.PackageInstaller.VerificationUserConfirmationInfo> CREATOR;
    field public static final int VERIFICATION_USER_ACTION_NEEDED_REASON_NETWORK_UNAVAILABLE = 1; // 0x1
    field public static final int VERIFICATION_USER_ACTION_NEEDED_REASON_PACKAGE_BLOCKED = 2; // 0x2
    field public static final int VERIFICATION_USER_ACTION_NEEDED_REASON_UNKNOWN = 0; // 0x0
  }
  }
  public class PackageItemInfo {
  public class PackageItemInfo {
+20 −78
Original line number Original line Diff line number Diff line
@@ -443,36 +443,12 @@ public class PackageInstaller {
    public static final String EXTRA_WARNINGS = "android.content.pm.extra.WARNINGS";
    public static final String EXTRA_WARNINGS = "android.content.pm.extra.WARNINGS";


    /**
    /**
     * When an installation fails because the verification was incomplete or blocked,
     * When verification is blocked as part of the installation, additional reason for the block
     * this extra provides a code that explains the reason, such
     * will be provided to the installer with a {@link VerificationFailedReason} as part of the
     * as {@link #VERIFICATION_FAILED_REASON_NETWORK_UNAVAILABLE}. It is included in the
     * installation result returned via the {@link IntentSender} in
     * installation result returned via the {@link IntentSender} in
     * {@link Session#commit(IntentSender)}. However, along with this reason code, installers can
     * {@link Session#commit(IntentSender)}. This extra is provided only when the installation has
     * receive different status codes from {@link #EXTRA_STATUS} depending on their target SDK and
     * failed. Installers can use this extra to check if the installation failure was caused by a
     * privileged status:
     * verification failure.
     * <p>
     *      Non-privileged installers targeting 36 or less will first receive the
     *      {@link #STATUS_PENDING_USER_ACTION} status code without this reason code. They will be
     *      forced through the user action flow to allow the OS to inform the user of such
     *      verification context before continuing to fail the install. If the user has the option
     *      to bypass the verification result and chooses to do so, the installation will proceed.
     *      Otherwise, the installer will receive the {@link #STATUS_FAILURE_ABORTED} status code
     *      along with this reason code that explains why the verification had failed.
     * </p>
     * <p>
     *     Privileged installer targeting 36 or less will directly receive the
     *     {@link #STATUS_FAILURE_ABORTED} status code. This is because they are not expected to
     *     have the capability of handling the {@link #STATUS_PENDING_USER_ACTION} flow, so the
     *     installation will directly fail. This reason code will be supplied to them for
     *     providing additional information.
     * </p>
     * <p>
     *     All installers targeting 37 and higher will receive a {@link #STATUS_FAILURE_ABORTED}
     *     status code along with this reason code, so the installers can explain the failure to the
     *     user accordingly. An {@link Intent#EXTRA_INTENT} will also be populated with an intent
     *     that can provide additional context where appropriate, should the installer prefer to
     *     defer to the OS to explain the failure to the user.
     * </p>
     */
     */
    @FlaggedApi(Flags.FLAG_VERIFICATION_SERVICE)
    @FlaggedApi(Flags.FLAG_VERIFICATION_SERVICE)
    public static final String EXTRA_VERIFICATION_FAILURE_REASON =
    public static final String EXTRA_VERIFICATION_FAILURE_REASON =
@@ -874,29 +850,22 @@ public class PackageInstaller {
    @SystemApi
    @SystemApi
    public static final int VERIFICATION_POLICY_NONE = 0; // platform default
    public static final int VERIFICATION_POLICY_NONE = 0; // platform default
    /**
    /**
     * Only block installations when the verification status says the package is blocked,
     * Only block installations on {@link #VERIFICATION_FAILED_REASON_PACKAGE_BLOCKED}.
     * and ask the user if they'd like to install anyway when the verification cannot complete for
     * any other reason. In case of a network issue, the user also has the option to retry the
     * verification.
     * @hide
     * @hide
     */
     */
    @FlaggedApi(Flags.FLAG_VERIFICATION_SERVICE)
    @FlaggedApi(Flags.FLAG_VERIFICATION_SERVICE)
    @SystemApi
    @SystemApi
    public static final int VERIFICATION_POLICY_BLOCK_FAIL_OPEN = 1;
    public static final int VERIFICATION_POLICY_BLOCK_FAIL_OPEN = 1;
    /**
    /**
     * Only block installations when the verification result says the package is blocked,
     * Only block installations on {@link #VERIFICATION_FAILED_REASON_PACKAGE_BLOCKED} and ask the
     * and ask the user if they'd like to install anyway when the verification cannot complete for
     * user if they'd like to install anyway when the verification is blocked for other reason.
     * any other reason. In case of a network issue, the user also has the option to retry the
     * verification.
     * @hide
     * @hide
     */
     */
    @FlaggedApi(Flags.FLAG_VERIFICATION_SERVICE)
    @FlaggedApi(Flags.FLAG_VERIFICATION_SERVICE)
    @SystemApi
    @SystemApi
    public static final int VERIFICATION_POLICY_BLOCK_FAIL_WARN = 2;
    public static final int VERIFICATION_POLICY_BLOCK_FAIL_WARN = 2;
    /**
    /**
     * Block installations when the verification result says the package is blocked or when the
     * Block installations whose verification status is blocked for any reason.
     * verification cannot be conducted because of unknown reasons. In case of a network issue,
     * the user has the option to retry the verification.
     * @hide
     * @hide
     */
     */
    @FlaggedApi(Flags.FLAG_VERIFICATION_SERVICE)
    @FlaggedApi(Flags.FLAG_VERIFICATION_SERVICE)
@@ -5012,59 +4981,32 @@ public class PackageInstaller {
    }
    }


    /**
    /**
     * Details about an incomplete or failed verification that requires user intervention.
     * Details about an incomplete or failed verification.
     *
     *
     * @hide
     * @hide
     */
     */
    @FlaggedApi(Flags.FLAG_VERIFICATION_SERVICE)
    @FlaggedApi(Flags.FLAG_VERIFICATION_SERVICE)
    @SystemApi
    @SystemApi
    public static final class VerificationUserConfirmationInfo implements Parcelable {
    public static final class VerificationUserConfirmationInfo implements Parcelable {
        /**
         * Verification requires user intervention because of unknown reasons, such as when the
         * verifier times out or cannot be connected.
         */
        public static final int VERIFICATION_USER_ACTION_NEEDED_REASON_UNKNOWN = 0;

        /**
         * Verification requires user intervention because the network is unavailable.
         */
        public static final int VERIFICATION_USER_ACTION_NEEDED_REASON_NETWORK_UNAVAILABLE = 1;

        /**
         * Verification requires user intervention because the package is blocked.
         */
        public static final int VERIFICATION_USER_ACTION_NEEDED_REASON_PACKAGE_BLOCKED = 2;

        /**
         * @hide
         */
        @IntDef(value = {
                VERIFICATION_USER_ACTION_NEEDED_REASON_UNKNOWN,
                VERIFICATION_USER_ACTION_NEEDED_REASON_NETWORK_UNAVAILABLE,
                VERIFICATION_USER_ACTION_NEEDED_REASON_PACKAGE_BLOCKED,
        })
        @Retention(RetentionPolicy.SOURCE)
        public @interface UserActionNeededReason {
        }


        @VerificationPolicy
        @VerificationPolicy
        private int mVerificationPolicy;
        private int mVerificationPolicy;


        @UserActionNeededReason
        @VerificationFailedReason
        private int mVerificationUserActionNeededReason;
        private int mVerificationFailureReason;


        public VerificationUserConfirmationInfo() {
        public VerificationUserConfirmationInfo() {
        }
        }


        public VerificationUserConfirmationInfo(@VerificationPolicy int policy,
        public VerificationUserConfirmationInfo(@VerificationPolicy int policy,
                @UserActionNeededReason int reason) {
                @VerificationFailedReason int failureReason) {
            mVerificationPolicy = policy;
            mVerificationPolicy = policy;
            mVerificationUserActionNeededReason = reason;
            mVerificationFailureReason = failureReason;
        }
        }


        private VerificationUserConfirmationInfo(@NonNull Parcel in) {
        private VerificationUserConfirmationInfo(@NonNull Parcel in) {
            mVerificationPolicy = in.readInt();
            mVerificationPolicy = in.readInt();
            mVerificationUserActionNeededReason = in.readInt();
            mVerificationFailureReason = in.readInt();
        }
        }


        @VerificationPolicy
        @VerificationPolicy
@@ -5072,9 +5014,9 @@ public class PackageInstaller {
            return mVerificationPolicy;
            return mVerificationPolicy;
        }
        }


        @UserActionNeededReason
        @VerificationFailedReason
        public int getVerificationUserActionNeededReason() {
        public int getVerificationFailureReason() {
            return mVerificationUserActionNeededReason;
            return mVerificationFailureReason;
        }
        }


        @Override
        @Override
@@ -5085,7 +5027,7 @@ public class PackageInstaller {
        @Override
        @Override
        public void writeToParcel(@NonNull Parcel dest, int flags) {
        public void writeToParcel(@NonNull Parcel dest, int flags) {
            dest.writeInt(mVerificationPolicy);
            dest.writeInt(mVerificationPolicy);
            dest.writeInt(mVerificationUserActionNeededReason);
            dest.writeInt(mVerificationFailureReason);
        }
        }


        public static final @NonNull Parcelable.Creator<VerificationUserConfirmationInfo>
        public static final @NonNull Parcelable.Creator<VerificationUserConfirmationInfo>
@@ -5105,7 +5047,7 @@ public class PackageInstaller {
        public String toString() {
        public String toString() {
            return "VerificationUserConfirmationInfo{"
            return "VerificationUserConfirmationInfo{"
                    + "verificationPolicy=" + mVerificationPolicy
                    + "verificationPolicy=" + mVerificationPolicy
                    + ", verificationUserActionReason=" + mVerificationUserActionNeededReason
                    + ", vericationFailureReason=" + mVerificationFailureReason
                    + '}';
                    + '}';
        }
        }
    }
    }
+17 −19
Original line number Original line Diff line number Diff line
@@ -19,6 +19,9 @@ package com.android.packageinstaller;
import static android.content.pm.PackageInstaller.EXTRA_SESSION_ID;
import static android.content.pm.PackageInstaller.EXTRA_SESSION_ID;
import static android.content.pm.PackageInstaller.SessionInfo;
import static android.content.pm.PackageInstaller.SessionInfo;
import static android.content.pm.PackageInstaller.SessionInfo.INVALID_ID;
import static android.content.pm.PackageInstaller.SessionInfo.INVALID_ID;
import static android.content.pm.PackageInstaller.VERIFICATION_FAILED_REASON_NETWORK_UNAVAILABLE;
import static android.content.pm.PackageInstaller.VERIFICATION_FAILED_REASON_PACKAGE_BLOCKED;
import static android.content.pm.PackageInstaller.VERIFICATION_FAILED_REASON_UNKNOWN;
import static android.content.pm.PackageInstaller.VERIFICATION_POLICY_BLOCK_FAIL_OPEN;
import static android.content.pm.PackageInstaller.VERIFICATION_POLICY_BLOCK_FAIL_OPEN;
import static android.content.pm.PackageInstaller.VERIFICATION_POLICY_BLOCK_FAIL_WARN;
import static android.content.pm.PackageInstaller.VERIFICATION_POLICY_BLOCK_FAIL_WARN;
import static android.content.pm.PackageInstaller.VERIFICATION_USER_RESPONSE_CANCEL;
import static android.content.pm.PackageInstaller.VERIFICATION_USER_RESPONSE_CANCEL;
@@ -26,9 +29,6 @@ import static android.content.pm.PackageInstaller.VERIFICATION_USER_RESPONSE_ERR
import static android.content.pm.PackageInstaller.VERIFICATION_USER_RESPONSE_INSTALL_ANYWAY;
import static android.content.pm.PackageInstaller.VERIFICATION_USER_RESPONSE_INSTALL_ANYWAY;
import static android.content.pm.PackageInstaller.VERIFICATION_USER_RESPONSE_OK;
import static android.content.pm.PackageInstaller.VERIFICATION_USER_RESPONSE_OK;
import static android.content.pm.PackageInstaller.VERIFICATION_USER_RESPONSE_RETRY;
import static android.content.pm.PackageInstaller.VERIFICATION_USER_RESPONSE_RETRY;
import static android.content.pm.PackageInstaller.VerificationUserConfirmationInfo.VERIFICATION_USER_ACTION_NEEDED_REASON_NETWORK_UNAVAILABLE;
import static android.content.pm.PackageInstaller.VerificationUserConfirmationInfo.VERIFICATION_USER_ACTION_NEEDED_REASON_PACKAGE_BLOCKED;
import static android.content.pm.PackageInstaller.VerificationUserConfirmationInfo.VERIFICATION_USER_ACTION_NEEDED_REASON_UNKNOWN;


import static com.android.packageinstaller.PackageUtil.AppSnippet;
import static com.android.packageinstaller.PackageUtil.AppSnippet;


@@ -111,8 +111,8 @@ public class ConfirmVerification extends Activity {
        }
        }


        int dialogTypeFlag = getUserConfirmationDialogFlag(verificationInfo);
        int dialogTypeFlag = getUserConfirmationDialogFlag(verificationInfo);
        int userActionNeededReason = verificationInfo.getVerificationUserActionNeededReason();
        int failureReason = verificationInfo.getVerificationFailureReason();
        int msgResId = getDialogMessageResourceId(userActionNeededReason);
        int msgResId = getDialogMessageResourceId(failureReason);


        AlertDialog.Builder builder = new AlertDialog.Builder(this)
        AlertDialog.Builder builder = new AlertDialog.Builder(this)
                .setIcon(mAppSnippet.icon)
                .setIcon(mAppSnippet.icon)
@@ -160,8 +160,7 @@ public class ConfirmVerification extends Activity {
        } else {
        } else {
            // allow only acknowledging the error
            // allow only acknowledging the error
            builder.setPositiveButton(
            builder.setPositiveButton(
                    (userActionNeededReason
                    (failureReason == VERIFICATION_FAILED_REASON_PACKAGE_BLOCKED)
                            == VERIFICATION_USER_ACTION_NEEDED_REASON_PACKAGE_BLOCKED)
                            ? R.string.close
                            ? R.string.close
                            : R.string.ok,
                            : R.string.ok,
                    (dialog, which) -> {
                    (dialog, which) -> {
@@ -204,18 +203,17 @@ public class ConfirmVerification extends Activity {
    }
    }


    /**
    /**
     * Returns the correct type of dialog based on the verification policy and the reason for user
     * Returns the correct type of dialog based on the verification policy and the failure reason
     * action.
     */
     */
    public static int getUserConfirmationDialogFlag(
    public static int getUserConfirmationDialogFlag(
            VerificationUserConfirmationInfo verificationInfo) {
            VerificationUserConfirmationInfo verificationInfo) {
        int userActionNeededReason = verificationInfo.getVerificationUserActionNeededReason();
        int verificationFailureReason = verificationInfo.getVerificationFailureReason();
        int verificationPolicy = verificationInfo.getVerificationPolicy();
        int verificationPolicy = verificationInfo.getVerificationPolicy();


        return switch (userActionNeededReason) {
        return switch (verificationFailureReason) {
            case VERIFICATION_USER_ACTION_NEEDED_REASON_PACKAGE_BLOCKED -> 0;
            case VERIFICATION_FAILED_REASON_PACKAGE_BLOCKED -> 0;


            case VERIFICATION_USER_ACTION_NEEDED_REASON_NETWORK_UNAVAILABLE -> {
            case VERIFICATION_FAILED_REASON_NETWORK_UNAVAILABLE -> {
                int flag = FLAG_VERIFICATION_FAILED_MAY_RETRY;
                int flag = FLAG_VERIFICATION_FAILED_MAY_RETRY;
                if (verificationPolicy == VERIFICATION_POLICY_BLOCK_FAIL_OPEN
                if (verificationPolicy == VERIFICATION_POLICY_BLOCK_FAIL_OPEN
                        || verificationPolicy == VERIFICATION_POLICY_BLOCK_FAIL_WARN) {
                        || verificationPolicy == VERIFICATION_POLICY_BLOCK_FAIL_WARN) {
@@ -224,7 +222,7 @@ public class ConfirmVerification extends Activity {
                yield flag;
                yield flag;
            }
            }


            case VERIFICATION_USER_ACTION_NEEDED_REASON_UNKNOWN -> {
            case VERIFICATION_FAILED_REASON_UNKNOWN -> {
                int flag = 0;
                int flag = 0;
                if (verificationPolicy == VERIFICATION_POLICY_BLOCK_FAIL_OPEN
                if (verificationPolicy == VERIFICATION_POLICY_BLOCK_FAIL_OPEN
                        || verificationPolicy == VERIFICATION_POLICY_BLOCK_FAIL_WARN) {
                        || verificationPolicy == VERIFICATION_POLICY_BLOCK_FAIL_WARN) {
@@ -234,18 +232,18 @@ public class ConfirmVerification extends Activity {
            }
            }


            default -> {
            default -> {
                Log.e(TAG, "Unknown user action needed reason: " + userActionNeededReason);
                Log.e(TAG, "Unknown failure reason: " + verificationFailureReason);
                yield 0;
                yield 0;
            }
            }
        };
        };
    }
    }


    private int getDialogMessageResourceId(int userActionNeededReason) {
    private int getDialogMessageResourceId(int failureReason) {
        return switch (userActionNeededReason) {
        return switch (failureReason) {
            case VERIFICATION_USER_ACTION_NEEDED_REASON_UNKNOWN ->
            case VERIFICATION_FAILED_REASON_UNKNOWN ->
                    R.string.cannot_install_verification_unavailable_summary;
                    R.string.cannot_install_verification_unavailable_summary;


            case VERIFICATION_USER_ACTION_NEEDED_REASON_NETWORK_UNAVAILABLE ->
            case VERIFICATION_FAILED_REASON_NETWORK_UNAVAILABLE ->
                    R.string.verification_incomplete_summary;
                    R.string.verification_incomplete_summary;


            default -> R.string.cannot_install_package_summary;
            default -> R.string.cannot_install_package_summary;
+18 −20
Original line number Original line Diff line number Diff line
@@ -16,15 +16,15 @@


package com.android.packageinstaller.v2.ui.fragments;
package com.android.packageinstaller.v2.ui.fragments;


import static android.content.pm.PackageInstaller.VERIFICATION_FAILED_REASON_NETWORK_UNAVAILABLE;
import static android.content.pm.PackageInstaller.VERIFICATION_FAILED_REASON_PACKAGE_BLOCKED;
import static android.content.pm.PackageInstaller.VERIFICATION_FAILED_REASON_UNKNOWN;
import static android.content.pm.PackageInstaller.VERIFICATION_POLICY_BLOCK_FAIL_OPEN;
import static android.content.pm.PackageInstaller.VERIFICATION_POLICY_BLOCK_FAIL_OPEN;
import static android.content.pm.PackageInstaller.VERIFICATION_POLICY_BLOCK_FAIL_WARN;
import static android.content.pm.PackageInstaller.VERIFICATION_POLICY_BLOCK_FAIL_WARN;
import static android.content.pm.PackageInstaller.VERIFICATION_USER_RESPONSE_CANCEL;
import static android.content.pm.PackageInstaller.VERIFICATION_USER_RESPONSE_CANCEL;
import static android.content.pm.PackageInstaller.VERIFICATION_USER_RESPONSE_INSTALL_ANYWAY;
import static android.content.pm.PackageInstaller.VERIFICATION_USER_RESPONSE_INSTALL_ANYWAY;
import static android.content.pm.PackageInstaller.VERIFICATION_USER_RESPONSE_OK;
import static android.content.pm.PackageInstaller.VERIFICATION_USER_RESPONSE_OK;
import static android.content.pm.PackageInstaller.VERIFICATION_USER_RESPONSE_RETRY;
import static android.content.pm.PackageInstaller.VERIFICATION_USER_RESPONSE_RETRY;
import static android.content.pm.PackageInstaller.VerificationUserConfirmationInfo.VERIFICATION_USER_ACTION_NEEDED_REASON_NETWORK_UNAVAILABLE;
import static android.content.pm.PackageInstaller.VerificationUserConfirmationInfo.VERIFICATION_USER_ACTION_NEEDED_REASON_PACKAGE_BLOCKED;
import static android.content.pm.PackageInstaller.VerificationUserConfirmationInfo.VERIFICATION_USER_ACTION_NEEDED_REASON_UNKNOWN;


import static com.android.packageinstaller.ConfirmVerification.FLAG_VERIFICATION_FAILED_MAY_BYPASS;
import static com.android.packageinstaller.ConfirmVerification.FLAG_VERIFICATION_FAILED_MAY_BYPASS;
import static com.android.packageinstaller.ConfirmVerification.FLAG_VERIFICATION_FAILED_MAY_RETRY;
import static com.android.packageinstaller.ConfirmVerification.FLAG_VERIFICATION_FAILED_MAY_RETRY;
@@ -78,8 +78,8 @@ public class VerificationConfirmationFragment extends DialogFragment {
        VerificationUserConfirmationInfo verificationInfo = mDialogData.getVerificationInfo();
        VerificationUserConfirmationInfo verificationInfo = mDialogData.getVerificationInfo();
        assert verificationInfo != null;
        assert verificationInfo != null;
        int dialogTypeFlag = getUserConfirmationDialogFlag(verificationInfo);
        int dialogTypeFlag = getUserConfirmationDialogFlag(verificationInfo);
        int userActionNeededReasonReason = verificationInfo.getVerificationUserActionNeededReason();
        int failureReason = verificationInfo.getVerificationFailureReason();
        int msgResId = getDialogMessageResourceId(userActionNeededReasonReason);
        int msgResId = getDialogMessageResourceId(failureReason);


        AlertDialog.Builder builder = new AlertDialog.Builder(requireActivity())
        AlertDialog.Builder builder = new AlertDialog.Builder(requireActivity())
                .setIcon(mDialogData.getAppIcon())
                .setIcon(mDialogData.getAppIcon())
@@ -117,9 +117,8 @@ public class VerificationConfirmationFragment extends DialogFragment {
        } else {
        } else {
            // allow only acknowledging the error
            // allow only acknowledging the error
            builder.setPositiveButton(
            builder.setPositiveButton(
                    (userActionNeededReasonReason
                    (failureReason == VERIFICATION_FAILED_REASON_PACKAGE_BLOCKED) ? R.string.close
                            == VERIFICATION_USER_ACTION_NEEDED_REASON_PACKAGE_BLOCKED)
                            : R.string.ok,
                            ? R.string.close : R.string.ok,
                    (dialog, which) -> mInstallActionListener.setVerificationUserResponse(
                    (dialog, which) -> mInstallActionListener.setVerificationUserResponse(
                            VERIFICATION_USER_RESPONSE_OK));
                            VERIFICATION_USER_RESPONSE_OK));
        }
        }
@@ -164,18 +163,17 @@ public class VerificationConfirmationFragment extends DialogFragment {
    }
    }


    /**
    /**
     * Returns the correct type of dialog based on the verification policy and the reason for user
     * Returns the correct type of dialog based on the verification policy and the failure reason
     * action
     */
     */
    private int getUserConfirmationDialogFlag(
    private int getUserConfirmationDialogFlag(
            VerificationUserConfirmationInfo verificationInfo) {
            VerificationUserConfirmationInfo verificationInfo) {
        int userActionNeededReason = verificationInfo.getVerificationUserActionNeededReason();
        int verificationFailureReason = verificationInfo.getVerificationFailureReason();
        int verificationPolicy = verificationInfo.getVerificationPolicy();
        int verificationPolicy = verificationInfo.getVerificationPolicy();


        return switch (userActionNeededReason) {
        return switch (verificationFailureReason) {
            case VERIFICATION_USER_ACTION_NEEDED_REASON_PACKAGE_BLOCKED -> 0;
            case VERIFICATION_FAILED_REASON_PACKAGE_BLOCKED -> 0;


            case VERIFICATION_USER_ACTION_NEEDED_REASON_NETWORK_UNAVAILABLE -> {
            case VERIFICATION_FAILED_REASON_NETWORK_UNAVAILABLE -> {
                int flag = FLAG_VERIFICATION_FAILED_MAY_RETRY;
                int flag = FLAG_VERIFICATION_FAILED_MAY_RETRY;
                if (verificationPolicy == VERIFICATION_POLICY_BLOCK_FAIL_OPEN
                if (verificationPolicy == VERIFICATION_POLICY_BLOCK_FAIL_OPEN
                        || verificationPolicy == VERIFICATION_POLICY_BLOCK_FAIL_WARN) {
                        || verificationPolicy == VERIFICATION_POLICY_BLOCK_FAIL_WARN) {
@@ -184,7 +182,7 @@ public class VerificationConfirmationFragment extends DialogFragment {
                yield flag;
                yield flag;
            }
            }


            case VERIFICATION_USER_ACTION_NEEDED_REASON_UNKNOWN -> {
            case VERIFICATION_FAILED_REASON_UNKNOWN -> {
                int flag = 0;
                int flag = 0;
                if (verificationPolicy == VERIFICATION_POLICY_BLOCK_FAIL_OPEN
                if (verificationPolicy == VERIFICATION_POLICY_BLOCK_FAIL_OPEN
                        || verificationPolicy == VERIFICATION_POLICY_BLOCK_FAIL_WARN) {
                        || verificationPolicy == VERIFICATION_POLICY_BLOCK_FAIL_WARN) {
@@ -194,18 +192,18 @@ public class VerificationConfirmationFragment extends DialogFragment {
            }
            }


            default -> {
            default -> {
                Log.e(LOG_TAG, "Unknown user action needed reason: " + userActionNeededReason);
                Log.e(LOG_TAG, "Unknown failure reason: " + verificationFailureReason);
                yield 0;
                yield 0;
            }
            }
        };
        };
    }
    }


    private int getDialogMessageResourceId(int userActionNeededReason) {
    private int getDialogMessageResourceId(int failureReason) {
        return switch (userActionNeededReason) {
        return switch (failureReason) {
            case VERIFICATION_USER_ACTION_NEEDED_REASON_UNKNOWN ->
            case VERIFICATION_FAILED_REASON_UNKNOWN ->
                    R.string.cannot_install_verification_unavailable_summary;
                    R.string.cannot_install_verification_unavailable_summary;


            case VERIFICATION_USER_ACTION_NEEDED_REASON_NETWORK_UNAVAILABLE ->
            case VERIFICATION_FAILED_REASON_NETWORK_UNAVAILABLE ->
                    R.string.verification_incomplete_summary;
                    R.string.verification_incomplete_summary;


            default -> R.string.cannot_install_package_summary;
            default -> R.string.cannot_install_package_summary;
+80 −75

File changed.

Preview size limit exceeded, changes collapsed.