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

Commit 1971ba5d authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Unify dispatching timeout constants

The same constant is defined today with slightly different names in both
WindowMananagerService and ActivityTaskManagerService. To prevent
proliferation, make a constant in aidl and use it here.

Also, the two constants used to be in either nanoseconds or
milliseconds.

Make all constants in milliseconds because aidl does not support "const
long", and 5 seconds' worth of nanoseconds does not fit into an int.

Bug: 143459140
Test: interact with device after booting
Test: adb shell dumpsys input

Change-Id: Ia9b3f56d8eddcc6f2f0132bac9254655b180837f

Change-Id: If4d40b63c41f6fb54b99d167da8db1924945f3ef
parent dab36502
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -350,7 +350,8 @@ public abstract class ActivityManagerInternal {
    /** @see com.android.server.am.ActivityManagerService#monitor */
    public abstract void monitor();

    /** Input dispatch timeout to a window, start the ANR process. */
    /** Input dispatch timeout to a window, start the ANR process. Return the timeout extension,
     * in milliseconds, or 0 to abort dispatch. */
    public abstract long inputDispatchingTimedOut(int pid, boolean aboveSystem, String reason);
    public abstract boolean inputDispatchingTimedOut(Object proc, String activityShortComponentName,
            ApplicationInfo aInfo, String parentShortComponentName, Object parentProc,
+2 −2
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ public final class InputApplicationHandle {
    public String name;

    // Dispatching timeout.
    public long dispatchingTimeoutNanos;
    public long dispatchingTimeoutMillis;

    public final IBinder token;

@@ -46,7 +46,7 @@ public final class InputApplicationHandle {

    public InputApplicationHandle(InputApplicationHandle handle) {
        this.token = handle.token;
        this.dispatchingTimeoutNanos = handle.dispatchingTimeoutNanos;
        this.dispatchingTimeoutMillis = handle.dispatchingTimeoutMillis;
        this.name = handle.name;
    }

+1 −1
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ public final class InputWindowHandle {
    public int layoutParamsType;

    // Dispatching timeout.
    public long dispatchingTimeoutNanos;
    public long dispatchingTimeoutMillis;

    // Window frame.
    public int frameLeft;
+5 −6
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ namespace android {
static struct {
    jfieldID ptr;
    jfieldID name;
    jfieldID dispatchingTimeoutNanos;
    jfieldID dispatchingTimeoutMillis;
    jfieldID token;
} gInputApplicationHandleClassInfo;

@@ -61,8 +61,8 @@ bool NativeInputApplicationHandle::updateInfo() {

    mInfo.name = getStringField(env, obj, gInputApplicationHandleClassInfo.name, "<null>");

    mInfo.dispatchingTimeoutNanos =
            env->GetLongField(obj, gInputApplicationHandleClassInfo.dispatchingTimeoutNanos);
    mInfo.dispatchingTimeoutMillis =
            env->GetLongField(obj, gInputApplicationHandleClassInfo.dispatchingTimeoutMillis);

    jobject tokenObj = env->GetObjectField(obj,
            gInputApplicationHandleClassInfo.token);
@@ -144,9 +144,8 @@ int register_android_view_InputApplicationHandle(JNIEnv* env) {
    GET_FIELD_ID(gInputApplicationHandleClassInfo.name, clazz,
            "name", "Ljava/lang/String;");

    GET_FIELD_ID(gInputApplicationHandleClassInfo.dispatchingTimeoutNanos,
            clazz,
            "dispatchingTimeoutNanos", "J");
    GET_FIELD_ID(gInputApplicationHandleClassInfo.dispatchingTimeoutMillis, clazz,
                 "dispatchingTimeoutMillis", "J");

    GET_FIELD_ID(gInputApplicationHandleClassInfo.token, clazz,
            "token", "Landroid/os/IBinder;");
+5 −5
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ static struct {
    jfieldID name;
    jfieldID layoutParamsFlags;
    jfieldID layoutParamsType;
    jfieldID dispatchingTimeoutNanos;
    jfieldID dispatchingTimeoutMillis;
    jfieldID frameLeft;
    jfieldID frameTop;
    jfieldID frameRight;
@@ -118,8 +118,8 @@ bool NativeInputWindowHandle::updateInfo() {
            env->GetIntField(obj, gInputWindowHandleClassInfo.layoutParamsFlags));
    mInfo.type = static_cast<InputWindowInfo::Type>(
            env->GetIntField(obj, gInputWindowHandleClassInfo.layoutParamsType));
    mInfo.dispatchingTimeout = decltype(mInfo.dispatchingTimeout)(
            env->GetLongField(obj, gInputWindowHandleClassInfo.dispatchingTimeoutNanos));
    mInfo.dispatchingTimeout = std::chrono::milliseconds(
            env->GetLongField(obj, gInputWindowHandleClassInfo.dispatchingTimeoutMillis));
    mInfo.frameLeft = env->GetIntField(obj,
            gInputWindowHandleClassInfo.frameLeft);
    mInfo.frameTop = env->GetIntField(obj,
@@ -293,8 +293,8 @@ int register_android_view_InputWindowHandle(JNIEnv* env) {
    GET_FIELD_ID(gInputWindowHandleClassInfo.layoutParamsType, clazz,
            "layoutParamsType", "I");

    GET_FIELD_ID(gInputWindowHandleClassInfo.dispatchingTimeoutNanos, clazz,
            "dispatchingTimeoutNanos", "J");
    GET_FIELD_ID(gInputWindowHandleClassInfo.dispatchingTimeoutMillis, clazz,
                 "dispatchingTimeoutMillis", "J");

    GET_FIELD_ID(gInputWindowHandleClassInfo.frameLeft, clazz,
            "frameLeft", "I");
Loading