Change the timeout for integrity verification from 10 seconds to 30 seconds.

Context: https://buganizer.corp.google.com/issues/154486093#comment24

Bug: 154486093
Test: N/A
Change-Id: I4fae3401ad7323acfa9cc520aac0cbb6bdbf6ada
This commit is contained in:
Song Pan
2020-04-30 16:38:51 +01:00
parent b1b07971f1
commit 74b5e72f17
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,