Merge "Fix work profile storage bugs." into oc-mr1-dev
am: 67f0299a25
Change-Id: Ia30e1b297d8c4f9b4167f09e92f1ce1645b26977
This commit is contained in:
@@ -117,6 +117,7 @@ public class ManageApplications extends InstrumentedPreferenceFragment
|
|||||||
public static final String EXTRA_VOLUME_NAME = "volumeName";
|
public static final String EXTRA_VOLUME_NAME = "volumeName";
|
||||||
public static final String EXTRA_STORAGE_TYPE = "storageType";
|
public static final String EXTRA_STORAGE_TYPE = "storageType";
|
||||||
public static final String EXTRA_WORK_ONLY = "workProfileOnly";
|
public static final String EXTRA_WORK_ONLY = "workProfileOnly";
|
||||||
|
public static final String EXTRA_WORK_ID = "workId";
|
||||||
|
|
||||||
private static final String EXTRA_SORT_ORDER = "sortOrder";
|
private static final String EXTRA_SORT_ORDER = "sortOrder";
|
||||||
private static final String EXTRA_SHOW_SYSTEM = "showSystem";
|
private static final String EXTRA_SHOW_SYSTEM = "showSystem";
|
||||||
@@ -222,6 +223,8 @@ public class ManageApplications extends InstrumentedPreferenceFragment
|
|||||||
public static final int STORAGE_TYPE_LEGACY = 2; // Show apps even if they can be categorized.
|
public static final int STORAGE_TYPE_LEGACY = 2; // Show apps even if they can be categorized.
|
||||||
public static final int STORAGE_TYPE_PHOTOS_VIDEOS = 3;
|
public static final int STORAGE_TYPE_PHOTOS_VIDEOS = 3;
|
||||||
|
|
||||||
|
private static final int NO_USER_SPECIFIED = -1;
|
||||||
|
|
||||||
// sort order
|
// sort order
|
||||||
private int mSortOrder = R.id.sort_order_alpha;
|
private int mSortOrder = R.id.sort_order_alpha;
|
||||||
|
|
||||||
@@ -282,6 +285,7 @@ public class ManageApplications extends InstrumentedPreferenceFragment
|
|||||||
private String mVolumeUuid;
|
private String mVolumeUuid;
|
||||||
private int mStorageType;
|
private int mStorageType;
|
||||||
private boolean mIsWorkOnly;
|
private boolean mIsWorkOnly;
|
||||||
|
private int mWorkUserId;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -338,6 +342,7 @@ public class ManageApplications extends InstrumentedPreferenceFragment
|
|||||||
}
|
}
|
||||||
mFilter = getDefaultFilter();
|
mFilter = getDefaultFilter();
|
||||||
mIsWorkOnly = args != null ? args.getBoolean(EXTRA_WORK_ONLY) : false;
|
mIsWorkOnly = args != null ? args.getBoolean(EXTRA_WORK_ONLY) : false;
|
||||||
|
mWorkUserId = args != null ? args.getInt(EXTRA_WORK_ID) : NO_USER_SPECIFIED;
|
||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
mSortOrder = savedInstanceState.getInt(EXTRA_SORT_ORDER, mSortOrder);
|
mSortOrder = savedInstanceState.getInt(EXTRA_SORT_ORDER, mSortOrder);
|
||||||
@@ -378,13 +383,15 @@ public class ManageApplications extends InstrumentedPreferenceFragment
|
|||||||
mApplications.mHasReceivedBridgeCallback =
|
mApplications.mHasReceivedBridgeCallback =
|
||||||
savedInstanceState.getBoolean(EXTRA_HAS_BRIDGE, false);
|
savedInstanceState.getBoolean(EXTRA_HAS_BRIDGE, false);
|
||||||
}
|
}
|
||||||
|
int userId = mIsWorkOnly ? mWorkUserId : UserHandle.getUserId(mCurrentUid);
|
||||||
if (mStorageType == STORAGE_TYPE_MUSIC) {
|
if (mStorageType == STORAGE_TYPE_MUSIC) {
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
mApplications.setExtraViewController(new MusicViewHolderController(
|
mApplications.setExtraViewController(
|
||||||
|
new MusicViewHolderController(
|
||||||
context,
|
context,
|
||||||
new StorageStatsSource(context),
|
new StorageStatsSource(context),
|
||||||
mVolumeUuid,
|
mVolumeUuid,
|
||||||
UserHandle.of(UserHandle.getUserId(mCurrentUid))));
|
UserHandle.of(userId)));
|
||||||
} else if (mStorageType == STORAGE_TYPE_PHOTOS_VIDEOS) {
|
} else if (mStorageType == STORAGE_TYPE_PHOTOS_VIDEOS) {
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
mApplications.setExtraViewController(
|
mApplications.setExtraViewController(
|
||||||
@@ -392,7 +399,7 @@ public class ManageApplications extends InstrumentedPreferenceFragment
|
|||||||
context,
|
context,
|
||||||
new StorageStatsSource(context),
|
new StorageStatsSource(context),
|
||||||
mVolumeUuid,
|
mVolumeUuid,
|
||||||
UserHandle.of(UserHandle.getUserId(mCurrentUid))));
|
UserHandle.of(userId)));
|
||||||
}
|
}
|
||||||
mListView.setAdapter(mApplications);
|
mListView.setAdapter(mApplications);
|
||||||
mListView.setRecyclerListener(mApplications);
|
mListView.setRecyclerListener(mApplications);
|
||||||
|
@@ -20,7 +20,6 @@ import android.app.Fragment;
|
|||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.TrafficStats;
|
import android.net.TrafficStats;
|
||||||
@@ -314,7 +313,7 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Intent getPhotosIntent() {
|
private Intent getPhotosIntent() {
|
||||||
Bundle args = new Bundle(2);
|
Bundle args = getWorkAnnotatedBundle(2);
|
||||||
args.putString(
|
args.putString(
|
||||||
ManageApplications.EXTRA_CLASSNAME, Settings.PhotosStorageActivity.class.getName());
|
ManageApplications.EXTRA_CLASSNAME, Settings.PhotosStorageActivity.class.getName());
|
||||||
args.putInt(
|
args.putInt(
|
||||||
@@ -336,8 +335,7 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bundle args = new Bundle();
|
Bundle args = getWorkAnnotatedBundle(4);
|
||||||
args.putBoolean(ManageApplications.EXTRA_WORK_ONLY, mIsWorkProfile);
|
|
||||||
args.putString(ManageApplications.EXTRA_CLASSNAME,
|
args.putString(ManageApplications.EXTRA_CLASSNAME,
|
||||||
Settings.StorageUseActivity.class.getName());
|
Settings.StorageUseActivity.class.getName());
|
||||||
args.putString(ManageApplications.EXTRA_VOLUME_UUID, mVolume.getFsUuid());
|
args.putString(ManageApplications.EXTRA_VOLUME_UUID, mVolume.getFsUuid());
|
||||||
@@ -353,8 +351,7 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bundle args = new Bundle();
|
Bundle args = getWorkAnnotatedBundle(3);
|
||||||
args.putBoolean(ManageApplications.EXTRA_WORK_ONLY, mIsWorkProfile);
|
|
||||||
args.putString(ManageApplications.EXTRA_CLASSNAME,
|
args.putString(ManageApplications.EXTRA_CLASSNAME,
|
||||||
Settings.StorageUseActivity.class.getName());
|
Settings.StorageUseActivity.class.getName());
|
||||||
args.putString(ManageApplications.EXTRA_VOLUME_UUID, mVolume.getFsUuid());
|
args.putString(ManageApplications.EXTRA_VOLUME_UUID, mVolume.getFsUuid());
|
||||||
@@ -365,8 +362,7 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Intent getGamesIntent() {
|
private Intent getGamesIntent() {
|
||||||
Bundle args = new Bundle(1);
|
Bundle args = getWorkAnnotatedBundle(1);
|
||||||
args.putBoolean(ManageApplications.EXTRA_WORK_ONLY, mIsWorkProfile);
|
|
||||||
args.putString(ManageApplications.EXTRA_CLASSNAME,
|
args.putString(ManageApplications.EXTRA_CLASSNAME,
|
||||||
Settings.GamesStorageActivity.class.getName());
|
Settings.GamesStorageActivity.class.getName());
|
||||||
return Utils.onBuildStartFragmentIntent(mContext,
|
return Utils.onBuildStartFragmentIntent(mContext,
|
||||||
@@ -375,8 +371,7 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Intent getMoviesIntent() {
|
private Intent getMoviesIntent() {
|
||||||
Bundle args = new Bundle(1);
|
Bundle args = getWorkAnnotatedBundle(1);
|
||||||
args.putBoolean(ManageApplications.EXTRA_WORK_ONLY, mIsWorkProfile);
|
|
||||||
args.putString(ManageApplications.EXTRA_CLASSNAME,
|
args.putString(ManageApplications.EXTRA_CLASSNAME,
|
||||||
Settings.MoviesStorageActivity.class.getName());
|
Settings.MoviesStorageActivity.class.getName());
|
||||||
return Utils.onBuildStartFragmentIntent(mContext,
|
return Utils.onBuildStartFragmentIntent(mContext,
|
||||||
@@ -384,6 +379,13 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
|||||||
null, false, mMetricsFeatureProvider.getMetricsCategory(mFragment));
|
null, false, mMetricsFeatureProvider.getMetricsCategory(mFragment));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Bundle getWorkAnnotatedBundle(int additionalCapacity) {
|
||||||
|
Bundle args = new Bundle(2 + additionalCapacity);
|
||||||
|
args.putBoolean(ManageApplications.EXTRA_WORK_ONLY, mIsWorkProfile);
|
||||||
|
args.putInt(ManageApplications.EXTRA_WORK_ID, mUserId);
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
private Intent getFilesIntent() {
|
private Intent getFilesIntent() {
|
||||||
return mSvp.findEmulatedForPrivate(mVolume).buildBrowseIntent();
|
return mSvp.findEmulatedForPrivate(mVolume).buildBrowseIntent();
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
package com.android.settings.deviceinfo.storage;
|
package com.android.settings.deviceinfo.storage;
|
||||||
|
|
||||||
|
|
||||||
|
import static com.android.settings.applications.ManageApplications.EXTRA_WORK_ID;
|
||||||
import static com.android.settings.applications.ManageApplications.EXTRA_WORK_ONLY;
|
import static com.android.settings.applications.ManageApplications.EXTRA_WORK_ONLY;
|
||||||
import static com.android.settings.utils.FileSizeFormatter.MEGABYTE_IN_BYTES;
|
import static com.android.settings.utils.FileSizeFormatter.MEGABYTE_IN_BYTES;
|
||||||
|
|
||||||
@@ -195,6 +196,10 @@ public class StorageItemPreferenceControllerTest {
|
|||||||
intent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
|
intent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
|
||||||
.getBoolean(EXTRA_WORK_ONLY))
|
.getBoolean(EXTRA_WORK_ONLY))
|
||||||
.isTrue();
|
.isTrue();
|
||||||
|
assertThat(
|
||||||
|
intent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
|
||||||
|
.getInt(EXTRA_WORK_ID))
|
||||||
|
.isEqualTo(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user