Change ProfileType definition
Bug: 141601408 Test: rebuild Change-Id: Ia4d4fabe8a4daad4ce54c243748fa3c29bf944ba
This commit is contained in:
@@ -1060,9 +1060,9 @@ public final class Utils extends com.android.settingslib.Utils {
|
|||||||
public static Fragment getTargetFragment(Activity activity, String fragmentName, Bundle args) {
|
public static Fragment getTargetFragment(Activity activity, String fragmentName, Bundle args) {
|
||||||
Fragment f = null;
|
Fragment f = null;
|
||||||
final boolean isPersonal = args != null ? args.getInt(ProfileSelectFragment.EXTRA_PROFILE)
|
final boolean isPersonal = args != null ? args.getInt(ProfileSelectFragment.EXTRA_PROFILE)
|
||||||
== ProfileSelectFragment.PERSONAL : false;
|
== ProfileSelectFragment.ProfileType.PERSONAL : false;
|
||||||
final boolean isWork = args != null ? args.getInt(ProfileSelectFragment.EXTRA_PROFILE)
|
final boolean isWork = args != null ? args.getInt(ProfileSelectFragment.EXTRA_PROFILE)
|
||||||
== ProfileSelectFragment.WORK : false;
|
== ProfileSelectFragment.ProfileType.WORK : false;
|
||||||
if (FeatureFlagUtils.isEnabled(activity, FeatureFlags.PERSONAL_WORK_PROFILE)
|
if (FeatureFlagUtils.isEnabled(activity, FeatureFlags.PERSONAL_WORK_PROFILE)
|
||||||
&& UserManager.get(activity).getUserProfiles().size() > 1
|
&& UserManager.get(activity).getUserProfiles().size() > 1
|
||||||
&& ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName) != null
|
&& ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName) != null
|
||||||
|
@@ -73,7 +73,7 @@ public class AccountDashboardFragment extends DashboardFragment {
|
|||||||
|
|
||||||
final AccountPreferenceController accountPrefController =
|
final AccountPreferenceController accountPrefController =
|
||||||
new AccountPreferenceController(context, parent, authorities,
|
new AccountPreferenceController(context, parent, authorities,
|
||||||
ProfileSelectFragment.ALL);
|
ProfileSelectFragment.ProfileType.ALL);
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
parent.getSettingsLifecycle().addObserver(accountPrefController);
|
parent.getSettingsLifecycle().addObserver(accountPrefController);
|
||||||
}
|
}
|
||||||
|
@@ -71,7 +71,7 @@ public class AccountPersonalDashboardFragment extends DashboardFragment {
|
|||||||
|
|
||||||
final AccountPreferenceController accountPrefController =
|
final AccountPreferenceController accountPrefController =
|
||||||
new AccountPreferenceController(context, parent, authorities,
|
new AccountPreferenceController(context, parent, authorities,
|
||||||
ProfileSelectFragment.PERSONAL);
|
ProfileSelectFragment.ProfileType.PERSONAL);
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
parent.getSettingsLifecycle().addObserver(accountPrefController);
|
parent.getSettingsLifecycle().addObserver(accountPrefController);
|
||||||
}
|
}
|
||||||
|
@@ -277,10 +277,10 @@ public class AccountPreferenceController extends AbstractPreferenceController
|
|||||||
final int profilesCount = profiles.size();
|
final int profilesCount = profiles.size();
|
||||||
for (int i = 0; i < profilesCount; i++) {
|
for (int i = 0; i < profilesCount; i++) {
|
||||||
if (profiles.get(i).isManagedProfile()
|
if (profiles.get(i).isManagedProfile()
|
||||||
&& (mType & ProfileSelectFragment.WORK) != 0) {
|
&& (mType & ProfileSelectFragment.ProfileType.WORK) != 0) {
|
||||||
updateProfileUi(profiles.get(i));
|
updateProfileUi(profiles.get(i));
|
||||||
} else if (!profiles.get(i).isManagedProfile()
|
} else if (!profiles.get(i).isManagedProfile()
|
||||||
&& (mType & ProfileSelectFragment.PERSONAL) != 0) {
|
&& (mType & ProfileSelectFragment.ProfileType.PERSONAL) != 0) {
|
||||||
updateProfileUi(profiles.get(i));
|
updateProfileUi(profiles.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -324,7 +324,7 @@ public class AccountPreferenceController extends AbstractPreferenceController
|
|||||||
preferenceGroup.setContentDescription(
|
preferenceGroup.setContentDescription(
|
||||||
mContext.getString(R.string.account_settings));
|
mContext.getString(R.string.account_settings));
|
||||||
} else if (userInfo.isManagedProfile()) {
|
} else if (userInfo.isManagedProfile()) {
|
||||||
if (mType == ProfileSelectFragment.ALL) {
|
if (mType == ProfileSelectFragment.ProfileType.ALL) {
|
||||||
preferenceGroup.setTitle(R.string.category_work);
|
preferenceGroup.setTitle(R.string.category_work);
|
||||||
final String workGroupSummary = getWorkGroupSummary(context, userInfo);
|
final String workGroupSummary = getWorkGroupSummary(context, userInfo);
|
||||||
preferenceGroup.setSummary(workGroupSummary);
|
preferenceGroup.setSummary(workGroupSummary);
|
||||||
@@ -336,7 +336,7 @@ public class AccountPreferenceController extends AbstractPreferenceController
|
|||||||
DISALLOW_REMOVE_MANAGED_PROFILE, UserHandle.myUserId());
|
DISALLOW_REMOVE_MANAGED_PROFILE, UserHandle.myUserId());
|
||||||
profileData.managedProfilePreference = newManagedProfileSettings();
|
profileData.managedProfilePreference = newManagedProfileSettings();
|
||||||
} else {
|
} else {
|
||||||
if (mType == ProfileSelectFragment.ALL) {
|
if (mType == ProfileSelectFragment.ProfileType.ALL) {
|
||||||
preferenceGroup.setTitle(R.string.category_personal);
|
preferenceGroup.setTitle(R.string.category_personal);
|
||||||
preferenceGroup.setContentDescription(
|
preferenceGroup.setContentDescription(
|
||||||
mContext.getString(R.string.accessibility_category_personal));
|
mContext.getString(R.string.accessibility_category_personal));
|
||||||
|
@@ -71,7 +71,7 @@ public class AccountWorkProfileDashboardFragment extends DashboardFragment {
|
|||||||
|
|
||||||
final AccountPreferenceController accountPrefController =
|
final AccountPreferenceController accountPrefController =
|
||||||
new AccountPreferenceController(context, parent, authorities,
|
new AccountPreferenceController(context, parent, authorities,
|
||||||
ProfileSelectFragment.WORK);
|
ProfileSelectFragment.ProfileType.WORK);
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
parent.getSettingsLifecycle().addObserver(accountPrefController);
|
parent.getSettingsLifecycle().addObserver(accountPrefController);
|
||||||
}
|
}
|
||||||
|
@@ -102,9 +102,9 @@ import com.android.settings.core.InstrumentedFragment;
|
|||||||
import com.android.settings.core.SubSettingLauncher;
|
import com.android.settings.core.SubSettingLauncher;
|
||||||
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
|
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
|
||||||
import com.android.settings.fuelgauge.HighPowerDetail;
|
import com.android.settings.fuelgauge.HighPowerDetail;
|
||||||
import com.android.settings.notification.app.AppNotificationSettings;
|
|
||||||
import com.android.settings.notification.ConfigureNotificationSettings;
|
import com.android.settings.notification.ConfigureNotificationSettings;
|
||||||
import com.android.settings.notification.NotificationBackend;
|
import com.android.settings.notification.NotificationBackend;
|
||||||
|
import com.android.settings.notification.app.AppNotificationSettings;
|
||||||
import com.android.settings.widget.LoadingViewController;
|
import com.android.settings.widget.LoadingViewController;
|
||||||
import com.android.settings.wifi.AppStateChangeWifiStateBridge;
|
import com.android.settings.wifi.AppStateChangeWifiStateBridge;
|
||||||
import com.android.settings.wifi.ChangeWifiStateDetails;
|
import com.android.settings.wifi.ChangeWifiStateDetails;
|
||||||
@@ -311,9 +311,9 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
final AppFilterRegistry appFilterRegistry = AppFilterRegistry.getInstance();
|
final AppFilterRegistry appFilterRegistry = AppFilterRegistry.getInstance();
|
||||||
mFilter = appFilterRegistry.get(appFilterRegistry.getDefaultFilterType(mListType));
|
mFilter = appFilterRegistry.get(appFilterRegistry.getDefaultFilterType(mListType));
|
||||||
mIsPersonalOnly = args != null ? args.getInt(ProfileSelectFragment.EXTRA_PROFILE)
|
mIsPersonalOnly = args != null ? args.getInt(ProfileSelectFragment.EXTRA_PROFILE)
|
||||||
== ProfileSelectFragment.PERSONAL : false;
|
== ProfileSelectFragment.ProfileType.PERSONAL : false;
|
||||||
mIsWorkOnly = args != null ? args.getInt(ProfileSelectFragment.EXTRA_PROFILE)
|
mIsWorkOnly = args != null ? args.getInt(ProfileSelectFragment.EXTRA_PROFILE)
|
||||||
== ProfileSelectFragment.WORK : false;
|
== ProfileSelectFragment.ProfileType.WORK : false;
|
||||||
mWorkUserId = args != null ? args.getInt(EXTRA_WORK_ID) : NO_USER_SPECIFIED;
|
mWorkUserId = args != null ? args.getInt(EXTRA_WORK_ID) : NO_USER_SPECIFIED;
|
||||||
mExpandSearch = activity.getIntent().getBooleanExtra(EXTRA_EXPAND_SEARCH_VIEW, false);
|
mExpandSearch = activity.getIntent().getBooleanExtra(EXTRA_EXPAND_SEARCH_VIEW, false);
|
||||||
|
|
||||||
|
@@ -53,25 +53,28 @@ public abstract class ProfileSelectFragment extends DashboardFragment {
|
|||||||
* Denotes the profile type.
|
* Denotes the profile type.
|
||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
@IntDef({PERSONAL, WORK, ALL})
|
@IntDef({
|
||||||
|
ProfileType.PERSONAL,
|
||||||
|
ProfileType.WORK,
|
||||||
|
ProfileType.ALL
|
||||||
|
})
|
||||||
public @interface ProfileType {
|
public @interface ProfileType {
|
||||||
|
/**
|
||||||
|
* It is personal work profile.
|
||||||
|
*/
|
||||||
|
int PERSONAL = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It is work profile
|
||||||
|
*/
|
||||||
|
int WORK = 1 << 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It is personal and work profile
|
||||||
|
*/
|
||||||
|
int ALL = PERSONAL | WORK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* It is personal work profile.
|
|
||||||
*/
|
|
||||||
public static final int PERSONAL = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* It is work profile
|
|
||||||
*/
|
|
||||||
public static final int WORK = 1 << 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* It is personal and work profile
|
|
||||||
*/
|
|
||||||
public static final int ALL = PERSONAL | WORK;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used in fragment argument and pass {@link ProfileType} to it
|
* Used in fragment argument and pass {@link ProfileType} to it
|
||||||
*/
|
*/
|
||||||
|
@@ -30,12 +30,12 @@ public class ProfileSelectManageApplications extends ProfileSelectFragment {
|
|||||||
@Override
|
@Override
|
||||||
public Fragment[] getFragments() {
|
public Fragment[] getFragments() {
|
||||||
final Bundle workOnly = getArguments() != null ? getArguments().deepCopy() : new Bundle();
|
final Bundle workOnly = getArguments() != null ? getArguments().deepCopy() : new Bundle();
|
||||||
workOnly.putInt(EXTRA_PROFILE, ProfileSelectFragment.WORK);
|
workOnly.putInt(EXTRA_PROFILE, ProfileSelectFragment.ProfileType.WORK);
|
||||||
final Fragment workFragment = new ManageApplications();
|
final Fragment workFragment = new ManageApplications();
|
||||||
workFragment.setArguments(workOnly);
|
workFragment.setArguments(workOnly);
|
||||||
|
|
||||||
final Bundle personalOnly = getArguments() != null ? getArguments() : new Bundle();
|
final Bundle personalOnly = getArguments() != null ? getArguments() : new Bundle();
|
||||||
personalOnly.putInt(EXTRA_PROFILE, ProfileSelectFragment.PERSONAL);
|
personalOnly.putInt(EXTRA_PROFILE, ProfileSelectFragment.ProfileType.PERSONAL);
|
||||||
final Fragment personalFragment = new ManageApplications();
|
final Fragment personalFragment = new ManageApplications();
|
||||||
personalFragment.setArguments(personalOnly);
|
personalFragment.setArguments(personalOnly);
|
||||||
return new Fragment[]{
|
return new Fragment[]{
|
||||||
|
@@ -37,7 +37,7 @@ public class ProfileSelectStorageFragment extends ProfileSelectFragment {
|
|||||||
|
|
||||||
final Bundle storageBundle = new Bundle();
|
final Bundle storageBundle = new Bundle();
|
||||||
storageBundle.putString(VolumeInfo.EXTRA_VOLUME_ID, VolumeInfo.ID_PRIVATE_INTERNAL);
|
storageBundle.putString(VolumeInfo.EXTRA_VOLUME_ID, VolumeInfo.ID_PRIVATE_INTERNAL);
|
||||||
storageBundle.putInt(EXTRA_PROFILE, ProfileSelectFragment.PERSONAL);
|
storageBundle.putInt(EXTRA_PROFILE, ProfileSelectFragment.ProfileType.PERSONAL);
|
||||||
|
|
||||||
final Fragment storageDashboardFragment = new StorageDashboardFragment();
|
final Fragment storageDashboardFragment = new StorageDashboardFragment();
|
||||||
storageDashboardFragment.setArguments(storageBundle);
|
storageDashboardFragment.setArguments(storageBundle);
|
||||||
|
@@ -87,7 +87,7 @@ public class StorageDashboardFragment extends DashboardFragment
|
|||||||
StorageManager sm = activity.getSystemService(StorageManager.class);
|
StorageManager sm = activity.getSystemService(StorageManager.class);
|
||||||
mVolume = Utils.maybeInitializeVolume(sm, getArguments());
|
mVolume = Utils.maybeInitializeVolume(sm, getArguments());
|
||||||
mPersonalOnly = getArguments().getInt(ProfileSelectFragment.EXTRA_PROFILE)
|
mPersonalOnly = getArguments().getInt(ProfileSelectFragment.EXTRA_PROFILE)
|
||||||
== ProfileSelectFragment.PERSONAL;
|
== ProfileSelectFragment.ProfileType.PERSONAL;
|
||||||
if (mVolume == null) {
|
if (mVolume == null) {
|
||||||
activity.finish();
|
activity.finish();
|
||||||
return;
|
return;
|
||||||
|
@@ -405,7 +405,8 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
|||||||
} else {
|
} else {
|
||||||
final Bundle args = new Bundle(2 + additionalCapacity);
|
final Bundle args = new Bundle(2 + additionalCapacity);
|
||||||
args.putInt(ProfileSelectFragment.EXTRA_PROFILE,
|
args.putInt(ProfileSelectFragment.EXTRA_PROFILE,
|
||||||
mIsWorkProfile ? ProfileSelectFragment.WORK : ProfileSelectFragment.ALL);
|
mIsWorkProfile ? ProfileSelectFragment.ProfileType.WORK
|
||||||
|
: ProfileSelectFragment.ProfileType.ALL);
|
||||||
args.putInt(ManageApplications.EXTRA_WORK_ID, mUserId);
|
args.putInt(ManageApplications.EXTRA_WORK_ID, mUserId);
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
@@ -98,7 +98,7 @@ public class AccountPreferenceControllerTest {
|
|||||||
.thenReturn(new AuthenticatorDescription[0]);
|
.thenReturn(new AuthenticatorDescription[0]);
|
||||||
when(mAccountManager.getAccountsAsUser(anyInt())).thenReturn(new Account[0]);
|
when(mAccountManager.getAccountsAsUser(anyInt())).thenReturn(new Account[0]);
|
||||||
mController = new AccountPreferenceController(mContext, mFragment, null, mAccountHelper,
|
mController = new AccountPreferenceController(mContext, mFragment, null, mAccountHelper,
|
||||||
ProfileSelectFragment.ALL);
|
ProfileSelectFragment.ProfileType.ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
Reference in New Issue
Block a user