From 79b8ce0212955f2d8326286b19ab260d20c37d34 Mon Sep 17 00:00:00 2001 From: Bonian Chen Date: Thu, 17 Dec 2020 01:59:56 +0000 Subject: [PATCH] [Settings] code refactor - rename isSubscriptionCanBeDisplayed canSubscriptionBeDisplayed is more readable. Reasonale: When cherry-picking ag/12886476 into Android R branch (ag/13209427), a comment from code reviewer suggested this change. Since ag/12886476 has been merged for a while, another patch for it is perferred option when comparing with reverting that CL and resubmit it. Bug: 175830728 Change-Id: Ie91eb82504fd7cff6671803a2bc2560139690952 Test: build pass --- .../settings/network/SubscriptionsPreferenceController.java | 6 +++--- .../network/SubscriptionsPreferenceControllerTest.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/com/android/settings/network/SubscriptionsPreferenceController.java b/src/com/android/settings/network/SubscriptionsPreferenceController.java index 864078cf671..f4ffd09f801 100644 --- a/src/com/android/settings/network/SubscriptionsPreferenceController.java +++ b/src/com/android/settings/network/SubscriptionsPreferenceController.java @@ -165,7 +165,7 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl // Avoid from showing subscription(SIM)s which has been marked as hidden // For example, only one subscription will be shown when there're multiple // subscriptions with same group UUID. - if (!isSubscriptionCanBeDisplayed(mContext, subId)) { + if (!canSubscriptionBeDisplayed(mContext, subId)) { continue; } activeSubIds.add(subId); @@ -290,7 +290,7 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl // For example, only one subscription will be shown when there're multiple // subscriptions with same group UUID. .filter(subInfo -> - isSubscriptionCanBeDisplayed(mContext, subInfo.getSubscriptionId())) + canSubscriptionBeDisplayed(mContext, subInfo.getSubscriptionId())) .count() >= (Utils.isProviderModelEnabled(mContext) ? 1 : 2); } @@ -331,7 +331,7 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl } @VisibleForTesting - boolean isSubscriptionCanBeDisplayed(Context context, int subId) { + boolean canSubscriptionBeDisplayed(Context context, int subId) { return (SubscriptionUtil.getAvailableSubscription(context, ProxySubscriptionManager.getInstance(context), subId) != null); } diff --git a/tests/robotests/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java index ea2212c31f6..57b2e2fd6cb 100644 --- a/tests/robotests/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java @@ -122,7 +122,7 @@ public class SubscriptionsPreferenceControllerTest { mController = spy( new SubscriptionsPreferenceController(mContext, mLifecycle, mUpdateListener, KEY, 5)); - doReturn(true).when(mController).isSubscriptionCanBeDisplayed(any(), anyInt()); + doReturn(true).when(mController).canSubscriptionBeDisplayed(any(), anyInt()); doReturn(mSignalStrengthIcon).when(mController).getIcon(anyInt(), anyInt(), anyBoolean()); } @@ -458,7 +458,7 @@ public class SubscriptionsPreferenceControllerTest { @Test public void displayPreference_subscriptionsWithSameGroupUUID_onlyOneWillBeSeen() { - doReturn(false).when(mController).isSubscriptionCanBeDisplayed(any(), eq(3)); + doReturn(false).when(mController).canSubscriptionBeDisplayed(any(), eq(3)); final List subs = setupMockSubscriptions(3); SubscriptionUtil.setActiveSubscriptionsForTesting(subs.subList(0, 3));