(TouchMode Permission 2.1/n) Add permission check when switching touch mode
This CL adds the following permission checks when switching touch mode state:
1. Allow touch mode switch if caller is granted with MODIFY_TOUCH_MODE_STATE;
2. If caller is not granted with MODIFY_TOUCH_MODE_STATE, touch mode
state change will be allowed if the caller's uid matches the focused
window owner's uid.
Touch mode switch will be denied if none of the conditions above match.
Bug: 198487159
Test: atest inputflinger_tests
Test: atest libinput_tests
Change-Id: Ic704682ac41fe470207d9be132b4c0f1a8019f39
diff --git a/services/inputflinger/dispatcher/InputDispatcher.h b/services/inputflinger/dispatcher/InputDispatcher.h
index 7564839..68950cb 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.h
+++ b/services/inputflinger/dispatcher/InputDispatcher.h
@@ -117,7 +117,7 @@
void setFocusedDisplay(int32_t displayId) override;
void setInputDispatchMode(bool enabled, bool frozen) override;
void setInputFilterEnabled(bool enabled) override;
- void setInTouchMode(bool inTouchMode) override;
+ bool setInTouchMode(bool inTouchMode, int32_t pid, int32_t uid, bool hasPermission) override;
void setMaximumObscuringOpacityForTouch(float opacity) override;
void setBlockUntrustedTouchesMode(android::os::BlockUntrustedTouchesMode mode) override;