public static final String EXTRA_VOLUME_NAME = "volumeName";
public static final String EXTRA_STORAGE_TYPE = "storageType";
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_SHOW_SYSTEM = "showSystem";
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;
+ private static final int NO_USER_SPECIFIED = -1;
+
// sort order
private int mSortOrder = R.id.sort_order_alpha;
private String mVolumeUuid;
private int mStorageType;
private boolean mIsWorkOnly;
+ private int mWorkUserId;
@Override
public void onCreate(Bundle savedInstanceState) {
}
mFilter = getDefaultFilter();
mIsWorkOnly = args != null ? args.getBoolean(EXTRA_WORK_ONLY) : false;
+ mWorkUserId = args != null ? args.getInt(EXTRA_WORK_ID) : NO_USER_SPECIFIED;
if (savedInstanceState != null) {
mSortOrder = savedInstanceState.getInt(EXTRA_SORT_ORDER, mSortOrder);
mApplications.mHasReceivedBridgeCallback =
savedInstanceState.getBoolean(EXTRA_HAS_BRIDGE, false);
}
+ int userId = mIsWorkOnly ? mWorkUserId : UserHandle.getUserId(mCurrentUid);
if (mStorageType == STORAGE_TYPE_MUSIC) {
Context context = getContext();
- mApplications.setExtraViewController(new MusicViewHolderController(
- context,
- new StorageStatsSource(context),
- mVolumeUuid,
- UserHandle.of(UserHandle.getUserId(mCurrentUid))));
+ mApplications.setExtraViewController(
+ new MusicViewHolderController(
+ context,
+ new StorageStatsSource(context),
+ mVolumeUuid,
+ UserHandle.of(userId)));
} else if (mStorageType == STORAGE_TYPE_PHOTOS_VIDEOS) {
Context context = getContext();
mApplications.setExtraViewController(
context,
new StorageStatsSource(context),
mVolumeUuid,
- UserHandle.of(UserHandle.getUserId(mCurrentUid))));
+ UserHandle.of(userId)));
}
mListView.setAdapter(mApplications);
mListView.setRecyclerListener(mApplications);
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
-import android.content.pm.PackageManager;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.net.TrafficStats;
}
private Intent getPhotosIntent() {
- Bundle args = new Bundle(2);
+ Bundle args = getWorkAnnotatedBundle(2);
args.putString(
ManageApplications.EXTRA_CLASSNAME, Settings.PhotosStorageActivity.class.getName());
args.putInt(
return null;
}
- Bundle args = new Bundle();
- args.putBoolean(ManageApplications.EXTRA_WORK_ONLY, mIsWorkProfile);
+ Bundle args = getWorkAnnotatedBundle(4);
args.putString(ManageApplications.EXTRA_CLASSNAME,
Settings.StorageUseActivity.class.getName());
args.putString(ManageApplications.EXTRA_VOLUME_UUID, mVolume.getFsUuid());
return null;
}
- Bundle args = new Bundle();
- args.putBoolean(ManageApplications.EXTRA_WORK_ONLY, mIsWorkProfile);
+ Bundle args = getWorkAnnotatedBundle(3);
args.putString(ManageApplications.EXTRA_CLASSNAME,
Settings.StorageUseActivity.class.getName());
args.putString(ManageApplications.EXTRA_VOLUME_UUID, mVolume.getFsUuid());
}
private Intent getGamesIntent() {
- Bundle args = new Bundle(1);
- args.putBoolean(ManageApplications.EXTRA_WORK_ONLY, mIsWorkProfile);
+ Bundle args = getWorkAnnotatedBundle(1);
args.putString(ManageApplications.EXTRA_CLASSNAME,
Settings.GamesStorageActivity.class.getName());
return Utils.onBuildStartFragmentIntent(mContext,
}
private Intent getMoviesIntent() {
- Bundle args = new Bundle(1);
- args.putBoolean(ManageApplications.EXTRA_WORK_ONLY, mIsWorkProfile);
+ Bundle args = getWorkAnnotatedBundle(1);
args.putString(ManageApplications.EXTRA_CLASSNAME,
Settings.MoviesStorageActivity.class.getName());
return Utils.onBuildStartFragmentIntent(mContext,
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() {
return mSvp.findEmulatedForPrivate(mVolume).buildBrowseIntent();
}