Merge changes I116b5f63,I6fa7adaa

* changes:
  Remove isWide from MobileIconGroup
  Move callback anonymous classes out of constructor
This commit is contained in:
Evan Laird
2021-09-14 14:59:25 +00:00
committed by Android (Google) Code Review
7 changed files with 156 additions and 144 deletions

View File

@@ -139,17 +139,15 @@ public class SignalIcon {
public static class MobileIconGroup extends IconGroup {
public final int dataContentDescription; // mContentDescriptionDataType
public final int dataType;
public final boolean isWide;
public final int qsDataType;
public MobileIconGroup(String name, int[][] sbIcons, int[][] qsIcons, int[] contentDesc,
int sbNullState, int qsNullState, int sbDiscState, int qsDiscState,
int discContentDesc, int dataContentDesc, int dataType, boolean isWide) {
int discContentDesc, int dataContentDesc, int dataType) {
super(name, sbIcons, qsIcons, contentDesc, sbNullState, qsNullState, sbDiscState,
qsDiscState, discContentDesc);
this.dataContentDescription = dataContentDesc;
this.dataType = dataType;
this.isWide = isWide;
this.qsDataType = dataType; // TODO: remove this field
}
}

View File

@@ -50,178 +50,194 @@ public class TelephonyIcons {
null,
null,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
0, 0,
0,
0,
0,
0,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
R.string.carrier_network_change_mode,
0,
false);
0
);
public static final MobileIconGroup THREE_G = new MobileIconGroup(
"3G",
null,
null,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
0, 0,
0,
0,
0,
0,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
R.string.data_connection_3g,
TelephonyIcons.ICON_3G,
true);
TelephonyIcons.ICON_3G
);
public static final MobileIconGroup WFC = new MobileIconGroup(
"WFC",
null,
null,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
0, 0,
0,
0,
0,
0,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
0, 0, false);
0,
0);
public static final MobileIconGroup UNKNOWN = new MobileIconGroup(
"Unknown",
null,
null,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
0, 0,
0,
0,
0,
0,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
0, 0, false);
0,
0);
public static final MobileIconGroup E = new MobileIconGroup(
"E",
null,
null,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
0, 0,
0,
0,
0,
0,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
R.string.data_connection_edge,
TelephonyIcons.ICON_E,
false);
TelephonyIcons.ICON_E
);
public static final MobileIconGroup ONE_X = new MobileIconGroup(
"1X",
null,
null,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
0, 0,
0,
0,
0,
0,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
R.string.data_connection_cdma,
TelephonyIcons.ICON_1X,
true);
TelephonyIcons.ICON_1X
);
public static final MobileIconGroup G = new MobileIconGroup(
"G",
null,
null,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
0, 0,
0,
0,
0,
0,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
R.string.data_connection_gprs,
TelephonyIcons.ICON_G,
false);
TelephonyIcons.ICON_G
);
public static final MobileIconGroup H = new MobileIconGroup(
"H",
null,
null,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
0, 0,
0,
0,
0,
0,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
R.string.data_connection_3_5g,
TelephonyIcons.ICON_H,
false);
TelephonyIcons.ICON_H
);
public static final MobileIconGroup H_PLUS = new MobileIconGroup(
"H+",
null,
null,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
0, 0,
0,
0,
0,
0,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
R.string.data_connection_3_5g_plus,
TelephonyIcons.ICON_H_PLUS,
false);
TelephonyIcons.ICON_H_PLUS
);
public static final MobileIconGroup FOUR_G = new MobileIconGroup(
"4G",
null,
null,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
0, 0,
0,
0,
0,
0,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
R.string.data_connection_4g,
TelephonyIcons.ICON_4G,
true);
TelephonyIcons.ICON_4G
);
public static final MobileIconGroup FOUR_G_PLUS = new MobileIconGroup(
"4G+",
null,
null,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
0, 0,
0,
0,
0,
0,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
R.string.data_connection_4g_plus,
TelephonyIcons.ICON_4G_PLUS,
true);
TelephonyIcons.ICON_4G_PLUS
);
public static final MobileIconGroup LTE = new MobileIconGroup(
"LTE",
null,
null,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
0, 0,
0,
0,
0,
0,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
R.string.data_connection_lte,
TelephonyIcons.ICON_LTE,
true);
TelephonyIcons.ICON_LTE
);
public static final MobileIconGroup LTE_PLUS = new MobileIconGroup(
"LTE+",
null,
null,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
0, 0,
0,
0,
0,
0,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
R.string.data_connection_lte_plus,
TelephonyIcons.ICON_LTE_PLUS,
true);
TelephonyIcons.ICON_LTE_PLUS
);
public static final MobileIconGroup LTE_CA_5G_E = new MobileIconGroup(
"5Ge",
null,
null,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
0, 0,
0,
0,
0,
0,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
R.string.data_connection_5ge_html,
TelephonyIcons.ICON_5G_E,
true);
TelephonyIcons.ICON_5G_E
);
public static final MobileIconGroup NR_5G = new MobileIconGroup(
"5G",
@@ -234,8 +250,8 @@ public class TelephonyIcons {
0,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
R.string.data_connection_5g,
TelephonyIcons.ICON_5G,
true);
TelephonyIcons.ICON_5G
);
public static final MobileIconGroup NR_5G_PLUS = new MobileIconGroup(
"5G_PLUS",
@@ -248,34 +264,36 @@ public class TelephonyIcons {
0,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
R.string.data_connection_5g_plus,
TelephonyIcons.ICON_5G_PLUS,
true);
TelephonyIcons.ICON_5G_PLUS
);
public static final MobileIconGroup DATA_DISABLED = new MobileIconGroup(
"DataDisabled",
null,
null,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
0, 0,
0,
0,
0,
0,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
R.string.cell_data_off_content_description,
0,
false);
0
);
public static final MobileIconGroup NOT_DEFAULT_DATA = new MobileIconGroup(
"NotDefaultData",
null,
null,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
0, 0,
0,
0,
0,
0,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
R.string.not_default_data_content_description,
0,
false);
0
);
public static final MobileIconGroup CARRIER_MERGED_WIFI = new MobileIconGroup(
"CWF",
@@ -288,8 +306,8 @@ public class TelephonyIcons {
/* qsDiscState= */ 0,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
R.string.data_connection_carrier_wifi,
TelephonyIcons.ICON_CWF,
/* isWide= */ true);
TelephonyIcons.ICON_CWF
);
// When adding a new MobileIconGround, check if the dataContentDescription has to be filtered
// in QSCarrier#hasValidTypeContentDescription

