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

Commit 2f3a476b authored by Govinda Wasserman's avatar Govinda Wasserman
Browse files

Rename PhenotypeHelper to DeviceConfigHelper

This class is used for simplifying interaction with the device
configuration and for testing. The new name is more descriptive of its
intended purpose.

Test: Tested locally
BUG:143952102
Change-Id: I5d9edf518b92f48d73e2ed5d142a162d348d24ba
parent b814d6b3
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ public final class AssistHandleBehaviorController implements AssistHandleCallbac
    private final Runnable mHideHandles = this::hideHandles;
    private final Runnable mShowAndGo = this::showAndGoInternal;
    private final Provider<AssistHandleViewController> mAssistHandleViewController;
    private final PhenotypeHelper mPhenotypeHelper;
    private final DeviceConfigHelper mDeviceConfigHelper;
    private final Map<AssistHandleBehavior, BehaviorController> mBehaviorMap;

    private boolean mHandlesShowing = false;
@@ -90,7 +90,7 @@ public final class AssistHandleBehaviorController implements AssistHandleCallbac
            AssistUtils assistUtils,
            @Named(ASSIST_HANDLE_THREAD_NAME) Handler handler,
            Provider<AssistHandleViewController> assistHandleViewController,
            PhenotypeHelper phenotypeHelper,
            DeviceConfigHelper deviceConfigHelper,
            Map<AssistHandleBehavior, BehaviorController> behaviorMap,
            NavigationModeController navigationModeController,
            DumpController dumpController) {
@@ -98,14 +98,14 @@ public final class AssistHandleBehaviorController implements AssistHandleCallbac
        mAssistUtils = assistUtils;
        mHandler = handler;
        mAssistHandleViewController = assistHandleViewController;
        mPhenotypeHelper = phenotypeHelper;
        mDeviceConfigHelper = deviceConfigHelper;
        mBehaviorMap = behaviorMap;

        mInGesturalMode = QuickStepContract.isGesturalMode(
                navigationModeController.addListener(this::handleNavigationModeChange));

        setBehavior(getBehaviorMode());
        mPhenotypeHelper.addOnPropertiesChangedListener(
        mDeviceConfigHelper.addOnPropertiesChangedListener(
                mHandler::post,
                (properties) -> {
                    if (properties.getKeyset().contains(
@@ -205,19 +205,19 @@ public final class AssistHandleBehaviorController implements AssistHandleCallbac
    }

    private long getShownFrequencyThreshold() {
        return mPhenotypeHelper.getLong(
        return mDeviceConfigHelper.getLong(
                SystemUiDeviceConfigFlags.ASSIST_HANDLES_SHOWN_FREQUENCY_THRESHOLD_MS,
                DEFAULT_SHOWN_FREQUENCY_THRESHOLD_MS);
    }

    private long getShowAndGoDuration() {
        return mPhenotypeHelper.getLong(
        return mDeviceConfigHelper.getLong(
                SystemUiDeviceConfigFlags.ASSIST_HANDLES_SHOW_AND_GO_DURATION_MS,
                DEFAULT_SHOW_AND_GO_DURATION_MS);
    }

    private String getBehaviorMode() {
        return mPhenotypeHelper.getString(
        return mDeviceConfigHelper.getString(
                SystemUiDeviceConfigFlags.ASSIST_HANDLES_BEHAVIOR_MODE,
                DEFAULT_BEHAVIOR.toString());
    }
+12 −12
Original line number Diff line number Diff line
@@ -155,7 +155,7 @@ final class AssistHandleReminderExpBehavior implements BehaviorController {

    private final Clock mClock;
    private final Handler mHandler;
    private final PhenotypeHelper mPhenotypeHelper;
    private final DeviceConfigHelper mDeviceConfigHelper;
    private final Lazy<StatusBarStateController> mStatusBarStateController;
    private final Lazy<ActivityManagerWrapper> mActivityManagerWrapper;
    private final Lazy<OverviewProxyService> mOverviewProxyService;
@@ -189,7 +189,7 @@ final class AssistHandleReminderExpBehavior implements BehaviorController {
    AssistHandleReminderExpBehavior(
            @Named(UPTIME_NAME) Clock clock,
            @Named(ASSIST_HANDLE_THREAD_NAME) Handler handler,
            PhenotypeHelper phenotypeHelper,
            DeviceConfigHelper deviceConfigHelper,
            Lazy<StatusBarStateController> statusBarStateController,
            Lazy<ActivityManagerWrapper> activityManagerWrapper,
            Lazy<OverviewProxyService> overviewProxyService,
@@ -199,7 +199,7 @@ final class AssistHandleReminderExpBehavior implements BehaviorController {
            Lazy<BroadcastDispatcher> broadcastDispatcher) {
        mClock = clock;
        mHandler = handler;
        mPhenotypeHelper = phenotypeHelper;
        mDeviceConfigHelper = deviceConfigHelper;
        mStatusBarStateController = statusBarStateController;
        mActivityManagerWrapper = activityManagerWrapper;
        mOverviewProxyService = overviewProxyService;
@@ -465,55 +465,55 @@ final class AssistHandleReminderExpBehavior implements BehaviorController {
    }

    private long getLearningTimeMs() {
        return mPhenotypeHelper.getLong(
        return mDeviceConfigHelper.getLong(
                SystemUiDeviceConfigFlags.ASSIST_HANDLES_LEARN_TIME_MS,
                DEFAULT_LEARNING_TIME_MS);
    }

    private int getLearningCount() {
        return mPhenotypeHelper.getInt(
        return mDeviceConfigHelper.getInt(
                SystemUiDeviceConfigFlags.ASSIST_HANDLES_LEARN_COUNT,
                DEFAULT_LEARNING_COUNT);
    }

    private long getShowAndGoDelayedShortDelayMs() {
        return mPhenotypeHelper.getLong(
        return mDeviceConfigHelper.getLong(
                SystemUiDeviceConfigFlags.ASSIST_HANDLES_SHOW_AND_GO_DELAYED_SHORT_DELAY_MS,
                DEFAULT_SHOW_AND_GO_DELAYED_SHORT_DELAY_MS);
    }

    private long getShowAndGoDelayedLongDelayMs() {
        return mPhenotypeHelper.getLong(
        return mDeviceConfigHelper.getLong(
                SystemUiDeviceConfigFlags.ASSIST_HANDLES_SHOW_AND_GO_DELAYED_LONG_DELAY_MS,
                DEFAULT_SHOW_AND_GO_DELAYED_LONG_DELAY_MS);
    }

    private long getShowAndGoDelayResetTimeoutMs() {
        return mPhenotypeHelper.getLong(
        return mDeviceConfigHelper.getLong(
                SystemUiDeviceConfigFlags.ASSIST_HANDLES_SHOW_AND_GO_DELAY_RESET_TIMEOUT_MS,
                DEFAULT_SHOW_AND_GO_DELAY_RESET_TIMEOUT_MS);
    }

    private boolean getSuppressOnLockscreen() {
        return mPhenotypeHelper.getBoolean(
        return mDeviceConfigHelper.getBoolean(
                SystemUiDeviceConfigFlags.ASSIST_HANDLES_SUPPRESS_ON_LOCKSCREEN,
                DEFAULT_SUPPRESS_ON_LOCKSCREEN);
    }

    private boolean getSuppressOnLauncher() {
        return mPhenotypeHelper.getBoolean(
        return mDeviceConfigHelper.getBoolean(
                SystemUiDeviceConfigFlags.ASSIST_HANDLES_SUPPRESS_ON_LAUNCHER,
                DEFAULT_SUPPRESS_ON_LAUNCHER);
    }

    private boolean getSuppressOnApps() {
        return mPhenotypeHelper.getBoolean(
        return mDeviceConfigHelper.getBoolean(
                SystemUiDeviceConfigFlags.ASSIST_HANDLES_SUPPRESS_ON_APPS,
                DEFAULT_SUPPRESS_ON_APPS);
    }

    private boolean getShowWhenTaught() {
        return mPhenotypeHelper.getBoolean(
        return mDeviceConfigHelper.getBoolean(
                SystemUiDeviceConfigFlags.ASSIST_HANDLES_SHOW_WHEN_TAUGHT,
                DEFAULT_SHOW_WHEN_TAUGHT);
    }
+3 −3
Original line number Diff line number Diff line
@@ -28,15 +28,15 @@ import javax.inject.Inject;
import javax.inject.Singleton;

/**
 * Wrapper class for retrieving phenotype flag values.
 * Wrapper class for retrieving System UI device configuration values.
 *
 * Can be mocked in tests for ease of testing the effects of particular values.
 */
@Singleton
public class PhenotypeHelper {
public class DeviceConfigHelper {

    @Inject
    public PhenotypeHelper() {}
    public DeviceConfigHelper() {}

    public long getLong(String name, long defaultValue) {
        return whitelistIpcs(() ->
+4 −4
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ public class AssistHandleBehaviorControllerTest extends SysuiTestCase {

    @Mock private AssistUtils mMockAssistUtils;
    @Mock private Handler mMockHandler;
    @Mock private PhenotypeHelper mMockPhenotypeHelper;
    @Mock private DeviceConfigHelper mMockDeviceConfigHelper;
    @Mock private AssistHandleOffBehavior mMockOffBehavior;
    @Mock private AssistHandleLikeHomeBehavior mMockLikeHomeBehavior;
    @Mock private AssistHandleReminderExpBehavior mMockReminderExpBehavior;
@@ -97,7 +97,7 @@ public class AssistHandleBehaviorControllerTest extends SysuiTestCase {
                        mMockAssistUtils,
                        mMockHandler,
                        () -> mMockAssistHandleViewController,
                        mMockPhenotypeHelper,
                        mMockDeviceConfigHelper,
                        behaviorMap,
                        mMockNavigationModeController,
                        mMockDumpController);
@@ -216,7 +216,7 @@ public class AssistHandleBehaviorControllerTest extends SysuiTestCase {
    public void showAndGo_doesNothingIfRecentlyHidden() {
        // Arrange
        when(mMockAssistUtils.getAssistComponentForUser(anyInt())).thenReturn(COMPONENT_NAME);
        when(mMockPhenotypeHelper.getLong(
        when(mMockDeviceConfigHelper.getLong(
                eq(SystemUiDeviceConfigFlags.ASSIST_HANDLES_SHOWN_FREQUENCY_THRESHOLD_MS),
                anyLong())).thenReturn(10000L);
        mAssistHandleBehaviorController.showAndGo();
@@ -297,7 +297,7 @@ public class AssistHandleBehaviorControllerTest extends SysuiTestCase {
    public void showAndGoDelayed_doesNothingIfRecentlyHidden() {
        // Arrange
        when(mMockAssistUtils.getAssistComponentForUser(anyInt())).thenReturn(COMPONENT_NAME);
        when(mMockPhenotypeHelper.getLong(
        when(mMockDeviceConfigHelper.getLong(
                eq(SystemUiDeviceConfigFlags.ASSIST_HANDLES_SHOWN_FREQUENCY_THRESHOLD_MS),
                anyLong())).thenReturn(10000L);
        mAssistHandleBehaviorController.showAndGo();