Merge changes from topic "displayinfo"

* changes:
  Move override logic from SysUI to Telephony
  Added telephony display info support
This commit is contained in:
Sarah Chin
2020-03-03 21:01:06 +00:00
committed by Gerrit Code Review
14 changed files with 407 additions and 577 deletions

View File

@@ -45210,6 +45210,19 @@ package android.telephony {
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.ClosedSubscriberGroupInfo> CREATOR;
}
public final class DisplayInfo implements android.os.Parcelable {
method public int describeContents();
method public int getNetworkType();
method public int getOverrideNetworkType();
method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.DisplayInfo> CREATOR;
field public static final int OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO = 2; // 0x2
field public static final int OVERRIDE_NETWORK_TYPE_LTE_CA = 1; // 0x1
field public static final int OVERRIDE_NETWORK_TYPE_NONE = 0; // 0x0
field public static final int OVERRIDE_NETWORK_TYPE_NR_NSA = 3; // 0x3
field public static final int OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE = 4; // 0x4
}
public class IccOpenLogicalChannelResponse implements android.os.Parcelable {
method public int describeContents();
method public int getChannel();
@@ -45435,6 +45448,7 @@ package android.telephony {
method public void onDataActivity(int);
method public void onDataConnectionStateChanged(int);
method public void onDataConnectionStateChanged(int, int);
method @RequiresPermission("android.permission.READ_PHONE_STATE") public void onDisplayInfoChanged(@NonNull android.telephony.DisplayInfo);
method @RequiresPermission("android.permission.READ_PRECISE_PHONE_STATE") public void onImsCallDisconnectCauseChanged(@NonNull android.telephony.ims.ImsReasonInfo);
method public void onMessageWaitingIndicatorChanged(boolean);
method @RequiresPermission("android.permission.MODIFY_PHONE_STATE") public void onPreciseDataConnectionStateChanged(@NonNull android.telephony.PreciseDataConnectionState);
@@ -45451,6 +45465,7 @@ package android.telephony {
field public static final int LISTEN_CELL_LOCATION = 16; // 0x10
field public static final int LISTEN_DATA_ACTIVITY = 128; // 0x80
field public static final int LISTEN_DATA_CONNECTION_STATE = 64; // 0x40
field public static final int LISTEN_DISPLAY_INFO_CHANGED = 1048576; // 0x100000
field public static final int LISTEN_EMERGENCY_NUMBER_LIST = 16777216; // 0x1000000
field @RequiresPermission("android.permission.READ_PRECISE_PHONE_STATE") public static final int LISTEN_IMS_CALL_DISCONNECT_CAUSES = 134217728; // 0x8000000
field public static final int LISTEN_MESSAGE_WAITING_INDICATOR = 4; // 0x4

View File

@@ -300,6 +300,13 @@ public class PhoneStateListener {
*/
public static final int LISTEN_USER_MOBILE_DATA_STATE = 0x00080000;
/**
* Listen for display info changed event.
*
* @see #onDisplayInfoChanged
*/
public static final int LISTEN_DISPLAY_INFO_CHANGED = 0x00100000;
/**
* Listen for changes to the phone capability.
*
@@ -836,6 +843,21 @@ public class PhoneStateListener {
// default implementation empty
}
/**
* Callback invoked when the display info has changed on the registered subscription.
* <p> The {@link DisplayInfo} contains status information shown to the user based on
* carrier policy.
*
* Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE} or that the calling
* app has carrier privileges (see {@link TelephonyManager#hasCarrierPrivileges}).
*
* @param displayInfo The display information.
*/
@RequiresPermission((android.Manifest.permission.READ_PHONE_STATE))
public void onDisplayInfoChanged(@NonNull DisplayInfo displayInfo) {
// default implementation empty
}
/**
* Callback invoked when the current emergency number list has changed on the registered
* subscription.
@@ -1201,6 +1223,15 @@ public class PhoneStateListener {
() -> psl.onUserMobileDataStateChanged(enabled)));
}
public void onDisplayInfoChanged(DisplayInfo displayInfo) {
PhoneStateListener psl = mPhoneStateListenerWeakRef.get();
if (psl == null) return;
Binder.withCleanCallingIdentity(
() -> mExecutor.execute(
() -> psl.onDisplayInfoChanged(displayInfo)));
}
public void onOemHookRawEvent(byte[] rawData) {
PhoneStateListener psl = mPhoneStateListenerWeakRef.get();
if (psl == null) return;

View File

@@ -535,6 +535,24 @@ public class TelephonyRegistryManager {
}
}
/**
* Notify display info changed.
*
* @param slotIndex The SIM slot index for which display info has changed. Can be
* derived from {@code subscriptionId} except when {@code subscriptionId} is invalid, such as
* when the device is in emergency-only mode.
* @param subscriptionId Subscription id for which display network info has changed.
* @param displayInfo The display info.
*/
public void notifyDisplayInfoChanged(int slotIndex, int subscriptionId,
@NonNull DisplayInfo displayInfo) {
try {
sRegistry.notifyDisplayInfoChanged(slotIndex, subscriptionId, displayInfo);
} catch (RemoteException ex) {
// system process is dead
}
}
/**
* Notify IMS call disconnect causes which contains {@link android.telephony.ims.ImsReasonInfo}.
*

View File

@@ -20,6 +20,7 @@ import android.telephony.CallAttributes;
import android.telephony.CellIdentity;
import android.telephony.CellInfo;
import android.telephony.DataConnectionRealTimeInfo;
import android.telephony.DisplayInfo;
import android.telephony.PhoneCapability;
import android.telephony.PreciseCallState;
import android.telephony.PreciseDataConnectionState;
@@ -53,6 +54,7 @@ oneway interface IPhoneStateListener {
void onOemHookRawEvent(in byte[] rawData);
void onCarrierNetworkChange(in boolean active);
void onUserMobileDataStateChanged(in boolean enabled);
void onDisplayInfoChanged(in DisplayInfo displayInfo);
void onPhoneCapabilityChanged(in PhoneCapability capability);
void onActiveDataSubIdChanged(in int subId);
void onRadioPowerStateChanged(in int state);

View File

@@ -22,6 +22,7 @@ import android.net.NetworkCapabilities;
import android.telephony.CallQuality;
import android.telephony.CellIdentity;
import android.telephony.CellInfo;
import android.telephony.DisplayInfo;
import android.telephony.ims.ImsReasonInfo;
import android.telephony.PhoneCapability;
import android.telephony.PhysicalChannelConfig;
@@ -87,6 +88,7 @@ interface ITelephonyRegistry {
void notifyOpportunisticSubscriptionInfoChanged();
void notifyCarrierNetworkChange(in boolean active);
void notifyUserMobileDataStateChangedForPhoneId(in int phoneId, in int subId, in boolean state);
void notifyDisplayInfoChanged(int slotIndex, int subId, in DisplayInfo displayInfo);
void notifyPhoneCapabilityChanged(in PhoneCapability capability);
void notifyActiveDataSubIdChanged(int activeDataSubId);
void notifyRadioPowerStateChanged(in int phoneId, in int subId, in int state);

View File

@@ -15,21 +15,17 @@
*/
package com.android.systemui.statusbar.policy;
import static android.telephony.AccessNetworkConstants.TRANSPORT_TYPE_WWAN;
import static android.telephony.NetworkRegistrationInfo.DOMAIN_PS;
import android.content.Context;
import android.content.Intent;
import android.database.ContentObserver;
import android.net.NetworkCapabilities;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.provider.Settings.Global;
import android.telephony.Annotation;
import android.telephony.CellSignalStrength;
import android.telephony.CellSignalStrengthCdma;
import android.telephony.NetworkRegistrationInfo;
import android.telephony.DisplayInfo;
import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
@@ -58,16 +54,10 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class MobileSignalController extends SignalController<
MobileSignalController.MobileState, MobileSignalController.MobileIconGroup> {
// The message to display Nr5G icon gracfully by CarrierConfig timeout
private static final int MSG_DISPLAY_GRACE = 1;
private final TelephonyManager mPhone;
private final SubscriptionDefaults mDefaults;
private final String mNetworkNameDefault;
@@ -84,19 +74,15 @@ public class MobileSignalController extends SignalController<
// Since some pieces of the phone state are interdependent we store it locally,
// this could potentially become part of MobileState for simplification/complication
// of code.
private int mDataNetType = TelephonyManager.NETWORK_TYPE_UNKNOWN;
private boolean mCA = false;
private boolean mCAPlus = false;
private int mDataState = TelephonyManager.DATA_DISCONNECTED;
private DisplayInfo mDisplayInfo = new DisplayInfo(TelephonyManager.NETWORK_TYPE_UNKNOWN,
DisplayInfo.OVERRIDE_NETWORK_TYPE_NONE);
private ServiceState mServiceState;
private SignalStrength mSignalStrength;
private MobileIconGroup mDefaultIcons;
private Config mConfig;
private final Handler mDisplayGraceHandler;
@VisibleForTesting
boolean mInflateSignalStrengths = false;
@VisibleForTesting
boolean mIsShowingIconGracefully = false;
// TODO: Reduce number of vars passed in, if we have the NetworkController, probably don't
// need listener lists anymore.
@@ -134,16 +120,6 @@ public class MobileSignalController extends SignalController<
updateTelephony();
}
};
mDisplayGraceHandler = new Handler(receiverLooper) {
@Override
public void handleMessage(Message msg) {
if (msg.what == MSG_DISPLAY_GRACE) {
mIsShowingIconGracefully = false;
updateTelephony();
}
}
};
}
public void setConfiguration(Config config) {
@@ -188,7 +164,8 @@ public class MobileSignalController extends SignalController<
| PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
| PhoneStateListener.LISTEN_DATA_ACTIVITY
| PhoneStateListener.LISTEN_CARRIER_NETWORK_CHANGE
| PhoneStateListener.LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE);
| PhoneStateListener.LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE
| PhoneStateListener.LISTEN_DISPLAY_INFO_CHANGED);
mContext.getContentResolver().registerContentObserver(Global.getUriFor(Global.MOBILE_DATA),
true, mObserver);
mContext.getContentResolver().registerContentObserver(Global.getUriFor(
@@ -266,52 +243,60 @@ public class MobileSignalController extends SignalController<
mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_LTE),
TelephonyIcons.FOUR_G);
if (mConfig.hideLtePlus) {
mNetworkToIconLookup.put(toIconKeyCA(TelephonyManager.NETWORK_TYPE_LTE),
TelephonyIcons.FOUR_G);
mNetworkToIconLookup.put(toDisplayIconKey(
DisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA), TelephonyIcons.FOUR_G);
} else {
mNetworkToIconLookup.put(toIconKeyCA(TelephonyManager.NETWORK_TYPE_LTE),
TelephonyIcons.FOUR_G_PLUS);
mNetworkToIconLookup.put(toDisplayIconKey(
DisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA), TelephonyIcons.FOUR_G_PLUS);
}
} else {
mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_LTE),
TelephonyIcons.LTE);
if (mConfig.hideLtePlus) {
mNetworkToIconLookup.put(toIconKeyCA(TelephonyManager.NETWORK_TYPE_LTE),
TelephonyIcons.LTE);
mNetworkToIconLookup.put(toDisplayIconKey(
DisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA), TelephonyIcons.LTE);
} else {
mNetworkToIconLookup.put(toIconKeyCA(TelephonyManager.NETWORK_TYPE_LTE),
TelephonyIcons.LTE_PLUS);
mNetworkToIconLookup.put(toDisplayIconKey(
DisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA), TelephonyIcons.LTE_PLUS);
}
}
mNetworkToIconLookup.put(toIconKeyCAPlus(TelephonyManager.NETWORK_TYPE_LTE),
TelephonyIcons.LTE_CA_5G_E);
mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_IWLAN),
TelephonyIcons.WFC);
mNetworkToIconLookup.put(toDisplayIconKey(
DisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO), TelephonyIcons.LTE_CA_5G_E);
mNetworkToIconLookup.put(toDisplayIconKey(
DisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA), TelephonyIcons.NR_5G);
mNetworkToIconLookup.put(toDisplayIconKey(
DisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE), TelephonyIcons.NR_5G_PLUS);
}
private String getIconKey() {
if (mCA) {
return toIconKeyCA(mDataNetType);
} else if (mCAPlus) {
return toIconKeyCAPlus(mDataNetType);
if (mDisplayInfo.getOverrideNetworkType() == DisplayInfo.OVERRIDE_NETWORK_TYPE_NONE) {
return toIconKey(mDisplayInfo.getNetworkType());
} else {
return toIconKey(mDataNetType);
return toDisplayIconKey(mDisplayInfo.getOverrideNetworkType());
}
}
// Some specific carriers have 5GE network which is special CA network.
private String toIconKeyCAPlus(@Annotation.NetworkType int networkType) {
return toIconKeyCA(networkType) + "_Plus";
}
private String toIconKeyCA(@Annotation.NetworkType int networkType) {
return toIconKey(networkType) + "_CA";
}
private String toIconKey(@Annotation.NetworkType int networkType) {
return Integer.toString(networkType);
}
private String toDisplayIconKey(@Annotation.OverrideNetworkType int displayNetworkType) {
switch (displayNetworkType) {
case DisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA:
return toIconKey(TelephonyManager.NETWORK_TYPE_LTE) + "_CA";
case DisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO:
return toIconKey(TelephonyManager.NETWORK_TYPE_LTE) + "_CA_Plus";
case DisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA:
return "5G";
case DisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE:
return "5G_Plus";
default:
return "unsupported";
}
}
private void updateInflateSignalStrength() {
mInflateSignalStrengths = SignalStrengthUtil.shouldInflateSignalStrength(mContext,
mSubscriptionInfo.getSubscriptionId());
@@ -463,26 +448,6 @@ public class MobileSignalController extends SignalController<
}
}
private boolean isCarrierSpecificDataIcon() {
if (mConfig.patternOfCarrierSpecificDataIcon == null
|| mConfig.patternOfCarrierSpecificDataIcon.length() == 0) {
return false;
}
Pattern stringPattern = Pattern.compile(mConfig.patternOfCarrierSpecificDataIcon);
String[] operatorNames = new String[]{mServiceState.getOperatorAlphaLongRaw(),
mServiceState.getOperatorAlphaShortRaw()};
for (String opName : operatorNames) {
if (!TextUtils.isEmpty(opName)) {
Matcher matcher = stringPattern.matcher(opName);
if (matcher.find()) {
return true;
}
}
}
return false;
}
/**
* Updates the network's name based on incoming spn and plmn.
*/
@@ -536,18 +501,18 @@ public class MobileSignalController extends SignalController<
}
/**
* Updates the current state based on mServiceState, mSignalStrength, mDataNetType,
* mDataState, and mSimState. It should be called any time one of these is updated.
* Updates the current state based on mServiceState, mSignalStrength, mDataState,
* mDisplayInfo, and mSimState. It should be called any time one of these is updated.
* This will call listeners if necessary.
*/
private final void updateTelephony() {
if (DEBUG) {
Log.d(mTag, "updateTelephonySignalStrength: hasService=" +
Utils.isInService(mServiceState) + " ss=" + mSignalStrength);
Utils.isInService(mServiceState) + " ss=" + mSignalStrength
+ " displayInfo=" + mDisplayInfo);
}
checkDefaultData();
mCurrentState.connected = Utils.isInService(mServiceState)
&& mSignalStrength != null;
mCurrentState.connected = Utils.isInService(mServiceState) && mSignalStrength != null;
if (mCurrentState.connected) {
if (!mSignalStrength.isGsm() && mConfig.alwaysShowCdmaRssi) {
mCurrentState.level = getCdmaLevel();
@@ -556,17 +521,8 @@ public class MobileSignalController extends SignalController<
}
}
// When the device is camped on a 5G Non-Standalone network, the data network type is still
// LTE. In this case, we first check which 5G icon should be shown.
MobileIconGroup nr5GIconGroup = getNr5GIconGroup();
if (mConfig.nrIconDisplayGracePeriodMs > 0) {
nr5GIconGroup = adjustNr5GIconGroupByDisplayGraceTime(nr5GIconGroup);
}
String iconKey = getIconKey();
if (nr5GIconGroup != null) {
mCurrentState.iconGroup = nr5GIconGroup;
} else if (mNetworkToIconLookup.get(iconKey) != null) {
if (mNetworkToIconLookup.get(iconKey) != null) {
mCurrentState.iconGroup = mNetworkToIconLookup.get(iconKey);
} else {
mCurrentState.iconGroup = mDefaultIcons;
@@ -578,8 +534,7 @@ public class MobileSignalController extends SignalController<
if (isCarrierNetworkChangeActive()) {
mCurrentState.iconGroup = TelephonyIcons.CARRIER_NETWORK_CHANGE;
} else if (isDataDisabled() && !mConfig.alwaysShowDataRatIcon) {
if (mSubscriptionInfo.getSubscriptionId()
!= mDefaults.getDefaultDataSubId()) {
if (mSubscriptionInfo.getSubscriptionId() != mDefaults.getDefaultDataSubId()) {
mCurrentState.iconGroup = TelephonyIcons.NOT_DEFAULT_DATA;
} else {
mCurrentState.iconGroup = TelephonyIcons.DATA_DISABLED;
@@ -621,82 +576,6 @@ public class MobileSignalController extends SignalController<
notifyListenersIfNecessary();
}
private MobileIconGroup getNr5GIconGroup() {
if (mServiceState == null) return null;
int nrState = mServiceState.getNrState();
if (nrState == NetworkRegistrationInfo.NR_STATE_CONNECTED) {
// Check if the NR 5G is using millimeter wave and the icon is config.
if (mServiceState.getNrFrequencyRange() == ServiceState.FREQUENCY_RANGE_MMWAVE) {
if (mConfig.nr5GIconMap.containsKey(Config.NR_CONNECTED_MMWAVE)) {
return mConfig.nr5GIconMap.get(Config.NR_CONNECTED_MMWAVE);
}
}
// If NR 5G is not using millimeter wave or there is no icon for millimeter wave, we
// check the normal 5G icon.
if (mConfig.nr5GIconMap.containsKey(Config.NR_CONNECTED)) {
return mConfig.nr5GIconMap.get(Config.NR_CONNECTED);
}
} else if (nrState == NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED) {
if (mCurrentState.activityDormant) {
if (mConfig.nr5GIconMap.containsKey(Config.NR_NOT_RESTRICTED_RRC_IDLE)) {
return mConfig.nr5GIconMap.get(Config.NR_NOT_RESTRICTED_RRC_IDLE);
}
} else {
if (mConfig.nr5GIconMap.containsKey(Config.NR_NOT_RESTRICTED_RRC_CON)) {
return mConfig.nr5GIconMap.get(Config.NR_NOT_RESTRICTED_RRC_CON);
}
}
} else if (nrState == NetworkRegistrationInfo.NR_STATE_RESTRICTED) {
if (mConfig.nr5GIconMap.containsKey(Config.NR_RESTRICTED)) {
return mConfig.nr5GIconMap.get(Config.NR_RESTRICTED);
}
}
return null;
}
/**
* The function to adjust MobileIconGroup depend on CarrierConfig's time
* nextIconGroup == null imply next state could be 2G/3G/4G/4G+
* nextIconGroup != null imply next state will be 5G/5G+
* Flag : mIsShowingIconGracefully
* ---------------------------------------------------------------------------------
* | Last state | Current state | Flag | Action |
* ---------------------------------------------------------------------------------
* | 5G/5G+ | 2G/3G/4G/4G+ | true | return previous IconGroup |
* | 5G/5G+ | 5G/5G+ | true | Bypass |
* | 2G/3G/4G/4G+ | 5G/5G+ | true | Bypass |
* | 2G/3G/4G/4G+ | 2G/3G/4G/4G+ | true | Bypass |
* | SS.connected | SS.disconnect | T|F | Reset timer |
* |NETWORK_TYPE_LTE|!NETWORK_TYPE_LTE| T|F | Reset timer |
* | 5G/5G+ | 2G/3G/4G/4G+ | false| Bypass |
* | 5G/5G+ | 5G/5G+ | false| Bypass |
* | 2G/3G/4G/4G+ | 5G/5G+ | false| SendMessageDelay(time), flag->true |
* | 2G/3G/4G/4G+ | 2G/3G/4G/4G+ | false| Bypass |
* ---------------------------------------------------------------------------------
*/
private MobileIconGroup adjustNr5GIconGroupByDisplayGraceTime(
MobileIconGroup candidateIconGroup) {
if (mIsShowingIconGracefully && candidateIconGroup == null) {
candidateIconGroup = (MobileIconGroup) mCurrentState.iconGroup;
} else if (!mIsShowingIconGracefully && candidateIconGroup != null
&& mLastState.iconGroup != candidateIconGroup) {
mDisplayGraceHandler.sendMessageDelayed(
mDisplayGraceHandler.obtainMessage(MSG_DISPLAY_GRACE),
mConfig.nrIconDisplayGracePeriodMs);
mIsShowingIconGracefully = true;
} else if (!mCurrentState.connected || mDataState == TelephonyManager.DATA_DISCONNECTED
|| candidateIconGroup == null) {
mDisplayGraceHandler.removeMessages(MSG_DISPLAY_GRACE);
mIsShowingIconGracefully = false;
candidateIconGroup = null;
}
return candidateIconGroup;
}
boolean isDataDisabled() {
return !mPhone.isDataConnectionEnabled();
}
@@ -707,8 +586,6 @@ public class MobileSignalController extends SignalController<
|| activity == TelephonyManager.DATA_ACTIVITY_IN;
mCurrentState.activityOut = activity == TelephonyManager.DATA_ACTIVITY_INOUT
|| activity == TelephonyManager.DATA_ACTIVITY_OUT;
mCurrentState.activityDormant = activity == TelephonyManager.DATA_ACTIVITY_DORMANT;
notifyListenersIfNecessary();
}
@@ -718,13 +595,10 @@ public class MobileSignalController extends SignalController<
pw.println(" mSubscription=" + mSubscriptionInfo + ",");
pw.println(" mServiceState=" + mServiceState + ",");
pw.println(" mSignalStrength=" + mSignalStrength + ",");
pw.println(" mDisplayInfo=" + mDisplayInfo + ",");
pw.println(" mDataState=" + mDataState + ",");
pw.println(" mDataNetType=" + mDataNetType + ",");
pw.println(" mCA=" + mCA + ",");
pw.println(" mCAPlus=" + mCAPlus + ",");
pw.println(" mInflateSignalStrengths=" + mInflateSignalStrengths + ",");
pw.println(" isDataDisabled=" + isDataDisabled() + ",");
pw.println(" mIsShowingIconGracefully=" + mIsShowingIconGracefully + ",");
}
class MobilePhoneStateListener extends PhoneStateListener {
@@ -749,14 +623,8 @@ public class MobileSignalController extends SignalController<
+ " dataState=" + state.getDataRegistrationState());
}
mServiceState = state;
if (mServiceState != null) {
NetworkRegistrationInfo regInfo = mServiceState.getNetworkRegistrationInfo(
DOMAIN_PS, TRANSPORT_TYPE_WWAN);
if (regInfo != null) {
updateDataNetType(regInfo.getAccessNetworkTechnology());
}
}
updateTelephony();
// onDisplayInfoChanged is invoked directly after onServiceStateChanged, so not calling
// updateTelephony() to prevent icon flickering in case of overrides.
}
@Override
@@ -766,21 +634,10 @@ public class MobileSignalController extends SignalController<
+ " type=" + networkType);
}
mDataState = state;
updateDataNetType(networkType);
updateTelephony();
}
private void updateDataNetType(int networkType) {
mDataNetType = networkType;
mCA = false;
mCAPlus = false;
if (mDataNetType == TelephonyManager.NETWORK_TYPE_LTE) {
if (isCarrierSpecificDataIcon()) {
mCAPlus = true;
} else if (mServiceState != null && mServiceState.isUsingCarrierAggregation()) {
mCA = true;
}
if (networkType != mDisplayInfo.getNetworkType()) {
mDisplayInfo = new DisplayInfo(networkType, DisplayInfo.OVERRIDE_NETWORK_TYPE_NONE);
}
updateTelephony();
}
@Override
@@ -797,7 +654,6 @@ public class MobileSignalController extends SignalController<
Log.d(mTag, "onCarrierNetworkChange: active=" + active);
}
mCurrentState.carrierNetworkChangeMode = active;
updateTelephony();
}
@@ -807,7 +663,16 @@ public class MobileSignalController extends SignalController<
updateDataSim();
updateTelephony();
}
};
@Override
public void onDisplayInfoChanged(DisplayInfo displayInfo) {
if (DEBUG) {
Log.d(mTag, "onDisplayInfoChanged: displayInfo=" + displayInfo);
}
mDisplayInfo = displayInfo;
updateTelephony();
}
}
static class MobileIconGroup extends SignalController.IconGroup {
final int mDataContentDescription; // mContentDescriptionDataType

View File

@@ -51,7 +51,6 @@ import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.util.Log;
import android.util.MathUtils;
import android.util.SparseArray;
@@ -67,7 +66,6 @@ import com.android.systemui.Dumpable;
import com.android.systemui.R;
import com.android.systemui.settings.CurrentUserTracker;
import com.android.systemui.statusbar.policy.DeviceProvisionedController.DeviceProvisionedListener;
import com.android.systemui.statusbar.policy.MobileSignalController.MobileIconGroup;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -75,10 +73,8 @@ import java.util.ArrayList;
import java.util.BitSet;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Named;
@@ -848,12 +844,6 @@ public class NetworkControllerImpl extends BroadcastReceiver
pw.println(emergencyToString(mEmergencySource));
pw.println(" - config ------");
pw.print(" patternOfCarrierSpecificDataIcon=");
pw.println(mConfig.patternOfCarrierSpecificDataIcon);
pw.print(" nr5GIconMap=");
pw.println(mConfig.nr5GIconMap.toString());
pw.print(" nrIconDisplayGracePeriodMs=");
pw.println(mConfig.nrIconDisplayGracePeriodMs);
for (int i = 0; i < mMobileSignalControllers.size(); i++) {
MobileSignalController mobileSignalController = mMobileSignalControllers.valueAt(i);
mobileSignalController.dump(pw);
@@ -1134,14 +1124,6 @@ public class NetworkControllerImpl extends BroadcastReceiver
@VisibleForTesting
static class Config {
static final int NR_CONNECTED_MMWAVE = 1;
static final int NR_CONNECTED = 2;
static final int NR_NOT_RESTRICTED_RRC_IDLE = 3;
static final int NR_NOT_RESTRICTED_RRC_CON = 4;
static final int NR_RESTRICTED = 5;
Map<Integer, MobileIconGroup> nr5GIconMap = new HashMap<>();
boolean showAtLeast3G = false;
boolean show4gFor3g = false;
boolean alwaysShowCdmaRssi = false;
@@ -1150,22 +1132,6 @@ public class NetworkControllerImpl extends BroadcastReceiver
boolean hspaDataDistinguishable;
boolean inflateSignalStrengths = false;
boolean alwaysShowDataRatIcon = false;
public String patternOfCarrierSpecificDataIcon = "";
public long nrIconDisplayGracePeriodMs;
/**
* Mapping from NR 5G status string to an integer. The NR 5G status string should match
* those in carrier config.
*/
private static final Map<String, Integer> NR_STATUS_STRING_TO_INDEX;
static {
NR_STATUS_STRING_TO_INDEX = new HashMap<>(5);
NR_STATUS_STRING_TO_INDEX.put("connected_mmwave", NR_CONNECTED_MMWAVE);
NR_STATUS_STRING_TO_INDEX.put("connected", NR_CONNECTED);
NR_STATUS_STRING_TO_INDEX.put("not_restricted_rrc_idle", NR_NOT_RESTRICTED_RRC_IDLE);
NR_STATUS_STRING_TO_INDEX.put("not_restricted_rrc_con", NR_NOT_RESTRICTED_RRC_CON);
NR_STATUS_STRING_TO_INDEX.put("restricted", NR_RESTRICTED);
}
static Config readConfig(Context context) {
Config config = new Config();
@@ -1194,64 +1160,9 @@ public class NetworkControllerImpl extends BroadcastReceiver
CarrierConfigManager.KEY_SHOW_4G_FOR_3G_DATA_ICON_BOOL);
config.hideLtePlus = b.getBoolean(
CarrierConfigManager.KEY_HIDE_LTE_PLUS_DATA_ICON_BOOL);
config.patternOfCarrierSpecificDataIcon = b.getString(
CarrierConfigManager.KEY_SHOW_CARRIER_DATA_ICON_PATTERN_STRING);
String nr5GIconConfiguration =
b.getString(CarrierConfigManager.KEY_5G_ICON_CONFIGURATION_STRING);
if (!TextUtils.isEmpty(nr5GIconConfiguration)) {
String[] nr5GIconConfigPairs = nr5GIconConfiguration.trim().split(",");
for (String pair : nr5GIconConfigPairs) {
add5GIconMapping(pair, config);
}
}
setDisplayGraceTime(
b.getInt(CarrierConfigManager.KEY_5G_ICON_DISPLAY_GRACE_PERIOD_SEC_INT),
config);
}
return config;
}
/**
* Add a mapping from NR 5G status to the 5G icon. All the icon resources come from
* {@link TelephonyIcons}.
*
* @param keyValuePair the NR 5G status and icon name separated by a colon.
* @param config container that used to store the parsed configs.
*/
@VisibleForTesting
static void add5GIconMapping(String keyValuePair, Config config) {
String[] kv = (keyValuePair.trim().toLowerCase()).split(":");
if (kv.length != 2) {
if (DEBUG) Log.e(TAG, "Invalid 5G icon configuration, config = " + keyValuePair);
return;
}
String key = kv[0], value = kv[1];
// There is no icon config for the specific 5G status.
if (value.equals("none")) return;
if (NR_STATUS_STRING_TO_INDEX.containsKey(key)
&& TelephonyIcons.ICON_NAME_TO_ICON.containsKey(value)) {
config.nr5GIconMap.put(
NR_STATUS_STRING_TO_INDEX.get(key),
TelephonyIcons.ICON_NAME_TO_ICON.get(value));
}
}
/**
* Set display gracefully period time(MS) depend on carrierConfig KEY
* KEY_5G_ICON_DISPLAY_GRACE_PERIOD_SEC_INT, and this function will convert to ms.
* {@link CarrierConfigManager}.
*
* @param time showing 5G icon gracefully in the period of the time(SECOND)
* @param config container that used to store the parsed configs.
*/
@VisibleForTesting
static void setDisplayGraceTime(int time, Config config) {
config.nrIconDisplayGracePeriodMs = time * DateUtils.SECOND_IN_MILLIS;
}
}
}