View File

@@ -108,8 +108,6 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
private Config mConfig;
@VisibleForTesting
boolean mInflateSignalStrengths = false;
private MobileStatusTracker.Callback mCallback;
private RegistrationCallback mRegistrationCallback;
private int mLastWwanLevel;
private int mLastWlanLevel;
private int mLastWlanCrossSimLevel;
@@ -121,6 +119,82 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
// Where to copy the next state into.
private int mMobileStatusHistoryIndex;
private final MobileStatusTracker.Callback mMobileCallback =
new MobileStatusTracker.Callback() {
private String mLastStatus;
@Override
public void onMobileStatusChanged(boolean updateTelephony,
MobileStatus mobileStatus) {
if (Log.isLoggable(mTag, Log.DEBUG)) {
Log.d(mTag, "onMobileStatusChanged="
+ " updateTelephony=" + updateTelephony
+ " mobileStatus=" + mobileStatus.toString());
}
String currentStatus = mobileStatus.toString();
if (!currentStatus.equals(mLastStatus)) {
mLastStatus = currentStatus;
String status = new StringBuilder()
.append(SSDF.format(System.currentTimeMillis())).append(",")
.append(currentStatus)
.toString();
recordLastMobileStatus(status);
}
updateMobileStatus(mobileStatus);
if (updateTelephony) {
updateTelephony();
} else {
notifyListenersIfNecessary();
}
}
};
private final RegistrationCallback mRegistrationCallback = new RegistrationCallback() {
@Override
public void onRegistered(ImsRegistrationAttributes attributes) {
Log.d(mTag, "onRegistered: " + "attributes=" + attributes);
int imsTransportType = attributes.getTransportType();
int registrationAttributes = attributes.getAttributeFlags();
if (imsTransportType == AccessNetworkConstants.TRANSPORT_TYPE_WWAN) {
mImsType = IMS_TYPE_WWAN;
IconState statusIcon = new IconState(
true,
getCallStrengthIcon(mLastWwanLevel, /* isWifi= */false),
getCallStrengthDescription(mLastWwanLevel, /* isWifi= */false));
notifyCallStateChange(statusIcon, mSubscriptionInfo.getSubscriptionId());
} else if (imsTransportType == AccessNetworkConstants.TRANSPORT_TYPE_WLAN) {
if (registrationAttributes == 0) {
mImsType = IMS_TYPE_WLAN;
IconState statusIcon = new IconState(
true,
getCallStrengthIcon(mLastWlanLevel, /* isWifi= */true),
getCallStrengthDescription(mLastWlanLevel, /* isWifi= */true));
notifyCallStateChange(statusIcon, mSubscriptionInfo.getSubscriptionId());
} else if (registrationAttributes
== ImsRegistrationAttributes.ATTR_EPDG_OVER_CELL_INTERNET) {
mImsType = IMS_TYPE_WLAN_CROSS_SIM;
IconState statusIcon = new IconState(
true,
getCallStrengthIcon(mLastWlanCrossSimLevel, /* isWifi= */false),
getCallStrengthDescription(
mLastWlanCrossSimLevel, /* isWifi= */false));
notifyCallStateChange(statusIcon, mSubscriptionInfo.getSubscriptionId());
}
}
}
@Override
public void onUnregistered(ImsReasonInfo info) {
Log.d(mTag, "onDeregistered: " + "info=" + info);
mImsType = IMS_TYPE_WWAN;
IconState statusIcon = new IconState(
true,
getCallStrengthIcon(mLastWwanLevel, /* isWifi= */false),
getCallStrengthDescription(mLastWwanLevel, /* isWifi= */false));
notifyCallStateChange(statusIcon, mSubscriptionInfo.getSubscriptionId());
}
};
// TODO: Reduce number of vars passed in, if we have the NetworkController, probably don't
// need listener lists anymore.
public MobileSignalController(
@@ -144,8 +218,8 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
mPhone = phone;
mDefaults = defaults;
mSubscriptionInfo = info;
mNetworkNameSeparator = getTextIfExists(R.string.status_bar_network_name_separator)
.toString();
mNetworkNameSeparator = getTextIfExists(
R.string.status_bar_network_name_separator).toString();
mNetworkNameDefault = getTextIfExists(
com.android.internal.R.string.lockscreen_carrier_default).toString();
mReceiverHandler = new Handler(receiverLooper);
@@ -165,83 +239,9 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
updateTelephony();
}
};
mCallback = new MobileStatusTracker.Callback() {
private String mLastStatus;
@Override
public void onMobileStatusChanged(boolean updateTelephony,
MobileStatus mobileStatus) {
if (Log.isLoggable(mTag, Log.DEBUG)) {
Log.d(mTag, "onMobileStatusChanged="
+ " updateTelephony=" + updateTelephony
+ " mobileStatus=" + mobileStatus.toString());
}
String currentStatus = mobileStatus.toString();
if (!currentStatus.equals(mLastStatus)) {
mLastStatus = currentStatus;
String status = new StringBuilder()
.append(SSDF.format(System.currentTimeMillis())).append(",")
.append(currentStatus)
.toString();
recordLastMobileStatus(status);
}
updateMobileStatus(mobileStatus);
if (updateTelephony) {
updateTelephony();
} else {
notifyListenersIfNecessary();
}
}
};
mRegistrationCallback = new RegistrationCallback() {
@Override
public void onRegistered(ImsRegistrationAttributes attributes) {
Log.d(mTag, "onRegistered: " + "attributes=" + attributes);
int imsTransportType = attributes.getTransportType();
int registrationAttributes = attributes.getAttributeFlags();
if (imsTransportType == AccessNetworkConstants.TRANSPORT_TYPE_WWAN) {
mImsType = IMS_TYPE_WWAN;
IconState statusIcon = new IconState(
true,
getCallStrengthIcon(mLastWwanLevel, /* isWifi= */false),
getCallStrengthDescription(mLastWwanLevel, /* isWifi= */false));
notifyCallStateChange(statusIcon, mSubscriptionInfo.getSubscriptionId());
} else if (imsTransportType == AccessNetworkConstants.TRANSPORT_TYPE_WLAN) {
if (registrationAttributes == 0) {
mImsType = IMS_TYPE_WLAN;
IconState statusIcon = new IconState(
true,
getCallStrengthIcon(mLastWlanLevel, /* isWifi= */true),
getCallStrengthDescription(mLastWlanLevel, /* isWifi= */true));
notifyCallStateChange(statusIcon, mSubscriptionInfo.getSubscriptionId());
} else if (registrationAttributes
== ImsRegistrationAttributes.ATTR_EPDG_OVER_CELL_INTERNET) {
mImsType = IMS_TYPE_WLAN_CROSS_SIM;
IconState statusIcon = new IconState(
true,
getCallStrengthIcon(mLastWlanCrossSimLevel, /* isWifi= */false),
getCallStrengthDescription(
mLastWlanCrossSimLevel, /* isWifi= */false));
notifyCallStateChange(statusIcon, mSubscriptionInfo.getSubscriptionId());
}
}
}
@Override
public void onUnregistered(ImsReasonInfo info) {
Log.d(mTag, "onDeregistered: " + "info=" + info);
mImsType = IMS_TYPE_WWAN;
IconState statusIcon = new IconState(
true,
getCallStrengthIcon(mLastWwanLevel, /* isWifi= */false),
getCallStrengthDescription(mLastWwanLevel, /* isWifi= */false));
notifyCallStateChange(statusIcon, mSubscriptionInfo.getSubscriptionId());
}
};
mImsMmTelManager = ImsMmTelManager.createForSubscriptionId(info.getSubscriptionId());
mMobileStatusTracker = new MobileStatusTracker(mPhone, receiverLooper,
info, mDefaults, mCallback);
info, mDefaults, mMobileCallback);
mProviderModelBehavior = featureFlags.isCombinedStatusBarSignalIconsEnabled();
mProviderModelSetting = featureFlags.isProviderModelSettingEnabled();
}
@@ -419,7 +419,7 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
MobileDataIndicators mobileDataIndicators = new MobileDataIndicators(
statusIcon, qsIcon, typeIcon, qsTypeIcon,
activityIn, activityOut, dataContentDescription, dataContentDescriptionHtml,
description, icons.isWide, mSubscriptionInfo.getSubscriptionId(),
description, mSubscriptionInfo.getSubscriptionId(),
mCurrentState.roaming, showTriangle);
callback.setMobileDataIndicators(mobileDataIndicators);
} else {
@@ -464,7 +464,7 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
MobileDataIndicators mobileDataIndicators = new MobileDataIndicators(
statusIcon, qsIcon, typeIcon, qsTypeIcon,
activityIn, activityOut, dataContentDescription, dataContentDescriptionHtml,
description, icons.isWide, mSubscriptionInfo.getSubscriptionId(),
description, mSubscriptionInfo.getSubscriptionId(),
mCurrentState.roaming, showTriangle);
callback.setMobileDataIndicators(mobileDataIndicators);
}

