Show work profile apps only on app list.
For the work profile drilldown, we used to show all apps when the user drilled down into the categories. This makes it so that the drill down only shows the work apps when that deep. Change-Id: I492cd3e9b9b923b87b68645a871dcfb2b91b4f95 Fixes: 62963093 Test: Settings robotest
This commit is contained in:
@@ -115,6 +115,7 @@ public class ManageApplications extends InstrumentedPreferenceFragment
|
|||||||
public static final String EXTRA_VOLUME_UUID = "volumeUuid";
|
public static final String EXTRA_VOLUME_UUID = "volumeUuid";
|
||||||
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";
|
||||||
|
|
||||||
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";
|
||||||
@@ -277,6 +278,7 @@ public class ManageApplications extends InstrumentedPreferenceFragment
|
|||||||
private ResetAppsHelper mResetAppsHelper;
|
private ResetAppsHelper mResetAppsHelper;
|
||||||
private String mVolumeUuid;
|
private String mVolumeUuid;
|
||||||
private int mStorageType;
|
private int mStorageType;
|
||||||
|
private boolean mIsWorkOnly;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -328,6 +330,7 @@ public class ManageApplications extends InstrumentedPreferenceFragment
|
|||||||
mListType = LIST_TYPE_MAIN;
|
mListType = LIST_TYPE_MAIN;
|
||||||
}
|
}
|
||||||
mFilter = getDefaultFilter();
|
mFilter = getDefaultFilter();
|
||||||
|
mIsWorkOnly = args != null ? args.getBoolean(EXTRA_WORK_ONLY) : false;
|
||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
mSortOrder = savedInstanceState.getInt(EXTRA_SORT_ORDER, mSortOrder);
|
mSortOrder = savedInstanceState.getInt(EXTRA_SORT_ORDER, mSortOrder);
|
||||||
@@ -423,6 +426,9 @@ public class ManageApplications extends InstrumentedPreferenceFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
AppFilter compositeFilter = getCompositeFilter(mListType, mStorageType, mVolumeUuid);
|
AppFilter compositeFilter = getCompositeFilter(mListType, mStorageType, mVolumeUuid);
|
||||||
|
if (mIsWorkOnly) {
|
||||||
|
compositeFilter = new CompoundFilter(compositeFilter, FILTERS[FILTER_APPS_WORK]);
|
||||||
|
}
|
||||||
if (compositeFilter != null) {
|
if (compositeFilter != null) {
|
||||||
mApplications.setCompositeFilter(compositeFilter);
|
mApplications.setCompositeFilter(compositeFilter);
|
||||||
}
|
}
|
||||||
|
@@ -101,8 +101,13 @@ public class StorageProfileFragment extends DashboardFragment
|
|||||||
protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
|
protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
|
||||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||||
final StorageManager sm = context.getSystemService(StorageManager.class);
|
final StorageManager sm = context.getSystemService(StorageManager.class);
|
||||||
mPreferenceController = new StorageItemPreferenceController(context, this,
|
mPreferenceController =
|
||||||
mVolume, new StorageManagerVolumeProvider(sm));
|
new StorageItemPreferenceController(
|
||||||
|
context,
|
||||||
|
this,
|
||||||
|
mVolume,
|
||||||
|
new StorageManagerVolumeProvider(sm),
|
||||||
|
/* isWorkProfile */ true);
|
||||||
controllers.add(mPreferenceController);
|
controllers.add(mPreferenceController);
|
||||||
return controllers;
|
return controllers;
|
||||||
}
|
}
|
||||||
|
@@ -95,6 +95,7 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
|||||||
private StorageItemPreference mSystemPreference;
|
private StorageItemPreference mSystemPreference;
|
||||||
|
|
||||||
private static final String AUTHORITY_MEDIA = "com.android.providers.media.documents";
|
private static final String AUTHORITY_MEDIA = "com.android.providers.media.documents";
|
||||||
|
private boolean mIsWorkProfile;
|
||||||
|
|
||||||
public StorageItemPreferenceController(
|
public StorageItemPreferenceController(
|
||||||
Context context, Fragment hostFragment, VolumeInfo volume, StorageVolumeProvider svp) {
|
Context context, Fragment hostFragment, VolumeInfo volume, StorageVolumeProvider svp) {
|
||||||
@@ -106,6 +107,16 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
|||||||
mUserId = UserHandle.myUserId();
|
mUserId = UserHandle.myUserId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public StorageItemPreferenceController(
|
||||||
|
Context context,
|
||||||
|
Fragment hostFragment,
|
||||||
|
VolumeInfo volume,
|
||||||
|
StorageVolumeProvider svp,
|
||||||
|
boolean isWorkProfile) {
|
||||||
|
this(context, hostFragment, volume, svp);
|
||||||
|
mIsWorkProfile = isWorkProfile;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAvailable() {
|
public boolean isAvailable() {
|
||||||
return true;
|
return true;
|
||||||
@@ -212,7 +223,7 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
|||||||
if (preference != null) {
|
if (preference != null) {
|
||||||
Drawable currentIcon = preference.getIcon();
|
Drawable currentIcon = preference.getIcon();
|
||||||
// Sigh... Applying the badge to the icon clobbers the tint on the base drawable.
|
// Sigh... Applying the badge to the icon clobbers the tint on the base drawable.
|
||||||
// For some reason, re-applying it here means the tint remains.
|
// For some reason, reapplying it here means the tint remains.
|
||||||
currentIcon = applyTint(mContext, currentIcon);
|
currentIcon = applyTint(mContext, currentIcon);
|
||||||
preference.setIcon(pm.getUserBadgedIcon(currentIcon, userHandle));
|
preference.setIcon(pm.getUserBadgedIcon(currentIcon, userHandle));
|
||||||
}
|
}
|
||||||
@@ -320,6 +331,7 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
|||||||
}
|
}
|
||||||
|
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
|
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());
|
||||||
@@ -336,6 +348,7 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
|||||||
}
|
}
|
||||||
|
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
|
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());
|
||||||
@@ -347,6 +360,7 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
|||||||
|
|
||||||
private Intent getGamesIntent() {
|
private Intent getGamesIntent() {
|
||||||
Bundle args = new Bundle(1);
|
Bundle args = new Bundle(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,
|
||||||
@@ -356,6 +370,7 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
|||||||
|
|
||||||
private Intent getMoviesIntent() {
|
private Intent getMoviesIntent() {
|
||||||
Bundle args = new Bundle(1);
|
Bundle args = new Bundle(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,
|
||||||
|
@@ -16,12 +16,12 @@
|
|||||||
package com.android.settings.deviceinfo.storage;
|
package com.android.settings.deviceinfo.storage;
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.nullable;
|
import static org.mockito.ArgumentMatchers.nullable;
|
||||||
import static org.mockito.Matchers.any;
|
|
||||||
import static org.mockito.Matchers.eq;
|
import static org.mockito.Matchers.eq;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
@@ -171,6 +171,29 @@ public class StorageItemPreferenceControllerTest {
|
|||||||
.isEqualTo(R.string.apps_storage);
|
.isEqualTo(R.string.apps_storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testClickAppsForWork() {
|
||||||
|
mController = new StorageItemPreferenceController(mContext, mFragment, mVolume, mSvp, true);
|
||||||
|
mPreference.setKey("pref_other_apps");
|
||||||
|
mController.handlePreferenceTreeClick(mPreference);
|
||||||
|
|
||||||
|
final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
|
||||||
|
verify(mFragment.getActivity())
|
||||||
|
.startActivityAsUser(argumentCaptor.capture(), nullable(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.apps_storage);
|
||||||
|
assertThat(
|
||||||
|
intent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
|
||||||
|
.getBoolean(EXTRA_WORK_ONLY))
|
||||||
|
.isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void handlePreferenceTreeClick_tappingAppsWhileUninitializedDoesntCrash() {
|
public void handlePreferenceTreeClick_tappingAppsWhileUninitializedDoesntCrash() {
|
||||||
mController.setVolume(null);
|
mController.setVolume(null);
|
||||||
|
Reference in New Issue
Block a user