View File

@@ -259,7 +259,6 @@ public abstract class SignalController<T extends SignalController.State,
boolean enabled;
boolean activityIn;
boolean activityOut;
public boolean activityDormant;
int level;
IconGroup iconGroup;
int inetCondition;
@@ -276,7 +275,6 @@ public abstract class SignalController<T extends SignalController.State,
inetCondition = state.inetCondition;
activityIn = state.activityIn;
activityOut = state.activityOut;
activityDormant = state.activityDormant;
rssi = state.rssi;
time = state.time;
}
@@ -300,7 +298,6 @@ public abstract class SignalController<T extends SignalController.State,
.append("iconGroup=").append(iconGroup).append(',')
.append("activityIn=").append(activityIn).append(',')
.append("activityOut=").append(activityOut).append(',')
.append("activityDormant=").append(activityDormant).append(',')
.append("rssi=").append(rssi).append(',')
.append("lastModified=").append(DateFormat.format("MM-dd HH:mm:ss", time));
}
@@ -318,7 +315,6 @@ public abstract class SignalController<T extends SignalController.State,
&& other.iconGroup == iconGroup
&& other.activityIn == activityIn
&& other.activityOut == activityOut
&& other.activityDormant == activityDormant
&& other.rssi == rssi;
}
}

View File

