From f399bd1a8c1f7ff2b4599172a4feb75bc06c9f36 Mon Sep 17 00:00:00 2001 From: Bonian Chen Date: Thu, 9 Jan 2020 14:50:03 +0800 Subject: [PATCH] [Settings] Code refactor Bug: 147338143 Test: build pass Change-Id: Ib4a92f659ceda3584310591f706958a06ba5ab21 --- src/com/android/settings/Utils.java | 11 ++++++----- .../settings/network/telephony/CellInfoUtil.java | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java index 2f198cf4f36..9b257b60b7e 100644 --- a/src/com/android/settings/Utils.java +++ b/src/com/android/settings/Utils.java @@ -372,7 +372,7 @@ public final class Utils extends com.android.settingslib.Utils { } 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 @@ public final class Utils extends com.android.settingslib.Utils { * @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 @@ public final class Utils extends com.android.settingslib.Utils { * 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 final class Utils extends com.android.settingslib.Utils { } 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 @@ public final class Utils extends com.android.settingslib.Utils { 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), diff --git a/src/com/android/settings/network/telephony/CellInfoUtil.java b/src/com/android/settings/network/telephony/CellInfoUtil.java index 31296945ff7..ab172c8510c 100644 --- a/src/com/android/settings/network/telephony/CellInfoUtil.java +++ b/src/com/android/settings/network/telephony/CellInfoUtil.java @@ -52,7 +52,7 @@ public final class CellInfoUtil { /** * 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 * @return Long Name if not null/empty, otherwise Short Name if not null/empty, * else MCCMNC string.