Move callback anonymous classes out of constructor
Cleans up the MobileSignalController constructor a bit. No behavior change Bug: 197851948 Test: atest SystemUITests Change-Id: I6fa7adaa6e2f82f4c4c0a1f01b2ca5339d86d1c6 Merged-In: I6fa7adaa6e2f82f4c4c0a1f01b2ca5339d86d1c6
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user