WM: Fix input dispatch timeout for instrumented processes
Input dispatch timeout varies based on the process state. This state was queried when the ActivityRecord was reparented. But this happens too early and as a result the ActivityRecord always got a default timeout. Fix this by updating the timeout when attaching a process to ActivityRecord. Test: atest WmTests:ActivityRecordTests#testKeyDispatchTimeout Bug: 162542125 Change-Id: I85db6b652790affc85d3464cca98ff8da3bab73b
This commit is contained in:
@@ -95,6 +95,7 @@ import static android.content.res.Configuration.UI_MODE_TYPE_MASK;
|
||||
import static android.content.res.Configuration.UI_MODE_TYPE_VR_HEADSET;
|
||||
import static android.os.Build.VERSION_CODES.HONEYCOMB;
|
||||
import static android.os.Build.VERSION_CODES.O;
|
||||
import static android.os.InputConstants.DEFAULT_DISPATCHING_TIMEOUT_MILLIS;
|
||||
import static android.os.Process.SYSTEM_UID;
|
||||
import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
|
||||
import static android.view.Display.COLOR_MODE_DEFAULT;
|
||||
@@ -635,7 +636,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
||||
private boolean mOccludesParent;
|
||||
|
||||
// The input dispatching timeout for this application token in milliseconds.
|
||||
long mInputDispatchingTimeoutMillis;
|
||||
long mInputDispatchingTimeoutMillis = DEFAULT_DISPATCHING_TIMEOUT_MILLIS;
|
||||
|
||||
private boolean mShowWhenLocked;
|
||||
private boolean mInheritShownWhenLocked;
|
||||
@@ -1443,7 +1444,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
||||
if (oldParent == null && newParent != null) {
|
||||
// First time we are adding the activity to the system.
|
||||
mVoiceInteraction = newTask.voiceSession != null;
|
||||
mInputDispatchingTimeoutMillis = getInputDispatchingTimeoutMillisLocked(this);
|
||||
|
||||
// TODO(b/36505427): Maybe this call should be moved inside
|
||||
// updateOverrideConfiguration()
|
||||
@@ -1983,6 +1983,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
||||
task.setRootProcess(proc);
|
||||
}
|
||||
proc.addActivityIfNeeded(this);
|
||||
mInputDispatchingTimeoutMillis = getInputDispatchingTimeoutMillisLocked(this);
|
||||
|
||||
// Update the associated task fragment after setting the process, since it's required for
|
||||
// filtering to only report activities that belong to the same process.
|
||||
@@ -3562,6 +3563,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
||||
app.removeActivity(this, false /* keepAssociation */);
|
||||
}
|
||||
app = null;
|
||||
mInputDispatchingTimeoutMillis = DEFAULT_DISPATCHING_TIMEOUT_MILLIS;
|
||||
}
|
||||
|
||||
void makeFinishingLocked() {
|
||||
|
||||
@@ -41,6 +41,7 @@ import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET;
|
||||
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
|
||||
import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
|
||||
import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
|
||||
import static android.os.InputConstants.DEFAULT_DISPATCHING_TIMEOUT_MILLIS;
|
||||
import static android.os.Process.NOBODY_UID;
|
||||
import static android.view.Display.DEFAULT_DISPLAY;
|
||||
import static android.view.InsetsState.ITYPE_IME;
|
||||
@@ -84,6 +85,7 @@ import static com.android.server.wm.ActivityRecord.State.RESUMED;
|
||||
import static com.android.server.wm.ActivityRecord.State.STARTED;
|
||||
import static com.android.server.wm.ActivityRecord.State.STOPPED;
|
||||
import static com.android.server.wm.ActivityRecord.State.STOPPING;
|
||||
import static com.android.server.wm.ActivityTaskManagerService.INSTRUMENTATION_KEY_DISPATCHING_TIMEOUT_MILLIS;
|
||||
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_APP_TRANSITION;
|
||||
import static com.android.server.wm.TaskFragment.TASK_FRAGMENT_VISIBILITY_INVISIBLE;
|
||||
import static com.android.server.wm.TaskFragment.TASK_FRAGMENT_VISIBILITY_VISIBLE;
|
||||
@@ -3259,6 +3261,29 @@ public class ActivityRecordTests extends WindowTestsBase {
|
||||
CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED);
|
||||
}
|
||||
|
||||
@Test // b/162542125
|
||||
public void testInputDispatchTimeout() throws RemoteException {
|
||||
final ActivityRecord activity = createActivityWithTask();
|
||||
final WindowProcessController wpc = activity.app;
|
||||
spyOn(wpc);
|
||||
doReturn(true).when(wpc).isInstrumenting();
|
||||
final ActivityRecord instrumentingActivity = createActivityOnDisplay(
|
||||
true /* defaultDisplay */, wpc);
|
||||
assertEquals(INSTRUMENTATION_KEY_DISPATCHING_TIMEOUT_MILLIS,
|
||||
instrumentingActivity.mInputDispatchingTimeoutMillis);
|
||||
|
||||
doReturn(false).when(wpc).isInstrumenting();
|
||||
final ActivityRecord nonInstrumentingActivity = createActivityOnDisplay(
|
||||
true /* defaultDisplay */, wpc);
|
||||
assertEquals(DEFAULT_DISPATCHING_TIMEOUT_MILLIS,
|
||||
nonInstrumentingActivity.mInputDispatchingTimeoutMillis);
|
||||
|
||||
final ActivityRecord noProcActivity = createActivityOnDisplay(true /* defaultDisplay */,
|
||||
null);
|
||||
assertEquals(DEFAULT_DISPATCHING_TIMEOUT_MILLIS,
|
||||
noProcActivity.mInputDispatchingTimeoutMillis);
|
||||
}
|
||||
|
||||
private ICompatCameraControlCallback getCompatCameraControlCallback() {
|
||||
return new ICompatCameraControlCallback.Stub() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user