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

Commit d0bbbfee authored by Yiwei Zhang's avatar Yiwei Zhang
Browse files

GUP: Fixed some typos and update some values

Bug: 119221883
Test: make RunSettingsRoboTests
Change-Id: I7b1e42cd3a823a72bcd6d61b26c4954c237ff6d0
Merged-In: I7b1e42cd3a823a72bcd6d61b26c4954c237ff6d0
parent dc62028e
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
@@ -9982,23 +9982,23 @@
         show both names, with the directory name wrapped in parenthesis -->
    <string name="directory_on_volume"><xliff:g id="volume" example="SD Card">%1$s</xliff:g> (<xliff:g id="directory" example="Movies">%2$s</xliff:g>)</string>
    <!-- Title for Game Update Packages dashboard where developers can configure apps to use GUP or not [CHAR LIMIT=50] -->
    <string name="gup_dashboard_title">Game Update Packages Preferences</string>
    <!-- Summary for Game Update Packages dashboard [CHAR LIMIT=50] -->
    <string name="gup_dashboard_summary">Modify Game Update Packages settings</string>
    <!-- Title for Game Update Packages preference [CHAR LIMIT=50] -->
    <!-- Title for Game Update Package dashboard where developers can configure apps to use GUP or not [CHAR LIMIT=50] -->
    <string name="gup_dashboard_title">Game Update Package Preferences</string>
    <!-- Summary for Game Update Package dashboard [CHAR LIMIT=50] -->
    <string name="gup_dashboard_summary">Modify Game Update Package settings</string>
    <!-- Title for Game Update Package preference [CHAR LIMIT=50] -->
    <string name="gup_app_preference_title">Select Graphics Driver</string>
    <!-- The default value for Game Update Packages preference [CHAR LIMIT=50] -->
    <!-- The default value for Game Update Package preference [CHAR LIMIT=50] -->
    <string name="gup_app_preference_default">Default</string>
    <!-- The gup value for Game Update Packages preference [CHAR LIMIT=50] -->
    <string name="gup_app_preference_gup">Game Update Packages</string>
    <!-- The native value for Game Update Packages preference [CHAR LIMIT=50] -->
    <string name="gup_app_preference_native">Native Graphics Driver</string>
    <!-- All the values for Game Update Packages preference [CHAR LIMIT=50] -->
    <!-- The gup value for Game Update Package preference [CHAR LIMIT=50] -->
    <string name="gup_app_preference_gup">Game Update Package</string>
    <!-- The system value for Game Update Package preference [CHAR LIMIT=50] -->
    <string name="gup_app_preference_system">System Graphics Driver</string>
    <!-- All the values for Game Update Package preference [CHAR LIMIT=50] -->
    <string-array name="gup_app_preference_values">
        <item>@string/gup_app_preference_default</item>
        <item>@string/gup_app_preference_gup</item>
        <item>@string/gup_app_preference_native</item>
        <item>@string/gup_app_preference_system</item>
    </string-array>
    <!-- Slices Strings -->
+7 −8
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ public class GupPreferenceController
    private final String mPreferenceTitle;
    private final String mPreferenceDefault;
    private final String mPreferenceGup;
    private final String mPreferenceNative;
    private final String mPreferenceSystem;

    private final List<AppInfo> mAppInfos;
    private final Set<String> mDevOptInApps;
@@ -62,7 +62,7 @@ public class GupPreferenceController
        mPreferenceTitle = resources.getString(R.string.gup_app_preference_title);
        mPreferenceDefault = resources.getString(R.string.gup_app_preference_default);
        mPreferenceGup = resources.getString(R.string.gup_app_preference_gup);
        mPreferenceNative = resources.getString(R.string.gup_app_preference_native);
        mPreferenceSystem = resources.getString(R.string.gup_app_preference_system);

        // TODO: Move this task to background if there's potential ANR/Jank.
        // Update the UI when all the app infos are ready.
