From 5901d8f71029b8e5bd8fe74d383f6d3d8fba3644 Mon Sep 17 00:00:00 2001 From: Massimo Carli Date: Fri, 24 Mar 2023 09:29:40 +0000 Subject: Show Reachability only once per user on device lifetime The Reachability education dialog will appear automatically only the first time an app eligible to be moved with double-tap action is displayed on the screen. Fixes: 274991247 Test: Manual Change-Id: Ifec12a4386e69d7fd2ba895a298a46059203a59d --- .../android/wm/shell/compatui/CompatUIConfiguration.java | 10 ++++------ .../wm/shell/compatui/LetterboxEduWindowManagerTest.java | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIConfiguration.java b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIConfiguration.java index 902c41c8fd2d..4e10ce82f365 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIConfiguration.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIConfiguration.java @@ -156,15 +156,13 @@ public class CompatUIConfiguration implements DeviceConfig.OnPropertiesChangedLi void setDontShowReachabilityEducationAgain(TaskInfo taskInfo) { mCompatUISharedPreferences.edit().putBoolean( - getDontShowAgainReachabilityEduKey(taskInfo.userId, - taskInfo.topActivity.getPackageName()), true).apply(); + getDontShowAgainReachabilityEduKey(taskInfo.userId), true).apply(); } boolean shouldShowReachabilityEducation(@NonNull TaskInfo taskInfo) { return getHasSeenLetterboxEducation(taskInfo.userId) && !mCompatUISharedPreferences.getBoolean( - getDontShowAgainReachabilityEduKey(taskInfo.userId, - taskInfo.topActivity.getPackageName()), /* default= */false); + getDontShowAgainReachabilityEduKey(taskInfo.userId), /* default= */false); } boolean getHasSeenLetterboxEducation(int userId) { @@ -206,8 +204,8 @@ public class CompatUIConfiguration implements DeviceConfig.OnPropertiesChangedLi } } - private static String getDontShowAgainReachabilityEduKey(int userId, String packageName) { - return HAS_SEEN_REACHABILITY_EDUCATION_KEY_PREFIX + "_" + packageName + "@" + userId; + private static String getDontShowAgainReachabilityEduKey(int userId) { + return HAS_SEEN_REACHABILITY_EDUCATION_KEY_PREFIX + "@" + userId; } private static String getDontShowLetterboxEduKey(int userId) { diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/LetterboxEduWindowManagerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/LetterboxEduWindowManagerTest.java index 3f79df6a82c8..12ceb0a9a9ba 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/LetterboxEduWindowManagerTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/LetterboxEduWindowManagerTest.java @@ -66,6 +66,8 @@ import org.mockito.Captor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import java.util.HashSet; +import java.util.Set; import java.util.function.Consumer; /** @@ -118,6 +120,18 @@ public class LetterboxEduWindowManagerTest extends ShellTestCase { mExecutor = new TestShellExecutor(); mCompatUIConfiguration = new CompatUIConfiguration(mContext, mExecutor) { + final Set mHasSeenSet = new HashSet<>(); + + @Override + boolean getHasSeenLetterboxEducation(int userId) { + return mHasSeenSet.contains(userId); + } + + @Override + void setSeenLetterboxEducation(int userId) { + mHasSeenSet.add(userId); + } + @Override protected String getCompatUISharedPreferenceName() { return TEST_COMPAT_UI_SHARED_PREFERENCES; -- cgit v1.2.3-59-g8ed1b