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

Commit 1686fa0f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Separate window and monitor ANR notifications"

parents 99db18e2 7fe1f0d4
Loading
Loading
Loading
Loading
+12 −20
Original line number Diff line number Diff line
@@ -2328,33 +2328,25 @@ public class InputManagerService extends IInputManager.Stub
    }

    // Native callback
    private void notifyConnectionUnresponsive(IBinder token, String reason) {
        Integer gestureMonitorPid;
        synchronized (mGestureMonitorPidsLock) {
            gestureMonitorPid = mGestureMonitorPidsByToken.get(token);
        }
        if (gestureMonitorPid != null) {
            mWindowManagerCallbacks.notifyGestureMonitorUnresponsive(gestureMonitorPid, reason);
            return;
        }
        // If we couldn't find a gesture monitor for this token, it's a window
    private void notifyWindowUnresponsive(IBinder token, String reason) {
        mWindowManagerCallbacks.notifyWindowUnresponsive(token, reason);
    }

    // Native callback
    private void notifyConnectionResponsive(IBinder token) {
        Integer gestureMonitorPid;
        synchronized (mGestureMonitorPidsLock) {
            gestureMonitorPid = mGestureMonitorPidsByToken.get(token);
        }
        if (gestureMonitorPid != null) {
            mWindowManagerCallbacks.notifyGestureMonitorResponsive(gestureMonitorPid);
            return;
    private void notifyMonitorUnresponsive(int pid, String reason) {
        mWindowManagerCallbacks.notifyGestureMonitorUnresponsive(pid, reason);
    }
        // If we couldn't find a gesture monitor for this token, it's a window

    // Native callback
    private void notifyWindowResponsive(IBinder token) {
        mWindowManagerCallbacks.notifyWindowResponsive(token);
    }

    // Native callback
    private void notifyMonitorResponsive(int pid) {
        mWindowManagerCallbacks.notifyGestureMonitorResponsive(pid);
    }

    // Native callback.
    private void notifySensorEvent(int deviceId, int sensorType, int accuracy, long timestamp,
            float[] values) {
+57 −16
Original line number Diff line number Diff line
@@ -98,8 +98,10 @@ static struct {
    jmethodID notifySwitch;
    jmethodID notifyInputChannelBroken;
    jmethodID notifyNoFocusedWindowAnr;
    jmethodID notifyConnectionUnresponsive;
    jmethodID notifyConnectionResponsive;
    jmethodID notifyWindowUnresponsive;
    jmethodID notifyWindowResponsive;
    jmethodID notifyMonitorUnresponsive;
    jmethodID notifyMonitorResponsive;
    jmethodID notifyFocusChanged;
    jmethodID notifySensorEvent;
    jmethodID notifySensorAccuracy;
@@ -288,9 +290,13 @@ public:
    void notifySwitch(nsecs_t when, uint32_t switchValues, uint32_t switchMask,
                      uint32_t policyFlags) override;
    void notifyConfigurationChanged(nsecs_t when) override;
    // ANR-related callbacks -- start
    void notifyNoFocusedWindowAnr(const std::shared_ptr<InputApplicationHandle>& handle) override;
    void notifyConnectionUnresponsive(const sp<IBinder>& token, const std::string& reason) override;
    void notifyConnectionResponsive(const sp<IBinder>& token) override;
    void notifyWindowUnresponsive(const sp<IBinder>& token, const std::string& reason) override;
    void notifyWindowResponsive(const sp<IBinder>& token) override;
    void notifyMonitorUnresponsive(int32_t pid, const std::string& reason) override;
    void notifyMonitorResponsive(int32_t pid) override;
    // ANR-related callbacks -- end
    void notifyInputChannelBroken(const sp<IBinder>& token) override;
    void notifyFocusChanged(const sp<IBinder>& oldToken, const sp<IBinder>& newToken) override;
    void notifySensorEvent(int32_t deviceId, InputDeviceSensorType sensorType,
@@ -775,10 +781,10 @@ void NativeInputManager::notifyNoFocusedWindowAnr(
    checkAndClearExceptionFromCallback(env, "notifyNoFocusedWindowAnr");
}

void NativeInputManager::notifyConnectionUnresponsive(const sp<IBinder>& token,
void NativeInputManager::notifyWindowUnresponsive(const sp<IBinder>& token,
                                                  const std::string& reason) {
#if DEBUG_INPUT_DISPATCHER_POLICY
    ALOGD("notifyConnectionUnresponsive");
    ALOGD("notifyWindowUnresponsive");
#endif
    ATRACE_CALL();

@@ -788,14 +794,14 @@ void NativeInputManager::notifyConnectionUnresponsive(const sp<IBinder>& token,
    jobject tokenObj = javaObjectForIBinder(env, token);
    ScopedLocalRef<jstring> reasonObj(env, env->NewStringUTF(reason.c_str()));

    env->CallVoidMethod(mServiceObj, gServiceClassInfo.notifyConnectionUnresponsive, tokenObj,
    env->CallVoidMethod(mServiceObj, gServiceClassInfo.notifyWindowUnresponsive, tokenObj,
                        reasonObj.get());
    checkAndClearExceptionFromCallback(env, "notifyConnectionUnresponsive");
    checkAndClearExceptionFromCallback(env, "notifyWindowUnresponsive");
}

void NativeInputManager::notifyConnectionResponsive(const sp<IBinder>& token) {
void NativeInputManager::notifyWindowResponsive(const sp<IBinder>& token) {
#if DEBUG_INPUT_DISPATCHER_POLICY
    ALOGD("notifyConnectionResponsive");
    ALOGD("notifyWindowResponsive");
#endif
    ATRACE_CALL();

@@ -804,8 +810,37 @@ void NativeInputManager::notifyConnectionResponsive(const sp<IBinder>& token) {

    jobject tokenObj = javaObjectForIBinder(env, token);

    env->CallVoidMethod(mServiceObj, gServiceClassInfo.notifyConnectionResponsive, tokenObj);
    checkAndClearExceptionFromCallback(env, "notifyConnectionResponsive");
    env->CallVoidMethod(mServiceObj, gServiceClassInfo.notifyWindowResponsive, tokenObj);
    checkAndClearExceptionFromCallback(env, "notifyWindowResponsive");
}

void NativeInputManager::notifyMonitorUnresponsive(int32_t pid, const std::string& reason) {
#if DEBUG_INPUT_DISPATCHER_POLICY
    ALOGD("notifyMonitorUnresponsive");
#endif
    ATRACE_CALL();

    JNIEnv* env = jniEnv();
    ScopedLocalFrame localFrame(env);

    ScopedLocalRef<jstring> reasonObj(env, env->NewStringUTF(reason.c_str()));

    env->CallVoidMethod(mServiceObj, gServiceClassInfo.notifyMonitorUnresponsive, pid,
                        reasonObj.get());
    checkAndClearExceptionFromCallback(env, "notifyMonitorUnresponsive");
}

void NativeInputManager::notifyMonitorResponsive(int32_t pid) {
#if DEBUG_INPUT_DISPATCHER_POLICY
    ALOGD("notifyMonitorResponsive");
#endif
    ATRACE_CALL();

    JNIEnv* env = jniEnv();
    ScopedLocalFrame localFrame(env);

    env->CallVoidMethod(mServiceObj, gServiceClassInfo.notifyMonitorResponsive, pid);
    checkAndClearExceptionFromCallback(env, "notifyMonitorResponsive");
}

void NativeInputManager::notifyInputChannelBroken(const sp<IBinder>& token) {
@@ -2202,12 +2237,18 @@ int register_android_server_InputManager(JNIEnv* env) {
    GET_METHOD_ID(gServiceClassInfo.notifyNoFocusedWindowAnr, clazz, "notifyNoFocusedWindowAnr",
                  "(Landroid/view/InputApplicationHandle;)V");

    GET_METHOD_ID(gServiceClassInfo.notifyConnectionUnresponsive, clazz,
                  "notifyConnectionUnresponsive", "(Landroid/os/IBinder;Ljava/lang/String;)V");
    GET_METHOD_ID(gServiceClassInfo.notifyWindowUnresponsive, clazz, "notifyWindowUnresponsive",
                  "(Landroid/os/IBinder;Ljava/lang/String;)V");

    GET_METHOD_ID(gServiceClassInfo.notifyConnectionResponsive, clazz, "notifyConnectionResponsive",
    GET_METHOD_ID(gServiceClassInfo.notifyMonitorUnresponsive, clazz, "notifyMonitorUnresponsive",
                  "(ILjava/lang/String;)V");

    GET_METHOD_ID(gServiceClassInfo.notifyWindowResponsive, clazz, "notifyWindowResponsive",
                  "(Landroid/os/IBinder;)V");

    GET_METHOD_ID(gServiceClassInfo.notifyMonitorResponsive, clazz, "notifyMonitorResponsive",
                  "(I)V");

    GET_METHOD_ID(gServiceClassInfo.filterInputEvent, clazz,
            "filterInputEvent", "(Landroid/view/InputEvent;I)Z");