[Settings] Code refactor
Bug: 147338143
Test: build pass
Change-Id: Ib4a92f659ceda3584310591f706958a06ba5ab21
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 2f198cf..9b257b6 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -372,7 +372,7 @@
}
public static boolean hasMultipleUsers(Context context) {
- return ((UserManager) context.getSystemService(Context.USER_SERVICE))
+ return context.getSystemService(UserManager.class)
.getUsers().size() > 1;
}
@@ -666,7 +666,7 @@
* @throws SecurityException if the given userId does not belong to the current user group.
*/
public static int enforceSameOwner(Context context, int userId) {
- final UserManager um = UserManager.get(context);
+ final UserManager um = context.getSystemService(UserManager.class);
final int[] profileIds = um.getProfileIdsWithDisabled(UserHandle.myUserId());
if (ArrayUtils.contains(profileIds, userId)) {
return userId;
@@ -686,7 +686,7 @@
* Returns the user id of the credential owner of the given user id.
*/
public static int getCredentialOwnerUserId(Context context, int userId) {
- final UserManager um = UserManager.get(context);
+ final UserManager um = context.getSystemService(UserManager.class);
return um.getCredentialOwnerProfile(userId);
}
@@ -823,7 +823,8 @@
}
public static boolean isDemoUser(Context context) {
- return UserManager.isDeviceInDemoMode(context) && UserManager.get(context).isDemoUser();
+ return UserManager.isDeviceInDemoMode(context)
+ && context.getSystemService(UserManager.class).isDemoUser();
}
public static ComponentName getDeviceOwnerComponent(Context context) {
@@ -1051,7 +1052,7 @@
final boolean isWork = args != null ? args.getInt(ProfileSelectFragment.EXTRA_PROFILE)
== ProfileSelectFragment.ProfileType.WORK : false;
if (FeatureFlagUtils.isEnabled(activity, FeatureFlags.PERSONAL_WORK_PROFILE)
- && UserManager.get(activity).getUserProfiles().size() > 1
+ && activity.getSystemService(UserManager.class).getUserProfiles().size() > 1
&& ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName) != null
&& !isWork && !isPersonal) {
f = Fragment.instantiate(activity, ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName),