mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-12-04 21:27:41 +08:00
add View::onFilterTouchEventForSecurity
This commit is contained in:
parent
18acce3218
commit
316f8996f3
@ -143,7 +143,10 @@ View::View(Context*ctx,const AttributeSet&attrs){
|
||||
setPivotY(attrs.getDimensionPixelSize("transformPivotY",0));
|
||||
|
||||
setKeyboardNavigationCluster( attrs.getBoolean("keyboardNavigationCluster",false) );
|
||||
|
||||
if(attrs.getBoolean("filterTouchesWhenObscured",false)){
|
||||
viewFlagValues |= FILTER_TOUCHES_WHEN_OBSCURED;
|
||||
viewFlagMasks |= FILTER_TOUCHES_WHEN_OBSCURED;
|
||||
}
|
||||
if( attrs.getBoolean( "focusableInTouchMode" , false ) ){
|
||||
viewFlagValues &= ~FOCUSABLE_AUTO;
|
||||
viewFlagValues |= FOCUSABLE_IN_TOUCH_MODE | FOCUSABLE;
|
||||
@ -161,6 +164,10 @@ View::View(Context*ctx,const AttributeSet&attrs){
|
||||
viewFlagValues |= LONG_CLICKABLE;
|
||||
viewFlagMasks |= LONG_CLICKABLE;
|
||||
}
|
||||
if( !attrs.getBoolean("saveEnabled",true)){
|
||||
viewFlagValues |=SAVE_DISABLED;
|
||||
viewFlagMasks |=SAVE_DISABLED_MASK;
|
||||
}
|
||||
if(attrs.getBoolean("duplicateParentState",false)){
|
||||
viewFlagValues |= DUPLICATE_PARENT_STATE;
|
||||
viewFlagMasks |= DUPLICATE_PARENT_STATE;
|
||||
@ -6061,6 +6068,27 @@ bool View::canReceivePointerEvents()const{
|
||||
return (mViewFlags & VISIBILITY_MASK) == VISIBLE || getAnimation() != nullptr;
|
||||
}
|
||||
|
||||
bool View::getFilterTouchesWhenObscured() const{
|
||||
return (mViewFlags & FILTER_TOUCHES_WHEN_OBSCURED) != 0;
|
||||
}
|
||||
|
||||
View& View::setFilterTouchesWhenObscured(bool enabled) {
|
||||
setFlags(enabled ? FILTER_TOUCHES_WHEN_OBSCURED : 0,
|
||||
FILTER_TOUCHES_WHEN_OBSCURED);
|
||||
//calculateAccessibilityDataSensitive();
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool View::onFilterTouchEventForSecurity(MotionEvent& event){
|
||||
//noinspection RedundantIfStatement
|
||||
if ((mViewFlags & FILTER_TOUCHES_WHEN_OBSCURED) != 0
|
||||
&& (event.getFlags() & MotionEvent::FLAG_WINDOW_IS_OBSCURED) != 0) {
|
||||
// Window is obscured, drop this touch.
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool View::dispatchTrackballEvent(MotionEvent& event){
|
||||
if (mInputEventConsistencyVerifier) {
|
||||
mInputEventConsistencyVerifier->onTrackballEvent(event, 0);
|
||||
@ -6157,10 +6185,10 @@ bool View::dispatchGenericMotionEvent(MotionEvent&event){
|
||||
if (mInputEventConsistencyVerifier)
|
||||
mInputEventConsistencyVerifier->onGenericMotionEvent(event, 0);
|
||||
if ((source & InputDevice::SOURCE_CLASS_POINTER) != 0) {
|
||||
int action = event.getAction();
|
||||
if (action == MotionEvent::ACTION_HOVER_ENTER
|
||||
|| action == MotionEvent::ACTION_HOVER_MOVE
|
||||
|| action == MotionEvent::ACTION_HOVER_EXIT) {
|
||||
const int action = event.getAction();
|
||||
if ((action == MotionEvent::ACTION_HOVER_ENTER)
|
||||
|| (action == MotionEvent::ACTION_HOVER_MOVE)
|
||||
|| (action == MotionEvent::ACTION_HOVER_EXIT)) {
|
||||
if (dispatchHoverEvent(event)) {
|
||||
return true;
|
||||
}
|
||||
@ -6184,18 +6212,19 @@ bool View::dispatchTouchEvent(MotionEvent&event){
|
||||
if (mInputEventConsistencyVerifier)
|
||||
mInputEventConsistencyVerifier->onTouchEvent(event, 0);
|
||||
|
||||
if (actionMasked == MotionEvent::ACTION_UP ||
|
||||
actionMasked == MotionEvent::ACTION_CANCEL ||
|
||||
if ( (actionMasked == MotionEvent::ACTION_UP) ||
|
||||
(actionMasked == MotionEvent::ACTION_CANCEL) ||
|
||||
(actionMasked == MotionEvent::ACTION_DOWN && !result)) {
|
||||
stopNestedScroll();
|
||||
}
|
||||
|
||||
if ((mViewFlags & ENABLED_MASK) == ENABLED && handleScrollBarDragging(event)) {
|
||||
if(onFilterTouchEventForSecurity(event)){
|
||||
if (((mViewFlags & ENABLED_MASK) == ENABLED) && handleScrollBarDragging(event)) {
|
||||
result = true;
|
||||
}
|
||||
|
||||
if ( mListenerInfo && mListenerInfo->mOnTouchListener
|
||||
&& (mViewFlags & ENABLED_MASK) == ENABLED
|
||||
&& ((mViewFlags & ENABLED_MASK) == ENABLED)
|
||||
&& mListenerInfo->mOnTouchListener(*this, event)) {
|
||||
result = true;
|
||||
}
|
||||
@ -6203,10 +6232,11 @@ bool View::dispatchTouchEvent(MotionEvent&event){
|
||||
if(!result&& onTouchEvent(event)){
|
||||
result=true;
|
||||
}
|
||||
}
|
||||
if (!result && mInputEventConsistencyVerifier)
|
||||
mInputEventConsistencyVerifier->onUnhandledEvent(event, 0);
|
||||
if (actionMasked == MotionEvent::ACTION_UP ||
|
||||
actionMasked == MotionEvent::ACTION_CANCEL ||
|
||||
if ( (actionMasked == MotionEvent::ACTION_UP) ||
|
||||
(actionMasked == MotionEvent::ACTION_CANCEL) ||
|
||||
(actionMasked == MotionEvent::ACTION_DOWN && !result)) {
|
||||
stopNestedScroll();
|
||||
}
|
||||
|
@ -236,8 +236,7 @@ public:
|
||||
SCROLLBARS_VERTICAL = 0x200 ,
|
||||
SCROLLBARS_MASK = 0x300 ,
|
||||
|
||||
CLIPCHILDREN = 0x400 ,
|
||||
TRANSPARENT = 0x800 ,
|
||||
FILTER_TOUCHES_WHEN_OBSCURED = 0x400,//CLIPCHILDREN = 0x400 ,TRANSPARENT = 0x800 ,
|
||||
|
||||
FADING_EDGE_NONE = 0x000000 ,
|
||||
FADING_EDGE_HORIZONTAL= 0x1000 ,
|
||||
@ -612,7 +611,10 @@ protected:
|
||||
virtual void dispatchCancelPendingInputEvents();
|
||||
virtual void onCancelPendingInputEvents();
|
||||
bool canReceivePointerEvents()const;
|
||||
bool getFilterTouchesWhenObscured()const;
|
||||
View& setFilterTouchesWhenObscured(bool enabled);
|
||||
virtual bool dispatchHoverEvent(MotionEvent&event);
|
||||
virtual bool onFilterTouchEventForSecurity(MotionEvent& event);
|
||||
virtual bool dispatchTrackballEvent(MotionEvent& event);
|
||||
virtual bool dispatchCapturedPointerEvent(MotionEvent& event);
|
||||
virtual bool dispatchGenericPointerEvent(MotionEvent& event);
|
||||
|
@ -2899,6 +2899,7 @@ bool ViewGroup::dispatchTouchEvent(MotionEvent&ev){
|
||||
}
|
||||
|
||||
bool handled = false;
|
||||
if(onFilterTouchEventForSecurity(ev)){
|
||||
if (actionMasked == MotionEvent::ACTION_DOWN) {
|
||||
cancelAndClearTouchTargets(&ev);
|
||||
resetTouchState();
|
||||
@ -3027,6 +3028,7 @@ bool ViewGroup::dispatchTouchEvent(MotionEvent&ev){
|
||||
int idBitsToRemove = 1 << ev.getPointerId(actionIndex);
|
||||
removePointersFromTouchTargets(idBitsToRemove);
|
||||
}
|
||||
}
|
||||
if (!handled && mInputEventConsistencyVerifier)
|
||||
mInputEventConsistencyVerifier->onUnhandledEvent(ev, 1);
|
||||
return handled;
|
||||
|
Loading…
Reference in New Issue
Block a user