From 5035ef9f943b713e6aa9deaa3f78a246f26c7c49 Mon Sep 17 00:00:00 2001 From: Yanting Yang Date: Wed, 26 May 2021 23:49:28 +0800 Subject: [PATCH] Remove silky flag from System for official release Remove the silky condition and clean up redundant files. Bug: 183670633 Test: robotests & visual Change-Id: I2743a65869c4fe2ea684e259373ddc309dea59c3 --- res/xml/system_dashboard_fragment.xml | 48 ++++++------ res/xml/system_dashboard_fragment_v2.xml | 75 ------------------- .../GesturesSettingPreferenceController.java | 39 ---------- .../system/ResetPreferenceController.java | 15 ---- .../system/SystemDashboardFragment.java | 8 +- ...turesSettingsPreferenceControllerTest.java | 56 -------------- .../system/ResetPreferenceControllerTest.java | 43 ----------- 7 files changed, 23 insertions(+), 261 deletions(-) delete mode 100644 res/xml/system_dashboard_fragment_v2.xml diff --git a/res/xml/system_dashboard_fragment.xml b/res/xml/system_dashboard_fragment.xml index 88b8d2f7e94..9228ddd5f5a 100644 --- a/res/xml/system_dashboard_fragment.xml +++ b/res/xml/system_dashboard_fragment.xml @@ -18,16 +18,14 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:settings="http://schemas.android.com/apk/res-auto" android:key="system_dashboard_screen" - android:title="@string/header_category_system" - settings:initialExpandedChildrenCount="4"> + android:title="@string/header_category_system"> + android:fragment="com.android.settings.language.LanguageAndInputSettings"/> - - - - - - - \ No newline at end of file + + + + + + diff --git a/res/xml/system_dashboard_fragment_v2.xml b/res/xml/system_dashboard_fragment_v2.xml deleted file mode 100644 index 57174e9fa4a..00000000000 --- a/res/xml/system_dashboard_fragment_v2.xml +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/com/android/settings/gestures/GesturesSettingPreferenceController.java b/src/com/android/settings/gestures/GesturesSettingPreferenceController.java index e01bc8810fa..ff069ab3581 100644 --- a/src/com/android/settings/gestures/GesturesSettingPreferenceController.java +++ b/src/com/android/settings/gestures/GesturesSettingPreferenceController.java @@ -16,19 +16,13 @@ package com.android.settings.gestures; -import android.content.ContentResolver; import android.content.Context; import android.hardware.display.AmbientDisplayConfiguration; -import android.provider.Settings; -import android.text.TextUtils; -import android.util.FeatureFlagUtils; import androidx.annotation.NonNull; -import com.android.settings.R; import com.android.settings.aware.AwareFeatureProvider; import com.android.settings.core.BasePreferenceController; -import com.android.settings.core.FeatureFlags; import com.android.settings.overlay.FeatureFactory; import com.android.settingslib.core.AbstractPreferenceController; @@ -85,37 +79,4 @@ public class GesturesSettingPreferenceController extends BasePreferenceControlle controllers.add(new PreventRingingParentPreferenceController(context, FAKE_PREF_KEY)); return controllers; } - - @Override - public CharSequence getSummary() { - if (FeatureFlagUtils.isEnabled(mContext, FeatureFlags.SILKY_HOME)) { - return null; - } - - if (!mFeatureProvider.isSensorAvailable(mContext)) { - return ""; - } - final ContentResolver contentResolver = mContext.getContentResolver(); - final boolean assistGestureEnabled = Settings.Secure.getInt( - contentResolver, Settings.Secure.ASSIST_GESTURE_ENABLED, 1) != 0; - final boolean assistGestureSilenceEnabled = Settings.Secure.getInt( - contentResolver, Settings.Secure.ASSIST_GESTURE_SILENCE_ALERTS_ENABLED, 1) != 0; - final boolean sensorSupported = mFeatureProvider.isSupported(mContext); - - final CharSequence awareSummary = mAwareFeatureProvider.getGestureSummary(mContext, - sensorSupported, assistGestureEnabled, assistGestureSilenceEnabled); - if (!TextUtils.isEmpty(awareSummary)) { - return awareSummary; - } - - if (sensorSupported && assistGestureEnabled) { - return mContext.getText( - R.string.language_input_gesture_summary_on_with_assist); - } - if (assistGestureSilenceEnabled) { - return mContext.getText( - R.string.language_input_gesture_summary_on_non_assist); - } - return mContext.getText(R.string.language_input_gesture_summary_off); - } } diff --git a/src/com/android/settings/system/ResetPreferenceController.java b/src/com/android/settings/system/ResetPreferenceController.java index ad33d30aa78..0740ac9dae0 100644 --- a/src/com/android/settings/system/ResetPreferenceController.java +++ b/src/com/android/settings/system/ResetPreferenceController.java @@ -17,11 +17,9 @@ package com.android.settings.system; import android.content.Context; import android.os.UserManager; -import android.util.FeatureFlagUtils; import com.android.settings.R; import com.android.settings.core.BasePreferenceController; -import com.android.settings.core.FeatureFlags; import com.android.settings.network.NetworkResetPreferenceController; public class ResetPreferenceController extends BasePreferenceController { @@ -42,17 +40,4 @@ public class ResetPreferenceController extends BasePreferenceController { return mContext.getResources().getBoolean(R.bool.config_show_reset_dashboard) ? AVAILABLE : UNSUPPORTED_ON_DEVICE; } - - @Override - public CharSequence getSummary() { - if (FeatureFlagUtils.isEnabled(mContext, FeatureFlags.SILKY_HOME)) { - return null; - } - - if (!mNetworkReset.isAvailable() && !mFactpruReset.isAvailable()) { - return mContext.getText(R.string.reset_dashboard_summary_onlyApps); - } - - return mContext.getText(R.string.reset_dashboard_summary); - } } diff --git a/src/com/android/settings/system/SystemDashboardFragment.java b/src/com/android/settings/system/SystemDashboardFragment.java index 997678b9b95..eed9814c4ff 100644 --- a/src/com/android/settings/system/SystemDashboardFragment.java +++ b/src/com/android/settings/system/SystemDashboardFragment.java @@ -19,7 +19,6 @@ import android.app.settings.SettingsEnums; import android.content.Context; import android.os.Bundle; import android.provider.SearchIndexableResource; -import android.util.FeatureFlagUtils; import androidx.annotation.VisibleForTesting; import androidx.preference.Preference; @@ -27,7 +26,6 @@ import androidx.preference.PreferenceGroup; import androidx.preference.PreferenceScreen; import com.android.settings.R; -import com.android.settings.core.FeatureFlags; import com.android.settings.dashboard.DashboardFragment; import com.android.settings.overlay.FeatureFactory; import com.android.settings.search.BaseSearchIndexProvider; @@ -77,9 +75,6 @@ public class SystemDashboardFragment extends DashboardFragment { @Override protected int getPreferenceScreenResId() { - if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) { - return R.xml.system_dashboard_fragment_v2; - } return R.xml.system_dashboard_fragment; } @@ -110,8 +105,7 @@ public class SystemDashboardFragment extends DashboardFragment { public List getXmlResourcesToIndex( Context context, boolean enabled) { final SearchIndexableResource sir = new SearchIndexableResource(context); - sir.xmlResId = FeatureFlagUtils.isEnabled(context, FeatureFlags.SILKY_HOME) - ? R.xml.system_dashboard_fragment_v2 : R.xml.system_dashboard_fragment; + sir.xmlResId = R.xml.system_dashboard_fragment; return Arrays.asList(sir); } }; diff --git a/tests/robotests/src/com/android/settings/gestures/GesturesSettingsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/GesturesSettingsPreferenceControllerTest.java index df1dfd03c6f..c185810946f 100644 --- a/tests/robotests/src/com/android/settings/gestures/GesturesSettingsPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/gestures/GesturesSettingsPreferenceControllerTest.java @@ -20,22 +20,9 @@ import static com.android.settings.core.BasePreferenceController.AVAILABLE; import static com.google.common.truth.Truth.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - import android.app.Activity; -import android.content.ContentResolver; -import android.content.Context; -import android.provider.Settings; -import android.util.FeatureFlagUtils; -import androidx.preference.Preference; - -import com.android.settings.R; -import com.android.settings.core.FeatureFlags; import com.android.settings.testutils.FakeFeatureFactory; -import com.android.settings.testutils.shadow.ShadowSecureSettings; import com.android.settingslib.core.AbstractPreferenceController; import org.junit.Before; @@ -46,7 +33,6 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; -import org.robolectric.annotation.Config; import org.robolectric.util.ReflectionHelpers; import java.util.ArrayList; @@ -57,8 +43,6 @@ public class GesturesSettingsPreferenceControllerTest { @Mock(answer = Answers.RETURNS_DEEP_STUBS) private Activity mActivity; - @Mock - private Preference mPreference; private GesturesSettingPreferenceController mController; @@ -67,7 +51,6 @@ public class GesturesSettingsPreferenceControllerTest { MockitoAnnotations.initMocks(this); FakeFeatureFactory.setupForTest(); mController = new GesturesSettingPreferenceController(mActivity); - FeatureFlagUtils.setEnabled(RuntimeEnvironment.application, FeatureFlags.SILKY_HOME, false); } @Test @@ -96,43 +79,4 @@ public class GesturesSettingsPreferenceControllerTest { assertThat(mController.isAvailable()).isFalse(); } - - @Test - @Config(shadows = ShadowSecureSettings.class) - public void updateState_assistSupported_shouldSetToAssistGestureStatus() { - final FakeFeatureFactory featureFactory = - (FakeFeatureFactory) FakeFeatureFactory.getFactory(mActivity); - when(featureFactory.assistGestureFeatureProvider.isSupported(any(Context.class))) - .thenReturn(true); - when(featureFactory.assistGestureFeatureProvider.isSensorAvailable(any(Context.class))) - .thenReturn(true); - - final ContentResolver cr = mActivity.getContentResolver(); - Settings.Secure.putInt(cr, Settings.Secure.ASSIST_GESTURE_ENABLED, 0); - Settings.Secure.putInt(cr, Settings.Secure.ASSIST_GESTURE_SILENCE_ALERTS_ENABLED, 0); - mController.updateState(mPreference); - verify(mActivity).getText(R.string.language_input_gesture_summary_off); - - Settings.Secure.putInt(cr, Settings.Secure.ASSIST_GESTURE_ENABLED, 1); - Settings.Secure.putInt(cr, Settings.Secure.ASSIST_GESTURE_SILENCE_ALERTS_ENABLED, 0); - mController.updateState(mPreference); - verify(mActivity).getText(R.string.language_input_gesture_summary_on_with_assist); - - Settings.Secure.putInt(cr, Settings.Secure.ASSIST_GESTURE_ENABLED, 0); - Settings.Secure.putInt(cr, Settings.Secure.ASSIST_GESTURE_SILENCE_ALERTS_ENABLED, 1); - mController.updateState(mPreference); - verify(mActivity).getText(R.string.language_input_gesture_summary_on_non_assist); - } - - @Test - @Config(shadows = ShadowSecureSettings.class) - public void updateState_sensorNotAvailable_shouldSetToEmptyStatus() { - final FakeFeatureFactory featureFactory = - (FakeFeatureFactory) FakeFeatureFactory.getFactory(mActivity); - when(featureFactory.assistGestureFeatureProvider.isSensorAvailable(any(Context.class))) - .thenReturn(false); - - mController.updateState(mPreference); - verify(mPreference).setSummary(""); - } } diff --git a/tests/robotests/src/com/android/settings/system/ResetPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/system/ResetPreferenceControllerTest.java index e80e77addc3..dd95d2973cb 100644 --- a/tests/robotests/src/com/android/settings/system/ResetPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/system/ResetPreferenceControllerTest.java @@ -18,14 +18,6 @@ package com.android.settings.system; import static com.google.common.truth.Truth.assertThat; import android.content.Context; -import android.content.pm.UserInfo; -import android.os.UserHandle; -import android.provider.Settings; -import android.util.FeatureFlagUtils; - -import com.android.settings.R; -import com.android.settings.core.FeatureFlags; -import com.android.settings.testutils.shadow.ShadowUserManager; import org.junit.Before; import org.junit.Test; @@ -35,11 +27,9 @@ import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Config; @RunWith(RobolectricTestRunner.class) -@Config(shadows = ShadowUserManager.class) public class ResetPreferenceControllerTest { private static final String KEY_RESET_DASHBOARD = "reset_dashboard"; - private ShadowUserManager mShadowUserManager; private Context mContext; private ResetPreferenceController mController; @@ -48,8 +38,6 @@ public class ResetPreferenceControllerTest { public void setUp() { mContext = RuntimeEnvironment.application; mController = new ResetPreferenceController(mContext, KEY_RESET_DASHBOARD); - mShadowUserManager = ShadowUserManager.getShadow(); - FeatureFlagUtils.setEnabled(mContext, FeatureFlags.SILKY_HOME, false); } @Test @@ -62,35 +50,4 @@ public class ResetPreferenceControllerTest { public void isAvailable_ifNotVisible_false() { assertThat(mController.isAvailable()).isFalse(); } - - @Test - public void getSummary_systemUser_shouldReturnFullSummary() { - mShadowUserManager.setIsAdminUser(true); - - assertThat(mController.getSummary()).isEqualTo( - mContext.getString(R.string.reset_dashboard_summary)); - } - - @Test - public void getSummary_nonSystemUser_shouldReturnAppsSummary() { - mShadowUserManager.setIsAdminUser(false); - mShadowUserManager.setIsDemoUser(false); - - assertThat(mController.getSummary()).isEqualTo( - mContext.getString(R.string.reset_dashboard_summary_onlyApps)); - } - - @Test - public void getSummary_demoUser_shouldReturnFullSummary() { - mShadowUserManager.setIsAdminUser(false); - - // Place the device in demo mode. - Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.DEVICE_DEMO_MODE, 1); - - // Indicate the user is a demo user. - mShadowUserManager.addUser(UserHandle.myUserId(), "test", UserInfo.FLAG_DEMO); - - assertThat(mController.getSummary()).isEqualTo( - mContext.getString(R.string.reset_dashboard_summary)); - } } \ No newline at end of file