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

Commit c208eff2 authored by Daniel Nishi's avatar Daniel Nishi
Browse files

Hook up the Games storage category preference to a games view.

This patch adds functionality for the soon-to-be-deprecated games
and the new app categorization.

Bug: 33199077
Test: settings robo
Change-Id: Iae055c6f1b4d1af3f51aba9897c140ae7aac41c9
parent 6cf09db1
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -8106,6 +8106,9 @@
    <!-- On status for the automatic storage manager. [CHAR_LIMIT=10] -->
    <string name="storage_manager_indicator_on">On</string>
    <!-- Title of games app storage screen [CHAR LIMIT=30] -->
    <string name="game_storage_settings">Games</string>
    <!-- UI webview setting: WebView uninstalled-for-user explanatory text [CHAR LIMIT=30] -->
    <string name="webview_uninstalled_for_user">Uninstalled for user <xliff:g id="user" example="John Doe">%s</xliff:g>\n</string>
    <!-- UI webview setting: WebView disabled-for-user explanatory text [CHAR LIMIT=30] -->
+1 −0
Original line number Diff line number Diff line
@@ -126,6 +126,7 @@ public class Settings extends SettingsActivity {
    public static class OtherSoundSettingsActivity extends SettingsActivity { /* empty */ }
    public static class ManageDomainUrlsActivity extends SettingsActivity { /* empty */ }
    public static class AutomaticStorageManagerSettingsActivity extends SettingsActivity { /* empty */ }
    public static class GamesStorageActivity extends SettingsActivity { /* empty */ }

    public static class TopLevelSettings extends SettingsActivity { /* empty */ }
    public static class ApnSettingsActivity extends SettingsActivity { /* empty */ }
+12 −1
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ import android.os.LocaleList;
import android.os.UserHandle;
import android.os.UserManager;
import android.preference.PreferenceFrameLayout;
import android.support.v7.preference.Preference;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
@@ -57,6 +56,7 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.AppHeader;
import com.android.settings.R;
import com.android.settings.Settings.AllApplicationsActivity;
import com.android.settings.Settings.GamesStorageActivity;
import com.android.settings.Settings.HighPowerApplicationsActivity;
import com.android.settings.Settings.ManageExternalSourcesActivity;
import com.android.settings.Settings.NotificationAppListActivity;
@@ -216,6 +216,7 @@ public class ManageApplications extends InstrumentedPreferenceFragment
    public static final int LIST_TYPE_OVERLAY = 6;
    public static final int LIST_TYPE_WRITE_SETTINGS = 7;
    public static final int LIST_TYPE_MANAGE_SOURCES = 8;
    public static final int LIST_TYPE_GAMES = 9;

    private View mRootView;

@@ -267,6 +268,9 @@ public class ManageApplications extends InstrumentedPreferenceFragment
            mListType = LIST_TYPE_WRITE_SETTINGS;
        } else if (className.equals(ManageExternalSourcesActivity.class.getName())) {
            mListType = LIST_TYPE_MANAGE_SOURCES;
        } else if (className.equals(GamesStorageActivity.class.getName())) {
            mListType = LIST_TYPE_GAMES;
            mSortOrder = R.id.sort_order_size;
        } else {
            mListType = LIST_TYPE_MAIN;
        }
@@ -359,6 +363,9 @@ public class ManageApplications extends InstrumentedPreferenceFragment
        if (mListType == LIST_TYPE_STORAGE) {
            mApplications.setOverrideFilter(new VolumeFilter(mVolumeUuid));
        }
        if (mListType == LIST_TYPE_GAMES) {
            mApplications.setOverrideFilter(ApplicationsState.FILTER_GAMES);
        }
    }

    @Override
@@ -399,6 +406,7 @@ public class ManageApplications extends InstrumentedPreferenceFragment
            case LIST_TYPE_MAIN:
            case LIST_TYPE_NOTIFICATION:
            case LIST_TYPE_STORAGE:
            case LIST_TYPE_GAMES:
                return mSortOrder == R.id.sort_order_alpha;
            default:
                return false;
@@ -413,6 +421,7 @@ public class ManageApplications extends InstrumentedPreferenceFragment
            case LIST_TYPE_NOTIFICATION:
                return MetricsEvent.MANAGE_APPLICATIONS_NOTIFICATIONS;
            case LIST_TYPE_STORAGE:
            case LIST_TYPE_GAMES:
                return MetricsEvent.APPLICATIONS_STORAGE_APPS;
            case LIST_TYPE_USAGE_ACCESS:
                return MetricsEvent.USAGE_ACCESS;
@@ -517,6 +526,8 @@ public class ManageApplications extends InstrumentedPreferenceFragment
                break;
            case LIST_TYPE_MANAGE_SOURCES:
                startAppInfoFragment(ExternalSourcesDetails.class, R.string.install_other_apps);
            case LIST_TYPE_GAMES:
                startAppInfoFragment(AppStorageSettings.class, R.string.game_storage_settings);
                break;
            // TODO: Figure out if there is a way where we can spin up the profile's settings
            // process ahead of time, to avoid a long load of data when user clicks on a managed app.
+11 −1
Original line number Diff line number Diff line
@@ -122,7 +122,8 @@ public class StorageItemPreferenceController extends PreferenceController
                intent = getAudioIntent();
                break;
            case GAME_KEY:
                // TODO: Once app categorization is added, make this section.
                intent = getGamesIntent();
                break;
            case OTHER_APPS_KEY:
                // Because we are likely constructed with a null volume, this is theoretically
                // possible.
@@ -259,6 +260,15 @@ public class StorageItemPreferenceController extends PreferenceController
                false);
    }

    private Intent getGamesIntent() {
            Bundle args = new Bundle(1);
            args.putString(ManageApplications.EXTRA_CLASSNAME,
                    Settings.GamesStorageActivity.class.getName());
            return Utils.onBuildStartFragmentIntent(mContext,
                    ManageApplications.class.getName(), args, null, R.string.game_storage_settings,
                    null, false);
    }

    private Intent getFilesIntent() {
        return mSvp.findEmulatedForPrivate(mVolume).buildBrowseIntent();
    }
+20 −0
Original line number Diff line number Diff line
@@ -140,6 +140,8 @@ public class StorageItemPreferenceControllerTest {
        assertThat(intent.getComponent().getClassName()).isEqualTo(SubSettings.class.getName());
        assertThat(intent.getStringExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT)).isEqualTo(
                ManageApplications.class.getName());
        assertThat(intent.getIntExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RESID, 0))
                .isEqualTo(R.string.apps_storage);
    }

    @Test
@@ -158,6 +160,24 @@ public class StorageItemPreferenceControllerTest {
        assertThat(intent.getData()).isEqualTo(browseIntent.getData());
    }

    @Test
    public void testClickGames() {
        mPreference.setKey("pref_games");
        mController.handlePreferenceTreeClick(mPreference);

        final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
        verify(mFragment.getActivity()).startActivityAsUser(argumentCaptor.capture(),
                any(UserHandle.class));

        Intent intent = argumentCaptor.getValue();
        assertThat(intent.getAction()).isEqualTo(Intent.ACTION_MAIN);
        assertThat(intent.getComponent().getClassName()).isEqualTo(SubSettings.class.getName());
        assertThat(intent.getStringExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT)).isEqualTo(
                ManageApplications.class.getName());
        assertThat(intent.getIntExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RESID, 0))
                .isEqualTo(R.string.game_storage_settings);
    }

    @Test
    public void testMeasurementCompletedUpdatesPreferences() {
        StorageItemPreferenceAlternate audio = new StorageItemPreferenceAlternate(mContext);