View File

@@ -101,7 +101,6 @@ public interface NetworkController extends CallbackController<SignalCallback>, D
public CharSequence typeContentDescription;
public CharSequence typeContentDescriptionHtml;
public CharSequence description;
public boolean isWide;
public int subId;
public boolean roaming;
public boolean showTriangle;
@@ -109,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, boolean isWide, int subId, boolean roaming,
CharSequence description, int subId, boolean roaming,
boolean showTriangle) {
this.statusIcon = statusIcon;
this.qsIcon = qsIcon;
@@ -120,7 +119,6 @@ public interface NetworkController extends CallbackController<SignalCallback>, D
this.typeContentDescription = typeContentDescription;
this.typeContentDescriptionHtml = typeContentDescriptionHtml;
this.description = description;
this.isWide = isWide;
this.subId = subId;
this.roaming = roaming;
this.showTriangle = showTriangle;
@@ -138,7 +136,6 @@ public interface NetworkController extends CallbackController<SignalCallback>, D
.append(",typeContentDescription=").append(typeContentDescription)
.append(",typeContentDescriptionHtml=").append(typeContentDescriptionHtml)
.append(",description=").append(description)
.append(",isWide=").append(isWide)
.append(",subId=").append(subId)
.append(",roaming=").append(roaming)
.append(",showTriangle=").append(showTriangle)

View File

@@ -172,7 +172,7 @@ public class WifiSignalController extends
MobileDataIndicators mobileDataIndicators = new MobileDataIndicators(
statusIcon, qsIcon, typeIcon, qsTypeIcon,
mCurrentState.activityIn, mCurrentState.activityOut, dataContentDescription,
dataContentDescriptionHtml, description, icons.isWide,
dataContentDescriptionHtml, description,
mCurrentState.subId, /* roaming= */ false, /* showTriangle= */ true
);
callback.setMobileDataIndicators(mobileDataIndicators);

View File

@@ -232,7 +232,7 @@ public class QSCarrierGroupControllerTest extends LeakCheckedTest {
MobileDataIndicators indicators = new MobileDataIndicators(
mock(NetworkController.IconState.class),
mock(NetworkController.IconState.class),
0, 0, true, true, "", "", "", true, 0, true, true);
0, 0, true, true, "", "", "", 0, true, true);
mSignalCallback.setMobileDataIndicators(indicators);
}

View File

@@ -124,7 +124,7 @@ public class CallbackHandlerTest extends SysuiTestCase {
boolean roaming = true;
MobileDataIndicators indicators = new MobileDataIndicators(
status, qs, type, qsType, in, out, typeDescription,
typeDescriptionHtml, description, wide, subId, roaming, true);
typeDescriptionHtml, description, subId, roaming, true);
mHandler.setMobileDataIndicators(indicators);
waitForCallbacks();
@@ -142,7 +142,6 @@ public class CallbackHandlerTest extends SysuiTestCase {
assertEquals(typeDescription, expected.typeContentDescription);
assertEquals(typeDescriptionHtml, expected.typeContentDescriptionHtml);
assertEquals(description, expected.description);
assertEquals(wide, expected.isWide);
assertEquals(subId, expected.subId);
assertTrue(expected.roaming);
assertTrue(expected.showTriangle);