Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dfc29ef6 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Don't show the QuickSetting tooltip when we stopped auto add qs tile for the user" into main

parents b14a7842 764f8d73
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.content.Context;
import android.os.Bundle;
import android.os.Handler;

import androidx.annotation.Nullable;
import androidx.preference.PreferenceScreen;

import com.android.settings.R;
@@ -42,6 +43,7 @@ public abstract class AccessibilityQuickSettingsPrimarySwitchPreferenceControlle
    private boolean mNeedsQSTooltipReshow = false;

    /** Returns the accessibility tile component name. */
    @Nullable
    abstract ComponentName getTileComponentName();

    /** Returns the accessibility tile tooltip content. */
+7 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.os.UserHandle;
import android.provider.Settings;
import android.text.TextUtils;

import androidx.annotation.Nullable;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;

@@ -125,9 +126,14 @@ public class ReduceBrightColorsPreferenceController
        mContext.getContentResolver().unregisterContentObserver(mSettingsContentObserver);
    }

    @Nullable
    @Override
    protected ComponentName getTileComponentName() {
        return REDUCE_BRIGHT_COLORS_TILE_SERVICE_COMPONENT_NAME;
        // TODO: When clean up the feature flag, change the parent class from
        // AccessibilityQuickSettingsPrimarySwitchPreferenceController to
        // TogglePreferenceController
        return android.view.accessibility.Flags.a11yQsShortcut()
                ? null : REDUCE_BRIGHT_COLORS_TILE_SERVICE_COMPONENT_NAME;
    }

    @Override
+24 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.settings.accessibility;

import static com.android.internal.accessibility.AccessibilityShortcutController.REDUCE_BRIGHT_COLORS_TILE_SERVICE_COMPONENT_NAME;

import static com.google.common.truth.Truth.assertThat;

import static org.mockito.Mockito.doReturn;
@@ -24,7 +26,12 @@ import static org.mockito.Mockito.when;

import android.content.Context;
import android.content.res.Resources;
import android.platform.test.annotations.RequiresFlagsDisabled;
import android.platform.test.annotations.RequiresFlagsEnabled;
import android.platform.test.flag.junit.CheckFlagsRule;
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
import android.provider.Settings;
import android.view.accessibility.Flags;

import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
@@ -33,6 +40,7 @@ import com.android.internal.R;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

@@ -40,6 +48,8 @@ import org.junit.runner.RunWith;
public class ReduceBrightColorsPreferenceControllerTest {
    private static final String PREF_KEY = "rbc_preference";

    @Rule
    public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
    private Context mContext;
    private Resources mResources;;
    private ReduceBrightColorsPreferenceController mController;
@@ -88,6 +98,20 @@ public class ReduceBrightColorsPreferenceControllerTest {
        assertThat(mController.isAvailable()).isFalse();
    }


    @Test
    @RequiresFlagsDisabled(Flags.FLAG_A11Y_QS_SHORTCUT)
    public void getTileComponentName_a11yQsFlagOff_returnComponentName() {
        assertThat(mController.getTileComponentName())
                .isEqualTo(REDUCE_BRIGHT_COLORS_TILE_SERVICE_COMPONENT_NAME);
    }

    @Test
    @RequiresFlagsEnabled(Flags.FLAG_A11Y_QS_SHORTCUT)
    public void getTileComponentName_a11yQsFlagOff_returnNull() {
        assertThat(mController.getTileComponentName()).isNull();
    }

    private int resourceId(String type, String name) {
        return mContext.getResources().getIdentifier(name, type, mContext.getPackageName());
    }