From 1e5d8146b5d2fece43a4ae0eb8fb261decc1c9fa Mon Sep 17 00:00:00 2001 From: Raff Tsai Date: Thu, 12 Dec 2019 11:45:41 +0800 Subject: [PATCH] Change ProfileType definition Bug: 141601408 Test: rebuild Change-Id: Ia4d4fabe8a4daad4ce54c243748fa3c29bf944ba --- src/com/android/settings/Utils.java | 4 +-- .../accounts/AccountDashboardFragment.java | 2 +- .../AccountPersonalDashboardFragment.java | 2 +- .../accounts/AccountPreferenceController.java | 8 ++--- .../AccountWorkProfileDashboardFragment.java | 2 +- .../ManageApplications.java | 6 ++-- .../ProfileSelectFragment.java | 35 ++++++++++--------- .../ProfileSelectManageApplications.java | 4 +-- .../ProfileSelectStorageFragment.java | 2 +- .../deviceinfo/StorageDashboardFragment.java | 2 +- .../StorageItemPreferenceController.java | 3 +- .../AccountPreferenceControllerTest.java | 2 +- 12 files changed, 38 insertions(+), 34 deletions(-) diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java index b5a1539cb3d..bef4f1bc90f 100644 --- a/src/com/android/settings/Utils.java +++ b/src/com/android/settings/Utils.java @@ -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 diff --git a/src/com/android/settings/accounts/AccountDashboardFragment.java b/src/com/android/settings/accounts/AccountDashboardFragment.java index bee90714f70..53b5ea3b87e 100644 --- a/src/com/android/settings/accounts/AccountDashboardFragment.java +++ b/src/com/android/settings/accounts/AccountDashboardFragment.java @@ -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); } diff --git a/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java b/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java index e0db7f55712..f29326e4f58 100644 --- a/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java +++ b/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java @@ -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); } diff --git a/src/com/android/settings/accounts/AccountPreferenceController.java b/src/com/android/settings/accounts/AccountPreferenceController.java index 36a7012cad0..1f2796365fe 100644 --- a/src/com/android/settings/accounts/AccountPreferenceController.java +++ b/src/com/android/settings/accounts/AccountPreferenceController.java @@ -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)); diff --git a/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java b/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java index 8dfa93493af..853c66b2fae 100644 --- a/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java +++ b/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java @@ -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); } diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java index 4ce8fa40e29..7da89e4b3b9 100644 --- a/src/com/android/settings/applications/manageapplications/ManageApplications.java +++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java @@ -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); diff --git a/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java b/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java index de23ec00f1f..79228c200eb 100644 --- a/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java +++ b/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java @@ -53,25 +53,28 @@ 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. + */ + 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 */ diff --git a/src/com/android/settings/dashboard/profileselector/ProfileSelectManageApplications.java b/src/com/android/settings/dashboard/profileselector/ProfileSelectManageApplications.java index a448f573b4a..17fed11b44b 100644 --- a/src/com/android/settings/dashboard/profileselector/ProfileSelectManageApplications.java +++ b/src/com/android/settings/dashboard/profileselector/ProfileSelectManageApplications.java @@ -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[]{ diff --git a/src/com/android/settings/dashboard/profileselector/ProfileSelectStorageFragment.java b/src/com/android/settings/dashboard/profileselector/ProfileSelectStorageFragment.java index c204ad46820..bb39cdb9560 100644 --- a/src/com/android/settings/dashboard/profileselector/ProfileSelectStorageFragment.java +++ b/src/com/android/settings/dashboard/profileselector/ProfileSelectStorageFragment.java @@ -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); diff --git a/src/com/android/settings/deviceinfo/StorageDashboardFragment.java b/src/com/android/settings/deviceinfo/StorageDashboardFragment.java index b36ad43004d..bbd87ab632f 100644 --- a/src/com/android/settings/deviceinfo/StorageDashboardFragment.java +++ b/src/com/android/settings/deviceinfo/StorageDashboardFragment.java @@ -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; diff --git a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java index 164eca775cc..1f58ea9c20d 100644 --- a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java +++ b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java @@ -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; } diff --git a/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java index d4a855fd445..65395a0b632 100644 --- a/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java @@ -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