[Settings] Code refactor

Bug: 147338143
Test: build pass
Change-Id: Ib4a92f659ceda3584310591f706958a06ba5ab21
This commit is contained in:
Bonian Chen
2020-01-09 14:50:03 +08:00
parent 0bb6ffd417
commit f399bd1a8c
2 changed files with 7 additions and 6 deletions

View File

@@ -372,7 +372,7 @@ public final class Utils extends com.android.settingslib.Utils {
} }
public static boolean hasMultipleUsers(Context context) { public static boolean hasMultipleUsers(Context context) {
return ((UserManager) context.getSystemService(Context.USER_SERVICE)) return context.getSystemService(UserManager.class)
.getUsers().size() > 1; .getUsers().size() > 1;
} }
@@ -666,7 +666,7 @@ public final class Utils extends com.android.settingslib.Utils {
* @throws SecurityException if the given userId does not belong to the current user group. * @throws SecurityException if the given userId does not belong to the current user group.
*/ */
public static int enforceSameOwner(Context context, int userId) { 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()); final int[] profileIds = um.getProfileIdsWithDisabled(UserHandle.myUserId());
if (ArrayUtils.contains(profileIds, userId)) { if (ArrayUtils.contains(profileIds, userId)) {
return userId; return userId;
@@ -686,7 +686,7 @@ public final class Utils extends com.android.settingslib.Utils {
* Returns the user id of the credential owner of the given user id. * Returns the user id of the credential owner of the given user id.
*/ */
public static int getCredentialOwnerUserId(Context context, int userId) { 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); return um.getCredentialOwnerProfile(userId);
} }
@@ -823,7 +823,8 @@ public final class Utils extends com.android.settingslib.Utils {
} }
public static boolean isDemoUser(Context context) { 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) { public static ComponentName getDeviceOwnerComponent(Context context) {
@@ -1051,7 +1052,7 @@ public final class Utils extends com.android.settingslib.Utils {
final boolean isWork = args != null ? args.getInt(ProfileSelectFragment.EXTRA_PROFILE) final boolean isWork = args != null ? args.getInt(ProfileSelectFragment.EXTRA_PROFILE)
== ProfileSelectFragment.ProfileType.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 && activity.getSystemService(UserManager.class).getUserProfiles().size() > 1
&& ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName) != null && ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName) != null
&& !isWork && !isPersonal) { && !isWork && !isPersonal) {
f = Fragment.instantiate(activity, ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName), f = Fragment.instantiate(activity, ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName),

View File

@@ -52,7 +52,7 @@ public final class CellInfoUtil {
/** /**
* Returns the title of the network obtained in the manual search. * Returns the title of the network obtained in the manual search.
* *
* @param cellId contains the information of the network. * @param cellId contains the identity of the network.
* @param networkMccMnc contains the MCCMNC string of the network * @param networkMccMnc contains the MCCMNC string of the network
* @return Long Name if not null/empty, otherwise Short Name if not null/empty, * @return Long Name if not null/empty, otherwise Short Name if not null/empty,
* else MCCMNC string. * else MCCMNC string.