Remove temp workaround for feature flag
Using the trunk stable feature flagging now. Bug: 295516544 Test: m Test: manual adb Test: atest SafetySourceBroadcastReceiverTest Test: atest PrivateSpaceSafetySourceTest Change-Id: I3d2d8c11dfb224ad2b09572493633366b4c4805c
This commit is contained in:
@@ -18,7 +18,7 @@ package com.android.settings.privatespace;
|
|||||||
|
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.FeatureFlagUtils;
|
import android.os.Flags;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.dashboard.DashboardFragment;
|
import com.android.settings.dashboard.DashboardFragment;
|
||||||
@@ -56,13 +56,8 @@ public class PrivateSpaceDashboardFragment extends DashboardFragment {
|
|||||||
new BaseSearchIndexProvider(R.xml.private_space_settings) {
|
new BaseSearchIndexProvider(R.xml.private_space_settings) {
|
||||||
@Override
|
@Override
|
||||||
protected boolean isPageSearchEnabled(Context context) {
|
protected boolean isPageSearchEnabled(Context context) {
|
||||||
// Temporary workaround for hiding PS Settings until the trunk stable feature
|
|
||||||
// flag is available.
|
|
||||||
// TODO(b/295516544): Remove this workaround when trunk stable feature flag is
|
|
||||||
// available.
|
|
||||||
return SafetyCenterManagerWrapper.get().isEnabled(context)
|
return SafetyCenterManagerWrapper.get().isEnabled(context)
|
||||||
&& FeatureFlagUtils.isEnabled(context,
|
&& Flags.allowPrivateProfile();
|
||||||
FeatureFlagUtils.SETTINGS_PRIVATE_SPACE_SETTINGS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -20,11 +20,11 @@ import android.app.PendingIntent;
|
|||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.os.Flags;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.safetycenter.SafetyEvent;
|
import android.safetycenter.SafetyEvent;
|
||||||
import android.safetycenter.SafetySourceData;
|
import android.safetycenter.SafetySourceData;
|
||||||
import android.safetycenter.SafetySourceStatus;
|
import android.safetycenter.SafetySourceStatus;
|
||||||
import android.util.FeatureFlagUtils;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
@@ -35,7 +35,7 @@ import com.android.settingslib.transition.SettingsTransitionHelper;
|
|||||||
/** Private Space safety source for the Safety Center */
|
/** Private Space safety source for the Safety Center */
|
||||||
public final class PrivateSpaceSafetySource {
|
public final class PrivateSpaceSafetySource {
|
||||||
public static final String SAFETY_SOURCE_ID = "AndroidPrivateSpace";
|
public static final String SAFETY_SOURCE_ID = "AndroidPrivateSpace";
|
||||||
private static final String TAG = "PrivateSpaceSafetySource";
|
private static final String TAG = "PrivateSpaceSafetySrc";
|
||||||
|
|
||||||
private PrivateSpaceSafetySource() {}
|
private PrivateSpaceSafetySource() {}
|
||||||
|
|
||||||
@@ -54,10 +54,7 @@ public final class PrivateSpaceSafetySource {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temporary workaround to help prevent the PS Settings showing up in droidfood builds.
|
if (!Flags.allowPrivateProfile()) {
|
||||||
// TODO(b/295516544): remove this when the trunk stable feature flag for PS is available.
|
|
||||||
if (!FeatureFlagUtils.isEnabled(context,
|
|
||||||
FeatureFlagUtils.SETTINGS_PRIVATE_SPACE_SETTINGS)) {
|
|
||||||
// Setting null safetySourceData so that an old entry gets cleared out and this way
|
// Setting null safetySourceData so that an old entry gets cleared out and this way
|
||||||
// provide a response since SC always expects one on rescan.
|
// provide a response since SC always expects one on rescan.
|
||||||
SafetyCenterManagerWrapper.get().setSafetySourceData(
|
SafetyCenterManagerWrapper.get().setSafetySourceData(
|
||||||
|
@@ -32,6 +32,7 @@ android_test {
|
|||||||
"truth-prebuilt",
|
"truth-prebuilt",
|
||||||
"androidx.test.uiautomator_uiautomator",
|
"androidx.test.uiautomator_uiautomator",
|
||||||
"kotlinx_coroutines_test",
|
"kotlinx_coroutines_test",
|
||||||
|
"flag-junit-base",
|
||||||
// Don't add SettingsLib libraries here - you can use them directly as they are in the
|
// Don't add SettingsLib libraries here - you can use them directly as they are in the
|
||||||
// instrumented Settings app.
|
// instrumented Settings app.
|
||||||
],
|
],
|
||||||
|
@@ -27,10 +27,11 @@ import static org.mockito.Mockito.verify;
|
|||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.Flags;
|
||||||
|
import android.platform.test.flag.junit.SetFlagsRule;
|
||||||
import android.safetycenter.SafetyEvent;
|
import android.safetycenter.SafetyEvent;
|
||||||
import android.safetycenter.SafetySourceData;
|
import android.safetycenter.SafetySourceData;
|
||||||
import android.safetycenter.SafetySourceStatus;
|
import android.safetycenter.SafetySourceStatus;
|
||||||
import android.util.FeatureFlagUtils;
|
|
||||||
|
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
@@ -39,6 +40,7 @@ import com.android.settings.safetycenter.SafetyCenterManagerWrapper;
|
|||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
@@ -51,15 +53,13 @@ public class PrivateSpaceSafetySourceTest {
|
|||||||
new SafetyEvent.Builder(SAFETY_EVENT_TYPE_DEVICE_REBOOTED).build();
|
new SafetyEvent.Builder(SAFETY_EVENT_TYPE_DEVICE_REBOOTED).build();
|
||||||
private Context mContext = ApplicationProvider.getApplicationContext();
|
private Context mContext = ApplicationProvider.getApplicationContext();
|
||||||
@Mock private SafetyCenterManagerWrapper mSafetyCenterManagerWrapper;
|
@Mock private SafetyCenterManagerWrapper mSafetyCenterManagerWrapper;
|
||||||
|
@Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||||
|
|
||||||
/** Required setup before a test. */
|
/** Required setup before a test. */
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
SafetyCenterManagerWrapper.sInstance = mSafetyCenterManagerWrapper;
|
SafetyCenterManagerWrapper.sInstance = mSafetyCenterManagerWrapper;
|
||||||
|
|
||||||
FeatureFlagUtils
|
|
||||||
.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PRIVATE_SPACE_SETTINGS, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Required setup after a test. */
|
/** Required setup after a test. */
|
||||||
@@ -83,6 +83,7 @@ public class PrivateSpaceSafetySourceTest {
|
|||||||
@Test
|
@Test
|
||||||
public void onDeviceRebootedEvent_whenSafetyCenterEnabled_setsData() {
|
public void onDeviceRebootedEvent_whenSafetyCenterEnabled_setsData() {
|
||||||
when(mSafetyCenterManagerWrapper.isEnabled(mContext)).thenReturn(true);
|
when(mSafetyCenterManagerWrapper.isEnabled(mContext)).thenReturn(true);
|
||||||
|
mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
|
||||||
|
|
||||||
PrivateSpaceSafetySource.setSafetySourceData(mContext, EVENT_TYPE_DEVICE_REBOOTED);
|
PrivateSpaceSafetySource.setSafetySourceData(mContext, EVENT_TYPE_DEVICE_REBOOTED);
|
||||||
|
|
||||||
@@ -90,13 +91,11 @@ public class PrivateSpaceSafetySourceTest {
|
|||||||
any(), eq(SAFETY_SOURCE_ID), any(), eq(EVENT_TYPE_DEVICE_REBOOTED));
|
any(), eq(SAFETY_SOURCE_ID), any(), eq(EVENT_TYPE_DEVICE_REBOOTED));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(b/295516544): Modify this test for the new trunk stable flag instead when available.
|
|
||||||
/** Tests that when the feature is disabled null data is set. */
|
/** Tests that when the feature is disabled null data is set. */
|
||||||
@Test
|
@Test
|
||||||
public void setSafetySourceData_whenFeatureDisabled_setsNullData() {
|
public void setSafetySourceData_whenFeatureDisabled_setsNullData() {
|
||||||
when(mSafetyCenterManagerWrapper.isEnabled(mContext)).thenReturn(true);
|
when(mSafetyCenterManagerWrapper.isEnabled(mContext)).thenReturn(true);
|
||||||
FeatureFlagUtils
|
mSetFlagsRule.disableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
|
||||||
.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PRIVATE_SPACE_SETTINGS, false);
|
|
||||||
|
|
||||||
PrivateSpaceSafetySource.setSafetySourceData(mContext, EVENT_TYPE_DEVICE_REBOOTED);
|
PrivateSpaceSafetySource.setSafetySourceData(mContext, EVENT_TYPE_DEVICE_REBOOTED);
|
||||||
|
|
||||||
@@ -105,15 +104,13 @@ public class PrivateSpaceSafetySourceTest {
|
|||||||
any(), eq(SAFETY_SOURCE_ID), captor.capture(), eq(EVENT_TYPE_DEVICE_REBOOTED));
|
any(), eq(SAFETY_SOURCE_ID), captor.capture(), eq(EVENT_TYPE_DEVICE_REBOOTED));
|
||||||
SafetySourceData safetySourceData = captor.getValue();
|
SafetySourceData safetySourceData = captor.getValue();
|
||||||
assertThat(safetySourceData).isNull();
|
assertThat(safetySourceData).isNull();
|
||||||
|
|
||||||
FeatureFlagUtils
|
|
||||||
.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PRIVATE_SPACE_SETTINGS, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Tests that setSafetySourceData sets the source status enabled. */
|
/** Tests that setSafetySourceData sets the source status enabled. */
|
||||||
@Test
|
@Test
|
||||||
public void setSafetySourceData_setsEnabled() {
|
public void setSafetySourceData_setsEnabled() {
|
||||||
when(mSafetyCenterManagerWrapper.isEnabled(mContext)).thenReturn(true);
|
when(mSafetyCenterManagerWrapper.isEnabled(mContext)).thenReturn(true);
|
||||||
|
mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
|
||||||
|
|
||||||
PrivateSpaceSafetySource.setSafetySourceData(mContext, EVENT_TYPE_DEVICE_REBOOTED);
|
PrivateSpaceSafetySource.setSafetySourceData(mContext, EVENT_TYPE_DEVICE_REBOOTED);
|
||||||
|
|
||||||
@@ -129,6 +126,7 @@ public class PrivateSpaceSafetySourceTest {
|
|||||||
@Test
|
@Test
|
||||||
public void setSafetySourceData_setsPsIntent() {
|
public void setSafetySourceData_setsPsIntent() {
|
||||||
when(mSafetyCenterManagerWrapper.isEnabled(mContext)).thenReturn(true);
|
when(mSafetyCenterManagerWrapper.isEnabled(mContext)).thenReturn(true);
|
||||||
|
mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
|
||||||
|
|
||||||
PrivateSpaceSafetySource.setSafetySourceData(mContext, EVENT_TYPE_DEVICE_REBOOTED);
|
PrivateSpaceSafetySource.setSafetySourceData(mContext, EVENT_TYPE_DEVICE_REBOOTED);
|
||||||
|
|
||||||
|
@@ -30,9 +30,10 @@ import static org.mockito.Mockito.when;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.os.Flags;
|
||||||
|
import android.platform.test.flag.junit.SetFlagsRule;
|
||||||
import android.safetycenter.SafetyEvent;
|
import android.safetycenter.SafetyEvent;
|
||||||
import android.safetycenter.SafetySourceData;
|
import android.safetycenter.SafetySourceData;
|
||||||
import android.util.FeatureFlagUtils;
|
|
||||||
|
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
@@ -43,6 +44,7 @@ import com.android.settings.testutils.FakeFeatureFactory;
|
|||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
@@ -62,6 +64,7 @@ public class SafetySourceBroadcastReceiverTest {
|
|||||||
@Mock private SafetyCenterManagerWrapper mSafetyCenterManagerWrapper;
|
@Mock private SafetyCenterManagerWrapper mSafetyCenterManagerWrapper;
|
||||||
|
|
||||||
@Mock private LockPatternUtils mLockPatternUtils;
|
@Mock private LockPatternUtils mLockPatternUtils;
|
||||||
|
@Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
@@ -241,15 +244,10 @@ public class SafetySourceBroadcastReceiverTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Tests that the PS source sets null data when it's disabled. */
|
/** Tests that the PS source sets null data when it's disabled. */
|
||||||
// TODO(b/295516544): Modify this test for the new trunk stable flag instead when available.
|
|
||||||
@Test
|
@Test
|
||||||
public void onReceive_onRefresh_withPrivateSpaceFeatureDisabled_setsNullData() {
|
public void onReceive_onRefresh_withPrivateSpaceFeatureDisabled_setsNullData() {
|
||||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||||
FeatureFlagUtils
|
mSetFlagsRule.disableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
|
||||||
.setEnabled(
|
|
||||||
mApplicationContext,
|
|
||||||
FeatureFlagUtils.SETTINGS_PRIVATE_SPACE_SETTINGS,
|
|
||||||
false);
|
|
||||||
|
|
||||||
Intent intent =
|
Intent intent =
|
||||||
new Intent()
|
new Intent()
|
||||||
@@ -265,12 +263,6 @@ public class SafetySourceBroadcastReceiverTest {
|
|||||||
.setSafetySourceData(any(), any(), captor.capture(), any());
|
.setSafetySourceData(any(), any(), captor.capture(), any());
|
||||||
|
|
||||||
assertThat(captor.getValue()).isEqualTo(null);
|
assertThat(captor.getValue()).isEqualTo(null);
|
||||||
|
|
||||||
FeatureFlagUtils
|
|
||||||
.setEnabled(
|
|
||||||
mApplicationContext,
|
|
||||||
FeatureFlagUtils.SETTINGS_PRIVATE_SPACE_SETTINGS,
|
|
||||||
true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user