Loading packages/SystemUI/res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -2075,6 +2075,8 @@ <string name="satellite_connected_carrier_text">Satellite SOS</string> <!-- Text displayed indicating that the user might be able to use satellite SOS. --> <string name="satellite_emergency_only_carrier_text">Emergency calls or SOS only</string> <!-- Text displayed indicating current network is satellite network. --> <string name="satellite_network_title_text">Satellite network</string> <!-- Content description skeleton. Input strings should be carrier name and signal bar description [CHAR LIMIT=NONE]--> <string name="accessibility_phone_string_format"><xliff:g id="carrier_name" example="Carrier Name">%1$s</xliff:g>, <xliff:g id="signal_strength_description" example="two bars">%2$s</xliff:g>.</string> Loading packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDetailsContentController.java +110 −74 Original line number Diff line number Diff line Loading @@ -53,6 +53,8 @@ import android.telephony.SubscriptionManager; import android.telephony.TelephonyCallback; import android.telephony.TelephonyDisplayInfo; import android.telephony.TelephonyManager; import android.telephony.satellite.SatelliteManager; import android.telephony.satellite.SatelliteModemStateCallback; import android.text.TextUtils; import android.util.Log; import android.view.Gravity; Loading Loading @@ -105,6 +107,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.concurrent.Executor; import java.util.concurrent.atomic.AtomicReference; Loading Loading @@ -153,19 +156,28 @@ public class InternetDetailsContentController implements AccessPointController.A static final int MAX_WIFI_ENTRY_COUNT = 3; static final int SATELLITE_CONNECTED = 2; static final int SATELLITE_STARTED = 1; static final int SATELLITE_NOT_STARTED = 0; private final FeatureFlags mFeatureFlags; //Should be accessible only to the main thread. @VisibleForTesting /** Should be accessible only to the main thread. */ final Map<Integer, TelephonyDisplayInfo> mSubIdTelephonyDisplayInfoMap = new HashMap<>(); final Map<Integer, TelephonyDisplayInfo> mSubIdTelephonyDisplayInfoMap = new HashMap<>(); //Should be accessible only to the main thread. @VisibleForTesting /** Should be accessible only to the main thread. */ final Map<Integer, TelephonyManager> mSubIdTelephonyManagerMap = new HashMap<>(); final Map<Integer, TelephonyManager> mSubIdTelephonyManagerMap = new HashMap<>(); // Should be accessible only to the main thread. @VisibleForTesting /** Should be accessible only to the main thread. */ final Map<Integer, TelephonyCallback> mSubIdTelephonyCallbackMap = new HashMap<>(); final Map<Integer, TelephonyCallback> mSubIdTelephonyCallbackMap = new HashMap<>(); private WifiManager mWifiManager; @Nullable private SatelliteManager mSatelliteManager; private Context mContext; private SubscriptionManager mSubscriptionManager; private TelephonyManager mTelephonyManager; Loading Loading @@ -222,6 +234,24 @@ public class InternetDetailsContentController implements AccessPointController.A @VisibleForTesting protected boolean mCarrierNetworkChangeMode; int mCurrentSatelliteState = SATELLITE_NOT_STARTED; final SatelliteModemStateCallback mSatelliteModemStateCallback = new SatelliteModemStateCallback() { @Override public void onSatelliteModemStateChanged(int state) { mCurrentSatelliteState = switch (state) { case SatelliteManager.SATELLITE_MODEM_STATE_OFF, SatelliteManager.SATELLITE_MODEM_STATE_UNAVAILABLE, SatelliteManager.SATELLITE_MODEM_STATE_UNKNOWN -> SATELLITE_NOT_STARTED; case SatelliteManager.SATELLITE_MODEM_STATE_CONNECTED -> SATELLITE_CONNECTED; default -> SATELLITE_STARTED; }; } }; private final KeyguardUpdateMonitorCallback mKeyguardUpdateCallback = new KeyguardUpdateMonitorCallback() { @Override Loading @@ -245,21 +275,18 @@ public class InternetDetailsContentController implements AccessPointController.A @Inject public InternetDetailsContentController(@ShadeDisplayAware Context context, UiEventLogger uiEventLogger, ActivityStarter starter, AccessPointController accessPointController, SubscriptionManager subscriptionManager, TelephonyManager telephonyManager, @Nullable WifiManager wifiManager, ConnectivityManager connectivityManager, UiEventLogger uiEventLogger, ActivityStarter starter, AccessPointController accessPointController, SubscriptionManager subscriptionManager, TelephonyManager telephonyManager, @Nullable WifiManager wifiManager, ConnectivityManager connectivityManager, Optional<SatelliteManager> optSatelliteManager, @Main Handler handler, @Main Executor mainExecutor, BroadcastDispatcher broadcastDispatcher, KeyguardUpdateMonitor keyguardUpdateMonitor, GlobalSettings globalSettings, KeyguardStateController keyguardStateController, @ShadeDisplayAware WindowManager windowManager, ToastFactory toastFactory, @Background Handler workerHandler, CarrierConfigTracker carrierConfigTracker, @Background Handler workerHandler, CarrierConfigTracker carrierConfigTracker, LocationController locationController, DialogTransitionAnimator dialogTransitionAnimator, WifiStateWorker wifiStateWorker, FeatureFlags featureFlags ) { DialogTransitionAnimator dialogTransitionAnimator, WifiStateWorker wifiStateWorker, FeatureFlags featureFlags) { if (DEBUG) { Log.d(TAG, "Init InternetDetailsContentController"); } Loading @@ -270,6 +297,7 @@ public class InternetDetailsContentController implements AccessPointController.A mGlobalSettings = globalSettings; mWifiManager = wifiManager; mTelephonyManager = telephonyManager; mSatelliteManager = optSatelliteManager.orElse(null); mConnectivityManager = connectivityManager; mSubscriptionManager = subscriptionManager; mCarrierConfigTracker = carrierConfigTracker; Loading Loading @@ -321,6 +349,15 @@ public class InternetDetailsContentController implements AccessPointController.A mConnectivityManager.registerDefaultNetworkCallback(mConnectivityManagerNetworkCallback); mCanConfigWifi = canConfigWifi; scanWifiAccessPoints(); if (mSatelliteManager != null) { try { mSatelliteManager.registerForModemStateChanged(mExecutor, mSatelliteModemStateCallback); } catch (IllegalStateException e) { Log.w(TAG, "Unable to register callback for modem state changes : " + e); } } } void onStop() { Loading @@ -339,13 +376,20 @@ public class InternetDetailsContentController implements AccessPointController.A mSubIdTelephonyManagerMap.clear(); mSubIdTelephonyCallbackMap.clear(); mSubIdTelephonyDisplayInfoMap.clear(); mSubscriptionManager.removeOnSubscriptionsChangedListener( mOnSubscriptionsChangedListener); mSubscriptionManager.removeOnSubscriptionsChangedListener(mOnSubscriptionsChangedListener); mAccessPointController.removeAccessPointCallback(this); mKeyguardUpdateMonitor.removeCallback(mKeyguardUpdateCallback); mConnectivityManager.unregisterNetworkCallback(mConnectivityManagerNetworkCallback); mConnectedWifiInternetMonitor.unregisterCallback(); mCallback = null; if (mSatelliteManager != null) { try { mSatelliteManager.unregisterForModemStateChanged(mSatelliteModemStateCallback); } catch (IllegalStateException e) { Log.w(TAG, "Unable to unregister callback for modem state changes : " + e); } } } /** Loading @@ -354,8 +398,7 @@ public class InternetDetailsContentController implements AccessPointController.A * {@link com.android.server.TelephonyRegistry}, so if subscription id and callback were cached * already, it shall do nothing to avoid registering redundant callback to Telephony. */ private void registerInternetTelephonyCallback( TelephonyManager telephonyManager, int subId) { private void registerInternetTelephonyCallback(TelephonyManager telephonyManager, int subId) { if (mSubIdTelephonyCallbackMap.containsKey(subId)) { // Avoid to generate and register unnecessary callback to Telephony. return; Loading Loading @@ -446,8 +489,8 @@ public class InternetDetailsContentController implements AccessPointController.A if (DEBUG) { Log.d(TAG, "No Wi-Fi item."); } boolean isActiveOnNonDds = getActiveAutoSwitchNonDdsSubId() != SubscriptionManager .INVALID_SUBSCRIPTION_ID; boolean isActiveOnNonDds = getActiveAutoSwitchNonDdsSubId() != SubscriptionManager.INVALID_SUBSCRIPTION_ID; if (!hasActiveSubIdOnDds() || (!isVoiceStateInService(mDefaultDataSubId) && !isDataStateInService(mDefaultDataSubId) && !isActiveOnNonDds)) { if (DEBUG) { Loading Loading @@ -560,9 +603,8 @@ public class InternetDetailsContentController implements AccessPointController.A Drawable getSignalStrengthIcon(int subId, Context context, int level, int numLevels, int iconType, boolean cutOut) { boolean isForDds = subId == mDefaultDataSubId; int levelDrawable = mCarrierNetworkChangeMode ? SignalDrawable.getCarrierChangeState(numLevels) : SignalDrawable.getState(level, numLevels, cutOut); int levelDrawable = mCarrierNetworkChangeMode ? SignalDrawable.getCarrierChangeState( numLevels) : SignalDrawable.getState(level, numLevels, cutOut); if (isForDds) { mSignalDrawable.setLevel(levelDrawable); } else { Loading @@ -570,16 +612,14 @@ public class InternetDetailsContentController implements AccessPointController.A } // Make the network type drawable final Drawable networkDrawable = iconType == NO_CELL_DATA_TYPE_ICON ? EMPTY_DRAWABLE final Drawable networkDrawable = iconType == NO_CELL_DATA_TYPE_ICON ? EMPTY_DRAWABLE : context.getResources().getDrawable(iconType, context.getTheme()); // Overlay the two drawables final Drawable[] layers = {networkDrawable, isForDds ? mSignalDrawable : mSecondarySignalDrawable}; final int iconSize = context.getResources().getDimensionPixelSize(R.dimen.signal_strength_icon_size); final Drawable[] layers = {networkDrawable, isForDds ? mSignalDrawable : mSecondarySignalDrawable}; final int iconSize = context.getResources().getDimensionPixelSize( R.dimen.signal_strength_icon_size); final LayerDrawable icons = new LayerDrawable(layers); // Set the network type icon at the top left Loading Loading @@ -614,21 +654,17 @@ public class InternetDetailsContentController implements AccessPointController.A // Map of SubscriptionId to DisplayName final Supplier<Stream<DisplayInfo>> originalInfos = () -> getSubscriptionInfo() .stream() .filter(i -> { () -> getSubscriptionInfo().stream().filter(i -> { // Filter out null values. return (i != null && i.getDisplayName() != null); }) .map(i -> new DisplayInfo(i, i.getDisplayName().toString().trim())); }).map(i -> new DisplayInfo(i, i.getDisplayName().toString().trim())); // A Unique set of display names Set<CharSequence> uniqueNames = new HashSet<>(); // Return the set of duplicate names final Set<CharSequence> duplicateOriginalNames = originalInfos.get() .filter(info -> !uniqueNames.add(info.originalName)) .map(info -> info.originalName) .collect(Collectors.toSet()); final Set<CharSequence> duplicateOriginalNames = originalInfos.get().filter( info -> !uniqueNames.add(info.originalName)).map(info -> info.originalName).collect( Collectors.toSet()); // If a display name is duplicate, append the final 4 digits of the phone number. // Creates a mapping of Subscription id to original display name + phone number display name Loading @@ -639,8 +675,8 @@ public class InternetDetailsContentController implements AccessPointController.A info.subscriptionInfo); String lastFourDigits = ""; if (phoneNumber != null) { lastFourDigits = (phoneNumber.length() > 4) ? phoneNumber.substring(phoneNumber.length() - 4) : phoneNumber; lastFourDigits = (phoneNumber.length() > 4) ? phoneNumber.substring( phoneNumber.length() - 4) : phoneNumber; } if (TextUtils.isEmpty(lastFourDigits)) { Loading @@ -659,19 +695,17 @@ public class InternetDetailsContentController implements AccessPointController.A // We might not have had permission to view the phone numbers. // There might also be multiple phone numbers whose last 4 digits the same. uniqueNames.clear(); final Set<CharSequence> duplicatePhoneNames = uniqueInfos.get() .filter(info -> !uniqueNames.add(info.uniqueName)) .map(info -> info.uniqueName) .collect(Collectors.toSet()); final Set<CharSequence> duplicatePhoneNames = uniqueInfos.get().filter( info -> !uniqueNames.add(info.uniqueName)).map(info -> info.uniqueName).collect( Collectors.toSet()); return uniqueInfos.get().map(info -> { if (duplicatePhoneNames.contains(info.uniqueName)) { info.uniqueName = info.originalName + " " + info.subscriptionInfo.getSubscriptionId(); info.uniqueName = info.originalName + " " + info.subscriptionInfo.getSubscriptionId(); } return info; }).collect(Collectors.toMap( info -> info.subscriptionInfo.getSubscriptionId(), }).collect(Collectors.toMap(info -> info.subscriptionInfo.getSubscriptionId(), info -> info.uniqueName)); } Loading Loading @@ -720,8 +754,8 @@ public class InternetDetailsContentController implements AccessPointController.A */ private String getNetworkTypeDescription(Context context, MobileMappings.Config config, int subId) { TelephonyDisplayInfo telephonyDisplayInfo = mSubIdTelephonyDisplayInfoMap.getOrDefault(subId, DEFAULT_TELEPHONY_DISPLAY_INFO); TelephonyDisplayInfo telephonyDisplayInfo = mSubIdTelephonyDisplayInfoMap.getOrDefault( subId, DEFAULT_TELEPHONY_DISPLAY_INFO); String iconKey = getIconKey(telephonyDisplayInfo); if (mapIconSets(config) == null || mapIconSets(config).get(iconKey) == null) { Loading @@ -741,8 +775,8 @@ public class InternetDetailsContentController implements AccessPointController.A resId = iconGroup.dataContentDescription; } return resId != 0 ? SubscriptionManager.getResourcesForSubId(context, subId).getString(resId) : ""; return resId != 0 ? SubscriptionManager.getResourcesForSubId(context, subId).getString( resId) : ""; } private String getMobileSummary(Context context, String networkTypeDescription, int subId) { Loading Loading @@ -873,8 +907,7 @@ public class InternetDetailsContentController implements AccessPointController.A return; } MergedCarrierEntry mergedCarrierEntry = mAccessPointController.getMergedCarrierEntry(); MergedCarrierEntry mergedCarrierEntry = mAccessPointController.getMergedCarrierEntry(); if (mergedCarrierEntry == null) { Log.e(TAG, errorLogPrefix + "no merged entry"); return; Loading Loading @@ -1009,8 +1042,8 @@ public class InternetDetailsContentController implements AccessPointController.A return; } mTelephonyManager.setDataEnabledForReason( TelephonyManager.DATA_ENABLED_REASON_USER, enabled); mTelephonyManager.setDataEnabledForReason(TelephonyManager.DATA_ENABLED_REASON_USER, enabled); if (disableOtherSubscriptions) { final List<SubscriptionInfo> subInfoList = mSubscriptionManager.getActiveSubscriptionInfoList(); Loading Loading @@ -1058,14 +1091,17 @@ public class InternetDetailsContentController implements AccessPointController.A final ServiceState serviceState = mSubIdServiceState.getOrDefault(subId, new ServiceState()); return serviceState != null && serviceState.getState() == serviceState.STATE_IN_SERVICE; return serviceState != null && serviceState.getState() == serviceState.STATE_IN_SERVICE; } public boolean isDeviceLocked() { return !mKeyguardStateController.isUnlocked(); } int getCurrentSatelliteState() { return mCurrentSatelliteState; } boolean activeNetworkIsCellular() { if (mConnectivityManager == null) { if (DEBUG) { Loading @@ -1079,8 +1115,8 @@ public class InternetDetailsContentController implements AccessPointController.A Log.d(TAG, "getActiveNetwork is null."); return false; } final NetworkCapabilities networkCapabilities = mConnectivityManager.getNetworkCapabilities(activeNetwork); final NetworkCapabilities networkCapabilities = mConnectivityManager.getNetworkCapabilities( activeNetwork); if (networkCapabilities == null) { return false; } Loading Loading @@ -1206,10 +1242,8 @@ public class InternetDetailsContentController implements AccessPointController.A } private class InternetTelephonyCallback extends TelephonyCallback implements TelephonyCallback.DataEnabledListener, TelephonyCallback.DataConnectionStateListener, TelephonyCallback.DisplayInfoListener, TelephonyCallback.ServiceStateListener, TelephonyCallback.DataEnabledListener, TelephonyCallback.DataConnectionStateListener, TelephonyCallback.DisplayInfoListener, TelephonyCallback.ServiceStateListener, TelephonyCallback.SignalStrengthsListener, TelephonyCallback.UserMobileDataStateListener, TelephonyCallback.CarrierNetworkListener { Loading Loading @@ -1273,8 +1307,8 @@ public class InternetDetailsContentController implements AccessPointController.A } } private class InternetOnSubscriptionChangedListener extends SubscriptionManager.OnSubscriptionsChangedListener { private class InternetOnSubscriptionChangedListener extends SubscriptionManager.OnSubscriptionsChangedListener { InternetOnSubscriptionChangedListener() { super(); } Loading Loading @@ -1326,8 +1360,8 @@ public class InternetDetailsContentController implements AccessPointController.A } // If the Wi-Fi is not connected yet, or it's the connected Wi-Fi with Internet // access. Then we don't need to listen to the callback to update the Wi-Fi entries. if (entry.getConnectedState() != CONNECTED_STATE_CONNECTED || (entry.isDefaultNetwork() && entry.hasInternetAccess())) { if (entry.getConnectedState() != CONNECTED_STATE_CONNECTED || (entry.isDefaultNetwork() && entry.hasInternetAccess())) { return; } mWifiEntry = entry; Loading Loading @@ -1458,6 +1492,8 @@ public class InternetDetailsContentController implements AccessPointController.A @Nullable WifiEntry connectedEntry, boolean hasMoreWifiEntries); void onWifiScan(boolean isScan); void onSatelliteModemStateChanged(int state); } void makeOverlayToast(int stringId) { Loading packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDetailsContentManager.kt +4 −0 Original line number Diff line number Diff line Loading @@ -1020,6 +1020,10 @@ constructor( override fun onWifiScan(isScan: Boolean) { setProgressBarVisible(isScan) } override fun onSatelliteModemStateChanged(state: Int) { updateContent(shouldUpdateMobileNetwork = true) } } enum class InternetDetailsEvent(private val id: Int) : UiEventLogger.UiEventEnum { Loading packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogDelegateLegacy.java +137 −102 File changed.Preview size limit exceeded, changes collapsed. Show changes packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDetailsContentControllerTest.java +5 −1 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ import android.telephony.SubscriptionManager; import android.telephony.TelephonyCallback; import android.telephony.TelephonyDisplayInfo; import android.telephony.TelephonyManager; import android.telephony.satellite.SatelliteManager; import android.testing.TestableLooper; import android.testing.TestableResources; import android.text.TextUtils; Loading Loading @@ -100,6 +101,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Optional; @SmallTest @RunWith(AndroidJUnit4.class) Loading @@ -121,6 +123,8 @@ public class InternetDetailsContentControllerTest extends SysuiTestCase { @Mock private ConnectivityManager mConnectivityManager; @Mock private Optional<SatelliteManager> mSatelliteManager; @Mock private Network mNetwork; @Mock private NetworkCapabilities mNetworkCapabilities; Loading Loading @@ -231,7 +235,7 @@ public class InternetDetailsContentControllerTest extends SysuiTestCase { mInternetDetailsContentController = new InternetDetailsContentController(mContext, mock(UiEventLogger.class), mock(ActivityStarter.class), mAccessPointController, mSubscriptionManager, mTelephonyManager, mWifiManager, mConnectivityManager, mHandler, mExecutor, mBroadcastDispatcher, mConnectivityManager, mSatelliteManager, mHandler, mExecutor, mBroadcastDispatcher, mock(KeyguardUpdateMonitor.class), mGlobalSettings, mKeyguardStateController, mWindowManager, mToastFactory, mWorkerHandler, mCarrierConfigTracker, mLocationController, mDialogTransitionAnimator, mWifiStateWorker, mFlags); Loading Loading
packages/SystemUI/res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -2075,6 +2075,8 @@ <string name="satellite_connected_carrier_text">Satellite SOS</string> <!-- Text displayed indicating that the user might be able to use satellite SOS. --> <string name="satellite_emergency_only_carrier_text">Emergency calls or SOS only</string> <!-- Text displayed indicating current network is satellite network. --> <string name="satellite_network_title_text">Satellite network</string> <!-- Content description skeleton. Input strings should be carrier name and signal bar description [CHAR LIMIT=NONE]--> <string name="accessibility_phone_string_format"><xliff:g id="carrier_name" example="Carrier Name">%1$s</xliff:g>, <xliff:g id="signal_strength_description" example="two bars">%2$s</xliff:g>.</string> Loading
packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDetailsContentController.java +110 −74 Original line number Diff line number Diff line Loading @@ -53,6 +53,8 @@ import android.telephony.SubscriptionManager; import android.telephony.TelephonyCallback; import android.telephony.TelephonyDisplayInfo; import android.telephony.TelephonyManager; import android.telephony.satellite.SatelliteManager; import android.telephony.satellite.SatelliteModemStateCallback; import android.text.TextUtils; import android.util.Log; import android.view.Gravity; Loading Loading @@ -105,6 +107,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.concurrent.Executor; import java.util.concurrent.atomic.AtomicReference; Loading Loading @@ -153,19 +156,28 @@ public class InternetDetailsContentController implements AccessPointController.A static final int MAX_WIFI_ENTRY_COUNT = 3; static final int SATELLITE_CONNECTED = 2; static final int SATELLITE_STARTED = 1; static final int SATELLITE_NOT_STARTED = 0; private final FeatureFlags mFeatureFlags; //Should be accessible only to the main thread. @VisibleForTesting /** Should be accessible only to the main thread. */ final Map<Integer, TelephonyDisplayInfo> mSubIdTelephonyDisplayInfoMap = new HashMap<>(); final Map<Integer, TelephonyDisplayInfo> mSubIdTelephonyDisplayInfoMap = new HashMap<>(); //Should be accessible only to the main thread. @VisibleForTesting /** Should be accessible only to the main thread. */ final Map<Integer, TelephonyManager> mSubIdTelephonyManagerMap = new HashMap<>(); final Map<Integer, TelephonyManager> mSubIdTelephonyManagerMap = new HashMap<>(); // Should be accessible only to the main thread. @VisibleForTesting /** Should be accessible only to the main thread. */ final Map<Integer, TelephonyCallback> mSubIdTelephonyCallbackMap = new HashMap<>(); final Map<Integer, TelephonyCallback> mSubIdTelephonyCallbackMap = new HashMap<>(); private WifiManager mWifiManager; @Nullable private SatelliteManager mSatelliteManager; private Context mContext; private SubscriptionManager mSubscriptionManager; private TelephonyManager mTelephonyManager; Loading Loading @@ -222,6 +234,24 @@ public class InternetDetailsContentController implements AccessPointController.A @VisibleForTesting protected boolean mCarrierNetworkChangeMode; int mCurrentSatelliteState = SATELLITE_NOT_STARTED; final SatelliteModemStateCallback mSatelliteModemStateCallback = new SatelliteModemStateCallback() { @Override public void onSatelliteModemStateChanged(int state) { mCurrentSatelliteState = switch (state) { case SatelliteManager.SATELLITE_MODEM_STATE_OFF, SatelliteManager.SATELLITE_MODEM_STATE_UNAVAILABLE, SatelliteManager.SATELLITE_MODEM_STATE_UNKNOWN -> SATELLITE_NOT_STARTED; case SatelliteManager.SATELLITE_MODEM_STATE_CONNECTED -> SATELLITE_CONNECTED; default -> SATELLITE_STARTED; }; } }; private final KeyguardUpdateMonitorCallback mKeyguardUpdateCallback = new KeyguardUpdateMonitorCallback() { @Override Loading @@ -245,21 +275,18 @@ public class InternetDetailsContentController implements AccessPointController.A @Inject public InternetDetailsContentController(@ShadeDisplayAware Context context, UiEventLogger uiEventLogger, ActivityStarter starter, AccessPointController accessPointController, SubscriptionManager subscriptionManager, TelephonyManager telephonyManager, @Nullable WifiManager wifiManager, ConnectivityManager connectivityManager, UiEventLogger uiEventLogger, ActivityStarter starter, AccessPointController accessPointController, SubscriptionManager subscriptionManager, TelephonyManager telephonyManager, @Nullable WifiManager wifiManager, ConnectivityManager connectivityManager, Optional<SatelliteManager> optSatelliteManager, @Main Handler handler, @Main Executor mainExecutor, BroadcastDispatcher broadcastDispatcher, KeyguardUpdateMonitor keyguardUpdateMonitor, GlobalSettings globalSettings, KeyguardStateController keyguardStateController, @ShadeDisplayAware WindowManager windowManager, ToastFactory toastFactory, @Background Handler workerHandler, CarrierConfigTracker carrierConfigTracker, @Background Handler workerHandler, CarrierConfigTracker carrierConfigTracker, LocationController locationController, DialogTransitionAnimator dialogTransitionAnimator, WifiStateWorker wifiStateWorker, FeatureFlags featureFlags ) { DialogTransitionAnimator dialogTransitionAnimator, WifiStateWorker wifiStateWorker, FeatureFlags featureFlags) { if (DEBUG) { Log.d(TAG, "Init InternetDetailsContentController"); } Loading @@ -270,6 +297,7 @@ public class InternetDetailsContentController implements AccessPointController.A mGlobalSettings = globalSettings; mWifiManager = wifiManager; mTelephonyManager = telephonyManager; mSatelliteManager = optSatelliteManager.orElse(null); mConnectivityManager = connectivityManager; mSubscriptionManager = subscriptionManager; mCarrierConfigTracker = carrierConfigTracker; Loading Loading @@ -321,6 +349,15 @@ public class InternetDetailsContentController implements AccessPointController.A mConnectivityManager.registerDefaultNetworkCallback(mConnectivityManagerNetworkCallback); mCanConfigWifi = canConfigWifi; scanWifiAccessPoints(); if (mSatelliteManager != null) { try { mSatelliteManager.registerForModemStateChanged(mExecutor, mSatelliteModemStateCallback); } catch (IllegalStateException e) { Log.w(TAG, "Unable to register callback for modem state changes : " + e); } } } void onStop() { Loading @@ -339,13 +376,20 @@ public class InternetDetailsContentController implements AccessPointController.A mSubIdTelephonyManagerMap.clear(); mSubIdTelephonyCallbackMap.clear(); mSubIdTelephonyDisplayInfoMap.clear(); mSubscriptionManager.removeOnSubscriptionsChangedListener( mOnSubscriptionsChangedListener); mSubscriptionManager.removeOnSubscriptionsChangedListener(mOnSubscriptionsChangedListener); mAccessPointController.removeAccessPointCallback(this); mKeyguardUpdateMonitor.removeCallback(mKeyguardUpdateCallback); mConnectivityManager.unregisterNetworkCallback(mConnectivityManagerNetworkCallback); mConnectedWifiInternetMonitor.unregisterCallback(); mCallback = null; if (mSatelliteManager != null) { try { mSatelliteManager.unregisterForModemStateChanged(mSatelliteModemStateCallback); } catch (IllegalStateException e) { Log.w(TAG, "Unable to unregister callback for modem state changes : " + e); } } } /** Loading @@ -354,8 +398,7 @@ public class InternetDetailsContentController implements AccessPointController.A * {@link com.android.server.TelephonyRegistry}, so if subscription id and callback were cached * already, it shall do nothing to avoid registering redundant callback to Telephony. */ private void registerInternetTelephonyCallback( TelephonyManager telephonyManager, int subId) { private void registerInternetTelephonyCallback(TelephonyManager telephonyManager, int subId) { if (mSubIdTelephonyCallbackMap.containsKey(subId)) { // Avoid to generate and register unnecessary callback to Telephony. return; Loading Loading @@ -446,8 +489,8 @@ public class InternetDetailsContentController implements AccessPointController.A if (DEBUG) { Log.d(TAG, "No Wi-Fi item."); } boolean isActiveOnNonDds = getActiveAutoSwitchNonDdsSubId() != SubscriptionManager .INVALID_SUBSCRIPTION_ID; boolean isActiveOnNonDds = getActiveAutoSwitchNonDdsSubId() != SubscriptionManager.INVALID_SUBSCRIPTION_ID; if (!hasActiveSubIdOnDds() || (!isVoiceStateInService(mDefaultDataSubId) && !isDataStateInService(mDefaultDataSubId) && !isActiveOnNonDds)) { if (DEBUG) { Loading Loading @@ -560,9 +603,8 @@ public class InternetDetailsContentController implements AccessPointController.A Drawable getSignalStrengthIcon(int subId, Context context, int level, int numLevels, int iconType, boolean cutOut) { boolean isForDds = subId == mDefaultDataSubId; int levelDrawable = mCarrierNetworkChangeMode ? SignalDrawable.getCarrierChangeState(numLevels) : SignalDrawable.getState(level, numLevels, cutOut); int levelDrawable = mCarrierNetworkChangeMode ? SignalDrawable.getCarrierChangeState( numLevels) : SignalDrawable.getState(level, numLevels, cutOut); if (isForDds) { mSignalDrawable.setLevel(levelDrawable); } else { Loading @@ -570,16 +612,14 @@ public class InternetDetailsContentController implements AccessPointController.A } // Make the network type drawable final Drawable networkDrawable = iconType == NO_CELL_DATA_TYPE_ICON ? EMPTY_DRAWABLE final Drawable networkDrawable = iconType == NO_CELL_DATA_TYPE_ICON ? EMPTY_DRAWABLE : context.getResources().getDrawable(iconType, context.getTheme()); // Overlay the two drawables final Drawable[] layers = {networkDrawable, isForDds ? mSignalDrawable : mSecondarySignalDrawable}; final int iconSize = context.getResources().getDimensionPixelSize(R.dimen.signal_strength_icon_size); final Drawable[] layers = {networkDrawable, isForDds ? mSignalDrawable : mSecondarySignalDrawable}; final int iconSize = context.getResources().getDimensionPixelSize( R.dimen.signal_strength_icon_size); final LayerDrawable icons = new LayerDrawable(layers); // Set the network type icon at the top left Loading Loading @@ -614,21 +654,17 @@ public class InternetDetailsContentController implements AccessPointController.A // Map of SubscriptionId to DisplayName final Supplier<Stream<DisplayInfo>> originalInfos = () -> getSubscriptionInfo() .stream() .filter(i -> { () -> getSubscriptionInfo().stream().filter(i -> { // Filter out null values. return (i != null && i.getDisplayName() != null); }) .map(i -> new DisplayInfo(i, i.getDisplayName().toString().trim())); }).map(i -> new DisplayInfo(i, i.getDisplayName().toString().trim())); // A Unique set of display names Set<CharSequence> uniqueNames = new HashSet<>(); // Return the set of duplicate names final Set<CharSequence> duplicateOriginalNames = originalInfos.get() .filter(info -> !uniqueNames.add(info.originalName)) .map(info -> info.originalName) .collect(Collectors.toSet()); final Set<CharSequence> duplicateOriginalNames = originalInfos.get().filter( info -> !uniqueNames.add(info.originalName)).map(info -> info.originalName).collect( Collectors.toSet()); // If a display name is duplicate, append the final 4 digits of the phone number. // Creates a mapping of Subscription id to original display name + phone number display name Loading @@ -639,8 +675,8 @@ public class InternetDetailsContentController implements AccessPointController.A info.subscriptionInfo); String lastFourDigits = ""; if (phoneNumber != null) { lastFourDigits = (phoneNumber.length() > 4) ? phoneNumber.substring(phoneNumber.length() - 4) : phoneNumber; lastFourDigits = (phoneNumber.length() > 4) ? phoneNumber.substring( phoneNumber.length() - 4) : phoneNumber; } if (TextUtils.isEmpty(lastFourDigits)) { Loading @@ -659,19 +695,17 @@ public class InternetDetailsContentController implements AccessPointController.A // We might not have had permission to view the phone numbers. // There might also be multiple phone numbers whose last 4 digits the same. uniqueNames.clear(); final Set<CharSequence> duplicatePhoneNames = uniqueInfos.get() .filter(info -> !uniqueNames.add(info.uniqueName)) .map(info -> info.uniqueName) .collect(Collectors.toSet()); final Set<CharSequence> duplicatePhoneNames = uniqueInfos.get().filter( info -> !uniqueNames.add(info.uniqueName)).map(info -> info.uniqueName).collect( Collectors.toSet()); return uniqueInfos.get().map(info -> { if (duplicatePhoneNames.contains(info.uniqueName)) { info.uniqueName = info.originalName + " " + info.subscriptionInfo.getSubscriptionId(); info.uniqueName = info.originalName + " " + info.subscriptionInfo.getSubscriptionId(); } return info; }).collect(Collectors.toMap( info -> info.subscriptionInfo.getSubscriptionId(), }).collect(Collectors.toMap(info -> info.subscriptionInfo.getSubscriptionId(), info -> info.uniqueName)); } Loading Loading @@ -720,8 +754,8 @@ public class InternetDetailsContentController implements AccessPointController.A */ private String getNetworkTypeDescription(Context context, MobileMappings.Config config, int subId) { TelephonyDisplayInfo telephonyDisplayInfo = mSubIdTelephonyDisplayInfoMap.getOrDefault(subId, DEFAULT_TELEPHONY_DISPLAY_INFO); TelephonyDisplayInfo telephonyDisplayInfo = mSubIdTelephonyDisplayInfoMap.getOrDefault( subId, DEFAULT_TELEPHONY_DISPLAY_INFO); String iconKey = getIconKey(telephonyDisplayInfo); if (mapIconSets(config) == null || mapIconSets(config).get(iconKey) == null) { Loading @@ -741,8 +775,8 @@ public class InternetDetailsContentController implements AccessPointController.A resId = iconGroup.dataContentDescription; } return resId != 0 ? SubscriptionManager.getResourcesForSubId(context, subId).getString(resId) : ""; return resId != 0 ? SubscriptionManager.getResourcesForSubId(context, subId).getString( resId) : ""; } private String getMobileSummary(Context context, String networkTypeDescription, int subId) { Loading Loading @@ -873,8 +907,7 @@ public class InternetDetailsContentController implements AccessPointController.A return; } MergedCarrierEntry mergedCarrierEntry = mAccessPointController.getMergedCarrierEntry(); MergedCarrierEntry mergedCarrierEntry = mAccessPointController.getMergedCarrierEntry(); if (mergedCarrierEntry == null) { Log.e(TAG, errorLogPrefix + "no merged entry"); return; Loading Loading @@ -1009,8 +1042,8 @@ public class InternetDetailsContentController implements AccessPointController.A return; } mTelephonyManager.setDataEnabledForReason( TelephonyManager.DATA_ENABLED_REASON_USER, enabled); mTelephonyManager.setDataEnabledForReason(TelephonyManager.DATA_ENABLED_REASON_USER, enabled); if (disableOtherSubscriptions) { final List<SubscriptionInfo> subInfoList = mSubscriptionManager.getActiveSubscriptionInfoList(); Loading Loading @@ -1058,14 +1091,17 @@ public class InternetDetailsContentController implements AccessPointController.A final ServiceState serviceState = mSubIdServiceState.getOrDefault(subId, new ServiceState()); return serviceState != null && serviceState.getState() == serviceState.STATE_IN_SERVICE; return serviceState != null && serviceState.getState() == serviceState.STATE_IN_SERVICE; } public boolean isDeviceLocked() { return !mKeyguardStateController.isUnlocked(); } int getCurrentSatelliteState() { return mCurrentSatelliteState; } boolean activeNetworkIsCellular() { if (mConnectivityManager == null) { if (DEBUG) { Loading @@ -1079,8 +1115,8 @@ public class InternetDetailsContentController implements AccessPointController.A Log.d(TAG, "getActiveNetwork is null."); return false; } final NetworkCapabilities networkCapabilities = mConnectivityManager.getNetworkCapabilities(activeNetwork); final NetworkCapabilities networkCapabilities = mConnectivityManager.getNetworkCapabilities( activeNetwork); if (networkCapabilities == null) { return false; } Loading Loading @@ -1206,10 +1242,8 @@ public class InternetDetailsContentController implements AccessPointController.A } private class InternetTelephonyCallback extends TelephonyCallback implements TelephonyCallback.DataEnabledListener, TelephonyCallback.DataConnectionStateListener, TelephonyCallback.DisplayInfoListener, TelephonyCallback.ServiceStateListener, TelephonyCallback.DataEnabledListener, TelephonyCallback.DataConnectionStateListener, TelephonyCallback.DisplayInfoListener, TelephonyCallback.ServiceStateListener, TelephonyCallback.SignalStrengthsListener, TelephonyCallback.UserMobileDataStateListener, TelephonyCallback.CarrierNetworkListener { Loading Loading @@ -1273,8 +1307,8 @@ public class InternetDetailsContentController implements AccessPointController.A } } private class InternetOnSubscriptionChangedListener extends SubscriptionManager.OnSubscriptionsChangedListener { private class InternetOnSubscriptionChangedListener extends SubscriptionManager.OnSubscriptionsChangedListener { InternetOnSubscriptionChangedListener() { super(); } Loading Loading @@ -1326,8 +1360,8 @@ public class InternetDetailsContentController implements AccessPointController.A } // If the Wi-Fi is not connected yet, or it's the connected Wi-Fi with Internet // access. Then we don't need to listen to the callback to update the Wi-Fi entries. if (entry.getConnectedState() != CONNECTED_STATE_CONNECTED || (entry.isDefaultNetwork() && entry.hasInternetAccess())) { if (entry.getConnectedState() != CONNECTED_STATE_CONNECTED || (entry.isDefaultNetwork() && entry.hasInternetAccess())) { return; } mWifiEntry = entry; Loading Loading @@ -1458,6 +1492,8 @@ public class InternetDetailsContentController implements AccessPointController.A @Nullable WifiEntry connectedEntry, boolean hasMoreWifiEntries); void onWifiScan(boolean isScan); void onSatelliteModemStateChanged(int state); } void makeOverlayToast(int stringId) { Loading
packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDetailsContentManager.kt +4 −0 Original line number Diff line number Diff line Loading @@ -1020,6 +1020,10 @@ constructor( override fun onWifiScan(isScan: Boolean) { setProgressBarVisible(isScan) } override fun onSatelliteModemStateChanged(state: Int) { updateContent(shouldUpdateMobileNetwork = true) } } enum class InternetDetailsEvent(private val id: Int) : UiEventLogger.UiEventEnum { Loading
packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogDelegateLegacy.java +137 −102 File changed.Preview size limit exceeded, changes collapsed. Show changes
packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDetailsContentControllerTest.java +5 −1 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ import android.telephony.SubscriptionManager; import android.telephony.TelephonyCallback; import android.telephony.TelephonyDisplayInfo; import android.telephony.TelephonyManager; import android.telephony.satellite.SatelliteManager; import android.testing.TestableLooper; import android.testing.TestableResources; import android.text.TextUtils; Loading Loading @@ -100,6 +101,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Optional; @SmallTest @RunWith(AndroidJUnit4.class) Loading @@ -121,6 +123,8 @@ public class InternetDetailsContentControllerTest extends SysuiTestCase { @Mock private ConnectivityManager mConnectivityManager; @Mock private Optional<SatelliteManager> mSatelliteManager; @Mock private Network mNetwork; @Mock private NetworkCapabilities mNetworkCapabilities; Loading Loading @@ -231,7 +235,7 @@ public class InternetDetailsContentControllerTest extends SysuiTestCase { mInternetDetailsContentController = new InternetDetailsContentController(mContext, mock(UiEventLogger.class), mock(ActivityStarter.class), mAccessPointController, mSubscriptionManager, mTelephonyManager, mWifiManager, mConnectivityManager, mHandler, mExecutor, mBroadcastDispatcher, mConnectivityManager, mSatelliteManager, mHandler, mExecutor, mBroadcastDispatcher, mock(KeyguardUpdateMonitor.class), mGlobalSettings, mKeyguardStateController, mWindowManager, mToastFactory, mWorkerHandler, mCarrierConfigTracker, mLocationController, mDialogTransitionAnimator, mWifiStateWorker, mFlags); Loading