@@ -105,19 +105,18 @@ public class GupPreferenceController

        // When user choose a new preference, update both Sets for
        // opt-in and opt-out apps. Then set the new summary text.
        if (value.equals(mPreferenceNative)) {
        if (value.equals(mPreferenceSystem)) {
            mDevOptInApps.remove(packageName);
            mDevOptOutApps.add(packageName);
            listPref.setSummary(mPreferenceNative);
        } else if (value.equals(mPreferenceGup)) {
            mDevOptInApps.add(packageName);
            mDevOptOutApps.remove(packageName);
            listPref.setSummary(mPreferenceGup);
        } else {
            mDevOptInApps.remove(packageName);
            mDevOptOutApps.remove(packageName);
            listPref.setSummary(mPreferenceDefault);
        }
        listPref.setValue(value);
        listPref.setSummary(value);

        // Push the updated Sets for opt-in and opt-out apps to
        // corresponding Settings.Global.GUP_DEV_OPT_(IN|OUT)_APPS
@@ -189,8 +188,8 @@ public class GupPreferenceController
        // Initialize preference default and summary with the opt in/out choices
        // from Settings.Global.GUP_DEV_OPT_(IN|OUT)_APPS
        if (mDevOptOutApps.contains(packageName)) {
            listPreference.setValue(mPreferenceNative);
            listPreference.setSummary(mPreferenceNative);
            listPreference.setValue(mPreferenceSystem);
            listPreference.setSummary(mPreferenceSystem);
        } else if (mDevOptInApps.contains(packageName)) {
            listPreference.setValue(mPreferenceGup);
            listPreference.setSummary(mPreferenceGup);
+14 −8
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ import org.robolectric.RuntimeEnvironment;
public class GupPreferenceControllerTest {
    private static final int DEFAULT = 0;
    private static final int GUP = 1;
    private static final int NATIVE = 2;
    private static final int SYSTEM = 2;
    private static final String TEST_APP_NAME = "testApp";
    private static final String TEST_PKG_NAME = "testPkg";

@@ -125,7 +125,7 @@ public class GupPreferenceControllerTest {
    }

    @Test
    public void createPreference_configNative_shouldSetNativeAttributes() {
    public void createPreference_configSystem_shouldSetSystemAttributes() {
        loadConfig("", TEST_PKG_NAME);
        final ListPreference preference =
                mController.createListPreference(TEST_PKG_NAME, TEST_APP_NAME);
@@ -135,9 +135,9 @@ public class GupPreferenceControllerTest {
        assertThat(preference.getDialogTitle()).isEqualTo(mDialogTitle);
        assertThat(preference.getEntries()).isEqualTo(mValueList);
        assertThat(preference.getEntryValues()).isEqualTo(mValueList);
        assertThat(preference.getEntry()).isEqualTo(mValueList[NATIVE]);
        assertThat(preference.getValue()).isEqualTo(mValueList[NATIVE]);
        assertThat(preference.getSummary()).isEqualTo(mValueList[NATIVE]);
        assertThat(preference.getEntry()).isEqualTo(mValueList[SYSTEM]);
        assertThat(preference.getValue()).isEqualTo(mValueList[SYSTEM]);
        assertThat(preference.getSummary()).isEqualTo(mValueList[SYSTEM]);
    }

    @Test
@@ -147,6 +147,8 @@ public class GupPreferenceControllerTest {
                mController.createListPreference(TEST_PKG_NAME, TEST_APP_NAME);
        mController.onPreferenceChange(preference, mValueList[DEFAULT]);

        assertThat(preference.getEntry()).isEqualTo(mValueList[DEFAULT]);
        assertThat(preference.getValue()).isEqualTo(mValueList[DEFAULT]);
        assertThat(preference.getSummary()).isEqualTo(mValueList[DEFAULT]);
        assertThat(Settings.Global.getString(mResolver, Settings.Global.GUP_DEV_OPT_IN_APPS))
                .isEqualTo("");
@@ -161,6 +163,8 @@ public class GupPreferenceControllerTest {
                mController.createListPreference(TEST_PKG_NAME, TEST_APP_NAME);
        mController.onPreferenceChange(preference, mValueList[GUP]);

        assertThat(preference.getEntry()).isEqualTo(mValueList[GUP]);
        assertThat(preference.getValue()).isEqualTo(mValueList[GUP]);
        assertThat(preference.getSummary()).isEqualTo(mValueList[GUP]);
        assertThat(Settings.Global.getString(mResolver, Settings.Global.GUP_DEV_OPT_IN_APPS))
                .isEqualTo(TEST_PKG_NAME);
@@ -169,13 +173,15 @@ public class GupPreferenceControllerTest {
    }

    @Test
    public void onPreferenceChange_selectNative_shouldUpdateAttributesAndSettingsGlobal() {
    public void onPreferenceChange_selectSystem_shouldUpdateAttributesAndSettingsGlobal() {
        loadDefaultConfig();
        final ListPreference preference =
                mController.createListPreference(TEST_PKG_NAME, TEST_APP_NAME);
        mController.onPreferenceChange(preference, mValueList[NATIVE]);
        mController.onPreferenceChange(preference, mValueList[SYSTEM]);

        assertThat(preference.getSummary()).isEqualTo(mValueList[NATIVE]);
        assertThat(preference.getEntry()).isEqualTo(mValueList[SYSTEM]);
        assertThat(preference.getValue()).isEqualTo(mValueList[SYSTEM]);
        assertThat(preference.getSummary()).isEqualTo(mValueList[SYSTEM]);
        assertThat(Settings.Global.getString(mResolver, Settings.Global.GUP_DEV_OPT_IN_APPS))
                .isEqualTo("");
        assertThat(Settings.Global.getString(mResolver, Settings.Global.GUP_DEV_OPT_OUT_APPS))