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

Commit 46d71637 authored by Dave Mankoff's avatar Dave Mankoff Committed by Android (Google) Code Review
Browse files

Merge "Remove FlagWriter class."

parents be589972 58ddf1de
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ import javax.inject.Inject;
 * To restore a flag back to its default, leave the `--ez value <0|1>` off of the command.
 */
@SysUISingleton
public class FeatureFlagsDebug implements FeatureFlags, FlagWriter, Dumpable {
public class FeatureFlagsDebug implements FeatureFlags, Dumpable {
    private static final String TAG = "SysUIFlags";

    private final FlagManager mFlagManager;
@@ -126,7 +126,6 @@ public class FeatureFlagsDebug implements FeatureFlags, FlagWriter, Dumpable {
    }

    /** Set whether a given {@link BooleanFlag} is enabled or not. */
    @Override
    public void setEnabled(int id, boolean value) {
        Boolean currentValue = isEnabledInternal(id);
        if (currentValue != null && currentValue == value) {
+1 −3
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ import javax.inject.Inject;
 * how to set flags.
 */
@SysUISingleton
public class FeatureFlagsRelease implements FeatureFlags, FlagWriter, Dumpable {
public class FeatureFlagsRelease implements FeatureFlags, Dumpable {
    SparseBooleanArray mAccessedFlags = new SparseBooleanArray();
    @Inject
    public FeatureFlagsRelease(DumpManager dumpManager) {
@@ -59,8 +59,6 @@ public class FeatureFlagsRelease implements FeatureFlags, FlagWriter, Dumpable {
        mAccessedFlags.append(key, defaultValue);
        return defaultValue;
    }
    @Override
    public void setEnabled(int key, boolean value) {}

    @Override
    public void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw, @NonNull String[] args) {
+0 −21
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.flags

interface FlagWriter {
    fun setEnabled(key: Int, value: Boolean) {}
}
 No newline at end of file
+0 −14
Original line number Diff line number Diff line
@@ -51,7 +51,6 @@ import java.io.StringWriter;
public class FeatureFlagsReleaseTest extends SysuiTestCase {
    FeatureFlagsRelease mFeatureFlagsRelease;

    @Mock private Context mContext;
    @Mock private DumpManager mDumpManager;

    @Before
@@ -68,25 +67,12 @@ public class FeatureFlagsReleaseTest extends SysuiTestCase {
        verifyNoMoreInteractions(mDumpManager);
    }

    @Test
    public void testIsEnabled() {
        mFeatureFlagsRelease.setEnabled(1, true);
        // Again, nothing changes.
        assertThat(mFeatureFlagsRelease.isEnabled(1, false)).isFalse();
    }

    @Test
    public void testDump() {
        // Even if a flag is set before
        mFeatureFlagsRelease.setEnabled(1, true);

        // WHEN the flags have been accessed
        assertFalse(mFeatureFlagsRelease.isEnabled(1, false));
        assertTrue(mFeatureFlagsRelease.isEnabled(2, true));

        // Even if a flag is set after
        mFeatureFlagsRelease.setEnabled(2, false);

        // THEN the dump contains the flags and the default values
        String dump = dumpToString();
        assertThat(dump).contains(" sysui_flag_1: false\n");