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

Commit a6cfe52e authored by rich cannings's avatar rich cannings
Browse files

Allow APKs to install when verifier times out.

When app verfication is enabled and the verifier times out, allow
PackageManagerService to continue with the installation.

Bug: 6531120
Change-Id: Ic6aef755af92588e8887c918b70fb195c683b24c
parent 9bc26c0d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -4255,6 +4255,9 @@ public final class Settings {
        /** Timeout for package verification. {@hide} */
        public static final String PACKAGE_VERIFIER_TIMEOUT = "verifier_timeout";

        /** Default response code for package verification. {@hide} */
        public static final String PACKAGE_VERIFIER_DEFAULT_RESPONSE = "verifier_default_response";

        /** {@hide} */
        public static final String
                READ_EXTERNAL_STORAGE_ENFORCED_DEFAULT = "read_external_storage_enforced_default";
+31 −1
Original line number Diff line number Diff line
@@ -206,6 +206,14 @@ public class PackageManagerService extends IPackageManager.Stub {
     */
    private static final long DEFAULT_VERIFICATION_TIMEOUT = 10 * 1000;

    /**
     * The default response for package verification timeout.
     *
     * This can be either PackageManager.VERIFICATION_ALLOW or
     * PackageManager.VERIFICATION_REJECT.
     */
    private static final int DEFAULT_VERIFICATION_RESPONSE = PackageManager.VERIFICATION_ALLOW;

    static final String DEFAULT_CONTAINER_PACKAGE = "com.android.defcontainer";

    static final ComponentName DEFAULT_CONTAINER_COMPONENT = new ComponentName(
@@ -765,7 +773,18 @@ public class PackageManagerService extends IPackageManager.Stub {
                        Slog.i(TAG, "Verification timed out for " + args.packageURI.toString());
                        mPendingVerification.remove(verificationId);

                        int ret = PackageManager.INSTALL_FAILED_VERIFICATION_TIMEOUT;
                        int ret = PackageManager.INSTALL_FAILED_VERIFICATION_FAILURE;

                        if (getDefaultVerificationResponse() == PackageManager.VERIFICATION_ALLOW) {
                          Slog.i(TAG, "Continuing with installation of " + args.packageURI.toString());
                          state.setVerifierResponse(Binder.getCallingUid(), PackageManager.VERIFICATION_ALLOW_WITHOUT_SUFFICIENT);
                          try {
                              ret = args.copyApk(mContainerService, true);
                          } catch (RemoteException e) {
                              Slog.e(TAG, "Could not contact the ContainerService");
                          }
                        }

                        processPendingInstall(args, ret);

                        mHandler.sendEmptyMessage(MCS_UNBIND);
@@ -5417,6 +5436,17 @@ public class PackageManagerService extends IPackageManager.Stub {
                DEFAULT_VERIFICATION_TIMEOUT);
    }

    /**
     * Get the default verification agent response code.
     *
     * @return default verification response code
     */
    private int getDefaultVerificationResponse() {
        return android.provider.Settings.Secure.getInt(mContext.getContentResolver(),
                android.provider.Settings.Secure.PACKAGE_VERIFIER_DEFAULT_RESPONSE,
                DEFAULT_VERIFICATION_RESPONSE);
    }

    /**
     * Check whether or not package verification has been enabled.
     *