Change ProfileType definition

Bug: 141601408
Test: rebuild
Change-Id: Ia4d4fabe8a4daad4ce54c243748fa3c29bf944ba
This commit is contained in:
Raff Tsai
2019-12-12 11:45:41 +08:00
parent 1ee247a6a7
commit 1e5d8146b5
12 changed files with 38 additions and 34 deletions

View File

@@ -1060,9 +1060,9 @@ public final class Utils extends com.android.settingslib.Utils {
public static Fragment getTargetFragment(Activity activity, String fragmentName, Bundle args) {
Fragment f = null;
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)
== ProfileSelectFragment.WORK : false;
== ProfileSelectFragment.ProfileType.WORK : false;
if (FeatureFlagUtils.isEnabled(activity, FeatureFlags.PERSONAL_WORK_PROFILE)
&& UserManager.get(activity).getUserProfiles().size() > 1
&& ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName) != null

View File

@@ -73,7 +73,7 @@ public class AccountDashboardFragment extends DashboardFragment {
final AccountPreferenceController accountPrefController =
new AccountPreferenceController(context, parent, authorities,
ProfileSelectFragment.ALL);
ProfileSelectFragment.ProfileType.ALL);
if (parent != null) {
parent.getSettingsLifecycle().addObserver(accountPrefController);
}

View File

@@ -71,7 +71,7 @@ public class AccountPersonalDashboardFragment extends DashboardFragment {
final AccountPreferenceController accountPrefController =
new AccountPreferenceController(context, parent, authorities,
ProfileSelectFragment.PERSONAL);
ProfileSelectFragment.ProfileType.PERSONAL);
if (parent != null) {
parent.getSettingsLifecycle().addObserver(accountPrefController);
}

View File

@@ -277,10 +277,10 @@ public class AccountPreferenceController extends AbstractPreferenceController
final int profilesCount = profiles.size();
for (int i = 0; i < profilesCount; i++) {
if (profiles.get(i).isManagedProfile()
&& (mType & ProfileSelectFragment.WORK) != 0) {
&& (mType & ProfileSelectFragment.ProfileType.WORK) != 0) {
updateProfileUi(profiles.get(i));
} else if (!profiles.get(i).isManagedProfile()
&& (mType & ProfileSelectFragment.PERSONAL) != 0) {
&& (mType & ProfileSelectFragment.ProfileType.PERSONAL) != 0) {
updateProfileUi(profiles.get(i));
}
}
@@ -324,7 +324,7 @@ public class AccountPreferenceController extends AbstractPreferenceController
preferenceGroup.setContentDescription(
mContext.getString(R.string.account_settings));
} else if (userInfo.isManagedProfile()) {
if (mType == ProfileSelectFragment.ALL) {
if (mType == ProfileSelectFragment.ProfileType.ALL) {
preferenceGroup.setTitle(R.string.category_work);
final String workGroupSummary = getWorkGroupSummary(context, userInfo);
preferenceGroup.setSummary(workGroupSummary);
@@ -336,7 +336,7 @@ public class AccountPreferenceController extends AbstractPreferenceController
DISALLOW_REMOVE_MANAGED_PROFILE, UserHandle.myUserId());
profileData.managedProfilePreference = newManagedProfileSettings();
} else {
if (mType == ProfileSelectFragment.ALL) {
if (mType == ProfileSelectFragment.ProfileType.ALL) {
preferenceGroup.setTitle(R.string.category_personal);
preferenceGroup.setContentDescription(
mContext.getString(R.string.accessibility_category_personal));

View File

@@ -71,7 +71,7 @@ public class AccountWorkProfileDashboardFragment extends DashboardFragment {
final AccountPreferenceController accountPrefController =
new AccountPreferenceController(context, parent, authorities,
ProfileSelectFragment.WORK);
ProfileSelectFragment.ProfileType.WORK);
if (parent != null) {
parent.getSettingsLifecycle().addObserver(accountPrefController);
}

View File

@@ -102,9 +102,9 @@ import com.android.settings.core.InstrumentedFragment;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
import com.android.settings.fuelgauge.HighPowerDetail;
import com.android.settings.notification.app.AppNotificationSettings;
import com.android.settings.notification.ConfigureNotificationSettings;
import com.android.settings.notification.NotificationBackend;
import com.android.settings.notification.app.AppNotificationSettings;
import com.android.settings.widget.LoadingViewController;
import com.android.settings.wifi.AppStateChangeWifiStateBridge;
import com.android.settings.wifi.ChangeWifiStateDetails;
@@ -311,9 +311,9 @@ public class ManageApplications extends InstrumentedFragment
final AppFilterRegistry appFilterRegistry = AppFilterRegistry.getInstance();
mFilter = appFilterRegistry.get(appFilterRegistry.getDefaultFilterType(mListType));
mIsPersonalOnly = args != null ? args.getInt(ProfileSelectFragment.EXTRA_PROFILE)
== ProfileSelectFragment.PERSONAL : false;
== ProfileSelectFragment.ProfileType.PERSONAL : false;
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;
mExpandSearch = activity.getIntent().getBooleanExtra(EXTRA_EXPAND_SEARCH_VIEW, false);

View File

@@ -53,24 +53,27 @@ public abstract class ProfileSelectFragment extends DashboardFragment {
* Denotes the profile type.
*/
@Retention(RetentionPolicy.SOURCE)
@IntDef({PERSONAL, WORK, ALL})
@IntDef({
ProfileType.PERSONAL,
ProfileType.WORK,
ProfileType.ALL
})
public @interface ProfileType {
}
/**
* It is personal work profile.
*/
public static final int PERSONAL = 1;
int PERSONAL = 1;
/**
* It is work profile
*/
public static final int WORK = 1 << 1;
int WORK = 1 << 1;
/**
* It is personal and work profile
*/
public static final int ALL = PERSONAL | WORK;
int ALL = PERSONAL | WORK;
}
/**
* Used in fragment argument and pass {@link ProfileType} to it

View File

@@ -30,12 +30,12 @@ public class ProfileSelectManageApplications extends ProfileSelectFragment {
@Override
public Fragment[] getFragments() {
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();
workFragment.setArguments(workOnly);
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();
personalFragment.setArguments(personalOnly);
return new Fragment[]{

View File

@@ -37,7 +37,7 @@ public class ProfileSelectStorageFragment extends ProfileSelectFragment {
final Bundle storageBundle = new Bundle();
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();
storageDashboardFragment.setArguments(storageBundle);

View File

@@ -87,7 +87,7 @@ public class StorageDashboardFragment extends DashboardFragment
StorageManager sm = activity.getSystemService(StorageManager.class);
mVolume = Utils.maybeInitializeVolume(sm, getArguments());
mPersonalOnly = getArguments().getInt(ProfileSelectFragment.EXTRA_PROFILE)
== ProfileSelectFragment.PERSONAL;
== ProfileSelectFragment.ProfileType.PERSONAL;
if (mVolume == null) {
activity.finish();
return;

View File

@@ -405,7 +405,8 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
} else {
final Bundle args = new Bundle(2 + additionalCapacity);
args.putInt(ProfileSelectFragment.EXTRA_PROFILE,
mIsWorkProfile ? ProfileSelectFragment.WORK : ProfileSelectFragment.ALL);
mIsWorkProfile ? ProfileSelectFragment.ProfileType.WORK
: ProfileSelectFragment.ProfileType.ALL);
args.putInt(ManageApplications.EXTRA_WORK_ID, mUserId);
return args;
}

View File

@@ -98,7 +98,7 @@ public class AccountPreferenceControllerTest {
.thenReturn(new AuthenticatorDescription[0]);
when(mAccountManager.getAccountsAsUser(anyInt())).thenReturn(new Account[0]);
mController = new AccountPreferenceController(mContext, mFragment, null, mAccountHelper,
ProfileSelectFragment.ALL);
ProfileSelectFragment.ProfileType.ALL);
}
@After