Create QsInfo and SbInfo boxes for MobileSignalController

Simplify MobileSignalController#notifyListeners() by splitting the QS
and SB portions of the method into their own *Info objects and moving
those calls out to their own methods.

Also adds mNetworkToIconLookup, mProviderModelBehavior, and
mProviderModelSetting to the MobileSignalController logs.

Test: dumpsys
Bug 197851948

Change-Id: Ibdaec230c4a407d23804fb8250809cc877a7f183
Merged-In: Ibdaec230c4a407d23804fb8250809cc877a7f183
This commit is contained in:
Evan Laird
2021-09-02 17:24:07 -04:00
parent d145f34cb1
commit 1b3972d7f8
6 changed files with 119 additions and 91 deletions

View File

@@ -239,6 +239,11 @@ public class SignalIcon {
return dataConnected && !carrierNetworkChangeMode && activityOut;
}
/** @return true if this state should show a RAT icon in quick settings */
public boolean showQuickSettingsRatIcon() {
return dataConnected || isDataDisabledOrNotDefault();
}
@Override
protected void toString(StringBuilder builder) {
super.toString(builder);
@@ -254,7 +259,8 @@ public class SignalIcon {
builder.append("carrierNetworkChangeMode=").append(carrierNetworkChangeMode)
.append(',');
builder.append("userSetup=").append(userSetup).append(',');
builder.append("defaultDataOff=").append(defaultDataOff);
builder.append("defaultDataOff=").append(defaultDataOff).append(',');
builder.append("showQuickSettingsRatIcon=").append(showQuickSettingsRatIcon());
}
@Override

View File

@@ -275,7 +275,7 @@ public class CellularTile extends QSTileImpl<SignalState> {
return;
}
mInfo.dataSubscriptionName = mController.getMobileDataNetworkName();
mInfo.dataContentDescription = indicators.description != null
mInfo.dataContentDescription = indicators.qsDescription != null
? indicators.typeContentDescriptionHtml : null;
mInfo.activityIn = indicators.activityIn;
mInfo.activityOut = indicators.activityOut;

View File

@@ -279,9 +279,9 @@ public class InternetTile extends QSTileImpl<SignalState> {
// Not data sim, don't display.
return;
}
mCellularInfo.mDataSubscriptionName = indicators.description == null
? mController.getMobileDataNetworkName() : indicators.description;
mCellularInfo.mDataContentDescription = indicators.description != null
mCellularInfo.mDataSubscriptionName = indicators.qsDescription == null
? mController.getMobileDataNetworkName() : indicators.qsDescription;
mCellularInfo.mDataContentDescription = indicators.qsDescription != null
? indicators.typeContentDescriptionHtml : null;
mCellularInfo.mMobileSignalIconId = indicators.qsIcon.icon;
mCellularInfo.mQsTypeIcon = indicators.qsType;

View File

@@ -385,92 +385,82 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
dataContentDescription = mContext.getString(R.string.data_connection_no_internet);
}
final boolean dataDisabled = mCurrentState.isDataDisabledOrNotDefault();
final QsInfo qsInfo = getQsInfo(contentDescription, icons.dataType);
final SbInfo sbInfo = getSbInfo(contentDescription, icons.dataType);
if (mProviderModelBehavior) {
// Show icon in QS when we are connected or data is disabled.
boolean showDataIcon = mCurrentState.dataConnected || dataDisabled;
MobileDataIndicators mobileDataIndicators = new MobileDataIndicators(
sbInfo.icon,
qsInfo.icon,
sbInfo.ratTypeIcon,
qsInfo.ratTypeIcon,
mCurrentState.hasActivityIn(),
mCurrentState.hasActivityOut(),
dataContentDescription,
dataContentDescriptionHtml,
qsInfo.description,
mSubscriptionInfo.getSubscriptionId(),
mCurrentState.roaming,
sbInfo.showTriangle);
callback.setMobileDataIndicators(mobileDataIndicators);
}
int qsTypeIcon = 0;
IconState qsIcon = null;
CharSequence description = null;
// Only send data sim callbacks to QS.
if (mCurrentState.dataSim && mCurrentState.isDefault) {
qsTypeIcon =
(showDataIcon || mConfig.alwaysShowDataRatIcon) ? icons.dataType : 0;
qsIcon = new IconState(mCurrentState.enabled
&& !mCurrentState.isEmergency, getQsCurrentIconId(), contentDescription);
description = mCurrentState.isEmergency ? null : mCurrentState.networkName;
private QsInfo getQsInfo(String contentDescription, int dataTypeIcon) {
int qsTypeIcon = 0;
IconState qsIcon = null;
CharSequence qsDescription = null;
boolean pm = mProviderModelSetting || mProviderModelBehavior;
if (mCurrentState.dataSim) {
// If using provider model behavior, only show QS icons if the state is also default
if (pm && !mCurrentState.isDefault) {
return new QsInfo(qsTypeIcon, qsIcon, qsDescription);
}
showDataIcon &= mCurrentState.dataSim && mCurrentState.isDefault;
boolean showTriangle = showDataIcon && !mCurrentState.airplaneMode;
int typeIcon = (showDataIcon || mConfig.alwaysShowDataRatIcon) ? icons.dataType : 0;
showDataIcon |= mCurrentState.roaming;
IconState statusIcon = new IconState(showDataIcon && !mCurrentState.airplaneMode,
if (mCurrentState.showQuickSettingsRatIcon() || mConfig.alwaysShowDataRatIcon) {
qsTypeIcon = dataTypeIcon;
}
boolean qsIconVisible = mCurrentState.enabled && !mCurrentState.isEmergency;
qsIcon = new IconState(qsIconVisible, getQsCurrentIconId(), contentDescription);
if (!mCurrentState.isEmergency) {
qsDescription = mCurrentState.networkName;
}
}
return new QsInfo(qsTypeIcon, qsIcon, qsDescription);
}
private SbInfo getSbInfo(String contentDescription, int dataTypeIcon) {
final boolean dataDisabled = mCurrentState.isDataDisabledOrNotDefault();
boolean showTriangle = false;
int typeIcon = 0;
IconState statusIcon = null;
if (mProviderModelBehavior) {
boolean showDataIconStatusBar = (mCurrentState.dataConnected || dataDisabled)
&& (mCurrentState.dataSim && mCurrentState.isDefault);
typeIcon =
(showDataIconStatusBar || mConfig.alwaysShowDataRatIcon) ? dataTypeIcon : 0;
showDataIconStatusBar |= mCurrentState.roaming;
statusIcon = new IconState(
showDataIconStatusBar && !mCurrentState.airplaneMode,
getCurrentIconId(), contentDescription);
MobileDataIndicators mobileDataIndicators = new MobileDataIndicators(
statusIcon,
qsIcon,
typeIcon,
qsTypeIcon,
mCurrentState.hasActivityIn(),
mCurrentState.hasActivityOut(),
dataContentDescription,
dataContentDescriptionHtml,
description,
mSubscriptionInfo.getSubscriptionId(),
mCurrentState.roaming,
showTriangle);
callback.setMobileDataIndicators(mobileDataIndicators);
showTriangle = showDataIconStatusBar && !mCurrentState.airplaneMode;
} else {
boolean showDataIcon = mCurrentState.dataConnected || dataDisabled;
IconState statusIcon = new IconState(
statusIcon = new IconState(
mCurrentState.enabled && !mCurrentState.airplaneMode,
getCurrentIconId(), contentDescription);
int qsTypeIcon = 0;
IconState qsIcon = null;
CharSequence description = null;
// Only send data sim callbacks to QS.
if (mProviderModelSetting) {
if (mCurrentState.dataSim && mCurrentState.isDefault) {
qsTypeIcon =
(showDataIcon || mConfig.alwaysShowDataRatIcon) ? icons.dataType : 0;
qsIcon = new IconState(
mCurrentState.enabled && !mCurrentState.isEmergency,
getQsCurrentIconId(), contentDescription);
description = mCurrentState.isEmergency ? null : mCurrentState.networkName;
}
} else {
if (mCurrentState.dataSim) {
qsTypeIcon =
(showDataIcon || mConfig.alwaysShowDataRatIcon) ? icons.dataType : 0;
qsIcon = new IconState(
mCurrentState.enabled && !mCurrentState.isEmergency,
getQsCurrentIconId(), contentDescription);
description = mCurrentState.isEmergency ? null : mCurrentState.networkName;
}
}
showDataIcon &= mCurrentState.isDefault || dataDisabled;
int typeIcon = (showDataIcon || mConfig.alwaysShowDataRatIcon) ? icons.dataType : 0;
boolean showTriangle = mCurrentState.enabled && !mCurrentState.airplaneMode;
MobileDataIndicators mobileDataIndicators = new MobileDataIndicators(
statusIcon,
qsIcon,
typeIcon,
qsTypeIcon,
mCurrentState.hasActivityIn(),
mCurrentState.hasActivityOut(),
dataContentDescription,
dataContentDescriptionHtml,
description,
mSubscriptionInfo.getSubscriptionId(),
mCurrentState.roaming,
showTriangle);
callback.setMobileDataIndicators(mobileDataIndicators);
boolean showDataIconInStatusBar =
(mCurrentState.dataConnected && mCurrentState.isDefault) || dataDisabled;
typeIcon =
(showDataIconInStatusBar || mConfig.alwaysShowDataRatIcon) ? dataTypeIcon : 0;
showTriangle = mCurrentState.enabled && !mCurrentState.airplaneMode;
}
return new SbInfo(showTriangle, typeIcon, statusIcon);
}
@Override
@@ -844,12 +834,15 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
public void dump(PrintWriter pw) {
super.dump(pw);
pw.println(" mSubscription=" + mSubscriptionInfo + ",");
pw.println(" mProviderModelSetting=" + mProviderModelSetting + ",");
pw.println(" mProviderModelBehavior=" + mProviderModelBehavior + ",");
pw.println(" mServiceState=" + mServiceState + ",");
pw.println(" mSignalStrength=" + mSignalStrength + ",");
pw.println(" mTelephonyDisplayInfo=" + mTelephonyDisplayInfo + ",");
pw.println(" mDataState=" + mDataState + ",");
pw.println(" mInflateSignalStrengths=" + mInflateSignalStrengths + ",");
pw.println(" isDataDisabled=" + isDataDisabled() + ",");
pw.println(" mNetworkToIconLookup=" + mNetworkToIconLookup + ",");
pw.println(" MobileStatusHistory");
int size = 0;
for (int i = 0; i < STATUS_HISTORY_SIZE; i++) {
@@ -865,4 +858,31 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
+ mMobileStatusHistory[i & (STATUS_HISTORY_SIZE - 1)]);
}
}
/** Box for QS icon info */
private static final class QsInfo {
final int ratTypeIcon;
final IconState icon;
final CharSequence description;
QsInfo(int typeIcon, IconState iconState, CharSequence desc) {
ratTypeIcon = typeIcon;
icon = iconState;
description = desc;
}
}
/** Box for StatusBar icon info */
private static final class SbInfo {
final boolean showTriangle;
final int ratTypeIcon;
final IconState icon;
SbInfo(boolean show, int typeIcon, IconState iconState) {
showTriangle = show;
ratTypeIcon = typeIcon;
icon = iconState;
}
}
}

View File

@@ -81,7 +81,7 @@ public interface NetworkController extends CallbackController<SignalCallback>, D
.append(",qsIcon=").append(qsIcon == null ? "" : qsIcon.toString())
.append(",activityIn=").append(activityIn)
.append(",activityOut=").append(activityOut)
.append(",description=").append(description)
.append(",qsDescription=").append(description)
.append(",isTransient=").append(isTransient)
.append(",statusLabel=").append(statusLabel)
.append(']').toString();
@@ -100,7 +100,7 @@ public interface NetworkController extends CallbackController<SignalCallback>, D
public boolean activityOut;
public CharSequence typeContentDescription;
public CharSequence typeContentDescriptionHtml;
public CharSequence description;
public CharSequence qsDescription;
public int subId;
public boolean roaming;
public boolean showTriangle;
@@ -108,7 +108,7 @@ public interface NetworkController extends CallbackController<SignalCallback>, D
public MobileDataIndicators(IconState statusIcon, IconState qsIcon, int statusType,
int qsType, boolean activityIn, boolean activityOut,
CharSequence typeContentDescription, CharSequence typeContentDescriptionHtml,
CharSequence description, int subId, boolean roaming,
CharSequence qsDescription, int subId, boolean roaming,
boolean showTriangle) {
this.statusIcon = statusIcon;
this.qsIcon = qsIcon;
@@ -118,7 +118,7 @@ public interface NetworkController extends CallbackController<SignalCallback>, D
this.activityOut = activityOut;
this.typeContentDescription = typeContentDescription;
this.typeContentDescriptionHtml = typeContentDescriptionHtml;
this.description = description;
this.qsDescription = qsDescription;
this.subId = subId;
this.roaming = roaming;
this.showTriangle = showTriangle;
@@ -135,7 +135,7 @@ public interface NetworkController extends CallbackController<SignalCallback>, D
.append(",activityOut=").append(activityOut)
.append(",typeContentDescription=").append(typeContentDescription)
.append(",typeContentDescriptionHtml=").append(typeContentDescriptionHtml)
.append(",description=").append(description)
.append(",description=").append(qsDescription)
.append(",subId=").append(subId)
.append(",roaming=").append(roaming)
.append(",showTriangle=").append(showTriangle)
@@ -183,11 +183,13 @@ public interface NetworkController extends CallbackController<SignalCallback>, D
default void setCallIndicator(IconState statusIcon, int subId) {}
}
public interface EmergencyListener {
/** */
interface EmergencyListener {
void setEmergencyCallsOnly(boolean emergencyOnly);
}
public static class IconState {
/** */
class IconState {
public final boolean visible;
public final int icon;
public final String contentDescription;
@@ -217,7 +219,7 @@ public interface NetworkController extends CallbackController<SignalCallback>, D
* Tracks changes in access points. Allows listening for changes, scanning for new APs,
* and connecting to new ones.
*/
public interface AccessPointController {
interface AccessPointController {
void addAccessPointCallback(AccessPointCallback callback);
void removeAccessPointCallback(AccessPointCallback callback);
void scanForAccessPoints();
@@ -227,7 +229,7 @@ public interface NetworkController extends CallbackController<SignalCallback>, D
boolean canConfigWifi();
boolean canConfigMobileData();
public interface AccessPointCallback {
interface AccessPointCallback {
void onAccessPointsChanged(List<WifiEntry> accessPoints);
void onSettingsActivityTriggered(Intent settingsIntent);
}

View File

@@ -141,7 +141,7 @@ public class CallbackHandlerTest extends SysuiTestCase {
assertEquals(out, expected.activityOut);
assertEquals(typeDescription, expected.typeContentDescription);
assertEquals(typeDescriptionHtml, expected.typeContentDescriptionHtml);
assertEquals(description, expected.description);
assertEquals(description, expected.qsDescription);
assertEquals(subId, expected.subId);
assertTrue(expected.roaming);
assertTrue(expected.showTriangle);