From d0df97d939c6ef81bff7d841cea4a38cf259a369 Mon Sep 17 00:00:00 2001 From: tomnatan Date: Tue, 8 Feb 2022 16:35:34 +0000 Subject: [PATCH] [10/n] Letterbox Education: don't show if taskbar education is showing. Introduce a LAUNCHER_TASKBAR_EDUCATION_SHOWING setting for taskbar to indicate that the education is about to be shown or is currently showing. After the taskbar education is dismissed, the letterbox education will only be shown for a different task or for the same task once its compat state changes and the letterbox education is eligible to be shown. Bug: 214590804 Test: N/A Change-Id: Ia8512e5f188fe421adf1de2fc8a0422b9cc79c76 --- core/java/android/provider/Settings.java | 13 +++++++++++++ .../letterboxedu/LetterboxEduWindowManager.java | 17 ++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 464567b852704..ea20ed42ee14e 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -10708,6 +10708,19 @@ public final class Settings { public static final String HDMI_CEC_SET_MENU_LANGUAGE_DENYLIST = "hdmi_cec_set_menu_language_denylist"; + /** + * Whether the Taskbar Education is about to be shown or is currently showing. + * + *

1 if true, 0 or unset otherwise. + * + *

This setting is used to inform other components that the Taskbar Education is + * currently showing, which can prevent them from showing something else to the user. + * + * @hide + */ + public static final String LAUNCHER_TASKBAR_EDUCATION_SHOWING = + "launcher_taskbar_education_showing"; + /** * These entries are considered common between the personal and the managed profile, * since the managed profile doesn't get to change them. diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterboxedu/LetterboxEduWindowManager.java b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterboxedu/LetterboxEduWindowManager.java index c461ebcb55ea2..074610bfce494 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterboxedu/LetterboxEduWindowManager.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterboxedu/LetterboxEduWindowManager.java @@ -16,11 +16,14 @@ package com.android.wm.shell.compatui.letterboxedu; +import static android.provider.Settings.Secure.LAUNCHER_TASKBAR_EDUCATION_SHOWING; + import android.annotation.Nullable; import android.app.TaskInfo; import android.content.Context; import android.content.SharedPreferences; import android.graphics.Rect; +import android.provider.Settings; import android.view.LayoutInflater; import android.view.View; import android.view.WindowManager; @@ -93,9 +96,12 @@ public class LetterboxEduWindowManager extends CompatUIWindowManagerAbstract { @Override protected boolean eligibleToShowLayout() { - // If the layout isn't null then it was previously showing, and we shouldn't check if the - // user has seen the letterbox education before. - return mEligibleForLetterboxEducation && (mLayout != null + // - If taskbar education is showing, the letterbox education shouldn't be shown for the + // given task until the taskbar education is dismissed and the compat info changes (then + // the controller will create a new instance of this class since this one isn't eligible). + // - If the layout isn't null then it was previously showing, and we shouldn't check if the + // user has seen the letterbox education before. + return mEligibleForLetterboxEducation && !isTaskbarEduShowing() && (mLayout != null || !getHasSeenLetterboxEducation()); } @@ -173,4 +179,9 @@ public class LetterboxEduWindowManager extends CompatUIWindowManagerAbstract { private String getPrefKey() { return String.valueOf(mContext.getUserId()); } + + private boolean isTaskbarEduShowing() { + return Settings.Secure.getInt(mContext.getContentResolver(), + LAUNCHER_TASKBAR_EDUCATION_SHOWING, /* def= */ 0) == 1; + } }