From 4794b798c427c53a9d0f8c608c367a3e6469ed5f Mon Sep 17 00:00:00 2001 From: Sunny Shao Date: Fri, 10 Jul 2020 10:36:15 +0800 Subject: [PATCH] Fix toggle widget can be switched under overlapped view - ag/11612781 added filterTouchesWhenObscured to toggle widget can't prevent the click behavior pass through the overlapped view. - Due to click events was handled by SwitchPreference instead of the toggle widget. - Enable the filterTouchesWhenObscured attribute on all SwitchPreferences in all pages of the special app access. Bug: 155288585 Test: manual test Here is the test steps 1.Create an overlapped view's app and launch it to overlap the other apps. 2.Launch Settings 3.Goto Apps & notification > Advanced > Special app access 4.Click any toggle under Special app access to monitor it can be switched or not. It must be not switched. Change-Id: I9c9cf4719153292ed03f55a6eb9d3a308677aee3 --- src/com/android/settings/widget/AppSwitchPreference.java | 3 ++- .../widget/FilterTouchesRestrictedSwitchPreference.java | 3 ++- .../android/settings/widget/FilterTouchesSwitchPreference.java | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/com/android/settings/widget/AppSwitchPreference.java b/src/com/android/settings/widget/AppSwitchPreference.java index 90f1dbd0782..aeb779f6968 100644 --- a/src/com/android/settings/widget/AppSwitchPreference.java +++ b/src/com/android/settings/widget/AppSwitchPreference.java @@ -36,7 +36,8 @@ public class AppSwitchPreference extends SwitchPreference { super.onBindViewHolder(holder); final View switchView = holder.findViewById(android.R.id.switch_widget); if (switchView != null) { - switchView.setFilterTouchesWhenObscured(true); + final View rootView = switchView.getRootView(); + rootView.setFilterTouchesWhenObscured(true); } } } diff --git a/src/com/android/settings/widget/FilterTouchesRestrictedSwitchPreference.java b/src/com/android/settings/widget/FilterTouchesRestrictedSwitchPreference.java index c5e0217dd0f..f4c3a14389a 100644 --- a/src/com/android/settings/widget/FilterTouchesRestrictedSwitchPreference.java +++ b/src/com/android/settings/widget/FilterTouchesRestrictedSwitchPreference.java @@ -52,7 +52,8 @@ public class FilterTouchesRestrictedSwitchPreference extends RestrictedSwitchPre super.onBindViewHolder(holder); final View switchView = holder.findViewById(android.R.id.switch_widget); if (switchView != null) { - switchView.setFilterTouchesWhenObscured(true); + final View rootView = switchView.getRootView(); + rootView.setFilterTouchesWhenObscured(true); } } } diff --git a/src/com/android/settings/widget/FilterTouchesSwitchPreference.java b/src/com/android/settings/widget/FilterTouchesSwitchPreference.java index a4e3c6e76da..1b4d6817bfb 100644 --- a/src/com/android/settings/widget/FilterTouchesSwitchPreference.java +++ b/src/com/android/settings/widget/FilterTouchesSwitchPreference.java @@ -50,7 +50,8 @@ public class FilterTouchesSwitchPreference extends SwitchPreference { super.onBindViewHolder(holder); final View switchView = holder.findViewById(android.R.id.switch_widget); if (switchView != null) { - switchView.setFilterTouchesWhenObscured(true); + final View rootView = switchView.getRootView(); + rootView.setFilterTouchesWhenObscured(true); } } }