Loading packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogController.java +15 −8 Original line number Diff line number Diff line Loading @@ -192,6 +192,7 @@ public class InternetDialogController implements AccessPointController.AccessPoi private DialogLaunchAnimator mDialogLaunchAnimator; private boolean mHasWifiEntries; private WifiStateWorker mWifiStateWorker; private boolean mHasActiveSubId; @VisibleForTesting static final float TOAST_PARAMS_HORIZONTAL_WEIGHT = 1.0f; Loading Loading @@ -299,6 +300,7 @@ public class InternetDialogController implements AccessPointController.AccessPoi mExecutor); // Listen the subscription changes mOnSubscriptionsChangedListener = new InternetOnSubscriptionChangedListener(); refreshHasActiveSubId(); mSubscriptionManager.addOnSubscriptionsChangedListener(mExecutor, mOnSubscriptionsChangedListener); mDefaultDataSubId = getDefaultDataSubscriptionId(); Loading Loading @@ -901,18 +903,22 @@ public class InternetDialogController implements AccessPointController.AccessPoi * @return whether there is the carrier item in the slice. */ boolean hasActiveSubId() { if (mSubscriptionManager == null) { if (DEBUG) { Log.d(TAG, "SubscriptionManager is null, can not check carrier."); } if (isAirplaneModeEnabled() || mTelephonyManager == null) { return false; } if (isAirplaneModeEnabled() || mTelephonyManager == null || mSubscriptionManager.getActiveSubscriptionIdList().length <= 0) { return false; return mHasActiveSubId; } return true; private void refreshHasActiveSubId() { if (mSubscriptionManager == null) { mHasActiveSubId = false; Log.e(TAG, "SubscriptionManager is null, set mHasActiveSubId = false"); return; } mHasActiveSubId = mSubscriptionManager.getActiveSubscriptionIdList().length > 0; Log.i(TAG, "mHasActiveSubId:" + mHasActiveSubId); } /** Loading Loading @@ -1204,6 +1210,7 @@ public class InternetDialogController implements AccessPointController.AccessPoi @Override public void onSubscriptionsChanged() { refreshHasActiveSubId(); updateListener(); } } Loading packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogControllerTest.java +16 −0 Original line number Diff line number Diff line Loading @@ -1069,6 +1069,22 @@ public class InternetDialogControllerTest extends SysuiTestCase { assertThat(mInternetDialogController.mCallback).isNull(); } @Test public void hasActiveSubId_activeSubIdListIsEmpty_returnFalse() { when(mSubscriptionManager.getActiveSubscriptionIdList()).thenReturn(new int[]{}); mInternetDialogController.mOnSubscriptionsChangedListener.onSubscriptionsChanged(); assertThat(mInternetDialogController.hasActiveSubId()).isFalse(); } @Test public void hasActiveSubId_activeSubIdListNotEmpty_returnTrue() { when(mSubscriptionManager.getActiveSubscriptionIdList()).thenReturn(new int[]{SUB_ID}); mInternetDialogController.mOnSubscriptionsChangedListener.onSubscriptionsChanged(); assertThat(mInternetDialogController.hasActiveSubId()).isTrue(); } private String getResourcesString(String name) { return mContext.getResources().getString(getResourcesId(name)); } Loading Loading
packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogController.java +15 −8 Original line number Diff line number Diff line Loading @@ -192,6 +192,7 @@ public class InternetDialogController implements AccessPointController.AccessPoi private DialogLaunchAnimator mDialogLaunchAnimator; private boolean mHasWifiEntries; private WifiStateWorker mWifiStateWorker; private boolean mHasActiveSubId; @VisibleForTesting static final float TOAST_PARAMS_HORIZONTAL_WEIGHT = 1.0f; Loading Loading @@ -299,6 +300,7 @@ public class InternetDialogController implements AccessPointController.AccessPoi mExecutor); // Listen the subscription changes mOnSubscriptionsChangedListener = new InternetOnSubscriptionChangedListener(); refreshHasActiveSubId(); mSubscriptionManager.addOnSubscriptionsChangedListener(mExecutor, mOnSubscriptionsChangedListener); mDefaultDataSubId = getDefaultDataSubscriptionId(); Loading Loading @@ -901,18 +903,22 @@ public class InternetDialogController implements AccessPointController.AccessPoi * @return whether there is the carrier item in the slice. */ boolean hasActiveSubId() { if (mSubscriptionManager == null) { if (DEBUG) { Log.d(TAG, "SubscriptionManager is null, can not check carrier."); } if (isAirplaneModeEnabled() || mTelephonyManager == null) { return false; } if (isAirplaneModeEnabled() || mTelephonyManager == null || mSubscriptionManager.getActiveSubscriptionIdList().length <= 0) { return false; return mHasActiveSubId; } return true; private void refreshHasActiveSubId() { if (mSubscriptionManager == null) { mHasActiveSubId = false; Log.e(TAG, "SubscriptionManager is null, set mHasActiveSubId = false"); return; } mHasActiveSubId = mSubscriptionManager.getActiveSubscriptionIdList().length > 0; Log.i(TAG, "mHasActiveSubId:" + mHasActiveSubId); } /** Loading Loading @@ -1204,6 +1210,7 @@ public class InternetDialogController implements AccessPointController.AccessPoi @Override public void onSubscriptionsChanged() { refreshHasActiveSubId(); updateListener(); } } Loading
packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogControllerTest.java +16 −0 Original line number Diff line number Diff line Loading @@ -1069,6 +1069,22 @@ public class InternetDialogControllerTest extends SysuiTestCase { assertThat(mInternetDialogController.mCallback).isNull(); } @Test public void hasActiveSubId_activeSubIdListIsEmpty_returnFalse() { when(mSubscriptionManager.getActiveSubscriptionIdList()).thenReturn(new int[]{}); mInternetDialogController.mOnSubscriptionsChangedListener.onSubscriptionsChanged(); assertThat(mInternetDialogController.hasActiveSubId()).isFalse(); } @Test public void hasActiveSubId_activeSubIdListNotEmpty_returnTrue() { when(mSubscriptionManager.getActiveSubscriptionIdList()).thenReturn(new int[]{SUB_ID}); mInternetDialogController.mOnSubscriptionsChangedListener.onSubscriptionsChanged(); assertThat(mInternetDialogController.hasActiveSubId()).isTrue(); } private String getResourcesString(String name) { return mContext.getResources().getString(getResourcesId(name)); } Loading