Merge "Change the timeout for integrity verification from 10 seconds to 30 seconds." into rvc-dev am: bc9515e4b9

Change-Id: I395f77ed3a958cad6957d9b7ca5c724fcff27a4b
This commit is contained in:
TreeHugger Robot
2020-05-13 22:43:56 +00:00
committed by Automerger Merge Worker
3 changed files with 28 additions and 4 deletions

View File

@@ -9936,6 +9936,11 @@ public final class Settings {
* @hide */
public static final String PACKAGE_VERIFIER_TIMEOUT = "verifier_timeout";
/** Timeout for app integrity verification.
* @hide */
public static final String APP_INTEGRITY_VERIFICATION_TIMEOUT =
"app_integrity_verification_timeout";
/** Default response code for package verification.
* @hide */
public static final String PACKAGE_VERIFIER_DEFAULT_RESPONSE = "verifier_default_response";

View File

@@ -588,8 +588,9 @@ public class SettingsBackupTest {
Settings.Global.POWER_BUTTON_VERY_LONG_PRESS,
Settings.Global.SHOW_MEDIA_ON_QUICK_SETTINGS, // Temporary for R beta
Settings.Global.INTEGRITY_CHECK_INCLUDES_RULE_PROVIDER,
Settings.Global.ADVANCED_BATTERY_USAGE_AMOUNT,
Settings.Global.CACHED_APPS_FREEZER_ENABLED);
Settings.Global.CACHED_APPS_FREEZER_ENABLED,
Settings.Global.APP_INTEGRITY_VERIFICATION_TIMEOUT,
Settings.Global.ADVANCED_BATTERY_USAGE_AMOUNT);
private static final Set<String> BACKUP_BLACKLISTED_SECURE_SETTINGS =
newHashSet(

View File

@@ -607,6 +607,12 @@ public class PackageManagerService extends IPackageManager.Stub
*/
private static final long DEFAULT_VERIFICATION_TIMEOUT = 10 * 1000;
/**
* The default maximum time to wait for the integrity verification to return in
* milliseconds.
*/
private static final long DEFAULT_INTEGRITY_VERIFICATION_TIMEOUT = 30 * 1000;
/**
* Timeout duration in milliseconds for enabling package rollback. If we fail to enable
* rollback within that period, the install will proceed without rollback enabled.
@@ -13837,6 +13843,19 @@ public class PackageManagerService extends IPackageManager.Stub
return Math.max(timeout, DEFAULT_VERIFICATION_TIMEOUT);
}
/**
* Get the integrity verification timeout.
*
* @return verification timeout in milliseconds
*/
private long getIntegrityVerificationTimeout() {
long timeout = Global.getLong(mContext.getContentResolver(),
Global.APP_INTEGRITY_VERIFICATION_TIMEOUT, DEFAULT_INTEGRITY_VERIFICATION_TIMEOUT);
// The setting can be used to increase the timeout but not decrease it, since that is
// equivalent to disabling the integrity component.
return Math.max(timeout, DEFAULT_INTEGRITY_VERIFICATION_TIMEOUT);
}
/**
* Get the default verification agent response code.
*
@@ -15032,8 +15051,7 @@ public class PackageManagerService extends IPackageManager.Stub
final Message msg =
mHandler.obtainMessage(CHECK_PENDING_INTEGRITY_VERIFICATION);
msg.arg1 = verificationId;
// TODO: do we want to use the same timeout?
mHandler.sendMessageDelayed(msg, getVerificationTimeout());
mHandler.sendMessageDelayed(msg, getIntegrityVerificationTimeout());
}
}, /* scheduler= */ null,
/* initialCode= */ 0,