Add a movies & tv apps category to storage settings.

Change-Id: Idfabe83739272b19cbef4b13a82339170f8f97b3
Fixes: 36223441
Test: Settings Robotest
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 8f645f8..9313281 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -118,6 +118,7 @@
     public static class ManageDomainUrlsActivity extends SettingsActivity { /* empty */ }
     public static class AutomaticStorageManagerSettingsActivity extends SettingsActivity { /* empty */ }
     public static class GamesStorageActivity extends SettingsActivity { /* empty */ }
+    public static class MoviesStorageActivity extends SettingsActivity { /* empty */ }
 
     public static class TopLevelSettings extends SettingsActivity { /* empty */ }
     public static class ApnSettingsActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/applications/ManageApplications.java b/src/com/android/settings/applications/ManageApplications.java
index f83dfeb..3499df6 100644
--- a/src/com/android/settings/applications/ManageApplications.java
+++ b/src/com/android/settings/applications/ManageApplications.java
@@ -61,6 +61,7 @@
 import com.android.settings.Settings.GamesStorageActivity;
 import com.android.settings.Settings.HighPowerApplicationsActivity;
 import com.android.settings.Settings.ManageExternalSourcesActivity;
+import com.android.settings.Settings.MoviesStorageActivity;
 import com.android.settings.Settings.NotificationAppListActivity;
 import com.android.settings.Settings.OverlaySettingsActivity;
 import com.android.settings.Settings.StorageUseActivity;
@@ -253,6 +254,7 @@
     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;
+    public static final int LIST_TYPE_MOVIES = 10;
 
     private View mRootView;
 
@@ -307,6 +309,9 @@
         } else if (className.equals(GamesStorageActivity.class.getName())) {
             mListType = LIST_TYPE_GAMES;
             mSortOrder = R.id.sort_order_size;
+        } else if (className.equals(MoviesStorageActivity.class.getName())) {
+            mListType = LIST_TYPE_MOVIES;
+            mSortOrder = R.id.sort_order_size;
         } else {
             mListType = LIST_TYPE_MAIN;
         }
@@ -415,6 +420,8 @@
         }
         if (mListType == LIST_TYPE_GAMES) {
             mApplications.setOverrideFilter(ApplicationsState.FILTER_GAMES);
+        } else if (mListType == LIST_TYPE_MOVIES) {
+            mApplications.setOverrideFilter(ApplicationsState.FILTER_MOVIES);
         }
     }
 
@@ -441,6 +448,7 @@
             case LIST_TYPE_NOTIFICATION:
             case LIST_TYPE_STORAGE:
             case LIST_TYPE_GAMES:
+            case LIST_TYPE_MOVIES:
                 return mSortOrder == R.id.sort_order_alpha;
             default:
                 return false;
@@ -461,6 +469,8 @@
                 return MetricsEvent.APPLICATIONS_STORAGE_APPS;
             case LIST_TYPE_GAMES:
                 return MetricsEvent.APPLICATIONS_STORAGE_GAMES;
+            case LIST_TYPE_MOVIES:
+                return MetricsEvent.APPLICATIONS_STORAGE_MOVIES;
             case LIST_TYPE_USAGE_ACCESS:
                 return MetricsEvent.USAGE_ACCESS;
             case LIST_TYPE_HIGH_POWER:
@@ -568,6 +578,9 @@
             case LIST_TYPE_GAMES:
                 startAppInfoFragment(AppStorageSettings.class, R.string.game_storage_settings);
                 break;
+            case LIST_TYPE_MOVIES:
+                startAppInfoFragment(AppStorageSettings.class, R.string.storage_movies_tv);
+                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.
             // Maybe when they load the list of apps that contains managed profile apps.
diff --git a/src/com/android/settings/deviceinfo/StorageProfileFragment.java b/src/com/android/settings/deviceinfo/StorageProfileFragment.java
index c5d1045..7e2d941 100644
--- a/src/com/android/settings/deviceinfo/StorageProfileFragment.java
+++ b/src/com/android/settings/deviceinfo/StorageProfileFragment.java
@@ -140,6 +140,7 @@
         // TODO(b/35927909): Attribute app sizes better than zeroing out for profiles.
         result.gamesSize = 0;
         result.musicAppsSize = 0;
+        result.videoAppsSize = 0;
         result.otherAppsSize = 0;
         return result;
     }
