Merge "Add support for a hw_timeout_multiplier system property." am: 7fe1ca63df am: 3c8dbe30d6

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1556750

Change-Id: Iaec0f4e259ebb1251c534fbf01081f89272c44b7
This commit is contained in:
Peter Collingbourne
2021-03-17 20:49:31 +00:00
committed by Automerger Merge Worker
9 changed files with 45 additions and 23 deletions

View File

@@ -31,6 +31,7 @@ import android.content.Intent;
import android.content.ServiceConnection;
import android.net.Uri;
import android.os.Binder;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
@@ -73,11 +74,12 @@ public final class JobServiceContext implements ServiceConnection {
private static final String TAG = "JobServiceContext";
/** Amount of time a job is allowed to execute for before being considered timed-out. */
public static final long EXECUTING_TIMESLICE_MILLIS = 10 * 60 * 1000; // 10mins.
public static final long EXECUTING_TIMESLICE_MILLIS =
10 * 60 * 1000 * Build.HW_TIMEOUT_MULTIPLIER; // 10mins.
/** Amount of time the JobScheduler waits for the initial service launch+bind. */
private static final long OP_BIND_TIMEOUT_MILLIS = 18 * 1000;
private static final long OP_BIND_TIMEOUT_MILLIS = 18 * 1000 * Build.HW_TIMEOUT_MULTIPLIER;
/** Amount of time the JobScheduler will wait for a response from an app for a message. */
private static final long OP_TIMEOUT_MILLIS = 8 * 1000;
private static final long OP_TIMEOUT_MILLIS = 8 * 1000 * Build.HW_TIMEOUT_MULTIPLIER;
private static final String[] VERB_STRINGS = {
"VERB_BINDING", "VERB_STARTING", "VERB_EXECUTING", "VERB_STOPPING", "VERB_FINISHED"

View File

@@ -744,7 +744,7 @@ public abstract class ContentResolver implements ContentInterface {
// Always log queries which take 500ms+; shorter queries are
// sampled accordingly.
private static final boolean ENABLE_CONTENT_SAMPLE = false;
private static final int SLOW_THRESHOLD_MILLIS = 500;
private static final int SLOW_THRESHOLD_MILLIS = 500 * Build.HW_TIMEOUT_MULTIPLIER;
private final Random mRandom = new Random(); // guarded by itself
/** @hide */
@@ -758,7 +758,8 @@ public abstract class ContentResolver implements ContentInterface {
* before we decide it must be hung.
* @hide
*/
public static final int CONTENT_PROVIDER_PUBLISH_TIMEOUT_MILLIS = 10 * 1000;
public static final int CONTENT_PROVIDER_PUBLISH_TIMEOUT_MILLIS =
10 * 1000 * Build.HW_TIMEOUT_MULTIPLIER;
/**
* How long we wait for an provider to be published. Should be longer than
@@ -766,10 +767,11 @@ public abstract class ContentResolver implements ContentInterface {
* @hide
*/
public static final int CONTENT_PROVIDER_READY_TIMEOUT_MILLIS =
CONTENT_PROVIDER_PUBLISH_TIMEOUT_MILLIS + 10 * 1000;
CONTENT_PROVIDER_PUBLISH_TIMEOUT_MILLIS + 10 * 1000 * Build.HW_TIMEOUT_MULTIPLIER;
// Timeout given a ContentProvider that has already been started and connected to.
private static final int CONTENT_PROVIDER_TIMEOUT_MILLIS = 3 * 1000;
private static final int CONTENT_PROVIDER_TIMEOUT_MILLIS =
3 * 1000 * Build.HW_TIMEOUT_MULTIPLIER;
// Should be >= {@link #CONTENT_PROVIDER_WAIT_TIMEOUT_MILLIS}, because that's how
// long ActivityManagerService is giving a content provider to get published if a new process

View File

@@ -1115,6 +1115,18 @@ public class Build {
}
}
/**
* A multiplier for various timeouts on the system.
*
* The intent is that products targeting software emulators that are orders of magnitude slower
* than real hardware may set this to a large number. On real devices and hardware-accelerated
* virtualized devices this should not be set.
*
* @hide
*/
public static final int HW_TIMEOUT_MULTIPLIER =
SystemProperties.getInt("ro.hw_timeout_multiplier", 1);
/**
* True if Treble is enabled and required for this device.
*

View File

@@ -75,7 +75,8 @@ public class Watchdog extends Thread {
// can trigger the watchdog.
// Note 2: The debug value is already below the wait time in ZygoteConnection. Wrapped
// applications may not work with a debug build. CTS will fail.
private static final long DEFAULT_TIMEOUT = DB ? 10 * 1000 : 60 * 1000;
private static final long DEFAULT_TIMEOUT =
(DB ? 10 * 1000 : 60 * 1000) * Build.HW_TIMEOUT_MULTIPLIER;
private static final long CHECK_INTERVAL = DEFAULT_TIMEOUT / 2;
// These are temporally ordered: larger values as lateness increases

View File

@@ -140,14 +140,14 @@ public final class ActiveServices {
private static final int DEBUG_FGS_ENFORCE_TYPE = 1;
// How long we wait for a service to finish executing.
static final int SERVICE_TIMEOUT = 20*1000;
static final int SERVICE_TIMEOUT = 20 * 1000 * Build.HW_TIMEOUT_MULTIPLIER;
// How long we wait for a service to finish executing.
static final int SERVICE_BACKGROUND_TIMEOUT = SERVICE_TIMEOUT * 10;
// How long the startForegroundService() grace period is to get around to
// calling startForeground() before we ANR + stop it.
static final int SERVICE_START_FOREGROUND_TIMEOUT = 10*1000;
static final int SERVICE_START_FOREGROUND_TIMEOUT = 10 * 1000 * Build.HW_TIMEOUT_MULTIPLIER;
final ActivityManagerService mAm;

View File

@@ -478,7 +478,7 @@ public class ActivityManagerService extends IActivityManager.Stub
// How long we wait for a launched process to attach to the activity manager
// before we decide it's never going to come up for real.
static final int PROC_START_TIMEOUT = 10*1000;
static final int PROC_START_TIMEOUT = 10 * 1000 * Build.HW_TIMEOUT_MULTIPLIER;
// How long we wait to kill an application zygote, after the last process using
// it has gone away.
static final int KILL_APP_ZYGOTE_DELAY_MS = 5 * 1000;
@@ -490,8 +490,8 @@ public class ActivityManagerService extends IActivityManager.Stub
static final int PROC_START_TIMEOUT_WITH_WRAPPER = 1200*1000;
// How long we allow a receiver to run before giving up on it.
static final int BROADCAST_FG_TIMEOUT = 10*1000;
static final int BROADCAST_BG_TIMEOUT = 60*1000;
static final int BROADCAST_FG_TIMEOUT = 10 * 1000 * Build.HW_TIMEOUT_MULTIPLIER;
static final int BROADCAST_BG_TIMEOUT = 60 * 1000 * Build.HW_TIMEOUT_MULTIPLIER;
public static final int MY_PID = myPid();
@@ -573,7 +573,8 @@ public class ActivityManagerService extends IActivityManager.Stub
private static final int MAX_BUGREPORT_TITLE_SIZE = 50;
private static final int MAX_BUGREPORT_DESCRIPTION_SIZE = 150;
private static final int NATIVE_DUMP_TIMEOUT_MS = 2000; // 2 seconds;
private static final int NATIVE_DUMP_TIMEOUT_MS =
2000 * Build.HW_TIMEOUT_MULTIPLIER; // 2 seconds;
private static final int JAVA_DUMP_MINIMUM_SIZE = 100; // 100 bytes.
OomAdjuster mOomAdjuster;

View File

@@ -18,6 +18,7 @@ package com.android.server.am;
import android.content.ContentResolver;
import android.database.ContentObserver;
import android.os.Build;
import android.os.Handler;
import android.provider.Settings;
import android.util.KeyValueListParser;
@@ -42,12 +43,13 @@ public class BroadcastConstants {
"bcast_allow_bg_activity_start_timeout";
// All time intervals are in milliseconds
private static final long DEFAULT_TIMEOUT = 10_000;
private static final long DEFAULT_SLOW_TIME = 5_000;
private static final long DEFAULT_DEFERRAL = 5_000;
private static final long DEFAULT_TIMEOUT = 10_000 * Build.HW_TIMEOUT_MULTIPLIER;
private static final long DEFAULT_SLOW_TIME = 5_000 * Build.HW_TIMEOUT_MULTIPLIER;
private static final long DEFAULT_DEFERRAL = 5_000 * Build.HW_TIMEOUT_MULTIPLIER;
private static final float DEFAULT_DEFERRAL_DECAY_FACTOR = 0.75f;
private static final long DEFAULT_DEFERRAL_FLOOR = 0;
private static final long DEFAULT_ALLOW_BG_ACTIVITY_START_TIMEOUT = 10_000;
private static final long DEFAULT_ALLOW_BG_ACTIVITY_START_TIMEOUT =
10_000 * Build.HW_TIMEOUT_MULTIPLIER;
// All time constants are in milliseconds

View File

@@ -110,6 +110,7 @@ import android.content.pm.UserInfo;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
import android.os.Debug;
import android.os.Handler;
@@ -165,13 +166,13 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
static final String TAG_TASKS = TAG + POSTFIX_TASKS;
/** How long we wait until giving up on the last activity telling us it is idle. */
private static final int IDLE_TIMEOUT = 10 * 1000;
private static final int IDLE_TIMEOUT = 10 * 1000 * Build.HW_TIMEOUT_MULTIPLIER;
/** How long we can hold the sleep wake lock before giving up. */
private static final int SLEEP_TIMEOUT = 5 * 1000;
private static final int SLEEP_TIMEOUT = 5 * 1000 * Build.HW_TIMEOUT_MULTIPLIER;
// How long we can hold the launch wake lock before giving up.
private static final int LAUNCH_TIMEOUT = 10 * 1000;
private static final int LAUNCH_TIMEOUT = 10 * 1000 * Build.HW_TIMEOUT_MULTIPLIER;
/** How long we wait until giving up on the activity telling us it released the top state. */
private static final int TOP_RESUMED_STATE_LOSS_TIMEOUT = 500;

View File

@@ -312,9 +312,10 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
private static final String TAG_CONFIGURATION = TAG + POSTFIX_CONFIGURATION;
// How long we wait until we timeout on key dispatching.
public static final int KEY_DISPATCHING_TIMEOUT_MS = 5 * 1000;
public static final int KEY_DISPATCHING_TIMEOUT_MS = 5 * 1000 * Build.HW_TIMEOUT_MULTIPLIER;
// How long we wait until we timeout on key dispatching during instrumentation.
static final int INSTRUMENTATION_KEY_DISPATCHING_TIMEOUT_MS = 60 * 1000;
static final int INSTRUMENTATION_KEY_DISPATCHING_TIMEOUT_MS =
60 * 1000 * Build.HW_TIMEOUT_MULTIPLIER;
// How long we permit background activity starts after an activity in the process
// started or finished.
static final long ACTIVITY_BG_START_GRACE_PERIOD_MS = 10 * 1000;