@@ -42,6 +42,7 @@ import android.net.wifi.WifiManager;
import android.os.Handler;
import android.provider.Settings;
import android.provider.Settings.Global;
import android.telephony.DisplayInfo;
import android.telephony.NetworkRegistrationInfo;
import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
@@ -93,6 +94,7 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
protected PhoneStateListener mPhoneStateListener;
protected SignalStrength mSignalStrength;
protected ServiceState mServiceState;
protected DisplayInfo mDisplayInfo;
protected ConnectivityManager mMockCm;
protected WifiManager mMockWm;
protected SubscriptionManager mMockSm;
@@ -143,6 +145,7 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
mSignalStrength = mock(SignalStrength.class);
mServiceState = mock(ServiceState.class);
mDisplayInfo = mock(DisplayInfo.class);
mConfig = new Config();
mConfig.hspaDataDistinguishable = true;
@@ -232,33 +235,6 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
NetworkCapabilities.TRANSPORT_CELLULAR, true, true);
}
public void setupDefaultNr5GIconConfiguration() {
NetworkControllerImpl.Config.add5GIconMapping("connected_mmwave:5g_plus", mConfig);
NetworkControllerImpl.Config.add5GIconMapping("connected:5g", mConfig);
}
public void setupNr5GIconConfigurationForNotRestrictedRrcCon() {
NetworkControllerImpl.Config.add5GIconMapping("connected_mmwave:5g_plus", mConfig);
NetworkControllerImpl.Config.add5GIconMapping("connected:5g_plus", mConfig);
NetworkControllerImpl.Config.add5GIconMapping("not_restricted_rrc_con:5g", mConfig);
}
public void setupNr5GIconConfigurationForNotRestrictedRrcIdle() {
NetworkControllerImpl.Config.add5GIconMapping("connected_mmwave:5g_plus", mConfig);
NetworkControllerImpl.Config.add5GIconMapping("connected:5g_plus", mConfig);
NetworkControllerImpl.Config.add5GIconMapping("not_restricted_rrc_idle:5g", mConfig);
}
public void setupDefaultNr5GIconDisplayGracePeriodTime_enableThirtySeconds() {
final int enableDisplayGraceTimeSec = 30;
NetworkControllerImpl.Config.setDisplayGraceTime(enableDisplayGraceTimeSec, mConfig);
}
public void setupDefaultNr5GIconDisplayGracePeriodTime_disabled() {
final int disableDisplayGraceTimeSec = 0;
NetworkControllerImpl.Config.setDisplayGraceTime(disableDisplayGraceTimeSec, mConfig);
}
public void setConnectivityViaBroadcast(
int networkType, boolean validated, boolean isConnected) {
setConnectivityCommon(networkType, validated, isConnected);
@@ -343,6 +319,7 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
protected void updateServiceState() {
Log.d(TAG, "Sending Service State: " + mServiceState);
mPhoneStateListener.onServiceStateChanged(mServiceState);
mPhoneStateListener.onDisplayInfoChanged(mDisplayInfo);
}
public void updateCallState(int state) {
@@ -358,6 +335,7 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
.build();
when(mServiceState.getNetworkRegistrationInfo(DOMAIN_PS, TRANSPORT_TYPE_WWAN))
.thenReturn(fakeRegInfo);
when(mDisplayInfo.getNetworkType()).thenReturn(dataNetType);
mPhoneStateListener.onDataConnectionStateChanged(dataState, dataNetType);
}

View File

@@ -3,17 +3,13 @@ package com.android.systemui.statusbar.policy;
import static android.telephony.AccessNetworkConstants.TRANSPORT_TYPE_WWAN;
import static android.telephony.NetworkRegistrationInfo.DOMAIN_PS;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import android.net.NetworkCapabilities;
import android.os.Looper;
import android.telephony.NetworkRegistrationInfo;
import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
import android.test.suitebuilder.annotation.SmallTest;
import android.testing.AndroidTestingRunner;
@@ -24,7 +20,6 @@ import com.android.settingslib.net.DataUsageController;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
@SmallTest
@RunWith(AndroidTestingRunner.class)
@@ -179,262 +174,6 @@ public class NetworkControllerDataTest extends NetworkControllerBaseTest {
false, false, NOT_DEFAULT_DATA_STRING);
}
@Test
public void testNr5GIcon_NrNotRestrictedRrcCon_show5GIcon() {
setupNr5GIconConfigurationForNotRestrictedRrcCon();
setupDefaultSignal();
updateDataConnectionState(TelephonyManager.DATA_CONNECTED,
TelephonyManager.NETWORK_TYPE_LTE);
updateDataActivity(TelephonyManager.DATA_ACTIVITY_INOUT);
ServiceState ss = Mockito.mock(ServiceState.class);
doReturn(NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED).when(ss).getNrState();
mPhoneStateListener.onServiceStateChanged(ss);
verifyLastMobileDataIndicators(true, DEFAULT_SIGNAL_STRENGTH, TelephonyIcons.ICON_5G,
true, DEFAULT_QS_SIGNAL_STRENGTH, TelephonyIcons.ICON_5G, true, true);
}
@Test
public void testNr5GIcon_NrNotRestrictedRrcIdle_show5GIcon() {
setupNr5GIconConfigurationForNotRestrictedRrcIdle();
setupDefaultSignal();
updateDataConnectionState(TelephonyManager.DATA_CONNECTED,
TelephonyManager.NETWORK_TYPE_LTE);
updateDataActivity(TelephonyManager.DATA_ACTIVITY_DORMANT);
ServiceState ss = Mockito.mock(ServiceState.class);
doReturn(NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED).when(ss).getNrState();
mPhoneStateListener.onServiceStateChanged(ss);
verifyDataIndicators(TelephonyIcons.ICON_5G);
}
@Test
public void testNr5GIcon_NrConnectedWithoutMMWave_show5GIcon() {
setupDefaultNr5GIconConfiguration();
setupDefaultSignal();
updateDataConnectionState(TelephonyManager.DATA_CONNECTED,
TelephonyManager.NETWORK_TYPE_LTE);
ServiceState ss = Mockito.mock(ServiceState.class);
doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(ss).getNrState();
doReturn(ServiceState.FREQUENCY_RANGE_HIGH).when(ss).getNrFrequencyRange();
mPhoneStateListener.onServiceStateChanged(ss);
verifyDataIndicators(TelephonyIcons.ICON_5G);
}
@Test
public void testNr5GIcon_NrConnectedWithMMWave_show5GPlusIcon() {
setupDefaultNr5GIconConfiguration();
setupDefaultSignal();
updateDataConnectionState(TelephonyManager.DATA_CONNECTED,
TelephonyManager.NETWORK_TYPE_LTE);
ServiceState ss = Mockito.mock(ServiceState.class);
doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(ss).getNrState();
doReturn(ServiceState.FREQUENCY_RANGE_MMWAVE).when(ss).getNrFrequencyRange();
mPhoneStateListener.onServiceStateChanged(ss);
verifyDataIndicators(TelephonyIcons.ICON_5G_PLUS);
}
@Test
public void testNr5GIcon_NrRestricted_showLteIcon() {
setupDefaultNr5GIconConfiguration();
setupDefaultSignal();
updateDataConnectionState(TelephonyManager.DATA_CONNECTED,
TelephonyManager.NETWORK_TYPE_LTE);
ServiceState ss = Mockito.mock(ServiceState.class);
doReturn(NetworkRegistrationInfo.NR_STATE_RESTRICTED).when(ss).getNrState();
mPhoneStateListener.onServiceStateChanged(mServiceState);
verifyDataIndicators(TelephonyIcons.ICON_LTE);
}
@Test
public void testNr5GIcon_displayGracePeriodTime_enabled() {
setupDefaultNr5GIconConfiguration();
setupDefaultNr5GIconDisplayGracePeriodTime_enableThirtySeconds();
setupDefaultSignal();
mNetworkController.handleConfigurationChanged();
mPhoneStateListener.onServiceStateChanged(mServiceState);
ServiceState ss = Mockito.mock(ServiceState.class);
// While nrIconDisplayGracePeriodMs > 0 & is Nr5G, mIsShowingIconGracefully should be true
doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(ss).getNrState();
doReturn(ServiceState.FREQUENCY_RANGE_HIGH).when(ss).getNrFrequencyRange();
mPhoneStateListener.onDataConnectionStateChanged(TelephonyManager.DATA_CONNECTED,
TelephonyManager.NETWORK_TYPE_LTE);
mPhoneStateListener.onServiceStateChanged(ss);
assertTrue(mConfig.nrIconDisplayGracePeriodMs > 0);
assertTrue(mMobileSignalController.mIsShowingIconGracefully);
}
@Test
public void testNr5GIcon_displayGracePeriodTime_disabled() {
setupDefaultNr5GIconConfiguration();
setupDefaultNr5GIconDisplayGracePeriodTime_disabled();
setupDefaultSignal();
assertTrue(mConfig.nrIconDisplayGracePeriodMs == 0);
// While nrIconDisplayGracePeriodMs <= 0, mIsShowingIconGracefully should be false
doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(mServiceState).getNrState();
doReturn(ServiceState.FREQUENCY_RANGE_HIGH).when(mServiceState).getNrFrequencyRange();
mPhoneStateListener.onDataConnectionStateChanged(TelephonyManager.DATA_CONNECTED,
TelephonyManager.NETWORK_TYPE_LTE);
assertFalse(mMobileSignalController.mIsShowingIconGracefully);
}
@Test
public void testNr5GIcon_enableDisplayGracePeriodTime_showIconGracefully() {
setupDefaultNr5GIconConfiguration();
setupDefaultNr5GIconDisplayGracePeriodTime_enableThirtySeconds();
setupDefaultSignal();
mNetworkController.handleConfigurationChanged();
mPhoneStateListener.onServiceStateChanged(mServiceState);
ServiceState ss = Mockito.mock(ServiceState.class);
doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(ss).getNrState();
doReturn(ServiceState.FREQUENCY_RANGE_HIGH).when(ss).getNrFrequencyRange();
mPhoneStateListener.onDataConnectionStateChanged(TelephonyManager.DATA_CONNECTED,
TelephonyManager.NETWORK_TYPE_LTE);
mPhoneStateListener.onServiceStateChanged(ss);
verifyDataIndicators(TelephonyIcons.ICON_5G);
// Enabled timer Nr5G switch to None Nr5G, showing 5G icon gracefully
ServiceState ssLte = Mockito.mock(ServiceState.class);
doReturn(NetworkRegistrationInfo.NR_STATE_NONE).when(ssLte).getNrState();
doReturn(ServiceState.FREQUENCY_RANGE_UNKNOWN).when(ssLte).getNrFrequencyRange();
mPhoneStateListener.onDataConnectionStateChanged(TelephonyManager.DATA_CONNECTED,
TelephonyManager.NETWORK_TYPE_LTE);
mPhoneStateListener.onServiceStateChanged(ssLte);
verifyDataIndicators(TelephonyIcons.ICON_5G);
}
@Test
public void testNr5GIcon_disableDisplayGracePeriodTime_showLatestIconImmediately() {
setupDefaultNr5GIconConfiguration();
setupDefaultNr5GIconDisplayGracePeriodTime_disabled();
setupDefaultSignal();
mNetworkController.handleConfigurationChanged();
doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(mServiceState).getNrState();
doReturn(ServiceState.FREQUENCY_RANGE_HIGH).when(mServiceState).getNrFrequencyRange();
mPhoneStateListener.onDataConnectionStateChanged(TelephonyManager.DATA_CONNECTED,
TelephonyManager.NETWORK_TYPE_LTE);
verifyDataIndicators(TelephonyIcons.ICON_5G);
doReturn(NetworkRegistrationInfo.NR_STATE_NONE).when(mServiceState).getNrState();
doReturn(ServiceState.FREQUENCY_RANGE_UNKNOWN).when(mServiceState).getNrFrequencyRange();
mPhoneStateListener.onDataConnectionStateChanged(TelephonyManager.DATA_CONNECTED,
TelephonyManager.NETWORK_TYPE_LTE);
verifyDataIndicators(TelephonyIcons.ICON_LTE);
}
@Test
public void testNr5GIcon_resetDisplayGracePeriodTime_whenDataDisconnected() {
setupDefaultNr5GIconConfiguration();
setupDefaultNr5GIconDisplayGracePeriodTime_enableThirtySeconds();
setupDefaultSignal();
mNetworkController.handleConfigurationChanged();
doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(mServiceState).getNrState();
doReturn(ServiceState.FREQUENCY_RANGE_HIGH).when(mServiceState).getNrFrequencyRange();
mPhoneStateListener.onDataConnectionStateChanged(TelephonyManager.DATA_CONNECTED,
TelephonyManager.NETWORK_TYPE_LTE);
verifyDataIndicators(TelephonyIcons.ICON_5G);
// Disabled timer, when out of service, reset timer to display latest state
updateDataConnectionState(TelephonyManager.DATA_CONNECTED,
TelephonyManager.NETWORK_TYPE_LTE);
doReturn(NetworkRegistrationInfo.NR_STATE_NONE).when(mServiceState).getNrState();
doReturn(ServiceState.FREQUENCY_RANGE_UNKNOWN).when(mServiceState).getNrFrequencyRange();
mPhoneStateListener.onDataConnectionStateChanged(TelephonyManager.DATA_DISCONNECTED,
TelephonyManager.NETWORK_TYPE_UMTS);
verifyDataIndicators(0);
}
@Test
public void testNr5GIcon_enableDisplayGracePeriodTime_show5G_switching_5GPlus() {
setupDefaultNr5GIconConfiguration();
setupDefaultNr5GIconDisplayGracePeriodTime_enableThirtySeconds();
setupDefaultSignal();
mNetworkController.handleConfigurationChanged();
mPhoneStateListener.onServiceStateChanged(mServiceState);
ServiceState ss5G = Mockito.mock(ServiceState.class);
doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(ss5G).getNrState();
doReturn(ServiceState.FREQUENCY_RANGE_HIGH).when(ss5G).getNrFrequencyRange();
mPhoneStateListener.onDataConnectionStateChanged(TelephonyManager.DATA_CONNECTED,
TelephonyManager.NETWORK_TYPE_LTE);
mPhoneStateListener.onServiceStateChanged(ss5G);
verifyDataIndicators(TelephonyIcons.ICON_5G);
// When timeout enabled, 5G/5G+ switching should be updated immediately
ServiceState ss5GPlus = Mockito.mock(ServiceState.class);
doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(ss5GPlus).getNrState();
doReturn(ServiceState.FREQUENCY_RANGE_MMWAVE).when(ss5GPlus).getNrFrequencyRange();
mPhoneStateListener.onDataConnectionStateChanged(TelephonyManager.DATA_CONNECTED,
TelephonyManager.NETWORK_TYPE_LTE);
mPhoneStateListener.onServiceStateChanged(ss5GPlus);
verifyDataIndicators(TelephonyIcons.ICON_5G_PLUS);
}
@Test
public void testNr5GIcon_carrierDisabledDisplayGracePeriodTime_shouldUpdateIconImmediately() {
setupDefaultNr5GIconConfiguration();
setupDefaultNr5GIconDisplayGracePeriodTime_enableThirtySeconds();
setupDefaultSignal();
mNetworkController.handleConfigurationChanged();
mPhoneStateListener.onServiceStateChanged(mServiceState);
ServiceState ss5G = Mockito.mock(ServiceState.class);
doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(ss5G).getNrState();
doReturn(ServiceState.FREQUENCY_RANGE_HIGH).when(ss5G).getNrFrequencyRange();
mPhoneStateListener.onDataConnectionStateChanged(TelephonyManager.DATA_CONNECTED,
TelephonyManager.NETWORK_TYPE_LTE);
mPhoneStateListener.onServiceStateChanged(ss5G);
verifyDataIndicators(TelephonyIcons.ICON_5G);
// State from NR_5G to NONE NR_5G with timeout, should show previous 5G icon
ServiceState ssLte = Mockito.mock(ServiceState.class);
doReturn(NetworkRegistrationInfo.NR_STATE_NONE).when(ssLte).getNrState();
doReturn(ServiceState.FREQUENCY_RANGE_UNKNOWN).when(ssLte).getNrFrequencyRange();
mPhoneStateListener.onDataConnectionStateChanged(TelephonyManager.DATA_CONNECTED,
TelephonyManager.NETWORK_TYPE_LTE);
mPhoneStateListener.onServiceStateChanged(ssLte);
verifyDataIndicators(TelephonyIcons.ICON_5G);
// Update nrIconDisplayGracePeriodMs to 0
setupDefaultNr5GIconDisplayGracePeriodTime_disabled();
mNetworkController.handleConfigurationChanged();
// State from NR_5G to NONE NR_STATE_RESTRICTED, showing corresponding icon
doReturn(NetworkRegistrationInfo.NR_STATE_RESTRICTED).when(mServiceState).getNrState();
NetworkRegistrationInfo fakeRegInfo = new NetworkRegistrationInfo.Builder()
.setTransportType(TRANSPORT_TYPE_WWAN)
.setDomain(DOMAIN_PS)
.setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_LTE)
.build();
doReturn(fakeRegInfo).when(mServiceState)
.getNetworkRegistrationInfo(DOMAIN_PS, TRANSPORT_TYPE_WWAN);
mPhoneStateListener.onDataConnectionStateChanged(TelephonyManager.DATA_CONNECTED,
TelephonyManager.NETWORK_TYPE_LTE);
assertTrue(mConfig.nrIconDisplayGracePeriodMs == 0);
verifyDataIndicators(TelephonyIcons.ICON_LTE);
}
@Test
public void testDataDisabledIcon_UserNotSetup() {
setupNetworkController();
@@ -496,6 +235,7 @@ public class NetworkControllerDataTest extends NetworkControllerBaseTest {
.build();
when(mServiceState.getNetworkRegistrationInfo(DOMAIN_PS, TRANSPORT_TYPE_WWAN))
.thenReturn(fakeRegInfo);
when(mDisplayInfo.getNetworkType()).thenReturn(TelephonyManager.NETWORK_TYPE_HSPA);
updateServiceState();
verifyDataIndicators(TelephonyIcons.ICON_H);
}

View File

@@ -59,6 +59,7 @@ import android.telephony.CellSignalStrengthTdscdma;
import android.telephony.CellSignalStrengthWcdma;
import android.telephony.DataFailCause;
import android.telephony.DisconnectCause;
import android.telephony.DisplayInfo;
import android.telephony.LocationAccessPolicy;
import android.telephony.PhoneCapability;
import android.telephony.PhoneStateListener;
@@ -205,6 +206,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
private boolean[] mUserMobileDataState;
private DisplayInfo[] mDisplayInfos;
private SignalStrength[] mSignalStrength;
private boolean[] mMessageWaiting;
@@ -283,7 +286,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR
| PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR
| PhoneStateListener.LISTEN_EMERGENCY_NUMBER_LIST
| PhoneStateListener.LISTEN_REGISTRATION_FAILURE;
| PhoneStateListener.LISTEN_REGISTRATION_FAILURE
| PhoneStateListener.LISTEN_DISPLAY_INFO_CHANGED;
static final int PRECISE_PHONE_STATE_PERMISSION_MASK =
PhoneStateListener.LISTEN_PRECISE_CALL_STATE
@@ -440,6 +444,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
mCallAttributes = copyOf(mCallAttributes, mNumPhones);
mOutgoingCallEmergencyNumber = copyOf(mOutgoingCallEmergencyNumber, mNumPhones);
mOutgoingSmsEmergencyNumber = copyOf(mOutgoingSmsEmergencyNumber, mNumPhones);
mDisplayInfos = copyOf(mDisplayInfos, mNumPhones);
// ds -> ss switch.
if (mNumPhones < oldNumPhones) {
@@ -477,6 +482,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
mForegroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE;
mBackgroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE;
mPreciseDataConnectionStates.add(new HashMap<String, PreciseDataConnectionState>());
mDisplayInfos[i] = null;
}
}
@@ -534,6 +540,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
mEmergencyNumberList = new HashMap<>();
mOutgoingCallEmergencyNumber = new EmergencyNumber[numPhones];
mOutgoingSmsEmergencyNumber = new EmergencyNumber[numPhones];
mDisplayInfos = new DisplayInfo[numPhones];
for (int i = 0; i < numPhones; i++) {
mCallState[i] = TelephonyManager.CALL_STATE_IDLE;
mDataActivity[i] = TelephonyManager.DATA_ACTIVITY_NONE;
@@ -561,6 +568,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
mForegroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE;
mBackgroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE;
mPreciseDataConnectionStates.add(new HashMap<String, PreciseDataConnectionState>());
mDisplayInfos[i] = null;
}
mAppOps = mContext.getSystemService(AppOpsManager.class);
@@ -971,6 +979,15 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
remove(r.binder);
}
}
if ((events & PhoneStateListener.LISTEN_DISPLAY_INFO_CHANGED) != 0) {
try {
if (mDisplayInfos[phoneId] != null) {
r.callback.onDisplayInfoChanged(mDisplayInfos[phoneId]);
}
} catch (RemoteException ex) {
remove(r.binder);
}
}
if ((events & PhoneStateListener.LISTEN_EMERGENCY_NUMBER_LIST) != 0) {
try {
r.callback.onEmergencyNumberListChanged(mEmergencyNumberList);
@@ -1481,6 +1498,45 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
}
}
/**
* Notify display network info changed.
*
* @param phoneId Phone id
* @param subId Subscription id
* @param displayInfo Display network info
*
* @see PhoneStateListener#onDisplayInfoChanged(DisplayInfo)
*/
public void notifyDisplayInfoChanged(int phoneId, int subId,
@NonNull DisplayInfo displayInfo) {
if (!checkNotifyPermission("notifyDisplayInfoChanged()")) {
return;
}
if (VDBG) {
log("notifyDisplayInfoChanged: PhoneId=" + phoneId
+ " subId=" + subId + " displayInfo=" + displayInfo);
}
synchronized (mRecords) {
if (validatePhoneId(phoneId)) {
if (mDisplayInfos[phoneId] != null) {
mDisplayInfos[phoneId] = displayInfo;
for (Record r : mRecords) {
if (r.matchPhoneStateListenerEvent(
PhoneStateListener.LISTEN_DISPLAY_INFO_CHANGED)
&& idMatch(r.subId, subId, phoneId)) {
try {
r.callback.onDisplayInfoChanged(displayInfo);
} catch (RemoteException ex) {
mRemoveList.add(r.binder);
}
}
}
}
}
handleRemoveListLocked();
}
}
public void notifyCallForwardingChanged(boolean cfi) {
notifyCallForwardingChangedForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, cfi);
}
@@ -2641,6 +2697,20 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
}
}
if ((events & PhoneStateListener.LISTEN_DISPLAY_INFO_CHANGED) != 0) {
try {
if (VDBG) {
log("checkPossibleMissNotify: onDisplayInfoChanged phoneId="
+ phoneId + " dpi=" + mDisplayInfos[phoneId]);
}
if (mDisplayInfos[phoneId] != null) {
r.callback.onDisplayInfoChanged(mDisplayInfos[phoneId]);
}
} catch (RemoteException ex) {
mRemoveList.add(r.binder);
}
}
if ((events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) {
try {
if (VDBG) {

View File

@@ -651,4 +651,16 @@ public class Annotation {
})
@Retention(RetentionPolicy.SOURCE)
public @interface UiccAppType{}
/**
* Override network type
*/
@Retention(RetentionPolicy.SOURCE)
@IntDef(prefix = "OVERRIDE_NETWORK_TYPE_", value = {
DisplayInfo.OVERRIDE_NETWORK_TYPE_NONE,
DisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA,
DisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO,
DisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA,
DisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE})
public @interface OverrideNetworkType {}
}

View File

@@ -0,0 +1,18 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony;
parcelable DisplayInfo;

View File

@@ -0,0 +1,172 @@
/*
* Copyright 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony;
import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcelable;
import android.telephony.Annotation.NetworkType;
import android.telephony.Annotation.OverrideNetworkType;
import java.util.Objects;
/**
* DisplayInfo contains telephony-related information used for display purposes only. This
* information is provided in accordance with carrier policy and branding preferences; it is not
* necessarily a precise or accurate representation of the current state and should be treated
* accordingly.
*/
public final class DisplayInfo implements Parcelable {
/**
* No override. {@link #getNetworkType()} should be used for display network
* type.
*/
public static final int OVERRIDE_NETWORK_TYPE_NONE = 0;
/**
* Override network type when the device is connected to
* {@link TelephonyManager#NETWORK_TYPE_LTE} cellular network and is using carrier aggregation.
*/
public static final int OVERRIDE_NETWORK_TYPE_LTE_CA = 1;
/**
* Override network type when the device is connected to advanced pro
* {@link TelephonyManager#NETWORK_TYPE_LTE} cellular network.
*/
public static final int OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO = 2;
/**
* Override network type when the device is connected to
* {@link TelephonyManager#NETWORK_TYPE_LTE} network and has E-UTRA-NR Dual Connectivity(EN-DC)
* capability or is currently connected to the secondary
* {@link TelephonyManager#NETWORK_TYPE_NR} cellular network.
*/
public static final int OVERRIDE_NETWORK_TYPE_NR_NSA = 3;
/**
* Override network type when the device is connected to
* {@link TelephonyManager#NETWORK_TYPE_LTE} network and has E-UTRA-NR Dual Connectivity(EN-DC)
* capability or is currently connected to the secondary
* {@link TelephonyManager#NETWORK_TYPE_NR} cellular network on millimeter wave bands.
*
* @see AccessNetworkConstants.NgranBands#FREQUENCY_RANGE_GROUP_2
*/
public static final int OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE = 4;
@NetworkType
private final int mNetworkType;
@OverrideNetworkType
private final int mOverrideNetworkType;
/**
* Constructor
*
* @param networkType Current packet-switching cellular network type
* @param overrideNetworkType The override network type
*
* @hide
*/
public DisplayInfo(@NetworkType int networkType, @OverrideNetworkType int overrideNetworkType) {
mNetworkType = networkType;
mOverrideNetworkType = overrideNetworkType;
}
/** @hide */
public DisplayInfo(Parcel p) {
mNetworkType = p.readInt();
mOverrideNetworkType = p.readInt();
}
/**
* Get current packet-switching cellular network type. This is the actual network type the
* device is camped on.
*
* @return The network type.
*/
@NetworkType
public int getNetworkType() {
return mNetworkType;
}
/**
* Get the override network type. Note the override network type is for market branding
* or visualization purposes only. It cannot be treated as the actual network type device is
* camped on.
*
* @return The override network type.
*/
@OverrideNetworkType
public int getOverrideNetworkType() {
return mOverrideNetworkType;
}
@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
dest.writeInt(mNetworkType);
dest.writeInt(mOverrideNetworkType);
}
public static final @NonNull Parcelable.Creator<DisplayInfo> CREATOR =
new Parcelable.Creator<DisplayInfo>() {
@Override
public DisplayInfo createFromParcel(Parcel source) {
return new DisplayInfo(source);
}
@Override
public DisplayInfo[] newArray(int size) {
return new DisplayInfo[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
DisplayInfo that = (DisplayInfo) o;
return mNetworkType == that.mNetworkType
&& mOverrideNetworkType == that.mOverrideNetworkType;
}
@Override
public int hashCode() {
return Objects.hash(mNetworkType, mOverrideNetworkType);
}
private static String overrideNetworkTypeToString(@OverrideNetworkType int type) {
switch (type) {
case OVERRIDE_NETWORK_TYPE_NONE: return "NONE";
case OVERRIDE_NETWORK_TYPE_LTE_CA: return "LTE_CA";
case OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO: return "LTE_ADV_PRO";
case OVERRIDE_NETWORK_TYPE_NR_NSA: return "NR_NSA";
case OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE: return "NR_NSA_MMWAVE";
default: return "UNKNOWN";
}
}
@Override
public String toString() {
return "DisplayInfo {network=" + TelephonyManager.getNetworkTypeName(mNetworkType)
+ ", override=" + overrideNetworkTypeToString(mOverrideNetworkType);
}
}