diff --git a/src/com/android/settings/deviceinfo/storage/StorageAsyncLoader.java b/src/com/android/settings/deviceinfo/storage/StorageAsyncLoader.java
index ae5e5f1..e83c5d2 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageAsyncLoader.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageAsyncLoader.java
@@ -18,6 +18,7 @@
 
 import static android.content.pm.ApplicationInfo.CATEGORY_AUDIO;
 import static android.content.pm.ApplicationInfo.CATEGORY_GAME;
+import static android.content.pm.ApplicationInfo.CATEGORY_VIDEO;
 
 import android.content.Context;
 import android.content.pm.ApplicationInfo;
@@ -99,6 +100,9 @@
                 case CATEGORY_AUDIO:
                     result.musicAppsSize += attributedAppSizeInBytes;
                     break;
+                case CATEGORY_VIDEO:
+                    result.videoAppsSize += attributedAppSizeInBytes;
+                    break;
                 default:
                     // The deprecated game flag does not set the category.
                     if ((app.flags & ApplicationInfo.FLAG_IS_GAME) != 0) {
@@ -123,6 +127,7 @@
     public static class AppsStorageResult {
         public long gamesSize;
         public long musicAppsSize;
+        public long videoAppsSize;
         public long otherAppsSize;
         public long systemSize;
         public StorageStatsSource.ExternalStorageStats externalStats;
diff --git a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
index 5b27592..36694f0 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
@@ -65,6 +65,8 @@
     @VisibleForTesting
     static final String GAME_KEY = "pref_games";
     @VisibleForTesting
+    static final String MOVIES_KEY = "pref_movies";
+    @VisibleForTesting
     static final String OTHER_APPS_KEY = "pref_other_apps";
     @VisibleForTesting
     static final String SYSTEM_KEY = "pref_system";
@@ -82,6 +84,7 @@
     private StorageItemPreference mPhotoPreference;
     private StorageItemPreference mAudioPreference;
     private StorageItemPreference mGamePreference;
+    private StorageItemPreference mMoviesPreference;
     private StorageItemPreference mAppPreference;
     private StorageItemPreference mFilePreference;
     private StorageItemPreference mSystemPreference;
@@ -123,6 +126,9 @@
             case GAME_KEY:
                 intent = getGamesIntent();
                 break;
+            case MOVIES_KEY:
+                intent = getMoviesIntent();
+                break;
             case OTHER_APPS_KEY:
                 // Because we are likely constructed with a null volume, this is theoretically
                 // possible.
@@ -204,6 +210,7 @@
         mPhotoPreference = (StorageItemPreference) screen.findPreference(PHOTO_KEY);
         mAudioPreference = (StorageItemPreference) screen.findPreference(AUDIO_KEY);
         mGamePreference = (StorageItemPreference) screen.findPreference(GAME_KEY);
+        mMoviesPreference = (StorageItemPreference) screen.findPreference(MOVIES_KEY);
         mAppPreference = (StorageItemPreference) screen.findPreference(OTHER_APPS_KEY);
         mSystemPreference = (StorageItemPreference) screen.findPreference(SYSTEM_KEY);
         mFilePreference = (StorageItemPreference) screen.findPreference(FILES_KEY);
@@ -217,6 +224,7 @@
         mAudioPreference.setStorageSize(
                 data.musicAppsSize + data.externalStats.audioBytes, mTotalSize);
         mGamePreference.setStorageSize(data.gamesSize, mTotalSize);
+        mMoviesPreference.setStorageSize(data.videoAppsSize, mTotalSize);
         mAppPreference.setStorageSize(data.otherAppsSize, mTotalSize);
         if (mSystemPreference != null) {
             mSystemPreference.setStorageSize(mSystemSize + data.systemSize, mTotalSize);
@@ -243,6 +251,7 @@
         list.add(PHOTO_KEY);
         list.add(AUDIO_KEY);
         list.add(GAME_KEY);
+        list.add(MOVIES_KEY);
         list.add(OTHER_APPS_KEY);
         list.add(SYSTEM_KEY);
         list.add(FILES_KEY);
@@ -281,12 +290,21 @@
     }
 
     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, mMetricsFeatureProvider.getMetricsCategory(mFragment));
+        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, mMetricsFeatureProvider.getMetricsCategory(mFragment));
+    }
+
+    private Intent getMoviesIntent() {
+        Bundle args = new Bundle(1);
+        args.putString(ManageApplications.EXTRA_CLASSNAME,
+                Settings.MoviesStorageActivity.class.getName());
+        return Utils.onBuildStartFragmentIntent(mContext,
+                ManageApplications.class.getName(), args, null, R.string.storage_movies_tv,
+                null, false, mMetricsFeatureProvider.getMetricsCategory(mFragment));
     }
 
     private Intent getFilesIntent() {